Salome HOME
Refactoring continues: UserService is created instead of UserDirectory. Database...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / DocumentTypeServiceImpl.java
index 63fecb5b6236687d0585a6eabae003b7b2fa6dc0..874bcb3e8af2b1d7c216915b186715b71e52dea4 100644 (file)
@@ -16,6 +16,8 @@ import org.hibernate.Hibernate;
 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;
@@ -40,7 +42,8 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * 
         * @return the list of all document types
         */
-       @Transactional(readOnly = true)
+//     @Transactional(readOnly = true)
+       @Transactional
        public List<DocumentType> selectAllTypes() {
                List<DocumentType> types = getDocumentTypeDAO().getAll();
                for (Iterator<DocumentType> i = types.iterator(); i.hasNext();) {
@@ -128,6 +131,19 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
                return types;
        }
 
+       /**
+        * Approve the document type.
+        * @param aType the document type to approve
+        * @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;
+    }
+
        /**
         * Get the documentTypeDAO.
         *