* @copyright OPEN CASCADE 2012
*****************************************************************************/
-package org.splat.service;
+package org.splat.service;
import java.util.List;
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
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.
*