]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman-Common/src/org/splat/service/DocumentTypeServiceImpl.java
Salome HOME
Modifications done to respect PMD rules. Versioning a document is fixed. Validation...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / DocumentTypeServiceImpl.java
index 874bcb3e8af2b1d7c216915b186715b71e52dea4..5fa287eb675225d1aa52edb17d34e25d77136346 100644 (file)
@@ -17,7 +17,6 @@ import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Restrictions;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.dao.som.Database;
 import org.splat.dal.dao.som.DocumentTypeDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
@@ -71,7 +70,7 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * @return the found document type
         */
        @Transactional(readOnly = true)
-       public DocumentType selectType(String name) {
+       public DocumentType selectType(final String name) {
                return getDocumentTypeDAO().findByCriteria(
                                Restrictions.eq("name", name));
        }
@@ -84,7 +83,7 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * @return the found document type
         */
        @Transactional(readOnly = true)
-       public DocumentType selectType(long index) {
+       public DocumentType selectType(final long index) {
                return getDocumentTypeDAO().get(index);
        }
 
@@ -102,7 +101,7 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         *             if some property is defined several times
         */
        @Transactional
-       public DocumentType createType(DocumentType.Properties tprop)
+       public DocumentType createType(final DocumentType.Properties tprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        MultiplyDefinedException {
                // TODO: Check for duplicate definition
@@ -119,7 +118,7 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * @return the list of found document types
         */
        @Transactional(readOnly = true)
-       public List<DocumentType> selectTypesOf(ProjectSettingsService.Step step) {
+       public List<DocumentType> selectTypesOf(final ProjectSettingsService.Step step) {
                Integer number = step.getNumber();
                String sampleStr = new StringBuffer("%-").append(number).append("-%")
                                .toString();
@@ -137,12 +136,14 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * @return true if approval succeeded
         */
        @Transactional
-    public boolean approve (DocumentType aType) {
-      if  (aType.getState() != ProgressState.inCHECK) return false;      
-      aType.setState(ProgressState.APPROVED);        // The type name is supposed being localized
-      getDocumentTypeDAO().update(aType);
-         return true;
-    }
+    public boolean approve(final DocumentType aType) {
+               boolean res = (aType.getState() == ProgressState.inCHECK);
+               if (res) {
+                       aType.setState(ProgressState.APPROVED); // The type name is supposed being localized
+                       getDocumentTypeDAO().update(aType);
+               }
+               return res;
+       }
 
        /**
         * Get the documentTypeDAO.
@@ -159,7 +160,7 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * @param documentTypeDAO
         *            the documentTypeDAO to set
         */
-       public void setDocumentTypeDAO(DocumentTypeDAO documentTypeDAO) {
+       public void setDocumentTypeDAO(final DocumentTypeDAO documentTypeDAO) {
                _documentTypeDAO = documentTypeDAO;
        }
 }