From: rkv Date: Fri, 2 Nov 2012 09:12:25 +0000 (+0000) Subject: PMD plugin is refreshed. Some code is modified to respect PMD rules. Ant build proced... X-Git-Tag: Root_Delivery1_2012_12_06~96 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=91082264d9d3a6d512e672450271caeee93ad212;p=tools%2Fsiman.git PMD plugin is refreshed. Some code is modified to respect PMD rules. Ant build procedure is improved - java compiler errors are taken into account now. --- diff --git a/Workspace/3dparty_src/.cvsignore b/Workspace/3dparty_src/.cvsignore new file mode 100644 index 0000000..3690de0 --- /dev/null +++ b/Workspace/3dparty_src/.cvsignore @@ -0,0 +1 @@ +.pmd diff --git a/Workspace/Converter/.pmd b/Workspace/Converter/.pmd index 05d8fd4..dc7a2c1 100644 --- a/Workspace/Converter/.pmd +++ b/Workspace/Converter/.pmd @@ -3,4 +3,5 @@ true siman-pmd.ruleset false + true diff --git a/Workspace/Converter/.project b/Workspace/Converter/.project index 5fc1506..3cdd13c 100644 --- a/Workspace/Converter/.project +++ b/Workspace/Converter/.project @@ -27,7 +27,7 @@ - net.sourceforge.pmd.runtime.pmdBuilder + net.sourceforge.pmd.eclipse.plugin.pmdBuilder @@ -36,5 +36,6 @@ org.eclipse.jdt.core.javanature com.atlassw.tools.eclipse.checkstyle.CheckstyleNature net.sourceforge.pmd.runtime.pmdNature + net.sourceforge.pmd.eclipse.plugin.pmdNature diff --git a/Workspace/Converter/build.properties b/Workspace/Converter/build.properties index 0ccd896..8868854 100644 --- a/Workspace/Converter/build.properties +++ b/Workspace/Converter/build.properties @@ -1,2 +1,3 @@ converter.src.dir=src converter.dist.dir=dist +siman-common.project.name=Siman-Common diff --git a/Workspace/Converter/build.xml b/Workspace/Converter/build.xml index e40903e..9810f13 100644 --- a/Workspace/Converter/build.xml +++ b/Workspace/Converter/build.xml @@ -6,10 +6,20 @@ + + + + + + + + + + - + diff --git a/Workspace/Converter/siman-pmd.ruleset b/Workspace/Converter/siman-pmd.ruleset index 534af48..e610618 100644 --- a/Workspace/Converter/siman-pmd.ruleset +++ b/Workspace/Converter/siman-pmd.ruleset @@ -8,7 +8,6 @@ level 5 : good practices - .*/org/.* .*/test/.* diff --git a/Workspace/DaoGenerator/.pmd b/Workspace/DaoGenerator/.pmd new file mode 100644 index 0000000..c4b848c --- /dev/null +++ b/Workspace/DaoGenerator/.pmd @@ -0,0 +1,1809 @@ + + + false + .ruleset + + + LooseCoupling + Type Resolution Rules + + + CloneMethodMustImplementCloneable + Type Resolution Rules + + + UnusedImports + Type Resolution Rules + + + SignatureDeclareThrowsException + Type Resolution Rules + + + IfStmtsMustUseBraces + Braces Rules + + + WhileLoopsMustUseBraces + Braces Rules + + + IfElseStmtsMustUseBraces + Braces Rules + + + ForLoopsMustUseBraces + Braces Rules + + + UnnecessaryConstructor + Controversial Rules + + + NullAssignment + Controversial Rules + + + OnlyOneReturn + Controversial Rules + + + UnusedModifier + Controversial Rules + + + AssignmentInOperand + Controversial Rules + + + AtLeastOneConstructor + Controversial Rules + + + DontImportSun + Controversial Rules + + + SuspiciousOctalEscape + Controversial Rules + + + CallSuperInConstructor + Controversial Rules + + + UnnecessaryParentheses + Controversial Rules + + + DefaultPackage + Controversial Rules + + + BooleanInversion + Controversial Rules + + + DataflowAnomalyAnalysis + Controversial Rules + + + AvoidFinalLocalVariable + Controversial Rules + + + AvoidUsingShortType + Controversial Rules + + + AvoidUsingVolatile + Controversial Rules + + + AvoidUsingNativeCode + Controversial Rules + + + AvoidAccessibilityAlteration + Controversial Rules + + + DoNotCallGarbageCollectionExplicitly + Controversial Rules + + + EmptyCatchBlock + Basic Rules + + + EmptyIfStmt + Basic Rules + + + EmptyWhileStmt + Basic Rules + + + EmptyTryBlock + Basic Rules + + + EmptyFinallyBlock + Basic Rules + + + EmptySwitchStatements + Basic Rules + + + JumbledIncrementer + Basic Rules + + + ForLoopShouldBeWhileLoop + Basic Rules + + + UnnecessaryConversionTemporary + Basic Rules + + + OverrideBothEqualsAndHashcode + Basic Rules + + + DoubleCheckedLocking + Basic Rules + + + ReturnFromFinallyBlock + Basic Rules + + + EmptySynchronizedBlock + Basic Rules + + + UnnecessaryReturn + Basic Rules + + + EmptyStaticInitializer + Basic Rules + + + UnconditionalIfStatement + Basic Rules + + + EmptyStatementNotInLoop + Basic Rules + + + BooleanInstantiation + Basic Rules + + + UnnecessaryFinalModifier + Basic Rules + + + CollapsibleIfStatements + Basic Rules + + + UselessOverridingMethod + Basic Rules + + + ClassCastExceptionWithToArray + Basic Rules + + + AvoidDecimalLiteralsInBigDecimalConstructor + Basic Rules + + + UselessOperationOnImmutable + Basic Rules + + + MisplacedNullCheck + Basic Rules + + + UnusedNullCheckInEquals + Basic Rules + + + AvoidThreadGroup + Basic Rules + + + BrokenNullCheck + Basic Rules + + + BigIntegerInstantiation + Basic Rules + + + AvoidUsingOctalValues + Basic Rules + + + AvoidUsingHardCodedIP + Basic Rules + + + CheckResultSet + Basic Rules + + + AvoidMultipleUnaryOperators + Basic Rules + + + UnusedPrivateField + Unused Code Rules + + + UnusedLocalVariable + Unused Code Rules + + + UnusedPrivateMethod + Unused Code Rules + + + UnusedFormalParameter + Unused Code Rules + + + MoreThanOneLogger + Java Logging Rules + + + LoggerIsNotStaticFinal + Java Logging Rules + + + SystemPrintln + Java Logging Rules + + + AvoidPrintStackTrace + Java Logging Rules + + + AvoidCatchingThrowable + Strict Exception Rules + + + SignatureDeclareThrowsException + Type Resolution Rules + + + ExceptionAsFlowControl + Strict Exception Rules + + + AvoidCatchingNPE + Strict Exception Rules + + + AvoidThrowingRawExceptionTypes + Strict Exception Rules + + + AvoidThrowingNullPointerException + Strict Exception Rules + + + AvoidRethrowingException + Strict Exception Rules + + + DoNotExtendJavaLangError + Strict Exception Rules + + + DoNotThrowExceptionInFinally + Strict Exception Rules + + + ReplaceVectorWithList + Migration Rules + + + ReplaceHashtableWithMap + Migration Rules + + + ReplaceEnumerationWithIterator + Migration Rules + + + AvoidEnumAsIdentifier + Migration Rules + + + AvoidAssertAsIdentifier + Migration Rules + + + IntegerInstantiation + Migration Rules + + + ByteInstantiation + Migration Rules + + + ShortInstantiation + Migration Rules + + + LongInstantiation + Migration Rules + + + JUnit4TestShouldUseBeforeAnnotation + Migration Rules + + + JUnit4TestShouldUseAfterAnnotation + Migration Rules + + + JUnit4TestShouldUseTestAnnotation + Migration Rules + + + JUnit4SuitesShouldUseSuiteAnnotation + Migration Rules + + + JUnitUseExpected + Migration Rules + + + UseSingleton + Design Rules + + + SimplifyBooleanReturns + Design Rules + + + SimplifyBooleanExpressions + Design Rules + + + SwitchStmtsShouldHaveDefault + Design Rules + + + AvoidDeeplyNestedIfStmts + Design Rules + + + AvoidReassigningParameters + Design Rules + + + SwitchDensity + Design Rules + + + ConstructorCallsOverridableMethod + Design Rules + + + AccessorClassGeneration + Design Rules + + + FinalFieldCouldBeStatic + Design Rules + + + CloseResource + Design Rules + + + NonStaticInitializer + Design Rules + + + DefaultLabelNotLastInSwitchStmt + Design Rules + + + NonCaseLabelInSwitchStatement + Design Rules + + + OptimizableToArrayCall + Design Rules + + + BadComparison + Design Rules + + + EqualsNull + Design Rules + + + ConfusingTernary + Design Rules + + + InstantiationToGetClass + Design Rules + + + IdempotentOperations + Design Rules + + + SimpleDateFormatNeedsLocale + Design Rules + + + ImmutableField + Design Rules + + + UseLocaleWithCaseConversions + Design Rules + + + AvoidProtectedFieldInFinalClass + Design Rules + + + AssignmentToNonFinalStatic + Design Rules + + + MissingStaticMethodInNonInstantiatableClass + Design Rules + + + AvoidSynchronizedAtMethodLevel + Design Rules + + + MissingBreakInSwitch + Design Rules + + + UseNotifyAllInsteadOfNotify + Design Rules + + + AvoidInstanceofChecksInCatchClause + Design Rules + + + AbstractClassWithoutAbstractMethod + Design Rules + + + SimplifyConditional + Design Rules + + + CompareObjectsWithEquals + Design Rules + + + PositionLiteralsFirstInComparisons + Design Rules + + + UnnecessaryLocalBeforeReturn + Design Rules + + + NonThreadSafeSingleton + Design Rules + + + UncommentedEmptyMethod + Design Rules + + + UncommentedEmptyConstructor + Design Rules + + + AvoidConstantsInterface + Design Rules + + + UnsynchronizedStaticDateFormatter + Design Rules + + + PreserveStackTrace + Design Rules + + + UseCollectionIsEmpty + Design Rules + + + ClassWithOnlyPrivateConstructorsShouldBeFinal + Design Rules + + + EmptyMethodInAbstractClassShouldBeAbstract + Design Rules + + + SingularField + Design Rules + + + ReturnEmptyArrayRatherThanNull + Design Rules + + + AbstractClassWithoutAnyMethod + Design Rules + + + TooFewBranchesForASwitchStatement + Design Rules + + + UseProperClassLoader + J2EE Rules + + + MDBAndSessionBeanNamingConvention + J2EE Rules + + + RemoteSessionInterfaceNamingConvention + J2EE Rules + + + LocalInterfaceSessionNamingConvention + J2EE Rules + + + LocalHomeNamingConvention + J2EE Rules + + + RemoteInterfaceNamingConvention + J2EE Rules + + + DoNotCallSystemExit + J2EE Rules + + + StaticEJBFieldShouldBeFinal + J2EE Rules + + + DoNotUseThreads + J2EE Rules + + + LocalVariableCouldBeFinal + Optimization Rules + + + MethodArgumentCouldBeFinal + Optimization Rules + + + AvoidInstantiatingObjectsInLoops + Optimization Rules + + + UseArrayListInsteadOfVector + Optimization Rules + + + SimplifyStartsWith + Optimization Rules + + + UseStringBufferForStringAppends + Optimization Rules + + + UseArraysAsList + Optimization Rules + + + AvoidArrayLoops + Optimization Rules + + + UnnecessaryWrapperObjectCreation + Optimization Rules + + + AddEmptyString + Optimization Rules + + + MethodReturnsInternalArray + Security Code Guidelines + + + ArrayIsStoredDirectly + Security Code Guidelines + + + CouplingBetweenObjects + Coupling Rules + + + ExcessiveImports + Coupling Rules + + + LooseCoupling + Type Resolution Rules + + + DuplicateImports + Import Statement Rules + + + DontImportJavaLang + Import Statement Rules + + + UnusedImports + Type Resolution Rules + + + ImportFromSamePackage + Import Statement Rules + + + TooManyStaticImports + Import Statement Rules + + + JUnitStaticSuite + JUnit Rules + + + JUnitSpelling + JUnit Rules + + + JUnitAssertionsShouldIncludeMessage + JUnit Rules + + + JUnitTestsShouldIncludeAssert + JUnit Rules + + + TestClassWithoutTestCases + JUnit Rules + + + UnnecessaryBooleanAssertion + JUnit Rules + + + UseAssertEqualsInsteadOfAssertTrue + JUnit Rules + + + UseAssertSameInsteadOfAssertTrue + JUnit Rules + + + UseAssertNullInsteadOfAssertTrue + JUnit Rules + + + SimplifyBooleanAssertion + JUnit Rules + + + ShortVariable + Naming Rules + + + LongVariable + Naming Rules + + + ShortMethodName + Naming Rules + + + VariableNamingConventions + Naming Rules + + + MethodNamingConventions + Naming Rules + + + ClassNamingConventions + Naming Rules + + + AbstractNaming + Naming Rules + + + AvoidDollarSigns + Naming Rules + + + MethodWithSameNameAsEnclosingClass + Naming Rules + + + SuspiciousHashcodeMethodName + Naming Rules + + + SuspiciousConstantFieldName + Naming Rules + + + SuspiciousEqualsMethodName + Naming Rules + + + AvoidFieldNameMatchingTypeName + Naming Rules + + + AvoidFieldNameMatchingMethodName + Naming Rules + + + NoPackage + Naming Rules + + + PackageCase + Naming Rules + + + MisleadingVariableName + Naming Rules + + + BooleanGetMethodName + Naming Rules + + + NPathComplexity + Code Size Rules + + + ExcessiveMethodLength + Code Size Rules + + + ExcessiveParameterList + Code Size Rules + + + ExcessiveClassLength + Code Size Rules + + + CyclomaticComplexity + Code Size Rules + + + ExcessivePublicCount + Code Size Rules + + + TooManyFields + Code Size Rules + + + NcssMethodCount + Code Size Rules + + + NcssTypeCount + Code Size Rules + + + NcssConstructorCount + Code Size Rules + + + TooManyMethods + Code Size Rules + + + EmptyFinalizer + Finalizer Rules + + + FinalizeOnlyCallsSuperFinalize + Finalizer Rules + + + FinalizeOverloaded + Finalizer Rules + + + FinalizeDoesNotCallSuperFinalize + Finalizer Rules + + + FinalizeShouldBeProtected + Finalizer Rules + + + AvoidCallingFinalize + Finalizer Rules + + + UseCorrectExceptionLogging + Jakarta Commons Logging Rules + + + ProperLogger + Jakarta Commons Logging Rules + + + BeanMembersShouldSerialize + JavaBean Rules + + + MissingSerialVersionUID + JavaBean Rules + + + ProperCloneImplementation + Clone Implementation Rules + + + CloneThrowsCloneNotSupportedException + Clone Implementation Rules + + + CloneMethodMustImplementCloneable + Type Resolution Rules + + + AvoidDuplicateLiterals + String and StringBuffer Rules + + + StringInstantiation + String and StringBuffer Rules + + + StringToString + String and StringBuffer Rules + + + InefficientStringBuffering + String and StringBuffer Rules + + + UnnecessaryCaseChange + String and StringBuffer Rules + + + UseStringBufferLength + String and StringBuffer Rules + + + AppendCharacterWithChar + String and StringBuffer Rules + + + ConsecutiveLiteralAppends + String and StringBuffer Rules + + + UseIndexOfChar + String and StringBuffer Rules + + + InefficientEmptyStringCheck + String and StringBuffer Rules + + + InsufficientStringBufferDeclaration + String and StringBuffer Rules + + + UselessStringValueOf + String and StringBuffer Rules + + + StringBufferInstantiationWithChar + String and StringBuffer Rules + + + UseEqualsToCompareStrings + String and StringBuffer Rules + + + AvoidStringBufferField + String and StringBuffer Rules + + + MissingStaticMethodInNonInstantiatableClass + pmd-eclipse + + + ExceptionAsFlowControl + pmd-eclipse + + + AvoidCatchingThrowable + pmd-eclipse + + + SingularField + pmd-eclipse + + + AvoidUsingNativeCode + pmd-eclipse + + + AvoidCatchingNPE + pmd-eclipse + + + AppendCharacterWithChar + pmd-eclipse + + + UseStringBufferForStringAppends + pmd-eclipse + + + ExcessiveImports + pmd-eclipse + + + AccessorClassGeneration + pmd-eclipse + + + SuspiciousHashcodeMethodName + pmd-eclipse + + + LooseCoupling + pmd-eclipse + + + LooseCoupling + pmd-eclipse + + + BrokenNullCheck + pmd-eclipse + + + ClassNamingConventions + pmd-eclipse + + + CloneMethodMustImplementCloneable + pmd-eclipse + + + AvoidDollarSigns + pmd-eclipse + + + DefaultLabelNotLastInSwitchStmt + pmd-eclipse + + + SignatureDeclareThrowsException + pmd-eclipse + + + InefficientStringBuffering + pmd-eclipse + + + AvoidInstantiatingObjectsInLoops + pmd-eclipse + + + MissingBreakInSwitch + pmd-eclipse + + + CallSuperInConstructor + pmd-eclipse + + + StringBufferInstantiationWithChar + pmd-eclipse + + + BeanMembersShouldSerialize + pmd-eclipse + + + NcssConstructorCount + pmd-eclipse + + + AbstractNaming + pmd-eclipse + + + AssignmentInOperand + pmd-eclipse + + + ConsecutiveLiteralAppends + pmd-eclipse + + + IfElseStmtsMustUseBraces + pmd-eclipse + + + SimpleDateFormatNeedsLocale + pmd-eclipse + + + AvoidThrowingNullPointerException + pmd-eclipse + + + JumbledIncrementer + pmd-eclipse + + + AddEmptyString + pmd-eclipse + + + TooManyFields + pmd-eclipse + + + AvoidSynchronizedAtMethodLevel + pmd-eclipse + + + SuspiciousEqualsMethodName + pmd-eclipse + + + CloseResource + pmd-eclipse + + + IdempotentOperations + pmd-eclipse + + + UselessOperationOnImmutable + pmd-eclipse + + + AvoidFieldNameMatchingTypeName + pmd-eclipse + + + AvoidInstanceofChecksInCatchClause + pmd-eclipse + + + SimplifyBooleanExpressions + pmd-eclipse + + + UselessOverridingMethod + pmd-eclipse + + + UseCorrectExceptionLogging + pmd-eclipse + + + WhileLoopsMustUseBraces + pmd-eclipse + + + NonThreadSafeSingleton + pmd-eclipse + + + BooleanInstantiation + pmd-eclipse + + + UnusedModifier + pmd-eclipse + + + ClassCastExceptionWithToArray + pmd-eclipse + + + UnnecessaryParentheses + pmd-eclipse + + + UseProperClassLoader + pmd-eclipse + + + ProperCloneImplementation + pmd-eclipse + + + ReturnFromFinallyBlock + pmd-eclipse + + + ReturnEmptyArrayRatherThanNull + pmd-eclipse + + + MisleadingVariableName + pmd-eclipse + + + ConfusingTernary + pmd-eclipse + + + SuspiciousConstantFieldName + pmd-eclipse + + + AvoidDuplicateLiterals + pmd-eclipse + + + UnusedImports + pmd-eclipse + + + UncommentedEmptyMethod + pmd-eclipse + + + UnusedPrivateMethod + pmd-eclipse + + + NonStaticInitializer + pmd-eclipse + + + ForLoopShouldBeWhileLoop + pmd-eclipse + + + AvoidFieldNameMatchingMethodName + pmd-eclipse + + + AvoidFinalLocalVariable + pmd-eclipse + + + InstantiationToGetClass + pmd-eclipse + + + DoNotExtendJavaLangError + pmd-eclipse + + + UselessStringValueOf + pmd-eclipse + + + MethodArgumentCouldBeFinal + pmd-eclipse + + + EqualsNull + pmd-eclipse + + + ConstructorCallsOverridableMethod + pmd-eclipse + + + SwitchDensity + pmd-eclipse + + + TooManyMethods + pmd-eclipse + + + SimplifyConditional + pmd-eclipse + + + EmptyCatchBlock + pmd-eclipse + + + LocalHomeNamingConvention + pmd-eclipse + + + DoNotUseConditionalExpression + pmd-eclipse + + + EmptyIfStmt + pmd-eclipse + + + ImmutableField + pmd-eclipse + + + DefaultPackage + pmd-eclipse + + + AvoidArrayLoops + pmd-eclipse + + + DoNotCallSystemExit + pmd-eclipse + + + CheckResultSet + pmd-eclipse + + + CyclomaticComplexity + pmd-eclipse + + + AvoidUsingShortType + pmd-eclipse + + + EmptyFinallyBlock + pmd-eclipse + + + CouplingBetweenObjects + pmd-eclipse + + + AvoidStringBufferField + pmd-eclipse + + + SimplifyBooleanReturns + pmd-eclipse + + + MethodWithSameNameAsEnclosingClass + pmd-eclipse + + + UnconditionalIfStatement + pmd-eclipse + + + UnnecessaryFinalModifier + pmd-eclipse + + + BigIntegerInstantiation + pmd-eclipse + + + LoggerIsNotStaticFinal + pmd-eclipse + + + NonCaseLabelInSwitchStatement + pmd-eclipse + + + InsufficientStringBufferDeclaration + pmd-eclipse + + + TooManyStaticImports + pmd-eclipse + + + CompareObjectsWithEquals + pmd-eclipse + + + ExcessiveParameterList + pmd-eclipse + + + DuplicateImports + pmd-eclipse + + + UnnecessaryReturn + pmd-eclipse + + + EmptySynchronizedBlock + pmd-eclipse + + + AssignmentToNonFinalStatic + pmd-eclipse + + + ReplaceVectorWithList + pmd-eclipse + + + SignatureDeclareThrowsException + pmd-eclipse + + + UnusedImports + pmd-eclipse + + + CloneThrowsCloneNotSupportedException + pmd-eclipse + + + AvoidConstantsInterface + pmd-eclipse + + + UseArraysAsList + pmd-eclipse + + + UnsynchronizedStaticDateFormatter + pmd-eclipse + + + ShortInstantiation + pmd-eclipse + + + AvoidReassigningParameters + pmd-eclipse + + + ReplaceHashtableWithMap + pmd-eclipse + + + UseIndexOfChar + pmd-eclipse + + + BadComparison + pmd-eclipse + + + UseNotifyAllInsteadOfNotify + pmd-eclipse + + + UnnecessaryConversionTemporary + pmd-eclipse + + + NcssMethodCount + pmd-eclipse + + + AvoidProtectedFieldInFinalClass + pmd-eclipse + + + OnlyOneReturn + pmd-eclipse + + + MisplacedNullCheck + pmd-eclipse + + + FinalizeOverloaded + pmd-eclipse + + + UseArrayListInsteadOfVector + pmd-eclipse + + + UnusedFormalParameter + pmd-eclipse + + + ParametersNamingRules + pmd-eclipse + + + ArrayIsStoredDirectly + pmd-eclipse + + + StringInstantiation + pmd-eclipse + + + ImportFromSamePackage + pmd-eclipse + + + PackageCase + pmd-eclipse + + + StringToString + pmd-eclipse + + + MissingSerialVersionUID + pmd-eclipse + + + FinalizeOnlyCallsSuperFinalize + pmd-eclipse + + + UncommentedEmptyConstructor + pmd-eclipse + + + AvoidPrintStackTrace + pmd-eclipse + + + NoPackage + pmd-eclipse + + + UnusedPrivateField + pmd-eclipse + + + StaticEJBFieldShouldBeFinal + pmd-eclipse + + + AvoidUsingOctalValues + pmd-eclipse + + + UnnecessaryWrapperObjectCreation + pmd-eclipse + + + BooleanInversion + pmd-eclipse + + + ClassWithOnlyPrivateConstructorsShouldBeFinal + pmd-eclipse + + + CloneMethodMustImplementCloneable + pmd-eclipse + + + PositionLiteralsFirstInComparisons + pmd-eclipse + + + UnusedNullCheckInEquals + pmd-eclipse + + + DoNotUseThreads + pmd-eclipse + + + InefficientEmptyStringCheck + pmd-eclipse + + + DataflowAnomalyAnalysis + pmd-eclipse + + + ForLoopsMustUseBraces + pmd-eclipse + + + FinalizeShouldBeProtected + pmd-eclipse + + + EmptyTryBlock + pmd-eclipse + + + UseStringBufferLength + pmd-eclipse + + + EmptyFinalizer + pmd-eclipse + + + FieldNamingRules + pmd-eclipse + + + AvoidUsingHardCodedIP + pmd-eclipse + + + ByteInstantiation + pmd-eclipse + + + DontImportSun + pmd-eclipse + + + MethodNamingConventions + pmd-eclipse + + + AvoidAccessibilityAlteration + pmd-eclipse + + + SuspiciousConstantFieldName + pmd-eclipse + + + SwitchStmtsShouldHaveDefault + pmd-eclipse + + + ExcessiveMethodLength + pmd-eclipse + + + OverrideBothEqualsAndHashcode + pmd-eclipse + + + MethodReturnsInternalArray + pmd-eclipse + + + TooFewBranchesForASwitchStatement + pmd-eclipse + + + NcssTypeCount + pmd-eclipse + + + AvoidDecimalLiteralsInBigDecimalConstructor + pmd-eclipse + + + DontImportJavaLang + pmd-eclipse + + + MDBAndSessionBeanNamingConvention + pmd-eclipse + + + EmptyMethodInAbstractClassShouldBeAbstract + pmd-eclipse + + + DoNotThrowExceptionInFinally + pmd-eclipse + + + PreserveStackTrace + pmd-eclipse + + + ExcessiveClassLength + pmd-eclipse + + + RemoteInterfaceNamingConvention + pmd-eclipse + + + EmptyStatementNotInLoop + pmd-eclipse + + + UseCollectionIsEmpty + pmd-eclipse + + + UnnecessaryConstructor + pmd-eclipse + + + BooleanGetMethodName + pmd-eclipse + + + SystemPrintln + pmd-eclipse + + + OptimizableToArrayCall + pmd-eclipse + + + EmptyStaticInitializer + pmd-eclipse + + + AvoidUsingVolatile + pmd-eclipse + + + UnnecessaryCaseChange + pmd-eclipse + + + ReplaceEnumerationWithIterator + pmd-eclipse + + + FinalFieldCouldBeStatic + pmd-eclipse + + + IntegerInstantiation + pmd-eclipse + + + AvoidThrowingRawExceptionTypes + pmd-eclipse + + + SuspiciousOctalEscape + pmd-eclipse + + + EmptySwitchStatements + pmd-eclipse + + + AvoidMultipleUnaryOperators + pmd-eclipse + + + CollapsibleIfStatements + pmd-eclipse + + + LocalInterfaceSessionNamingConvention + pmd-eclipse + + + EmptyWhileStmt + pmd-eclipse + + + NullAssignment + pmd-eclipse + + + FinalizeDoesNotCallSuperFinalize + pmd-eclipse + + + ProperLogger + pmd-eclipse + + + IfStmtsMustUseBraces + pmd-eclipse + + + AbstractClassWithoutAnyMethod + pmd-eclipse + + + MoreThanOneLogger + pmd-eclipse + + + UnusedLocalVariable + pmd-eclipse + + + AbstractClassWithoutAbstractMethod + pmd-eclipse + + + LongInstantiation + pmd-eclipse + + + VariableNamingConventions + pmd-eclipse + + + UseSingleton + pmd-eclipse + + + UseEqualsToCompareStrings + pmd-eclipse + + + AvoidRethrowingException + pmd-eclipse + + + SimplifyStartsWith + pmd-eclipse + + + AvoidDeeplyNestedIfStmts + pmd-eclipse + + + AvoidCallingFinalize + pmd-eclipse + + + RemoteSessionInterfaceNamingConvention + pmd-eclipse + + + AvoidThreadGroup + pmd-eclipse + + + NPathComplexity + pmd-eclipse + + + DoubleCheckedLocking + pmd-eclipse + + + ExcessivePublicCount + pmd-eclipse + + + DoNotCallGarbageCollectionExplicitly + pmd-eclipse + + + false + true + diff --git a/Workspace/SPlat/.cvsignore b/Workspace/SPlat/.cvsignore index abc70c2..4ffb44f 100644 --- a/Workspace/SPlat/.cvsignore +++ b/Workspace/SPlat/.cvsignore @@ -6,3 +6,5 @@ dist/* bin/* *.class *.war +reports +reports/* diff --git a/Workspace/SPlat/.pmd b/Workspace/SPlat/.pmd index 05d8fd4..dc7a2c1 100644 --- a/Workspace/SPlat/.pmd +++ b/Workspace/SPlat/.pmd @@ -3,4 +3,5 @@ true siman-pmd.ruleset false + true diff --git a/Workspace/SPlat/.project b/Workspace/SPlat/.project index 01d2e08..541e729 100644 --- a/Workspace/SPlat/.project +++ b/Workspace/SPlat/.project @@ -36,7 +36,7 @@ - net.sourceforge.pmd.runtime.pmdBuilder + net.sourceforge.pmd.eclipse.plugin.pmdBuilder @@ -48,5 +48,6 @@ org.eclipse.jem.workbench.JavaEMFNature com.atlassw.tools.eclipse.checkstyle.CheckstyleNature net.sourceforge.pmd.runtime.pmdNature + net.sourceforge.pmd.eclipse.plugin.pmdNature diff --git a/Workspace/SPlat/siman-pmd.ruleset b/Workspace/SPlat/siman-pmd.ruleset index 534af48..e610618 100644 --- a/Workspace/SPlat/siman-pmd.ruleset +++ b/Workspace/SPlat/siman-pmd.ruleset @@ -8,7 +8,6 @@ level 5 : good practices - .*/org/.* .*/test/.* diff --git a/Workspace/SPlat/src/org/splat/manox/Toolbox.java b/Workspace/SPlat/src/org/splat/manox/Toolbox.java index 20954bf..e6da679 100644 --- a/Workspace/SPlat/src/org/splat/manox/Toolbox.java +++ b/Workspace/SPlat/src/org/splat/manox/Toolbox.java @@ -3,15 +3,17 @@ package org.splat.manox; import java.io.File; -public abstract class Toolbox { +public class Toolbox { // ============================================================================================================================== // Public services // ============================================================================================================================== - public static Reader getReader (File file) { + public static Reader getReader (final File file) { // ------------------------------------------ - if (!file.exists()) return null; + if (!file.exists()) { + return null; + } String[] name = file.getName().split("\\x2E"); // Split around '.' (period) character String fext = name[name.length-1]; @@ -19,17 +21,21 @@ public abstract class Toolbox { if (fext.equals("xml")) { XMLDocument odoc = new XMLDocument(file); // Parses the file - if (odoc.isWordDocument()) me = new WordXMLDocument(odoc); + if (odoc.isWordDocument()) { + me = new WordXMLDocument(odoc); + } } else - if (fext.equals("docx")) { + if (fext.equals("docx")) { //NOPMD: todo //TODO: me = new WordDOCXDocument(file); } return me; } - public static Writer getWriter (File file) { + public static Writer getWriter (final File file) { // ------------------------------------------ - if (!file.exists()) return null; + if (!file.exists()) { + return null; + } String[] name = file.getName().split("\\x2E"); // Split around '.' (period) character String fext = name[name.length-1]; @@ -37,7 +43,9 @@ public abstract class Toolbox { if (fext.equals("xml")) { XMLDocument odoc = new XMLDocument(file); // Parses the file - if (odoc.isWordDocument()) me = new WordXMLDocument(odoc); + if (odoc.isWordDocument()) { + me = new WordXMLDocument(odoc); + } } return me; } diff --git a/Workspace/SPlat/src/org/splat/manox/TypeMismatchException.java b/Workspace/SPlat/src/org/splat/manox/TypeMismatchException.java index 55d1650..d8cdf4c 100644 --- a/Workspace/SPlat/src/org/splat/manox/TypeMismatchException.java +++ b/Workspace/SPlat/src/org/splat/manox/TypeMismatchException.java @@ -5,8 +5,9 @@ public class TypeMismatchException extends Exception { private static final long serialVersionUID = 5083246617526245578L; public TypeMismatchException () { + super(); } - public TypeMismatchException (String message) { + public TypeMismatchException (final String message) { super(message); } } \ No newline at end of file diff --git a/Workspace/SPlat/src/org/splat/manox/WordDOCXDocument.java b/Workspace/SPlat/src/org/splat/manox/WordDOCXDocument.java index e1e3ede..2eaa38e 100644 --- a/Workspace/SPlat/src/org/splat/manox/WordDOCXDocument.java +++ b/Workspace/SPlat/src/org/splat/manox/WordDOCXDocument.java @@ -4,56 +4,58 @@ import java.io.File; import java.io.FileInputStream; import java.io.InputStream; +import org.apache.log4j.Logger; import org.apache.poi.xwpf.extractor.XWPFWordExtractor; import org.apache.poi.xwpf.usermodel.XWPFDocument; - public class WordDOCXDocument implements Reader { -// private File myfile; - private XWPFWordExtractor mytool; - private String contents; - -// ============================================================================================================================== -// Constructor -// ============================================================================================================================== - - public WordDOCXDocument (File file) { -// ----------------------------------- - try { - InputStream from = new FileInputStream(file); - XWPFDocument odoc = new XWPFDocument(from); - - mytool = new XWPFWordExtractor(odoc); - contents = mytool.getText(); - } - catch (Exception error) { - - } - } - -// ============================================================================================================================== -// Public services -// ============================================================================================================================== - - public String extractProperty (String name) { -// ------------------------------------------- - String value = null; - String proname = "DOCPROPERTY " + name; - int index = contents.indexOf(proname); - if (index > 0) { - String fragment = contents.substring(index + proname.length() + 18); - index = fragment.indexOf(""); - if (index > 0) { - value = fragment.substring(0, index); - if (value.startsWith("<") && value.endsWith(">")) value = null; - } - } - return value; - } - - public String extractText () { -// ---------------------------- - return contents; - } + private final static Logger LOGGER = Logger.getLogger(WordDOCXDocument.class); + + private transient String _contents; + + // ============================================================================================================================== + // Constructor + // ============================================================================================================================== + + public WordDOCXDocument(final File file) { + XWPFWordExtractor aTool; + try { + InputStream from = new FileInputStream(file); + XWPFDocument odoc = new XWPFDocument(from); + + aTool = new XWPFWordExtractor(odoc); + _contents = aTool.getText(); + } catch (Exception error) { + LOGGER.error(error.getMessage()); + } + } + + // ============================================================================================================================== + // Public services + // ============================================================================================================================== + + public String extractProperty(final String name) { + // ------------------------------------------- + String value = null; + String proname = "DOCPROPERTY " + name; + int index = _contents.indexOf(proname); + if (index > 0) { + String fragment = _contents + .substring(index + proname.length() + 18); + index = fragment.indexOf(''); + if (index > 0) { + value = fragment.substring(0, index); + if (value.startsWith("<") && value.endsWith(">")) { + value = null; + } + } + } + return value; + } + + public String extractText() { + // ---------------------------- + return _contents; + } } \ No newline at end of file diff --git a/Workspace/SPlat/src/org/splat/manox/WordXMLDocument.java b/Workspace/SPlat/src/org/splat/manox/WordXMLDocument.java index 474caaa..286181b 100644 --- a/Workspace/SPlat/src/org/splat/manox/WordXMLDocument.java +++ b/Workspace/SPlat/src/org/splat/manox/WordXMLDocument.java @@ -1,169 +1,197 @@ package org.splat.manox; import java.io.File; +import java.util.ArrayList; import java.util.HashMap; -import java.util.Vector; +import java.util.List; +import java.util.Map; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - public class WordXMLDocument extends XMLDocument implements Reader, Writer { - private HashMap binprop; // Built-in properties - private HashMap capprop; // Custom application properties - private Node body; // Body of the document - private Vector fields = null; // Fields into the document body - -// ============================================================================================================================== -// Constructors -// ============================================================================================================================== - - public WordXMLDocument (File file) throws TypeMismatchException { -// ---------------------------------- - super(file); - if (!isWordDocument()) throw new TypeMismatchException("The file to be open is not a Word document"); - initializeMe(); - } - protected WordXMLDocument (XMLDocument parse) { // Downcast internal constructor -// --------------------------------------------- - super(parse); - initializeMe(); // The given document is supposed being Word - } - -// ============================================================================================================================== -// Public services -// ============================================================================================================================== - - public String extractProperty (String name) { -// ------------------------------------------- - Node property; -// Properties not conform to the naming scheme - if (name.equals("author")) property = binprop.get("creator"); - else if (name.equals("type")) property = binprop.get("category"); -// Other properties - else { - property = capprop.get(name); // Looking into custom properties first - if (property != null) { - property = property.getFirstChild(); // vt:lpwstr node - } else { - property = binprop.get(name); - } - } - if (property == null) return null; - String value = property.getTextContent(); - if (value.startsWith("<") && value.endsWith(">")) value = null; // Property not set - return value; - } - - public String extractText () { -// ---------------------------- - String text = ""; - if (body != null) { - Node body = this.body.getFirstChild(); // w:document node -// if (body == null) return text; // Should not happen - body = body.getFirstChild(); // w:body node - if (body != null) text = extractTextContent(body, text); - } - return text; - } - - public String updateProperty (String name, String value) { -// -------------------------------------------------------- - if (fields == null) { - fields = collectFieldNodes(body, new Vector()); - } -// Setting of the property - Node property = capprop.get(name); // Looking into custom properties first - if (property != null) { - property = property.getFirstChild(); - } else { - if (name.equals("author")) property = binprop.get("creator"); // thanks to Bill Gates... - else property = binprop.get(name); -// Built-in property names are capitalized into the document body (thanks again, Bill Gates) - char initial = name.charAt(0); - name = name.replaceFirst(String.valueOf(initial), String.valueOf(initial).toUpperCase()); - } - if (property == null) return null; - String oldvalue = property.getTextContent(); - property.setTextContent(value); - -// Update of the property fields, if exist - String proname = " DOCPROPERTY " + name + " "; - - for (int j=0; j(); - binprop = new HashMap(); - - Node property = mynodes.get("/docProps/custom.xml"); - if (property != null) { - NodeList nlist = property.getFirstChild().getChildNodes(); // Contents of Properties node - for (int i=0; i collectFieldNodes (Node from, Vector to) { -// ------------------------------------------------------------------- - NodeList nlist = from.getChildNodes(); - for (int i=0; i _binprop; // Built-in properties + private transient Map _capprop; // Custom application properties + private transient Node _body; // Body of the document + private transient List _fields = null; // Fields into the document body + + // ============================================================================================================================== + // Constructors + // ============================================================================================================================== + + public WordXMLDocument(final File file) throws TypeMismatchException { + // ---------------------------------- + super(file); + if (!isWordDocument()) { + throw new TypeMismatchException( + "The file to be open is not a Word document"); + } + initializeMe(); + } + + protected WordXMLDocument(final XMLDocument parse) { // Downcast internal constructor + // --------------------------------------------- + super(parse); + initializeMe(); // The given document is supposed being Word + } + + // ============================================================================================================================== + // Public services + // ============================================================================================================================== + + public String extractProperty(final String name) { + // ------------------------------------------- + Node property; + // Properties not conform to the naming scheme + if ("author".equals(name)) { + property = _binprop.get("creator"); + } else if ("type".equals(name)) { + property = _binprop.get("category"); + } else { + property = _capprop.get(name); // Looking into custom properties first + if (property == null) { + property = _binprop.get(name); + } else { + property = property.getFirstChild(); // vt:lpwstr node + } + } + String value = null; + if (property != null) { + value = property.getTextContent(); + if (value.startsWith("<") && value.endsWith(">")) { + value = null; // Property not set + } + } + return value; + } + + public String extractText() { + // ---------------------------- + String text = ""; + if (_body != null) { + Node body = this._body.getFirstChild(); // w:document node + // if (body == null) return text; // Should not happen + body = body.getFirstChild(); // w:body node + if (body != null) { + text = extractTextContent(body, text); + } + } + return text; + } + + public String updateProperty(String name, final String value) { + // -------------------------------------------------------- + if (_fields == null) { + _fields = collectFieldNodes(_body, new ArrayList()); + } + // Setting of the property + Node property = _capprop.get(name); // Looking into custom properties first + if (property == null) { + if ("author".equals(name)) { + property = _binprop.get("creator"); // thanks to Bill Gates... + } else { + property = _binprop.get(name); + } + // Built-in property names are capitalized into the document body (thanks again, Bill Gates) + char initial = name.charAt(0); + name = name.replaceFirst(String.valueOf(initial), String.valueOf( + initial).toUpperCase()); + } else { + property = property.getFirstChild(); + } + String oldvalue = null; + if (property != null) { + oldvalue = property.getTextContent(); + property.setTextContent(value); + + // Update of the property fields, if exist + String proname = " DOCPROPERTY " + name + " "; + + for (int j = 0; j < _fields.size(); j++) { + Node cnode = _fields.get(j); + String aname = cnode.getAttributes().getNamedItem("w:instr") + .getNodeValue(); + if (!aname.startsWith(proname)) { + continue; + } + + property = XDOM.getChildNode("w:t", cnode.getFirstChild()); + property.setTextContent(value); + } + } + return oldvalue; + } + + public boolean save() { + // ------------------- + return XDOM.saveDocument(_myfile, _myxdoc); + } + + // ============================================================================================================================== + // Private services + // ============================================================================================================================== + + private void initializeMe() { + // ---------------------------- + loadDocument(); // Parses myfile XML document + + _body = _mynodes.get("/word/document.xml"); + _capprop = new HashMap(); + _binprop = new HashMap(); + + Node property = _mynodes.get("/docProps/custom.xml"); + if (property != null) { + NodeList nlist = property.getFirstChild().getChildNodes(); // Contents of Properties node + for (int i = 0; i < nlist.getLength(); i++) { + property = nlist.item(i); + // if (!property.getNodeName().equals("property")) continue; + + String name = property.getAttributes().getNamedItem("name") + .getNodeValue(); + _capprop.put(name, property); + } + } + property = _mynodes.get("/docProps/core.xml"); + if (property != null) { + NodeList nlist = property.getFirstChild().getChildNodes(); // Contents of cp:coreProperties node + String name; + for (int i = 0; i < nlist.getLength(); i++) { + property = nlist.item(i); + name = property.getNodeName(); + // if (!name.startsWith("dc:")) continue; // Subset of user properties + + String[] parse = name.split(":"); + _binprop.put(parse[1], property); + } + } + } + + private List collectFieldNodes(final Node from, List to) { + // ------------------------------------------------------------------- + NodeList nlist = from.getChildNodes(); + for (int i = 0; i < nlist.getLength(); i++) { + Node cnode = nlist.item(i); + if (cnode.getNodeName().equals("w:fldSimple")) { + to.add(cnode); + } else { + to = collectFieldNodes(cnode, to); + } + } + return to; + } + + private String extractTextContent(final Node from, String to) { + // -------------------------------------------------------- + NodeList nlist = from.getChildNodes(); + for (int i = 0; i < nlist.getLength(); i++) { + Node cnode = nlist.item(i); + if (cnode.getNodeName().equals("w:t")) { + to = to + " " + cnode.getTextContent(); + } else { + to = extractTextContent(cnode, to); + } + } + return to; + } } \ No newline at end of file diff --git a/Workspace/SPlat/src/org/splat/manox/XDOM.java b/Workspace/SPlat/src/org/splat/manox/XDOM.java index 8cc4598..3c2eea1 100644 --- a/Workspace/SPlat/src/org/splat/manox/XDOM.java +++ b/Workspace/SPlat/src/org/splat/manox/XDOM.java @@ -5,7 +5,6 @@ package org.splat.manox; * @copyright OPEN CASCADE 2012 */ -import org.apache.log4j.Logger; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -20,6 +19,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.apache.log4j.Logger; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -27,9 +27,9 @@ import org.w3c.dom.NodeList; public class XDOM { - private final static Logger logger = Logger.getLogger(XDOM.class); + private final static Logger LOGGER = Logger.getLogger(XDOM.class); - public static org.w3c.dom.Document createDocument (String name) { + public static org.w3c.dom.Document createDocument (final String name) { // --------------------------------------------------------------- DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); try { @@ -42,17 +42,19 @@ public class XDOM { return document; } catch (Exception error) { - logger.error("Could not create document " + name + ", reason:", error); + LOGGER.error("Could not create document " + name + ", reason:", error); return null; } } - public static Node getChildNode (String name, Node from) { + public static Node getChildNode (final String name, final Node from) { // -------------------------------------------------------- NodeList nlist = from.getChildNodes(); for (int i=0; i mynodes = null; + protected transient File _myfile; + protected transient String _mytype; + protected transient org.w3c.dom.Document _myxdoc = null; + protected transient Map _mynodes = null; - protected final static Logger logger = Logger.getLogger(XMLDocument.class); + protected final static Logger LOGGER = Logger.getLogger(XMLDocument.class); // ============================================================================================================================== // Construction // ============================================================================================================================== - public XMLDocument (File file) { + public XMLDocument (final File file) { // ------------------------------ - myfile = file; - mytype = "any"; + _myfile = file; + _mytype = "any"; try { InputStream ist = new FileInputStream(file); BufferedReader buffer = new BufferedReader(new InputStreamReader(ist)); @@ -42,44 +43,52 @@ public class XMLDocument { if (line.indexOf("mso-application ") > 0) { String[] parse = line.split("\""); int natr; - for (natr=0; natr getNamedPartNodes (org.w3c.dom.Document xmldoc) { + private Map getNamedPartNodes (final org.w3c.dom.Document xmldoc) { // ---------------------------------------------------------------------------- HashMap mapnode = new HashMap(); Node root = xmldoc.getDocumentElement(); @@ -112,18 +121,20 @@ public class XMLDocument { for (int i=0; itrue siman-pmd.ruleset false + true diff --git a/Workspace/Siman-Common/.project b/Workspace/Siman-Common/.project index 775fb4d..a4f5095 100644 --- a/Workspace/Siman-Common/.project +++ b/Workspace/Siman-Common/.project @@ -42,7 +42,7 @@ - net.sourceforge.pmd.runtime.pmdBuilder + net.sourceforge.pmd.eclipse.plugin.pmdBuilder @@ -55,5 +55,6 @@ org.eclipse.jem.workbench.JavaEMFNature com.atlassw.tools.eclipse.checkstyle.CheckstyleNature net.sourceforge.pmd.runtime.pmdNature + net.sourceforge.pmd.eclipse.plugin.pmdNature diff --git a/Workspace/Siman-Common/build.properties b/Workspace/Siman-Common/build.properties index be45f31..aeda9b7 100644 --- a/Workspace/Siman-Common/build.properties +++ b/Workspace/Siman-Common/build.properties @@ -2,5 +2,12 @@ siman-common.src.dir=src siman-common.lib.dir=lib siman-common.bin.dir=bin siman-common.dist.dir=dist +siman-common.ext.dir=ext siman-common.jar.name=siman-common.jar splat.project.name=SPlat + +compiler.debug=on +compiler.generate.no.warnings=off +compiler.max.memory=256m +compiler.optimize=on +compiler.deprecation=on diff --git a/Workspace/Siman-Common/build.xml b/Workspace/Siman-Common/build.xml index 10f8462..afb8714 100644 --- a/Workspace/Siman-Common/build.xml +++ b/Workspace/Siman-Common/build.xml @@ -27,10 +27,31 @@ + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + - + diff --git a/Workspace/Siman/siman-pmd.ruleset b/Workspace/Siman/siman-pmd.ruleset index 534af48..e610618 100644 --- a/Workspace/Siman/siman-pmd.ruleset +++ b/Workspace/Siman/siman-pmd.ruleset @@ -8,7 +8,6 @@ level 5 : good practices - .*/org/.* .*/test/.* diff --git a/Workspace/Siman/src/hibernate.properties b/Workspace/Siman/src/hibernate.properties index 94db428..dd6d274 100644 --- a/Workspace/Siman/src/hibernate.properties +++ b/Workspace/Siman/src/hibernate.properties @@ -1,4 +1,4 @@ -# Generated at 12/10/2012 07:20:45 +# Generated at 02/11/2012 08:35:56 # Don't edit manually. See the source in D:\users\rkv\SIMAN\SIMAN_SRC\Workspace\Siman\conf\templates. # Connection properties connection.driver_class=com.mysql.jdbc.Driver diff --git a/Workspace/Siman/src/jdbc.properties b/Workspace/Siman/src/jdbc.properties index aeb70cc..7573dfc 100644 --- a/Workspace/Siman/src/jdbc.properties +++ b/Workspace/Siman/src/jdbc.properties @@ -1,4 +1,4 @@ -# Generated at 12/10/2012 07:20:45 +# Generated at 02/11/2012 08:35:56 # Don't edit manually. See the source in D:\users\rkv\SIMAN\SIMAN_SRC\Workspace\Siman\conf\templates. # Connection properties connection.url=jdbc:mysql://localhost/simer diff --git a/Workspace/Siman/src/org/splat/module/SaveDocumentAction.java b/Workspace/Siman/src/org/splat/module/SaveDocumentAction.java index 878975b..332d920 100644 --- a/Workspace/Siman/src/org/splat/module/SaveDocumentAction.java +++ b/Workspace/Siman/src/org/splat/module/SaveDocumentAction.java @@ -9,18 +9,8 @@ import java.util.Vector; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.Transaction; -import org.splat.kernel.Do; import org.splat.dal.bo.kernel.User; -import org.splat.service.DocumentTypeService; -import org.splat.service.PublicationService; -import org.splat.service.ScenarioService; -import org.splat.service.SimulationContextService; -import org.splat.service.StepService; -import org.splat.service.technical.RepositoryService; -import org.splat.simer.Action; -import org.splat.simer.OpenStudy; import org.splat.dal.bo.som.ConvertsRelation; -import org.splat.dal.dao.som.Database; import org.splat.dal.bo.som.Document; import org.splat.dal.bo.som.DocumentType; import org.splat.dal.bo.som.ProgressState; @@ -28,6 +18,16 @@ import org.splat.dal.bo.som.Publication; import org.splat.dal.bo.som.Scenario; import org.splat.dal.bo.som.SimulationContext; import org.splat.dal.bo.som.SimulationContextType; +import org.splat.dal.dao.som.Database; +import org.splat.kernel.Do; +import org.splat.service.DocumentTypeService; +import org.splat.service.PublicationService; +import org.splat.service.ScenarioService; +import org.splat.service.SimulationContextService; +import org.splat.service.StepService; +import org.splat.service.technical.RepositoryService; +import org.splat.simer.Action; +import org.splat.simer.OpenStudy; import org.splat.som.Step; public class SaveDocumentAction extends Action { @@ -105,8 +105,9 @@ public class SaveDocumentAction extends Action { .setAuthor(user)); // Writing the uploaded file into the created document File target = credoc.getSourceFile().asFile(); - if (target.exists()) + if (target.exists()) { target.delete(); + } Do.copy(upfile, target); // Instead of rename for keeping the "uploaded" file for further use // upfile.renameTo(target); @@ -129,8 +130,9 @@ public class SaveDocumentAction extends Action { credoc, "brep"); target = export.getTo().asFile(); - if (target.exists()) + if (target.exists()) { target.delete(); + } Do.copy(upfile, target); // Instead of rename for keeping the "uploaded" file for further use } // 2. Addition of simulation contexts @@ -200,7 +202,7 @@ public class SaveDocumentAction extends Action { * @param publicationService * the publicationService to set */ - public void setPublicationService(PublicationService publicationService) { + public void setPublicationService(final PublicationService publicationService) { _publicationService = publicationService; } @@ -219,7 +221,7 @@ public class SaveDocumentAction extends Action { * @param scenarioService * the scenarioService to set */ - public void setScenarioService(ScenarioService scenarioService) { + public void setScenarioService(final ScenarioService scenarioService) { _scenarioService = scenarioService; } @@ -238,7 +240,7 @@ public class SaveDocumentAction extends Action { * @param stepService * the stepService to set */ - public void setStepService(StepService stepService) { + public void setStepService(final StepService stepService) { _stepService = stepService; } @@ -268,16 +270,18 @@ public class SaveDocumentAction extends Action { Publication current = mystudy.getSelectedDocument(); Document.Properties dprop = new Document.Properties(); dprop.setAuthor(user); - if (summary.length() > 0) + if (summary.length() > 0) { dprop.setDescription(summary); + } Publication next = getStepService().versionDocument(step, current, dprop); // Writing the uploaded file into the created document File target = next.getSourceFile().asFile(); - if (target.exists()) + if (target.exists()) { target.delete(); + } Do.copy(upfile, target); // Instead of rename for keeping the "uploaded" file for further use // upfile.renameTo(target); @@ -301,8 +305,9 @@ public class SaveDocumentAction extends Action { "brep"); String fname = table[0]; - for (int i = 1; i < table.length - 1; i++) + for (int i = 1; i < table.length - 1; i++) { fname = fname + table[i]; + } upfile = new File(upath + fname + ".brep"); upfile.renameTo(export.getTo().asFile()); } @@ -335,27 +340,27 @@ public class SaveDocumentAction extends Action { return summary; } - public void setDescription(String summary) { + public void setDescription(final String summary) { // ------------------------------------------- this.summary = summary; } - public void setDocumentName(String name) { + public void setDocumentName(final String name) { // ----------------------------------------- this.docname = name; } - public void setDocumentState(String state) { + public void setDocumentState(final String state) { // ------------------------------------------- this.state = ProgressState.valueOf(state); } - public void setDocumentType(String value) { + public void setDocumentType(final String value) { // ------------------------------------------ this.doctype = Integer.valueOf(value); } - public void setFileName(String name) { + public void setFileName(final String name) { // ------------------------------------- this.filename = name; } @@ -364,16 +369,17 @@ public class SaveDocumentAction extends Action { // Private service // ============================================================================================================================== - private void setupDefaultUses(DocumentType type) { + private void setupDefaultUses(final DocumentType type) { Set uses = type.getDefaultUses(); for (Iterator i = uses.iterator(); i.hasNext();) { DocumentType usetype = i.next(); List usedoc = mystudy.collectInvolvedDocuments(usetype); - if (usedoc.isEmpty()) + if (usedoc.isEmpty()) { setupDefaultUses(usetype); - else + } else { defuses.addAll(usedoc); + } } } @@ -392,7 +398,7 @@ public class SaveDocumentAction extends Action { * @param repositoryService * the repositoryService to set */ - public void setRepositoryService(RepositoryService repositoryService) { + public void setRepositoryService(final RepositoryService repositoryService) { _repositoryService = repositoryService; } @@ -412,7 +418,7 @@ public class SaveDocumentAction extends Action { * the simulationContextService to set */ public void setSimulationContextService( - SimulationContextService simulationContextService) { + final SimulationContextService simulationContextService) { _simulationContextService = simulationContextService; } @@ -431,7 +437,7 @@ public class SaveDocumentAction extends Action { * @param documentTypeService * the documentTypeService to set */ - public void setDocumentTypeService(DocumentTypeService documentTypeService) { + public void setDocumentTypeService(final DocumentTypeService documentTypeService) { _documentTypeService = documentTypeService; } } \ No newline at end of file