]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeServiceImpl.java
Salome HOME
Refactoring continues: UserService is created instead of UserDirectory. Database...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / KnowledgeElementTypeServiceImpl.java
index a5dd084e996c5ec73a0876d389cd1b97eede91d5..f644d141dc7720a49a5c83230ab3ae2bbd5c2f66 100644 (file)
@@ -8,7 +8,7 @@
  * @copyright      OPEN CASCADE 2012
  *****************************************************************************/
 
-package org.splat.service; 
+package org.splat.service;
 
 import java.util.List;
 
@@ -17,10 +17,11 @@ import org.hibernate.criterion.Restrictions;
 import org.splat.dal.bo.som.KnowledgeElementType;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.dao.som.KnowledgeElementTypeDAO;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * KnowledgeElementTypeService implementation for working with knowledge types.
- *
+ * 
  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 public class KnowledgeElementTypeServiceImpl implements
@@ -89,6 +90,43 @@ public class KnowledgeElementTypeServiceImpl implements
                return getKnowledgeElementTypeDAO().get(index);
        }
 
+       /**
+        * Approve the knowledge type.
+        * 
+        * @param kelt
+        *            the knowledge type to approve
+        * @return true if approval succeeded
+        */
+       @Transactional
+       public boolean approve(KnowledgeElementType kelt) {
+               if (kelt.getState() != ProgressState.inCHECK)
+                       return false;
+               kelt.setState(ProgressState.APPROVED); // The type name is supposed being localized
+               if (kelt.isSaved()) {
+                       getKnowledgeElementTypeDAO().update(kelt);
+               }
+               return true;
+       }
+
+       /**
+        * Reserves this type for the management of simulation contexts. For being able to get the studies in which simulation contexts are
+        * used, all study scenarios are indexed through this knowledge element type, whether they include knowledge elements or not.
+        * 
+        * @param kelt
+        *            the knowledge type to approve
+        * @return true if approval succeeded
+        */
+       @Transactional
+       public boolean reserve(KnowledgeElementType kelt) {
+               if (kelt.getState() != ProgressState.inCHECK)
+                       return false;
+               kelt.setState(ProgressState.inWORK);
+               if (kelt.isSaved()) {
+                       getKnowledgeElementTypeDAO().update(kelt);
+               }
+               return true;
+       }
+
        /**
         * Get the knowledgeElementTypeDAO.
         *