From 330b4ef8e6c87a25897847aaade03d2445bafb8c Mon Sep 17 00:00:00 2001
From: rkv
Date: Fri, 19 Oct 2012 12:27:16 +0000
Subject: [PATCH] More business logic has been moved from BO to services.
ServiceLocator is created as a temporary solution for *Rights classes.
---
.../common/properties/MessageKeyEnum.java | 2 +-
.../splat/dal/bo/som/ConvertsRelation.java | 2 +-
.../src/org/splat/dal/bo/som/Document.java | 374 +---
.../org/splat/dal/bo/som/DocumentType.java | 4 +-
.../src/org/splat/dal/bo/som/File.java | 2 +-
.../splat/dal/bo/som/KnowledgeElement.hbm.xml | 2 +-
.../splat/dal/bo/som/KnowledgeElement.java | 64 +-
.../src/org/splat/dal/bo/som/Publication.java | 15 -
.../src/org/splat/dal/bo/som/Scenario.java | 54 +-
.../src/org/splat/dal/bo/som/Study.java | 732 ++++----
.../src/org/splat/dal/bo/som/Timestamp.java | 2 +-
.../org/splat/dal/bo/som/ValidationCycle.java | 135 +-
.../src/org/splat/dal/dao/kernel/AnyDAO.java | 2 +-
.../org/splat/dal/dao/kernel/AnyDAOImpl.java | 2 +-
.../splat/dal/dao/kernel/AttributeDAO.java | 2 +-
.../dal/dao/kernel/AttributeDAOImpl.java | 2 +-
.../org/splat/dal/dao/kernel/EntityDAO.java | 2 +-
.../splat/dal/dao/kernel/EntityDAOImpl.java | 2 +-
.../org/splat/dal/dao/kernel/GenericDAO.java | 36 +-
.../splat/dal/dao/kernel/GenericDAOImpl.java | 51 +-
.../splat/dal/dao/kernel/PersistentDAO.java | 2 +-
.../dal/dao/kernel/PersistentDAOImpl.java | 2 +-
.../org/splat/dal/dao/kernel/RelationDAO.java | 2 +-
.../splat/dal/dao/kernel/RelationDAOImpl.java | 2 +-
.../src/org/splat/dal/dao/kernel/RoleDAO.java | 2 +-
.../org/splat/dal/dao/kernel/RoleDAOImpl.java | 2 +-
.../dal/dao/kernel/TextAttributeDAO.java | 2 +-
.../dal/dao/kernel/TextAttributeDAOImpl.java | 2 +-
.../src/org/splat/dal/dao/kernel/UserDAO.java | 2 +-
.../org/splat/dal/dao/kernel/UserDAOImpl.java | 2 +-
.../dal/dao/som/ContributorRelationDAO.java | 2 +-
.../dao/som/ContributorRelationDAOImpl.java | 2 +-
.../dal/dao/som/ConvertsRelationDAO.java | 2 +-
.../dal/dao/som/ConvertsRelationDAOImpl.java | 2 +-
.../org/splat/dal/dao/som/DocumentDAO.java | 2 +-
.../splat/dal/dao/som/DocumentDAOImpl.java | 2 +-
.../splat/dal/dao/som/DocumentTypeDAO.java | 2 +-
.../dal/dao/som/DocumentTypeDAOImpl.java | 2 +-
.../src/org/splat/dal/dao/som/FileDAO.java | 2 +-
.../org/splat/dal/dao/som/FileDAOImpl.java | 2 +-
.../org/splat/dal/dao/som/IDBuilderDAO.java | 2 +-
.../splat/dal/dao/som/IDBuilderDAOImpl.java | 2 +-
.../dal/dao/som/KnowledgeElementDAO.java | 2 +-
.../dal/dao/som/KnowledgeElementDAOImpl.java | 2 +-
.../dal/dao/som/KnowledgeElementTypeDAO.java | 2 +-
.../dao/som/KnowledgeElementTypeDAOImpl.java | 2 +-
.../splat/dal/dao/som/ProjectElementDAO.java | 2 +-
.../dal/dao/som/ProjectElementDAOImpl.java | 2 +-
.../org/splat/dal/dao/som/PublicationDAO.java | 2 +-
.../splat/dal/dao/som/PublicationDAOImpl.java | 2 +-
.../org/splat/dal/dao/som/ScenarioDAO.java | 2 +-
.../splat/dal/dao/som/ScenarioDAOImpl.java | 2 +-
.../dal/dao/som/SimulationContextDAO.java | 2 +-
.../dal/dao/som/SimulationContextDAOImpl.java | 2 +-
.../dal/dao/som/SimulationContextTypeDAO.java | 2 +-
.../dao/som/SimulationContextTypeDAOImpl.java | 2 +-
.../splat/dal/dao/som/StampRelationDAO.java | 2 +-
.../dal/dao/som/StampRelationDAOImpl.java | 2 +-
.../src/org/splat/dal/dao/som/StudyDAO.java | 2 +-
.../org/splat/dal/dao/som/StudyDAOImpl.java | 2 +-
.../org/splat/dal/dao/som/TimestampDAO.java | 2 +-
.../splat/dal/dao/som/TimestampDAOImpl.java | 2 +-
.../splat/dal/dao/som/UsedByRelationDAO.java | 2 +-
.../dal/dao/som/UsedByRelationDAOImpl.java | 2 +-
.../splat/dal/dao/som/UsesRelationDAO.java | 2 +-
.../dal/dao/som/UsesRelationDAOImpl.java | 2 +-
.../splat/dal/dao/som/ValidationCycleDAO.java | 2 +-
.../dal/dao/som/ValidationCycleDAOImpl.java | 2 +-
.../dao/som/ValidationCycleRelationDAO.java | 2 +-
.../som/ValidationCycleRelationDAOImpl.java | 2 +-
.../dal/dao/som/VersionsRelationDAO.java | 2 +-
.../dal/dao/som/VersionsRelationDAOImpl.java | 2 +-
.../splat/exception/AbstractException.java | 2 +-
.../exception/LockAlreadyExistsException.java | 2 +-
.../exception/LockNotExistsException.java | 2 +-
.../exception/LockOutdatedException.java | 2 +-
.../exception/LockProtectedException.java | 2 +-
.../src/org/splat/i18n/I18nUtils.java | 2 +-
.../src/org/splat/log/AppLogger.java | 2 +-
.../org/splat/service/DocumentService.java | 163 +-
.../splat/service/DocumentServiceImpl.java | 409 ++++-
.../splat/service/DocumentTypeService.java | 73 +-
.../service/DocumentTypeServiceImpl.java | 139 +-
.../service/KnowledgeElementService.java | 57 +-
.../service/KnowledgeElementServiceImpl.java | 165 +-
.../service/KnowledgeElementTypeService.java | 67 +
.../KnowledgeElementTypeServiceImpl.java | 112 ++
.../src/org/splat/service/LockService.java | 2 +-
.../org/splat/service/LockServiceImpl.java | 2 +-
.../splat/service/ProjectElementService.java | 2 +-
.../service/ProjectElementServiceImpl.java | 2 +-
.../org/splat/service/PublicationService.java | 42 +-
.../splat/service/PublicationServiceImpl.java | 211 ++-
.../org/splat/service/ScenarioService.java | 22 +-
.../splat/service/ScenarioServiceImpl.java | 130 +-
.../src/org/splat/service/SearchService.java | 2 +-
.../org/splat/service/SearchServiceImpl.java | 2 +-
.../src/org/splat/service/ServiceLocator.java | 25 +
.../org/splat/service/ServiceLocatorImpl.java | 63 +
.../service/SimulationContextService.java | 2 +-
.../service/SimulationContextServiceImpl.java | 2 +-
.../src/org/splat/service/StepService.java | 133 +-
.../org/splat/service/StepServiceImpl.java | 197 ++-
.../src/org/splat/service/StudyService.java | 82 +-
.../org/splat/service/StudyServiceImpl.java | 448 ++++-
.../src/org/splat/service/UtilService.java | 2 +-
.../org/splat/service/UtilServiceImpl.java | 2 +-
.../service/technical/DatabaseService.java | 2 +-
.../technical/DatabaseServiceImpl.java | 2 +-
.../splat/service/technical/IndexService.java | 2 +-
.../service/technical/IndexServiceImpl.java | 3 +-
.../technical/ProjectSettingsService.java | 2 +-
.../technical/ProjectSettingsServiceImpl.java | 62 +-
.../service/technical/RepositoryService.java | 2 +-
.../technical/RepositoryServiceImpl.java | 2 +-
.../src/org/splat/som/DocumentRights.java | 6 +-
.../Siman-Common/src/org/splat/som/Step.java | 378 ++--
.../src/org/splat/som/StepRights.java | 16 +-
.../src/org/splat/som/StudyRights.java | 14 +-
.../src/org/splat/util/BeanHelper.java | 2 +-
.../org/splat/util/TimestampTransformer.java | 2 +-
.../util/TimestampTransformerFactory.java | 2 +-
.../src/spring/businessServiceContext.xml | 56 +-
.../src/spring/technicalServiceContext.xml | 8 +-
.../src/test/splat/common/BaseTest.java | 2 +-
.../splat/common/TestListingAndOrder.java | 2 +-
.../splat/dao/TestKnowledgeElementDAO.java | 2 +-
.../org/splat/module/SaveDocumentAction.java | 36 +-
.../org/splat/simer/ApplicationSettings.java | 1551 +++++++++--------
.../org/splat/simer/EditDocumentAction.java | 27 +-
.../simer/EditKnowledgeElementAction.java | 324 ++--
.../org/splat/simer/ImportDocumentAction.java | 26 +-
.../org/splat/simer/NewScenarioAction.java | 46 +-
.../src/org/splat/simer/NewStudyAction.java | 23 +-
.../src/org/splat/simer/OpenKnowledge.java | 22 -
.../Siman/src/org/splat/simer/OpenObject.java | 564 +++---
.../Siman/src/org/splat/simer/OpenStudy.java | 905 +++++-----
.../splat/simer/SearchKnowledgeAction.java | 427 +++--
.../splat/simer/StudyPropertiesAction.java | 740 ++++----
.../Siman/src/spring/applicationContext.xml | 45 +-
140 files changed, 5909 insertions(+), 3557 deletions(-)
create mode 100644 Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeService.java
create mode 100644 Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeServiceImpl.java
create mode 100644 Workspace/Siman-Common/src/org/splat/service/ServiceLocator.java
create mode 100644 Workspace/Siman-Common/src/org/splat/service/ServiceLocatorImpl.java
diff --git a/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java b/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java
index 6c1950b..b7c2921 100644
--- a/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java
+++ b/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 03.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/ConvertsRelation.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/ConvertsRelation.java
index ff2997a..1e79f75 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/ConvertsRelation.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/ConvertsRelation.java
@@ -36,7 +36,7 @@ public class ConvertsRelation extends Relation {
this.got = true;
this.description = null; // Conversion not described
}
- protected ConvertsRelation (Document from, File to, String description) {
+ public ConvertsRelation (Document from, File to, String description) {
// -----------------------------------------------------------------------
super(from);
this.refer = to;
diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java
index d998f3e..f084a22 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java
@@ -6,36 +6,27 @@ package org.splat.dal.bo.som;
* @copyright OPEN CASCADE 2012
*/
-import java.text.DecimalFormat;
-import java.text.SimpleDateFormat;
import java.util.Arrays;
-import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
-import org.hibernate.Hibernate;
-import org.hibernate.Session;
-
import org.splat.dal.bo.kernel.Persistent;
import org.splat.dal.bo.kernel.Relation;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.Timestamp.ComparatorByDate;
-import org.splat.dal.dao.som.Database;
-import org.splat.kernel.NotApplicableException;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
-import org.splat.manox.Reader;
-import org.splat.manox.Toolbox;
-import org.splat.service.StudyService;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.service.technical.ProjectSettingsServiceImpl;
-import org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming;
import org.splat.som.Revision;
import org.splat.som.Step;
+/**
+ * Document persistent class.
+ */
public class Document extends Entity {
// Persistent fields
@@ -50,8 +41,6 @@ public class Document extends Entity {
private int history;
private User author;
private Date lasdate;
- private ProjectSettingsService _projectSettingsService;
- private StudyService _studyService;
// Transient fields
public static String suformat = "00"; // Format of the suffix number of document did and file name
@@ -60,7 +49,9 @@ public class Document extends Entity {
// Construction
// ==============================================================================================================================
- // Fields initialization class
+ /**
+ * Fields initialization class.
+ */
public static class Properties extends Persistent.Properties {
// ------------------------------------------------------------
private DocumentType type = null;
@@ -493,327 +484,6 @@ public class Document extends Entity {
return (history > 0);
}
- // ==============================================================================================================================
- // Public services
- // ==============================================================================================================================
-
- public static DocumentType createType(DocumentType.Properties tprop)
- throws MissedPropertyException, InvalidPropertyException,
- MultiplyDefinedException, RuntimeException {
- // ---------------------------------------------------------------------
- // TODO: Check for duplicate definition
- DocumentType type = new DocumentType(tprop);
- Session session = Database.getSession();
- session.save(type);
-
- return type;
- }
-
- public static Properties extractProperties(java.io.File file) {
- // --------------------------------------------------------------
- Properties fprop = new Properties();
- Reader tool = Toolbox.getReader(file);
- String value;
- if (tool != null)
- try {
- value = tool.extractProperty("title");
- if (value != null)
- fprop.setName(value);
-
- value = tool.extractProperty("reference");
- if (value != null)
- fprop.setReference(value);
- } catch (Exception e) {
- }
- return fprop;
- }
-
- @SuppressWarnings("unchecked")
- public static List selectAllTypes() {
- // --------------------------------------------------
- String query = "from DocumentType";
-
- List types = Database.getSession().createQuery(query)
- .list();
- for (Iterator i = types.iterator(); i.hasNext();) {
- Hibernate.initialize(i.next()); // Supposed fetching document types
- }
- return types;
- }
-
- @SuppressWarnings("unchecked")
- public static List selectResultTypes() {
- // -----------------------------------------------------
- String query = "from DocumentType where result is not null order by result asc";
-
- return Database.getSession().createQuery(query).list();
- }
-
- public static DocumentType selectType(String name) {
- // ---------------------------------------------------
- String query = new StringBuffer("from DocumentType where name='")
- .append(name).append("'").toString();
-
- return (DocumentType) Database.getSession().createQuery(query)
- .uniqueResult();
- }
-
- public static DocumentType selectType(long index) {
- // -------------------------------------------------
- String query = new StringBuffer("from DocumentType where rid='")
- .append(index).append("'").toString();
-
- return (DocumentType) Database.getSession().createQuery(query)
- .uniqueResult();
- }
-
- @SuppressWarnings("unchecked")
- public static List selectTypesOf(
- ProjectSettingsService.Step step) {
- // --------------------------------------------------------------------------
- Integer number = step.getNumber();
- String query = new StringBuffer("from DocumentType").append(
- " where step like '%-").append(number).append("-%'").toString();
-
- List types = Database.getSession().createQuery(query)
- .list();
- for (Iterator i = types.iterator(); i.hasNext();) {
- Hibernate.initialize(i.next()); // For fetching document types
- }
- return types;
- }
-
- // ==============================================================================================================================
- // Protected services
- // ==============================================================================================================================
-
- protected ConvertsRelation attach(String format) {
- // -------------------------------------------------
- return attach(format, null);
- }
-
- protected ConvertsRelation attach(String format, String description) {
- // ---------------------------------------------------------------------
- String path = this.getRelativePath();
- File export = new File(path + "." + format);
- ConvertsRelation attach = new ConvertsRelation(this, export,
- description);
- Session session = Database.getSession();
-
- session.save(export);
- session.save(attach);
-
- this.addRelation(attach); // Updates this
-
- return attach;
- }
-
- public boolean buildReferenceFrom(ProjectElement scope, Document lineage) {
- // -----------------------------------------------------------------------------
- if (state != ProgressState.inWORK)
- return false;
- Study owner = null;
- Scenario context = null;
- if (scope instanceof Study)
- owner = (Study) scope;
- else {
- context = ((Scenario) scope);
- owner = context.getOwnerStudy();
- }
- did = lineage.did;
- if (context != null && (lineage.isVersioned() || owner.shares(lineage))) {
- version = new Revision(version).setBranch(context.getReference())
- .toString();
- }
- return true;
- }
-
- public boolean buildReferenceFrom(Study scope) {
- // --------------------------------------------------
- if (state != ProgressState.inWORK && state != ProgressState.EXTERN)
- return false;
- DecimalFormat tostring = new DecimalFormat(suformat);
-
- did = did.replace("%" + suformat, tostring.format(scope
- .getLastLocalIndex()));
- return true;
- }
-
- public boolean demote() {
- // ---------------------------
- ValidationStep torem;
-
- if (state == ProgressState.inCHECK) {
- state = ProgressState.inDRAFT;
- torem = ValidationStep.REVIEW;
- // This operation must not change the version number of documents.
- // Consequently, inDRAFT documents may have a minor version number equal to zero.
- } else if (state == ProgressState.inDRAFT) {
- state = ProgressState.inWORK;
- torem = ValidationStep.PROMOTION;
- } else {
- return false;
- }
- for (Iterator i = this.getAllRelations().iterator(); i
- .hasNext();) {
- Relation link = i.next();
- if (!(link instanceof StampRelation))
- continue;
- if (((StampRelation) link).getStampType() != torem)
- continue;
- i.remove();
- break;
- }
- Database.getSession().update(this);
- return true;
- }
-
- /**
- * Increments the reference count of this document following its publication into a Study step.
- *
- * @see #release()
- */
- public void hold() {
- // ----------------------
- countag += 1;
- if (this.isSaved())
- Database.getSession().update(this);
- }
-
- public boolean promote(Timestamp stamp) {
- // -------------------------------------------
- ProgressState newstate = null;
-
- if (state == ProgressState.inWORK) {
- newstate = ProgressState.inDRAFT; // Promotion to being reviewed
- } else if (state == ProgressState.inDRAFT) {
- newstate = ProgressState.inCHECK; // Promotion to approval
- Revision myvers = new Revision(version);
- if (myvers.isMinor()) {
- version = myvers.incrementAs(newstate).toString();
- // TODO: If my physical file is programatically editable, update its (property) version number
- // ISSUE: What about attached files such as PDF if exist, should we remove them ?
- }
- } else if (state == ProgressState.inCHECK) {
- newstate = ProgressState.APPROVED;
- }
- this.state = newstate;
- if (stamp != null)
- this.addRelation(stamp.getContext());
- Database.getSession().update(this);
- return true;
- }
-
- /**
- * Decrements the reference count of this document following the removal of a Publication from a Study step.
- *
- * @see #hold()
- */
- public void release() {
- // -------------------------
- countag -= 1;
- if (this.isSaved())
- Database.getSession().update(this);
- }
-
- protected void rename(String title) throws InvalidPropertyException {
- // ------------------------------------
- if (title.length() == 0)
- throw new InvalidPropertyException("name");
-
- Calendar current = Calendar.getInstance();
- this.name = title;
- this.lasdate = current.getTime(); // Today
- Database.getSession().update(this);
- }
-
- public void updateAs(Revision newvers) {
- // ------------------------------------------
- version = newvers.setBranch(version).toString(); // Branch names are propagated by the versionning
- ProgressState newstate = ProgressState.inCHECK;
- if (newvers.isMinor())
- newstate = ProgressState.inWORK;
- state = null; // Just to tell updateAs(sate) to not increment the version number
- updateAs(newstate);
- }
-
- public void updateAs(ProgressState state) {
- // ---------------------------------------------
- Document previous = null;
-
- // Set of version number
- if (state == ProgressState.EXTERN) {
- if (this.state != ProgressState.EXTERN)
- this.version = null; // Strange use-case...
- } else {
- Revision myvers = new Revision(version);
- if (!myvers.isNull()) { // Versionning context
- for (Iterator i = getAllRelations().iterator(); i
- .hasNext();) {
- Relation link = i.next();
- if (!link.getClass().equals(VersionsRelation.class))
- continue;
- previous = (Document) link.getTo(); // Versioned document
- break;
- }
- }
- if (this.state != null)
- myvers.incrementAs(state); // Incrementation if the reversion number is not imposed
- this.version = myvers.toString();
- }
- // Update this document and the previous version, if exit
- Session session = Database.getSession();
- if (previous != null) {
- previous.history += 1;
- session.update(previous);
- }
- this.state = state;
- session.update(this);
- }
-
- // protected void upgrade () {
- // -------------------------
- // if (this.state != ProgressState.inWORK) return;
- //
- // Calendar current = Calendar.getInstance();
- // for (Iterator i=getAllRelations().iterator(); i.hasNext();) {
- // Relation link = i.next();
- // if (!link.getClass().equals(UsesRelation.class)) continue;
- //
- // Document used = (Document)link.getTo();
- // if (!used.isVersioned()) continue;
- // TODO: Update the uses relation
- // }
- // this.promote();
- // this.lasdate = current.getTime(); // Today
- // Database.getSession().update(this);
- //
- // TODO: Promote documents using this one
- // }
-
- /**
- * @return
- */
- private ProjectSettingsService getProjectSettingsService() {
- return _projectSettingsService;
- }
-
- public void setProjectSettingsService(
- ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
- }
-
- /**
- * @return
- */
- public StudyService getStudyService() {
- return _studyService;
- }
-
- public void setStudyService(StudyService studyService) {
- _studyService = studyService;
- }
-
/**
* Get the step.
* @return the step
@@ -877,4 +547,36 @@ public class Document extends Entity {
public void setHistory(int history) {
this.history = history;
}
+
+ /**
+ * Set the version.
+ * @param version the version to set
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * Set the state.
+ * @param state the state to set
+ */
+ public void setProgressState(ProgressState state) {
+ this.state = state;
+ }
+
+ /**
+ * Get the countag.
+ * @return the countag
+ */
+ public int getCountag() {
+ return countag;
+ }
+
+ /**
+ * Set the countag.
+ * @param countag the countag to set
+ */
+ public void setCountag(int countag) {
+ this.countag = countag;
+ }
}
\ No newline at end of file
diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/DocumentType.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/DocumentType.java
index 6b83936..3f68472 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/DocumentType.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/DocumentType.java
@@ -5,7 +5,6 @@ package org.splat.dal.bo.som;
* @copyright OPEN CASCADE 2012
*/
-import java.util.List;
import java.util.Set;
import java.util.HashSet;
@@ -15,7 +14,6 @@ import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.technical.ProjectSettingsService.Step;
public class DocumentType extends Persistent {
@@ -85,7 +83,7 @@ public class DocumentType extends Persistent {
// -------------------------
}
// Initialization constructor
- protected DocumentType (Properties dprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
+ public DocumentType (Properties dprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
// -----------------------------------------
super(dprop); // Throws one of the above exception if not valid
name = dprop.name;
diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/File.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/File.java
index 64f2998..5675884 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/File.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/File.java
@@ -37,7 +37,7 @@ public class File extends Persistent {
this.myfile = null;
}
// Internal constructors
- protected File (String path) {
+ public File (String path) {
// ----------------------------
Calendar current = Calendar.getInstance();
String[] table = path.split("\\x2E");
diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/KnowledgeElement.hbm.xml b/Workspace/Siman-Common/src/org/splat/dal/bo/som/KnowledgeElement.hbm.xml
index 15a2c12..d471b0f 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/KnowledgeElement.hbm.xml
+++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/KnowledgeElement.hbm.xml
@@ -28,7 +28,7 @@
-
+
diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/KnowledgeElement.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/KnowledgeElement.java
index 0923f9f..0bfa2e5 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/KnowledgeElement.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/KnowledgeElement.java
@@ -275,63 +275,6 @@ public class KnowledgeElement extends Persistent {
return getOwnerScenario().getOwnerStudy().getVisibility();
}
- public void update (String description) {
-// ---------------------------------------
- value = description.trim();
- if (!value.startsWith("")) {
- StringBuffer text = new StringBuffer("
");
- int index = value.indexOf("
");
- if (index > 0) {
- value = text.append(value.substring(0, index)).append("
").append(value.substring(index)).toString();
- } else {
- value = text.append(value).append("
").toString();
- }
- }
- Database.getSession().update(this); // No need to update the Lucene index
- }
-
-// ==============================================================================================================================
-// Public services
-// ==============================================================================================================================
-
- public static KnowledgeElementType createType (String name) throws RuntimeException {
-// -----------------------------------------------------------
-//TODO: Check for duplicate definition
- KnowledgeElementType kelt = new KnowledgeElementType(name);
- Session session = Database.getSession();
- session.save(kelt);
-
- return kelt;
- }
-
- @SuppressWarnings("unchecked")
- public static List selectAllTypes () {
-// ----------------------------------------------------------
- StringBuffer query = new StringBuffer("from KnowledgeElementType");
- query = query.append(" order by rid asc");
- return Database.getSession().createQuery(query.toString()).list();
- }
-
- @SuppressWarnings("unchecked")
- public static List selectTypesWhere (ProgressState state) {
-// -------------------------------------------------------------------------------
- StringBuffer query = new StringBuffer("from KnowledgeElementType where state='").append(state).append("'");
- query = query.append(" order by rid asc");
- return Database.getSession().createQuery(query.toString()).list();
- }
-
- public static KnowledgeElementType selectType (String name) {
-// -----------------------------------------------------------
- StringBuffer query = new StringBuffer("from KnowledgeElementType where name='").append(name).append("'");
- return (KnowledgeElementType)Database.getSession().createQuery(query.toString()).uniqueResult();
- }
-
- public static KnowledgeElementType selectType (int index) {
-// ---------------------------------------------------------
- StringBuffer query = new StringBuffer("from KnowledgeElementType where rid='").append(index).append("'");
- return (KnowledgeElementType)Database.getSession().createQuery(query.toString()).uniqueResult();
- }
-
/**
* @param aState knowledge element progress state to set
*/
@@ -344,4 +287,11 @@ public class KnowledgeElement extends Persistent {
public void setTitle(String aTitle) {
title = aTitle;
}
+ /**
+ * Set the value.
+ * @param value the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
}
\ No newline at end of file
diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Publication.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Publication.java
index 0ce5c59..c869da1 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Publication.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Publication.java
@@ -108,16 +108,6 @@ public class Publication extends Persistent {
return true;
}
- public ConvertsRelation attach (String format) {
-// ----------------------------------------------
- return mydoc.attach(format);
- }
-
- public ConvertsRelation attach (String format, String description) {
-// ------------------------------------------------------------------
- return mydoc.attach(format, description);
- }
-
/**
* Returns either the Study Scenario or the Study itself to which this publication belongs, depending on the Study Step into
* which the referenced document has been published.
@@ -209,11 +199,6 @@ public class Publication extends Persistent {
public void setIsnew(char isnew) {
this.isnew = isnew;
}
- public void rename (String title) throws InvalidPropertyException {
-// ---------------------------------
- mydoc.rename(title);
- }
-
/**
* Out-dates this publication and recursively all publications using this one.
* Typically, a publication is out-dated when modifying a document to which it depends.
diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Scenario.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Scenario.java
index f4458be..362e169 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Scenario.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Scenario.java
@@ -5,7 +5,6 @@ package org.splat.dal.bo.som;
* @copyright OPEN CASCADE 2012
*/
-import java.io.IOException;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
@@ -16,17 +15,12 @@ import java.util.Set;
import java.util.HashSet;
import java.util.Vector;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.splat.dal.bo.kernel.Persistent;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.dao.som.Database;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
-import org.splat.service.StepService;
-import org.splat.service.technical.IndexService;
import org.splat.som.Step;
@@ -36,19 +30,34 @@ public class Scenario extends ProjectElement {
private Study owner;
private int sid; // Identifier unique in the scope of owner study
private User cuser; // User having checked-out the scenario, if done
+ /**
+ * The persistent set of scenario knowledge elements.
+ */
private Set kelms;
// Transient fields
- private HashMap> known;
- private List knowl; // Copy of kelms excluding the internal Knowledge Element (ucase below)
- private KnowledgeElement ucase; // Internal Knowledge Element for accessing to all used simulation contexts
+ /**
+ * The transient map of knowledge elements grouped by types.
+ */
+ transient private HashMap> known;
+ /**
+ * The scenario transient list of knowledge elements.
+ */
+ transient private List knowl; // Copy of kelms excluding the internal Knowledge Element (ucase below)
+ /**
+ * The scenario transient "use case" knowledge element.
+ */
+ transient private KnowledgeElement ucase; // Internal Knowledge Element for accessing to all used simulation contexts
// ==============================================================================================================================
// Construction
// ==============================================================================================================================
-// Fields initialization class
+
+ /**
+ * Fields initialization class.
+ */
public static class Properties extends Persistent.Properties {
// ------------------------------------------------------------
private Study owner = null;
@@ -151,7 +160,7 @@ public class Scenario extends ProjectElement {
kelms = new HashSet();
manager = sprop.manager;
- if (!owner.isStaffedBy(manager)) throw new InvalidPropertyException("manager");
+//RKV: The business logic is moved to business services: if (!owner.isStaffedBy(manager)) throw new InvalidPropertyException("manager");
credate = sprop.date; // Inherited attribute
if (credate == null) {
@@ -258,26 +267,29 @@ public class Scenario extends ProjectElement {
// Private services
// ==============================================================================================================================
/**
- * @return
+ * Get the persistent set of knowledge elements.
+ * @return the persistent set of scenario knowledge elements
*/
public Set getKnowledgeElements() {
return kelms;
}
- /**
- * @param kelm
+ /**
+ * Get the transient list of knowledge elements.
+ * @return the transient list of knowledge elements
*/
- public void setUcase(KnowledgeElement kelm) {
- ucase = kelm;
+ public List getKnowledgeElementsList() {
+ return knowl;
}
/**
- * @return
+ * Set the scenario transient "use case" knowledge element.
+ * @param kelm the scenario transient "use case" knowledge element
*/
- public List getKnowledgeElementsList() {
- return knowl;
+ public void setUcase(KnowledgeElement kelm) {
+ ucase = kelm;
}
/**
- * Get the ucase.
- * @return the ucase
+ * Get the scenario transient "use case" knowledge element.
+ * @return the scenario transient "use case" knowledge element
*/
public KnowledgeElement getUcase() {
return ucase;
diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.java
index 7fdb682..1fd88f4 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.java
@@ -1,4 +1,5 @@
package org.splat.dal.bo.som;
+
/**
*
* @author Daniel Brunier-Coulin
@@ -6,443 +7,392 @@ package org.splat.dal.bo.som;
*/
import java.util.Calendar;
-import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.LinkedList;
+import java.util.Map;
import java.util.Set;
import java.util.Vector;
-import org.hibernate.Session;
import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.bo.kernel.Relation;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
import org.splat.kernel.MultiplyDefinedException;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
-import org.splat.kernel.UserDirectory;
-import org.splat.service.StepService;
-import org.splat.service.technical.IndexServiceImpl;
-import org.splat.service.technical.ProjectSettingsServiceImpl;
-import org.splat.service.technical.ProjectSettingsServiceImpl.ProjectSettingsValidationCycle;
import org.splat.som.Revision;
-
+/**
+ * Siman Study persistent object.
+ */
public class Study extends ProjectElement {
-// Persistent fields
- private String sid; // External unique reference in a format conform to the configuration pattern
- private int docount; // Total number of documents of this study, including versions
- private ProgressState state;
- private Visibility visibility;
- private List scenarii;
- private String version;
- private int history; // Number of studies versioning this one, if any
-
-// Transient fields
- private List contributor; // Shortcut to contributors
- private HashMap validactor; // Shortcut to validation cycles
- private Set actor; // Summary of above actors
- private StepService _stepService;
-
-// ==============================================================================================================================
-// Construction
-// ==============================================================================================================================
-
-// Fields initialization class
- public static class Properties extends Persistent.Properties {
-// ------------------------------------------------------------
- private String sid = null; // Search criterion only
- private String title = null;
- private String summary = null;
- private User manager = null;
- private User actor = null; // Search criterion only
- private Visibility visibility = null; // Search criterion only
- private ProgressState state = null; // Search criterion only
- private Date date = null;
- private List context = new Vector(); // Search criterion only
-
-// - Public services
-
- public void clear () {
- super.clear();
- sid = null;
- title = null;
- summary = null;
- manager = null;
- actor = null;
- visibility = null;
- state = null;
- date = null;
- context = new Vector(); // as clear() may generate side effects
- }
- public Properties copy () {
- Properties copy = new Properties();
- copy.sid = this.sid;
- copy.title = this.title;
- copy.summary = this.summary;
- copy.manager = this.manager;
- copy.actor = this.actor;
- copy.visibility = this.visibility;
- copy.state = this.state;
- copy.date = this.date;
- copy.context = this.context;
- return copy;
- }
-// - Protected services
-
- public User getActor () {
- return actor;
- }
- public User getManager () {
- return manager;
- }
- public ProgressState getProgressState () {
- return state;
- }
- public String getReference () {
- return sid;
- }
- public List getSimulationContexts () {
- return context;
- }
- public String getTitle () {
- return title;
- }
- public String getSummary () {
- return summary;
- }
- public Visibility getVisibility () {
- return visibility;
- }
-// - Property setters
-
-// For building a search query
- public Properties setActor (User actor)
- {
- this.actor = actor;
- return this;
- }
- public Properties setDate (Date date)
- {
- this.date = date;
- return this;
- }
- public Properties setDescription (String summary)
- {
- if (summary.length() > 0) this.summary = summary;
- return this;
- }
- public Properties setManager (User user)
- {
- this.manager = user;
- return this;
- }
-// For building a search query
- public Properties setReference (String sid) throws InvalidPropertyException
- {
- if (sid.length() == 0) throw new InvalidPropertyException("reference");
- this.sid = sid;
- return this;
- }
-// For building a search query
- public Properties setSimulationContexts (List context) {
- this.context = context;
- return this;
- }
-// For building a search query
- public Properties setState (ProgressState state)
- {
- this.state = state;
- return this;
- }
- public Properties setTitle (String title) throws InvalidPropertyException
- {
- if (title.length() == 0) throw new InvalidPropertyException("title");
- this.title = title;
- return this;
- }
-// For building a search query
- public Properties setVisibility (Visibility area)
- {
- this.visibility = area;
- return this;
- }
-// - Global validity check
-
- public void checkValidity() throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException
- {
- if (title == null) throw new MissedPropertyException("title");
- if (manager == null) throw new MissedPropertyException("manager");
- }
- }
-// Database fetch constructor
- protected Study () {
-// ------------------
- contributor = null;
- validactor = null;
- actor = null;
- }
-// Internal constructor
- public Study (Properties sprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
-// ----------------------------------
- super(sprop); // Throws one of the above exception if not valid
- sid = sprop.sid; // Reset after save
- title = sprop.title; // Inherited attribute
- manager = sprop.manager;
- docount = 0;
- history = 0;
- scenarii = new LinkedList();
- visibility = Visibility.PRIVATE;
- state = ProgressState.inWORK;
-
- credate = sprop.date; // Inherited attribute
- if (credate == null) {
- Calendar current = Calendar.getInstance();
- credate = current.getTime(); // Today
- }
- lasdate = credate; // Inherited attribute
- version = new Revision().incrementAs(state).toString();
-
- if (sprop.summary != null) this.setAttribute( new DescriptionAttribute(this, sprop.summary) );
-
- contributor = null;
- validactor = null;
- actor = null;
- }
-
- /**
- * Returns all actors of this study other than the author, including contributors, reviewers and approvers.
- *
- * @return the actors of this study
- * @see #hasActor(User)
- */
- public Set getActors () {
- // -----------------------------
- if (actor == null) setShortCuts();
- return Collections.unmodifiableSet(actor);
- }
-
- /**
- * Returns all actors of this study other than the author, including contributors, reviewers and approvers.
- *
- * @return the actors of this study
- * @see #hasActor(User)
- */
- public Set getModifiableActors () {
- // -----------------------------
- if (actor == null) setShortCuts();
- return actor;
- }
-
- public List getContributors () {
- // ------------------------------------
- if (contributor == null) setShortCuts();
- return Collections.unmodifiableList(contributor); // May be empty
- }
-
- public List getModifiableContributors () {
- if (contributor == null) setShortCuts();
- return contributor; // May be empty
- }
-
- public ProgressState getProgressState () {
-// ----------------------------------------
- return state;
- }
+ // Persistent fields
+ /**
+ * Persistent sid property. It is an external unique reference in a format conform to the configuration pattern.
+ */
+ private String sid;
+ /**
+ * Persistent docount property. It is a total number of documents of this study, including versions.
+ */
+ private int docount;
+ /**
+ * Persistent state property. It is a study progress state.
+ *
+ * @see org.splat.dal.bo.som.ProgressState enumeration
+ */
+ private ProgressState state;
+ /**
+ * Persistent visibility property.
+ *
+ * @see org.splat.dal.bo.som.Visibility enumeration
+ */
+ private Visibility visibility;
+ /**
+ * Persistent list of study scenarii.
+ */
+ private List scenarii;
+ private String version;
+ /**
+ * Persistent history property. It is a number of studies versioning this one, if any.
+ */
+ private int history;
-/**
- * Returns the global unique reference of this study.
- * The study reference is common to all versions of the study (versioning a study does not change its reference).
- * The form of this study reference is defined in the configuration of the application server - see the SOM XML customization
- * file.
- */
- public String getReference () {
- return sid;
- }
+ // Transient fields
+ /**
+ * Transient list of contributors.
+ */
+ private transient List contributor = new Vector(); // Shortcut to contributors
+ /**
+ * Transient map of document types to validation cycles.
+ */
+ private transient Map validactor = new HashMap(); // Shortcut to validation cycles
+ /**
+ * Transient set of all actors of the study, i.d. contributors and validation cycles participants.
+ */
+ private transient Set actor = new HashSet(); // Summary of above actors
- public void setReference (String aReference) {
- sid = aReference;
- }
+ // ==============================================================================================================================
+ // Construction
+ // ==============================================================================================================================
- public Scenario[] getScenarii () {
-// --------------------------------
- return scenarii.toArray(new Scenario[scenarii.size()]);
- }
+ /**
+ * Fields initialization class.
+ */
+ public static class Properties extends Persistent.Properties {
+ // ------------------------------------------------------------
+ private String sid = null; // Search criterion only
+ private String title = null;
+ private String summary = null;
+ private User manager = null;
+ private User actor = null; // Search criterion only
+ private Visibility visibility = null; // Search criterion only
+ private ProgressState state = null; // Search criterion only
+ private Date date = null;
+ private List context = new Vector(); // Search criterion only
+
+ // - Public services
+
+ public void clear() {
+ super.clear();
+ sid = null;
+ title = null;
+ summary = null;
+ manager = null;
+ actor = null;
+ visibility = null;
+ state = null;
+ date = null;
+ context = new Vector(); // as clear() may generate side effects
+ }
+
+ public Properties copy() {
+ Properties copy = new Properties();
+ copy.sid = this.sid;
+ copy.title = this.title;
+ copy.summary = this.summary;
+ copy.manager = this.manager;
+ copy.actor = this.actor;
+ copy.visibility = this.visibility;
+ copy.state = this.state;
+ copy.date = this.date;
+ copy.context = this.context;
+ return copy;
+ }
+
+ // - Protected services
+
+ public User getActor() {
+ return actor;
+ }
+
+ public User getManager() {
+ return manager;
+ }
+
+ public ProgressState getProgressState() {
+ return state;
+ }
+
+ public String getReference() {
+ return sid;
+ }
+
+ public List getSimulationContexts() {
+ return context;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getSummary() {
+ return summary;
+ }
+
+ public Visibility getVisibility() {
+ return visibility;
+ }
+
+ // - Property setters
+
+ // For building a search query
+ public Properties setActor(User actor) {
+ this.actor = actor;
+ return this;
+ }
+
+ public Properties setDate(Date date) {
+ this.date = date;
+ return this;
+ }
+
+ public Properties setDescription(String summary) {
+ if (summary.length() > 0)
+ this.summary = summary;
+ return this;
+ }
+
+ public Properties setManager(User user) {
+ this.manager = user;
+ return this;
+ }
+
+ // For building a search query
+ public Properties setReference(String sid)
+ throws InvalidPropertyException {
+ if (sid.length() == 0)
+ throw new InvalidPropertyException("reference");
+ this.sid = sid;
+ return this;
+ }
+
+ // For building a search query
+ public Properties setSimulationContexts(List context) {
+ this.context = context;
+ return this;
+ }
+
+ // For building a search query
+ public Properties setState(ProgressState state) {
+ this.state = state;
+ return this;
+ }
+
+ public Properties setTitle(String title)
+ throws InvalidPropertyException {
+ if (title.length() == 0)
+ throw new InvalidPropertyException("title");
+ this.title = title;
+ return this;
+ }
+
+ // For building a search query
+ public Properties setVisibility(Visibility area) {
+ this.visibility = area;
+ return this;
+ }
+
+ // - Global validity check
+
+ public void checkValidity() throws MissedPropertyException,
+ InvalidPropertyException, MultiplyDefinedException {
+ if (title == null)
+ throw new MissedPropertyException("title");
+ if (manager == null)
+ throw new MissedPropertyException("manager");
+ }
+ }
- public List getScenariiList () {
-// --------------------------------
- return scenarii;
- }
+ // Database fetch constructor
+ protected Study() {
+ contributor.clear();
+ validactor.clear();
+ actor.clear();
+ }
-/**
- * Returns the validation cycle of the given document type.
- *
- * @param doc the document type being subject of validation
- * @return the validation cycle of the document, or null if not defined.
- */
- public ValidationCycle getValidationCycleOf (DocumentType type) {
-// ---------------------------------------------------------------
- if (validactor == null) setShortCuts();
- ValidationCycle result = validactor.get(type.getName());
- if (result == null) {
- if (type.isStepResult()) result = validactor.get("default"); // "default" validation cycle defined in the configuration, if exist
- if (result == null) result = validactor.get("built-in");
- }
- return result;
- }
-
- public String getVersion () {
-// ---------------------------
- return version;
- }
-
- public Visibility getVisibility () {
-// ----------------------------------
- return visibility;
- }
+ // Internal constructor
+ public Study(Properties sprop) throws MissedPropertyException,
+ InvalidPropertyException, MultiplyDefinedException {
+ // ----------------------------------
+ super(sprop); // Throws one of the above exception if not valid
+ sid = sprop.sid; // Reset after save
+ title = sprop.title; // Inherited attribute
+ manager = sprop.manager;
+ docount = 0;
+ history = 0;
+ scenarii = new LinkedList();
+ visibility = Visibility.PRIVATE;
+ state = ProgressState.inWORK;
+
+ credate = sprop.date; // Inherited attribute
+ if (credate == null) {
+ Calendar current = Calendar.getInstance();
+ credate = current.getTime(); // Today
+ }
+ lasdate = credate; // Inherited attribute
+ version = new Revision().incrementAs(state).toString();
+
+ if (sprop.summary != null)
+ this.setAttribute(new DescriptionAttribute(this, sprop.summary));
+
+ contributor.clear();
+ validactor.clear();
+ actor.clear();
+ }
-/**
- * Checks if the given user is actor of this study.
- * Actors include contributors, reviewers and approvers.
- *
- * @return true if the given user is actor of this study.
- * @see #getActors()
- */
- public boolean hasActor (User user) {
-// -----------------------------------
- if (user == null) return false;
- for (Iterator i=this.getActors().iterator(); i.hasNext(); ) {
- User involved = i.next();
- if (involved.equals(user)) return true;
- }
- return false;
- }
+ public ProgressState getProgressState() {
+ return state;
+ }
+
+ /**
+ * Returns the global unique reference of this study. The study reference is common to all versions of the study (versioning a study
+ * does not change its reference). The form of this study reference is defined in the configuration of the application server - see the
+ * SOM XML customization file.
+ */
+ public String getReference() {
+ return sid;
+ }
+
+ public void setReference(String aReference) {
+ sid = aReference;
+ }
+
+ public Scenario[] getScenarii() {
+ // --------------------------------
+ return scenarii.toArray(new Scenario[scenarii.size()]);
+ }
+
+ public List getScenariiList() {
+ // --------------------------------
+ return scenarii;
+ }
+
+ public String getVersion() {
+ // ---------------------------
+ return version;
+ }
+
+ public Visibility getVisibility() {
+ // ----------------------------------
+ return visibility;
+ }
-/**
- * Checks whether this study is in the Public or the Reference area of the repository.
- *
- * @return true if the study is public.
- * @see #moveToPublic()
- * @see #moveToReference()
- */
- public boolean isPublic () {
-// --------------------------
- return (visibility != Visibility.PRIVATE);
- }
-/**
- * Checks if the given user participates to this study.
- * The Study staff includes the author and contributors.
- *
- * @return true if the given user is actor of this study.
- * @see #getContributors()
- */
- public boolean isStaffedBy (User user) {
-// --------------------------------------
- if (user == null) return false;
- if (manager.equals(user)) return true;
- for (Iterator i=getContributors().iterator(); i.hasNext();) {
- if (i.next().equals(user)) return true;
- }
- return false;
- }
-
- public boolean isVersioned () {
-// -----------------------------
- return (history > 0);
- }
-
- public boolean shares (Document doc) {
-// ------------------------------------
- Scenario[] scene = this.getScenarii(); // If shared from within the study, the document is shared by the scenarios
- int counter = 0;
-
- for (int i=0; i();
- validactor = new HashMap();
- actor = new HashSet();
-
-// Get the contributors
- for (Iterator i=getRelations(ContributorRelation.class).iterator(); i.hasNext(); ) {
- ContributorRelation link = (ContributorRelation)i.next();
- contributor.add(link.getTo());
- }
-// Get the validation cycles specific to this study
- for (Iterator i=getRelations(ValidationCycleRelation.class).iterator(); i.hasNext(); ) {
- ValidationCycleRelation link = (ValidationCycleRelation)i.next();
- validactor.put(link.getDocumentType().getName(), link.getTo()); // The associated document type is necessarily not null in this context
- }
-// Get the validation cycles coming from the configured workflow and not overridden in this study
- for (Iterator i=ProjectSettingsServiceImpl.getAllValidationCycles().iterator(); i.hasNext(); ) {
- ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle = i.next();
- String type = cycle.getName();
- if (!validactor.containsKey(type)) validactor.put(type, new ValidationCycle(this, cycle));
- }
-// Get all corresponding actors
- for (Iterator i=validactor.values().iterator(); i.hasNext(); ) {
- ValidationCycle cycle = i.next();
- User[] user = cycle.getAllActors();
- for (int j=0; j i=this.getAllRelations().iterator(); i.hasNext(); ) {
- Relation link = i.next();
- Class> kindof = link.getClass().getSuperclass();
- if (!kindof.equals(ActorRelation.class)) continue;
- actor.add( ((ActorRelation)link).getTo() );
- }
- }
/**
- * @param aVisibility a study visibility to set
+ * Checks whether this study is in the Public or the Reference area of the repository.
+ *
+ * @return true if the study is public.
+ * @see #moveToPublic()
+ * @see #moveToReference()
+ */
+ public boolean isPublic() {
+ // --------------------------
+ return (visibility != Visibility.PRIVATE);
+ }
+
+ public boolean isVersioned() {
+ // -----------------------------
+ return (history > 0);
+ }
+
+ public boolean shares(Document doc) {
+ // ------------------------------------
+ Scenario[] scene = this.getScenarii(); // If shared from within the study, the document is shared by the scenarios
+ int counter = 0;
+
+ for (int i = 0; i < scene.length; i++) {
+ if (!scene[i].publishes(doc))
+ continue;
+ if (counter == 1)
+ return true;
+ counter += 1;
+ }
+ return false;
+ }
+
+ public int getLastLocalIndex() {
+ // ----------------------------------
+ return docount;
+ }
+
+ /**
+ * @param aVisibility
+ * a study visibility to set
*/
public void setVisibility(Visibility aVisibility) {
visibility = aVisibility;
}
+
/**
- * @param aState a study progress state to set
+ * @param aState
+ * a study progress state to set
*/
public void setProgressState(ProgressState aState) {
state = aState;
}
+
/**
- * @param string
+ * @param aVersion
*/
public void setVersion(String aVersion) {
version = aVersion;
}
+
/**
- * @param i
+ * Set total number of documents of this study, including versions. It is stored in the persistent property docount.
+ *
+ * @param anIndex
+ * a number of study documents
*/
public void setLastLocalIndex(int anIndex) {
docount = anIndex;
}
+
/**
- * @return
+ * Get the transient map of document types to validation cycles.
+ *
+ * @return map of validation cycles
*/
- public HashMap getValidationCycles() {
+ public Map getValidationCycles() {
return validactor;
}
+
+ /**
+ * Get the transient list of study contributors.
+ *
+ * @return the List of User objects
+ */
+ public List getContributor() {
+ return contributor;
+ }
+
+ /**
+ * Get the transient set of all study actors (contributors and validation cycles participants).
+ *
+ * @return the set of User objects
+ */
+ public Set getActor() {
+ return actor;
+ }
}
\ No newline at end of file
diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Timestamp.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Timestamp.java
index 6593c54..ff87997 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Timestamp.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Timestamp.java
@@ -81,7 +81,7 @@ public class Timestamp extends Any {
// Protected services
// ==============================================================================================================================
- protected StampRelation getContext () {
+ public StampRelation getContext () {
// -------------------------------------
return context;
}
diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/ValidationCycle.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/ValidationCycle.java
index 8803d52..989cd25 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/ValidationCycle.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/ValidationCycle.java
@@ -100,44 +100,41 @@ public class ValidationCycle extends Persistent {
{
if (doctype == null) throw new MissedPropertyException("type");
}
+
+ /**
+ * Get the publisher.
+ * @return the publisher
+ */
+ public User getPublisher() {
+ return publisher;
+ }
+
+ /**
+ * Get the reviewer.
+ * @return the reviewer
+ */
+ public User getReviewer() {
+ return reviewer;
+ }
+
+ /**
+ * Get the approver.
+ * @return the approver
+ */
+ public User getApprover() {
+ return approver;
+ }
+
+ /**
+ * Get the signatory.
+ * @return the signatory
+ */
+ public User getSignatory() {
+ return signatory;
+ }
}
// Database fetch constructor
- protected ValidationCycle () {
- }
-// Internal constructors
- protected ValidationCycle (Study from, ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle) {
-// -----------------------------------------------------------------------------
- Actor[] actype = cycle.getActorTypes();
- User.Properties uprop = new User.Properties();
-
- mytype = Document.selectType(cycle.getName()); // Null in case of default validation cycle
-// context = new ValidationCycleRelation(from, this);
- context = null; // Validation cycle defined in the workflow
- for (int i=0; i manager = UserDirectory.selectUsersWhere(uprop.setOrganizationName("Nx1"));
- if (manager.size() == 1) actor = manager.get(0);
- } else
- if (actype[i] == Actor.Nx2) {
- List manager = UserDirectory.selectUsersWhere(uprop.setOrganizationName("Nx2"));
- if (manager.size() == 1) actor = manager.get(0);
- } else { /* Actor.customer */
- actor = from.getAuthor();
-//TODO: Get the customer of the study, if exists
- }
- } catch (Exception e) { // Should not happen
- actor = null;
- }
- if (i == 0) reviewer = actor;
- else if (i == 1) approver = actor;
- else if (i == 2) signatory = actor;
- }
+ public ValidationCycle () {
}
public ValidationCycle (Study from, Properties vprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
// --------------------------------------------------------
@@ -214,8 +211,16 @@ public class ValidationCycle extends Persistent {
* @see #isDefault()
*/
public DocumentType getDocumentType () {
-// --------------------------------------
- return mytype; // May be null
+ // --------------------------------------
+ return mytype; // May be null
+ }
+
+ /**
+ * Set a document type for the validation cycle.
+ * @param aType the document type
+ */
+ public void setDocumentType (DocumentType aType) {
+ mytype = aType; // May be null
}
/**
@@ -252,30 +257,32 @@ public class ValidationCycle extends Persistent {
// -----------------------------------------------
return context;
}
-
- protected void remove (ValidationStep step) {
-// ------------------------------------------
- if (step == ValidationStep.REVIEW) reviewer = null;
- else if (step == ValidationStep.APPROVAL) approver = null;
- else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) signatory = null;
- if (this.isSaved()) Database.getSession().update(this);
- }
-
- public void resetActors (Properties vprop) {
-// ---------------------------------------------
- publisher = vprop.publisher; // May be null
- reviewer = vprop.reviewer; // May be null
- approver = vprop.approver; // May be null
- signatory = vprop.signatory; // May be null
- if (this.isSaved()) Database.getSession().update(this);
- }
-
- protected void setActor (ValidationStep step, User actor) {
-// --------------------------------------------------------
- if (step == ValidationStep.PROMOTION) publisher = actor;
- else if (step == ValidationStep.REVIEW) reviewer = actor;
- else if (step == ValidationStep.APPROVAL) approver = actor;
- else if (step == ValidationStep.ACCEPTANCE || step == ValidationStep.REFUSAL) signatory = actor;
- if (this.isSaved()) Database.getSession().update(this);
- }
+ /**
+ * Set the publisher.
+ * @param publisher the publisher to set
+ */
+ public void setPublisher(User publisher) {
+ this.publisher = publisher;
+ }
+ /**
+ * Set the reviewer.
+ * @param reviewer the reviewer to set
+ */
+ public void setReviewer(User reviewer) {
+ this.reviewer = reviewer;
+ }
+ /**
+ * Set the approver.
+ * @param approver the approver to set
+ */
+ public void setApprover(User approver) {
+ this.approver = approver;
+ }
+ /**
+ * Set the signatory.
+ * @param signatory the signatory to set
+ */
+ public void setSignatory(User signatory) {
+ this.signatory = signatory;
+ }
}
\ No newline at end of file
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AnyDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AnyDAO.java
index d554554..1afa838 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AnyDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AnyDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AnyDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AnyDAOImpl.java
index 8059f70..2a8d646 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AnyDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AnyDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AttributeDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AttributeDAO.java
index 85d23ed..22e7036 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AttributeDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AttributeDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AttributeDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AttributeDAOImpl.java
index eb446eb..fc639d1 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AttributeDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AttributeDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/EntityDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/EntityDAO.java
index e8e09da..9b219dc 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/EntityDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/EntityDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/EntityDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/EntityDAOImpl.java
index 938d6f7..62e383b 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/EntityDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/EntityDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAO.java
index 9ae2887..68f67d2 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 08.10.2012
@@ -70,6 +70,24 @@ public interface GenericDAO {
*/
public T findByCriteria(Criterion aCondition);
+ /**
+ * Retrieve a list of all objects of the considered type T which were previously persisted to the database.
+ *
+ * @return a list of all objects of the considered type T
+ */
+ @SuppressWarnings("unchecked")
+ public List getAll();
+
+ /**
+ * Retrieve an ordered list of all objects of the considered type T which were previously persisted to the database.
+ *
+ * @param anOrder
+ * a result list order. Null is ignored and in such case the result list is unordered.
+ * @return an ordered list of all objects of the considered type T
+ */
+ @SuppressWarnings("unchecked")
+ public List getAll(Order anOrder);
+
/**
* Retrieve a list of objects which were previously persisted to the database using the given criteria.
*
@@ -89,4 +107,20 @@ public interface GenericDAO {
*/
@SuppressWarnings("unchecked")
public List getFilteredList(Criterion aCondition, Order anOrder);
+
+ /**
+ * Makes detached object persistent.
+ * @param transientObject
+ * transient instance of the object to be made persistent
+ */
+ public void persist(T transientObject);
+
+ /**
+ * Merge detached object with persistent data.
+ *
+ * @param transientObject
+ * transient instance of the object to be merged with persistent data
+ * @return merged persistent object
+ */
+ public T merge(T transientObject);
}
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAOImpl.java
index d76653b..64d3a6a 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 08.10.2012
@@ -15,7 +15,6 @@ import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
-import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
@@ -67,6 +66,32 @@ public abstract class GenericDAOImpl extends
.uniqueResult();
}
+ /**
+ * Retrieve a list of all objects of the considered type T which were previously persisted to the database.
+ *
+ * @return a list of all objects of the considered type T
+ */
+ @SuppressWarnings("unchecked")
+ public List getAll() {
+ return getSession().createCriteria(getType()).list();
+ }
+
+ /**
+ * Retrieve an ordered list of all objects of the considered type T which were previously persisted to the database.
+ *
+ * @param anOrder
+ * a result list order. Null is ignored and in such case the result list is unordered.
+ * @return an ordered list of all objects of the considered type T
+ */
+ @SuppressWarnings("unchecked")
+ public List getAll(Order anOrder) {
+ Criteria aCriteria = getSession().createCriteria(getType());
+ if (anOrder != null) {
+ aCriteria.addOrder(anOrder);
+ }
+ return aCriteria.list();
+ }
+
/**
* Retrieve a list of objects which were previously persisted to the database using the given criteria.
*
@@ -118,6 +143,28 @@ public abstract class GenericDAOImpl extends
getSession().delete(persistentObject);
}
+ /**
+ * Makes detached object persistent.
+ *
+ * @param transientObject
+ * transient instance of the object to be made persistent
+ */
+ public void persist(T transientObject) {
+ getSession().persist(transientObject);
+ }
+
+ /**
+ * Merge detached object with persistent data.
+ *
+ * @param transientObject
+ * transient instance of the object to be merged with persistent data
+ * @return merged persistent object
+ */
+ @SuppressWarnings("unchecked")
+ public T merge(T transientObject) {
+ return (T) getSession().merge(transientObject);
+ }
+
/**
* Get persistent object type.
*
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/PersistentDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/PersistentDAO.java
index 651148d..a7ad02f 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/PersistentDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/PersistentDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/PersistentDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/PersistentDAOImpl.java
index 53ff63d..a95ea66 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/PersistentDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/PersistentDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RelationDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RelationDAO.java
index e8e09fc..10820f1 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RelationDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RelationDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RelationDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RelationDAOImpl.java
index e1247fd..2e78522 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RelationDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RelationDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAO.java
index 5f32b66..900f464 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAOImpl.java
index 4c2fb01..732abb2 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAO.java
index c003804..6e46390 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAOImpl.java
index 9224146..eef3992 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAO.java
index 01b386d..3bb4f41 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAOImpl.java
index 7a721b6..be18440 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAO.java
index 84d9b5e..4ca3260 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAOImpl.java
index 87b4125..e908dfb 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAO.java
index df35aeb..4cd4c87 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAOImpl.java
index c4b014d..43c5e54 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAO.java
index 5f6eb47..c56c730 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAOImpl.java
index 59e48d8..74a3b16 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAO.java
index 71b3633..2f47380 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAOImpl.java
index dfb94f5..5004061 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAO.java
index 439109a..9677aaa 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAOImpl.java
index 4527ce0..3a0ed00 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAO.java
index 896d485..96163ef 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAOImpl.java
index 1369931..ca139e3 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAO.java
index e415f66..dcdc8ba 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAOImpl.java
index 115cd38..d559ebc 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAO.java
index ab15fdd..1541a10 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAOImpl.java
index 088adef..00590cc 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ProjectElementDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ProjectElementDAO.java
index 59e3ce5..99218cd 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ProjectElementDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ProjectElementDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ProjectElementDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ProjectElementDAOImpl.java
index 8ef2256..7d660ea 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ProjectElementDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ProjectElementDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAO.java
index dd4fbc1..e25072a 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAOImpl.java
index 9343f55..a5a70ec 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAO.java
index 414f826..8391883 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAOImpl.java
index 2423845..920e530 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAO.java
index eb2ae9b..baef74c 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAOImpl.java
index 20531c2..4c1a7ec 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAO.java
index 0bf5554..bd1ad8c 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAOImpl.java
index ed85d85..3066bc4 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAO.java
index ddb279c..78c50a7 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAOImpl.java
index 6cdcdd2..9f66a7d 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAO.java
index 5ec1476..5b3c513 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAOImpl.java
index 9ff5306..e6e3aa6 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAO.java
index 869cf59..2639da2 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAOImpl.java
index cd2d1d9..dca4c40 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAO.java
index 0bd25f0..dfb2487 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAOImpl.java
index c7ce03e..1b4078c 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAO.java
index d8fe1df..0c5254b 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAOImpl.java
index 3f77cd5..2d6a3a4 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAO.java
index 358f20f..a89ce09 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAOImpl.java
index 3ba01cf..da0ad86 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAO.java
index 03666ba..fbae333 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAOImpl.java
index 05147ae..fae40ce 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAO.java
index 07c8cfc..468549a 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAO.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAO.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAOImpl.java
index c03bce7..247e0be 100644
--- a/Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAOImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAOImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/exception/AbstractException.java b/Workspace/Siman-Common/src/org/splat/exception/AbstractException.java
index 0f8ae1e..da21548 100644
--- a/Workspace/Siman-Common/src/org/splat/exception/AbstractException.java
+++ b/Workspace/Siman-Common/src/org/splat/exception/AbstractException.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File Id:
* Creation date 02.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/exception/LockAlreadyExistsException.java b/Workspace/Siman-Common/src/org/splat/exception/LockAlreadyExistsException.java
index b87884a..b174567 100644
--- a/Workspace/Siman-Common/src/org/splat/exception/LockAlreadyExistsException.java
+++ b/Workspace/Siman-Common/src/org/splat/exception/LockAlreadyExistsException.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File Id:
* Creation date 02.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/exception/LockNotExistsException.java b/Workspace/Siman-Common/src/org/splat/exception/LockNotExistsException.java
index 0084884..8dc10e3 100644
--- a/Workspace/Siman-Common/src/org/splat/exception/LockNotExistsException.java
+++ b/Workspace/Siman-Common/src/org/splat/exception/LockNotExistsException.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 03.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/exception/LockOutdatedException.java b/Workspace/Siman-Common/src/org/splat/exception/LockOutdatedException.java
index 1d73311..44990da 100644
--- a/Workspace/Siman-Common/src/org/splat/exception/LockOutdatedException.java
+++ b/Workspace/Siman-Common/src/org/splat/exception/LockOutdatedException.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 03.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/exception/LockProtectedException.java b/Workspace/Siman-Common/src/org/splat/exception/LockProtectedException.java
index 54bf663..08fe780 100644
--- a/Workspace/Siman-Common/src/org/splat/exception/LockProtectedException.java
+++ b/Workspace/Siman-Common/src/org/splat/exception/LockProtectedException.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 03.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/i18n/I18nUtils.java b/Workspace/Siman-Common/src/org/splat/i18n/I18nUtils.java
index 5f3b06e..679ddec 100644
--- a/Workspace/Siman-Common/src/org/splat/i18n/I18nUtils.java
+++ b/Workspace/Siman-Common/src/org/splat/i18n/I18nUtils.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File Id:
* Creation date 02.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/log/AppLogger.java b/Workspace/Siman-Common/src/org/splat/log/AppLogger.java
index 7463e6f..9062fff 100644
--- a/Workspace/Siman-Common/src/org/splat/log/AppLogger.java
+++ b/Workspace/Siman-Common/src/org/splat/log/AppLogger.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 02.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/DocumentService.java b/Workspace/Siman-Common/src/org/splat/service/DocumentService.java
index 967489c..84078b4 100644
--- a/Workspace/Siman-Common/src/org/splat/service/DocumentService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/DocumentService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -9,17 +9,28 @@
package org.splat.service;
+import java.util.List;
+
+import org.splat.dal.bo.som.ConvertsRelation;
import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.ProjectElement;
+import org.splat.dal.bo.som.Study;
+import org.splat.dal.bo.som.Timestamp;
import org.splat.dal.bo.som.Document.Properties;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
import org.splat.kernel.NotApplicableException;
+import org.splat.service.technical.ProjectSettingsService;
+import org.splat.som.Revision;
import org.splat.som.Step;
/**
* Document service interface.
*
- * @author Roman Kozlov (RKV)
+ * @author Roman Kozlov (RKV)
*
*/
public interface DocumentService {
@@ -73,11 +84,155 @@ public interface DocumentService {
* document properties (owner project element is used)
*/
public void generateDocumentId(Document aDoc, Properties dprop);
-
+
/**
* Get a directory where the document file is saved.
- * @param aDoc the document
+ *
+ * @param aDoc
+ * the document
* @return a directory
*/
public java.io.File getSaveDirectory(Document aDoc);
+
+ /**
+ * Extract title and reference properties from the given file.
+ *
+ * @param file
+ * the file to parse
+ * @return the extracted properties
+ */
+ public Properties extractProperties(java.io.File file);
+
+ /**
+ * Create "Converts" relation for the given document and the given format.
+ *
+ * @param aDoc
+ * the document
+ * @param format
+ * the format
+ * @return the created "Converts" relation
+ */
+ public ConvertsRelation attach(Document aDoc, String format);
+
+ /**
+ * Create "Converts" relation for the given document, format and description.
+ *
+ * @param aDoc
+ * the document
+ * @param format
+ * the format
+ * @param description
+ * the description of the relation
+ * @return the created "Converts" relation
+ */
+ public ConvertsRelation attach(Document aDoc, String format,
+ String description);
+
+ /**
+ * Build a reference (document id) for the given document in the given study basing on the given original document.
+ *
+ * @param aDoc
+ * the document to set set the new reference to
+ * @param scope
+ * the study
+ * @param lineage
+ * the original document
+ * @return true if the new reference is set
+ */
+ public boolean buildReferenceFrom(Document aDoc, ProjectElement scope,
+ Document lineage);
+
+ /**
+ * Build a reference (document id) for the given document in the given study.
+ *
+ * @param aDoc
+ * the document to set set the new reference to
+ * @param scope
+ * the study
+ * @return true if the new reference is set
+ */
+ public boolean buildReferenceFrom(Document aDoc, Study scope);
+
+ /**
+ * Demote a document.
+ *
+ * @param aDoc
+ * the document to demote
+ * @return true if demoting succeeded
+ */
+ public boolean demote(Document aDoc);
+
+ /**
+ * Promote a document.
+ *
+ * @param aDoc
+ * the document to promote
+ * @param stamp
+ * the timestamp of the promotion
+ * @return true if promotion succeeded
+ */
+ public boolean promote(Document aDoc, Timestamp stamp);
+
+ /**
+ * Increments the reference count of this document following its publication in a Study step.
+ *
+ * @param aDoc
+ * the document to hold
+ * @see #release()
+ */
+ public void hold(Document aDoc);
+
+ /**
+ * Decrements the reference count of this document following the removal of a Publication from a Study step.
+ *
+ * @param aDoc
+ * the document to release
+ * @see #hold()
+ */
+ public void release(Document aDoc);
+
+ /**
+ * Rename a document.
+ *
+ * @param aDoc
+ * the document to rename
+ * @param title
+ * the new document title
+ * @throws InvalidPropertyException
+ * if the new title is empty
+ */
+ public void rename(Document aDoc, String title)
+ throws InvalidPropertyException;
+
+ /**
+ * Update a version of the given document.
+ *
+ * @param aDoc
+ * the document
+ * @param newvers
+ * the new version
+ */
+ public void updateAs(Document aDoc, Revision newvers);
+
+ /**
+ * Update a state of the given document.
+ *
+ * @param aDoc
+ * the document
+ * @param state
+ * the new state
+ */
+ public void updateAs(Document aDoc, ProgressState state);
+
+ /**
+ * Checks if documents of this type are result of a study. A document is the result of a study when it is the result of the last step of
+ * the study.
+ *
+ * @param aType
+ * the document type
+ * @return true if documents of this type are result of a study.
+ * @see #isStepResult()
+ * @see #isResultOf(org.splat.service.technical.ProjectSettingsServiceImpl.Step)
+ */
+ public boolean isStudyResult(DocumentType aType);
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/DocumentServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/DocumentServiceImpl.java
index 1d06100..df410aa 100644
--- a/Workspace/Siman-Common/src/org/splat/service/DocumentServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/DocumentServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -12,21 +12,40 @@ package org.splat.service;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
+import java.util.Iterator;
+import java.util.List;
+import org.hibernate.Hibernate;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
+import org.splat.dal.bo.kernel.Relation;
+import org.splat.dal.bo.som.ConvertsRelation;
import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.File;
+import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.ProjectElement;
import org.splat.dal.bo.som.Scenario;
+import org.splat.dal.bo.som.StampRelation;
import org.splat.dal.bo.som.Study;
+import org.splat.dal.bo.som.Timestamp;
+import org.splat.dal.bo.som.ValidationStep;
+import org.splat.dal.bo.som.VersionsRelation;
import org.splat.dal.bo.som.Document.Properties;
import org.splat.dal.dao.som.DocumentDAO;
+import org.splat.dal.dao.som.DocumentTypeDAO;
+import org.splat.dal.dao.som.FileDAO;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
import org.splat.kernel.NotApplicableException;
+import org.splat.manox.Reader;
+import org.splat.manox.Toolbox;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.service.technical.ProjectSettingsServiceImpl;
import org.splat.service.technical.RepositoryService;
import org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming;
+import org.splat.som.Revision;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -50,9 +69,17 @@ public class DocumentServiceImpl implements DocumentService {
*/
private RepositoryService _repositoryService;
/**
- * Injected document service.
+ * Injected document DAO.
*/
private DocumentDAO _documentDAO;
+ /**
+ * Injected document type DAO.
+ */
+ private DocumentTypeDAO _documentTypeDAO;
+ /**
+ * Injected file DAO.
+ */
+ private FileDAO _fileDAO;
/**
* {@inheritDoc}
@@ -154,6 +181,7 @@ public class DocumentServiceImpl implements DocumentService {
*
* @see org.splat.service.DocumentService#initialize(org.splat.dal.bo.som.Document, org.splat.dal.bo.som.Document.Properties)
*/
+ @Transactional
public void initialize(Document aDoc, Properties dprop)
throws MissedPropertyException, InvalidPropertyException,
NotApplicableException {
@@ -201,6 +229,345 @@ public class DocumentServiceImpl implements DocumentService {
return new java.io.File(path.append("/").toString());
}
+ /**
+ * Extract title and reference properties from the given file.
+ *
+ * @param file
+ * the file to parse
+ * @return the extracted properties
+ */
+ public Properties extractProperties(java.io.File file) {
+ Properties fprop = new Properties();
+ Reader tool = Toolbox.getReader(file);
+ String value;
+ if (tool != null)
+ try {
+ value = tool.extractProperty("title");
+ if (value != null)
+ fprop.setName(value);
+
+ value = tool.extractProperty("reference");
+ if (value != null)
+ fprop.setReference(value);
+ } catch (Exception e) {
+ }
+ return fprop;
+ }
+
+ /**
+ * Create "Converts" relation for the given document and the given format.
+ *
+ * @param aDoc
+ * the document
+ * @param format
+ * the format
+ * @return the created "Converts" relation
+ */
+ public ConvertsRelation attach(Document aDoc, String format) {
+ return attach(aDoc, format, null);
+ }
+
+ /**
+ * Create "Converts" relation for the given document, format and description.
+ *
+ * @param aDoc
+ * the document
+ * @param format
+ * the format
+ * @param description
+ * the description of the relation
+ * @return the created "Converts" relation
+ */
+ @Transactional
+ public ConvertsRelation attach(Document aDoc, String format,
+ String description) {
+ String path = aDoc.getRelativePath();
+ File export = new File(path + "." + format);
+ ConvertsRelation attach = new ConvertsRelation(aDoc, export,
+ description);
+
+ // RKV Session session = Database.getSession();
+ // RKV session.save(export);
+ // RKV session.save(attach);
+
+ getFileDAO().create(export);
+
+ // RKV aDoc.addRelation(attach); // Updates this
+ aDoc.getAllRelations().add(attach); // Updates this //RKV
+
+ return attach;
+ }
+
+ /**
+ * Build a reference (document id) for the given document in the given study basing on the given original document.
+ *
+ * @param aDoc
+ * the document to set set the new reference to
+ * @param scope
+ * the study
+ * @param lineage
+ * the original document
+ * @return true if the new reference is set
+ */
+ public boolean buildReferenceFrom(Document aDoc, ProjectElement scope,
+ Document lineage) {
+ if (aDoc.getProgressState() != ProgressState.inWORK)
+ return false;
+ Study owner = null;
+ Scenario context = null;
+ if (scope instanceof Study)
+ owner = (Study) scope;
+ else {
+ context = ((Scenario) scope);
+ owner = context.getOwnerStudy();
+ }
+ aDoc.setDid(lineage.getDid());
+ if (context != null && (lineage.isVersioned() || owner.shares(lineage))) {
+ aDoc.setVersion(new Revision(aDoc.getVersion()).setBranch(
+ context.getReference()).toString());
+ }
+ return true;
+ }
+
+ /**
+ * Build a reference (document id) for the given document in the given study.
+ *
+ * @param aDoc
+ * the document to set set the new reference to
+ * @param scope
+ * the study
+ * @return true if the new reference is set
+ */
+ public boolean buildReferenceFrom(Document aDoc, Study scope) {
+ if (aDoc.getProgressState() != ProgressState.inWORK
+ && aDoc.getProgressState() != ProgressState.EXTERN)
+ return false;
+ DecimalFormat tostring = new DecimalFormat(Document.suformat);
+
+ aDoc.setDid(aDoc.getDid().replace("%" + Document.suformat,
+ tostring.format(scope.getLastLocalIndex())));
+ return true;
+ }
+
+ /**
+ * Demote a document.
+ *
+ * @param aDoc
+ * the document to demote
+ * @return true if demoting succeeded
+ */
+ @Transactional
+ public boolean demote(Document aDoc) {
+ ValidationStep torem;
+
+ if (aDoc.getProgressState() == ProgressState.inCHECK) {
+ aDoc.setProgressState(ProgressState.inDRAFT);
+ torem = ValidationStep.REVIEW;
+ // This operation must not change the version number of documents.
+ // Consequently, inDRAFT documents may have a minor version number equal to zero.
+ } else if (aDoc.getProgressState() == ProgressState.inDRAFT) {
+ aDoc.setProgressState(ProgressState.inWORK);
+ torem = ValidationStep.PROMOTION;
+ } else {
+ return false;
+ }
+ for (Iterator i = aDoc.getAllRelations().iterator(); i
+ .hasNext();) {
+ Relation link = i.next();
+ if (!(link instanceof StampRelation))
+ continue;
+ if (((StampRelation) link).getStampType() != torem)
+ continue;
+ i.remove();
+ break;
+ }
+ getDocumentDAO().update(aDoc);
+ return true;
+ }
+
+ /**
+ * Promote a document.
+ *
+ * @param aDoc
+ * the document to promote
+ * @param stamp
+ * the timestamp of the promotion
+ * @return true if promotion succeeded
+ */
+ @Transactional
+ public boolean promote(Document aDoc, Timestamp stamp) {
+ ProgressState newstate = null;
+
+ if (aDoc.getProgressState() == ProgressState.inWORK) {
+ newstate = ProgressState.inDRAFT; // Promotion to being reviewed
+ } else if (aDoc.getProgressState() == ProgressState.inDRAFT) {
+ newstate = ProgressState.inCHECK; // Promotion to approval
+ Revision myvers = new Revision(aDoc.getVersion());
+ if (myvers.isMinor()) {
+ aDoc.setVersion(myvers.incrementAs(newstate).toString());
+ // TODO: If my physical file is programatically editable, update its (property) version number
+ // ISSUE: What about attached files such as PDF if exist, should we remove them ?
+ }
+ } else if (aDoc.getProgressState() == ProgressState.inCHECK) {
+ newstate = ProgressState.APPROVED;
+ }
+ aDoc.setProgressState(newstate);
+ if (stamp != null) {
+ // RKV: aDoc.addRelation(stamp.getContext());
+ aDoc.getAllRelations().add(stamp.getContext());
+ }
+ getDocumentDAO().update(aDoc);
+ return true;
+ }
+
+ /**
+ * Increments the reference count of this document following its publication in a Study step.
+ *
+ * @param aDoc
+ * the document to hold
+ * @see #release()
+ */
+ @Transactional
+ public void hold(Document aDoc) {
+ aDoc.setCountag(aDoc.getCountag() + 1);
+ if (aDoc.isSaved()) {
+ getDocumentDAO().update(aDoc);
+ }
+ }
+
+ /**
+ * Decrements the reference count of this document following the removal of a Publication from a Study step.
+ *
+ * @param aDoc
+ * the document to release
+ * @see #hold()
+ */
+ @Transactional
+ public void release(Document aDoc) {
+ aDoc.setCountag(aDoc.getCountag() - 1);
+ if (aDoc.isSaved()) {
+ getDocumentDAO().update(aDoc);
+ }
+ }
+
+ /**
+ * Rename a document.
+ *
+ * @param aDoc
+ * the document to rename
+ * @param title
+ * the new document title
+ * @throws InvalidPropertyException
+ * if the new title is empty
+ */
+ @Transactional
+ public void rename(Document aDoc, String title)
+ throws InvalidPropertyException {
+ if (title.length() == 0)
+ throw new InvalidPropertyException("name");
+
+ Calendar current = Calendar.getInstance();
+ aDoc.setTitle(title);
+ aDoc.setLastModificationDate(current.getTime()); // Today
+ getDocumentDAO().update(aDoc);
+ }
+
+ /**
+ * Update a version of the given document.
+ *
+ * @param aDoc
+ * the document
+ * @param newvers
+ * the new version
+ */
+ public void updateAs(Document aDoc, Revision newvers) {
+ aDoc.setVersion(newvers.setBranch(aDoc.getVersion()).toString()); // Branch names are propagated by the versionning
+ ProgressState newstate = ProgressState.inCHECK;
+ if (newvers.isMinor())
+ newstate = ProgressState.inWORK;
+ aDoc.setProgressState(null); // Just to tell updateAs(state) to not increment the version number
+ updateAs(aDoc, newstate);
+ }
+
+ /**
+ * Update a state of the given document.
+ *
+ * @param aDoc
+ * the document
+ * @param state
+ * the new state
+ */
+ @Transactional
+ public void updateAs(Document aDoc, ProgressState state) {
+ Document previous = null;
+
+ // Set of version number
+ if (state == ProgressState.EXTERN) {
+ if (aDoc.getProgressState() != ProgressState.EXTERN)
+ aDoc.setVersion(null); // Strange use-case...
+ } else {
+ Revision myvers = new Revision(aDoc.getVersion());
+ if (!myvers.isNull()) { // Versionning context
+ for (Iterator i = aDoc.getAllRelations().iterator(); i
+ .hasNext();) {
+ Relation link = i.next();
+ if (!link.getClass().equals(VersionsRelation.class))
+ continue;
+ previous = (Document) link.getTo(); // Versioned document
+ break;
+ }
+ }
+ if (aDoc.getProgressState() != null)
+ myvers.incrementAs(state); // Incrementation if the reversion number is not imposed
+ aDoc.setVersion(myvers.toString());
+ }
+ // Update this document and the previous version, if exit
+ if (previous != null) {
+ previous.setHistory(previous.getHistory() + 1);
+ getDocumentDAO().update(previous);
+ }
+ aDoc.setProgressState(state);
+ getDocumentDAO().update(aDoc);
+ }
+
+ // protected void upgrade () {
+ // -------------------------
+ // if (this.state != ProgressState.inWORK) return;
+ //
+ // Calendar current = Calendar.getInstance();
+ // for (Iterator i=getAllRelations().iterator(); i.hasNext();) {
+ // Relation link = i.next();
+ // if (!link.getClass().equals(UsesRelation.class)) continue;
+ //
+ // Document used = (Document)link.getTo();
+ // if (!used.isVersioned()) continue;
+ // TODO: Update the uses relation
+ // }
+ // this.promote();
+ // this.lasdate = current.getTime(); // Today
+ // Database.getSession().update(this);
+ //
+ // TODO: Promote documents using this one
+ // }
+
+ /**
+ * Checks if documents of this type are result of a study. A document is the result of a study when it is the result of the last step of
+ * the study.
+ *
+ * @param aType
+ * the document type
+ * @return true if documents of this type are result of a study.
+ * @see #isStepResult()
+ * @see #isResultOf(org.splat.service.technical.ProjectSettingsServiceImpl.Step)
+ */
+ public boolean isStudyResult(DocumentType aType) {
+ // -------------------------------
+ List step = getProjectSettings()
+ .getAllSteps();
+ ProjectSettingsService.Step lastep = step.get(step.size() - 1);
+ return (aType.isResultOf(lastep));
+ }
+
/**
* Get the studyService.
*
@@ -277,4 +644,42 @@ public class DocumentServiceImpl implements DocumentService {
_repositoryService = repositoryService;
}
+ /**
+ * Get the documentTypeDAO.
+ *
+ * @return the documentTypeDAO
+ */
+ public DocumentTypeDAO getDocumentTypeDAO() {
+ return _documentTypeDAO;
+ }
+
+ /**
+ * Set the documentTypeDAO.
+ *
+ * @param documentTypeDAO
+ * the documentTypeDAO to set
+ */
+ public void setDocumentTypeDAO(DocumentTypeDAO documentTypeDAO) {
+ _documentTypeDAO = documentTypeDAO;
+ }
+
+ /**
+ * Get the fileDAO.
+ *
+ * @return the fileDAO
+ */
+ public FileDAO getFileDAO() {
+ return _fileDAO;
+ }
+
+ /**
+ * Set the fileDAO.
+ *
+ * @param fileDAO
+ * the fileDAO to set
+ */
+ public void setFileDAO(FileDAO fileDAO) {
+ _fileDAO = fileDAO;
+ }
+
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/DocumentTypeService.java b/Workspace/Siman-Common/src/org/splat/service/DocumentTypeService.java
index 84d82cc..3875736 100644
--- a/Workspace/Siman-Common/src/org/splat/service/DocumentTypeService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/DocumentTypeService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -7,23 +7,78 @@
* @version $Revision$
*****************************************************************************/
-package org.splat.service;
+package org.splat.service;
+
+import java.util.List;
import org.splat.dal.bo.som.DocumentType;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
+import org.splat.service.technical.ProjectSettingsService;
/**
- * @author RKV
+ * Document type service interface.
*
+ * @author Roman Kozlov (RKV)
*/
public interface DocumentTypeService {
/**
- * Checks if documents of this type are result of a study.
- * A document is the result of a study when it is the result of the last step of the study.
+ * Get all document types from the database.
+ *
+ * @return the list of all document types
+ */
+ public List selectAllTypes();
+
+ /**
+ * Find all result document types.
+ *
+ * @return the list of found types
+ */
+ public List selectResultTypes();
+
+ /**
+ * Get document type by the given type name.
+ *
+ * @param name
+ * the type name
+ * @return the found document type
+ */
+ public DocumentType selectType(String name);
+
+ /**
+ * Get document type by the given id.
+ *
+ * @param index
+ * the id
+ * @return the found document type
+ */
+ public DocumentType selectType(long index);
+
+ /**
+ * Create a new document type.
+ *
+ * @param tprop
+ * properties of the new document type
+ * @return the created document type
+ * @throws MissedPropertyException
+ * if a mandatory property is missed
+ * @throws InvalidPropertyException
+ * if some property doesn't exist
+ * @throws MultiplyDefinedException
+ * if some property is defined several times
+ */
+ public DocumentType createType(DocumentType.Properties tprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException;
+
+ /**
+ * Get document types applicable for the given study step.
*
- * @return true if documents of this type are result of a study.
- * @see #isStepResult()
- * @see #isResultOf(org.splat.service.technical.ProjectSettingsServiceImpl.Step)
+ * @param step
+ * the step (study activity)
+ * @return the list of found document types
*/
- public boolean isStudyResult (DocumentType aType);
+ public List selectTypesOf(ProjectSettingsService.Step step);
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/DocumentTypeServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/DocumentTypeServiceImpl.java
index c88ec88..63fecb5 100644
--- a/Workspace/Siman-Common/src/org/splat/service/DocumentTypeServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/DocumentTypeServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -7,46 +7,143 @@
* @version $Revision$
*****************************************************************************/
-package org.splat.service;
+package org.splat.service;
+import java.util.Iterator;
import java.util.List;
+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.dao.som.DocumentTypeDAO;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
import org.splat.service.technical.ProjectSettingsService;
+import org.springframework.transaction.annotation.Transactional;
/**
- * @author RKV
+ * Document type service implementation.
*
+ * @author Roman Kozlov (RKV)
*/
public class DocumentTypeServiceImpl implements DocumentTypeService {
- private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected document type DAO.
+ */
+ private DocumentTypeDAO _documentTypeDAO;
+
+ /**
+ * Get all document types from the database.
+ *
+ * @return the list of all document types
+ */
+ @Transactional(readOnly = true)
+ public List selectAllTypes() {
+ List types = getDocumentTypeDAO().getAll();
+ for (Iterator i = types.iterator(); i.hasNext();) {
+ Hibernate.initialize(i.next()); // Supposed fetching document types
+ }
+ return types;
+ }
/**
- * Checks if documents of this type are result of a study.
- * A document is the result of a study when it is the result of the last step of the study.
+ * Find all result document types.
*
- * @return true if documents of this type are result of a study.
- * @see #isStepResult()
- * @see #isResultOf(org.splat.service.technical.ProjectSettingsServiceImpl.Step)
+ * @return the list of found types
*/
- public boolean isStudyResult (DocumentType aType) {
- // -------------------------------
- List step = getProjectSettings().getAllSteps();
- ProjectSettingsService.Step lastep = step.get( step.size()-1 );
- return (aType.isResultOf(lastep));
- }
+ @Transactional(readOnly = true)
+ public List selectResultTypes() {
+ return getDocumentTypeDAO().getFilteredList(
+ Restrictions.isNotNull("result"), Order.asc("result"));
+ }
/**
- * @return
+ * Get document type by the given type name.
+ *
+ * @param name
+ * the type name
+ * @return the found document type
*/
- public ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
+ @Transactional(readOnly = true)
+ public DocumentType selectType(String name) {
+ return getDocumentTypeDAO().findByCriteria(
+ Restrictions.eq("name", name));
}
- public void setProjectSettings(
- ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
+ /**
+ * Get document type by the given id.
+ *
+ * @param index
+ * the id
+ * @return the found document type
+ */
+ @Transactional(readOnly = true)
+ public DocumentType selectType(long index) {
+ return getDocumentTypeDAO().get(index);
}
+ /**
+ * Create a new document type.
+ *
+ * @param tprop
+ * properties of the new document type
+ * @return the created document type
+ * @throws MissedPropertyException
+ * if a mandatory property is missed
+ * @throws InvalidPropertyException
+ * if some property doesn't exist
+ * @throws MultiplyDefinedException
+ * if some property is defined several times
+ */
+ @Transactional
+ public DocumentType createType(DocumentType.Properties tprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException {
+ // TODO: Check for duplicate definition
+ DocumentType type = new DocumentType(tprop);
+ getDocumentTypeDAO().create(type);
+ return type;
+ }
+
+ /**
+ * Get document types applicable for the given study step.
+ *
+ * @param step
+ * the step (study activity)
+ * @return the list of found document types
+ */
+ @Transactional(readOnly = true)
+ public List selectTypesOf(ProjectSettingsService.Step step) {
+ Integer number = step.getNumber();
+ String sampleStr = new StringBuffer("%-").append(number).append("-%")
+ .toString();
+ List types = getDocumentTypeDAO().getFilteredList(
+ Restrictions.like("step", sampleStr));
+ for (Iterator i = types.iterator(); i.hasNext();) {
+ Hibernate.initialize(i.next()); // For fetching document types
+ }
+ return types;
+ }
+
+ /**
+ * Get the documentTypeDAO.
+ *
+ * @return the documentTypeDAO
+ */
+ public DocumentTypeDAO getDocumentTypeDAO() {
+ return _documentTypeDAO;
+ }
+
+ /**
+ * Set the documentTypeDAO.
+ *
+ * @param documentTypeDAO
+ * the documentTypeDAO to set
+ */
+ public void setDocumentTypeDAO(DocumentTypeDAO documentTypeDAO) {
+ _documentTypeDAO = documentTypeDAO;
+ }
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementService.java b/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementService.java
index 62cec62..2ccef0c 100644
--- a/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -9,23 +9,76 @@
package org.splat.service;
+import java.util.List;
+
import org.splat.dal.bo.som.KnowledgeElement;
+import org.splat.dal.bo.som.KnowledgeElementType;
+import org.splat.dal.bo.som.ProgressState;
import org.splat.kernel.InvalidPropertyException;
/**
- * @author RKV
+ * Knowledge element service interface.
*
+ * @author Roman Kozlov (RKV)
*/
public interface KnowledgeElementService {
+ /**
+ * Approve the knowledge element.
+ *
+ * @param knowledgeElement
+ * the knowledge element to approve
+ * @return true if approving succeeded
+ */
public boolean approve(KnowledgeElement knowledgeElement);
+ /**
+ * Demote the knowledge element.
+ *
+ * @param knowledgeElement
+ * the knowledge element to demote
+ * @return true if demoting succeeded
+ */
public boolean demote(KnowledgeElement knowledgeElement);
+ /**
+ * Promote the knowledge element.
+ *
+ * @param knowledgeElement
+ * the knowledge element to promote
+ * @return true if promotion succeeded
+ */
public boolean promote(KnowledgeElement knowledgeElement);
+ /**
+ * Rename the knowledge element.
+ *
+ * @param knowledgeElement
+ * the knowledge element to rename
+ * @param title
+ * the new title of the knowledge element
+ * @throws InvalidPropertyException
+ * if renaming is failed
+ */
public void rename(KnowledgeElement knowledgeElement, String title)
throws InvalidPropertyException;
+ /**
+ * Get a knowledge element by its id.
+ *
+ * @param index
+ * the knowledge element id
+ * @return the found knowledge element
+ */
public KnowledgeElement selectKnowledgeElement(long index);
+
+ /**
+ * Update the description of the knowledge element.
+ *
+ * @param kelm
+ * the knoledge element to update
+ * @param description
+ * the new description
+ */
+ public void update(KnowledgeElement kelm, String description);
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementServiceImpl.java
index 485ce62..c6c23dd 100644
--- a/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -7,35 +7,60 @@
* @version $Revision$
*****************************************************************************/
-package org.splat.service;
+package org.splat.service;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.dao.kernel.GenericDAO;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.dao.som.KnowledgeElementDAO;
import org.splat.kernel.InvalidPropertyException;
+import org.splat.log.AppLogger;
import org.splat.service.technical.IndexService;
+import org.springframework.transaction.annotation.Transactional;
/**
- * @author RKV
- *
+ * Knowledge element service implementation.
+ *
+ * @author Roman Kozlov (RKV)
*/
public class KnowledgeElementServiceImpl implements KnowledgeElementService {
+ /**
+ * The logger for the service.
+ */
+ public final static AppLogger logger = AppLogger
+ .getLogger(KnowledgeElementServiceImpl.class);
+
+ /**
+ * Injected index service.
+ */
private IndexService _indexService;
+ /**
+ * Injected knowledge element DAO.
+ */
private KnowledgeElementDAO _knowledgeElementDAO;
+ /**
+ * Injected study service.
+ */
+ private StudyService _studyService;
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.KnowledgeElementService#approve(org.splat.dal.bo.som.KnowledgeElement)
+ */
public boolean approve(KnowledgeElement knowledgeElement) {
- // -------------------------
if (knowledgeElement.getProgressState() != ProgressState.inCHECK)
return false;
knowledgeElement.setProgressState(ProgressState.APPROVED);
return update(knowledgeElement);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.KnowledgeElementService#demote(org.splat.dal.bo.som.KnowledgeElement)
+ */
public boolean demote(KnowledgeElement knowledgeElement) {
- // ------------------------
if (knowledgeElement.getProgressState() != ProgressState.APPROVED
&& knowledgeElement.getProgressState() != ProgressState.inCHECK)
return false;
@@ -43,61 +68,137 @@ public class KnowledgeElementServiceImpl implements KnowledgeElementService {
return update(knowledgeElement);
}
+ /**
+ * Update knowledge element in the database and in the lucene index.
+ * @param knowledgeElement the knowledge element to update
+ * @return true if updating succeeded
+ */
protected boolean update(KnowledgeElement knowledgeElement) {
- // -----------------------------
try {
getKnowledgeElementDAO().update(knowledgeElement);
getIndexService().update(knowledgeElement);
return true;
} catch (Exception error) {
- // logger.error("Unable to re-index the knowledge '" + getIndex() + "', reason:", error);
+ logger.error("Unable to re-index the knowledge '"
+ + knowledgeElement.getIndex() + "', reason:", error);
return false;
}
}
- public boolean promote (KnowledgeElement knowledgeElement) {
-// -------------------------
- if (knowledgeElement.getProgressState() != ProgressState.inDRAFT) return false;
- knowledgeElement.setProgressState(ProgressState.inCHECK);
- return update(knowledgeElement);
- }
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.KnowledgeElementService#promote(org.splat.dal.bo.som.KnowledgeElement)
+ */
+ public boolean promote(KnowledgeElement knowledgeElement) {
+ // -------------------------
+ if (knowledgeElement.getProgressState() != ProgressState.inDRAFT)
+ return false;
+ knowledgeElement.setProgressState(ProgressState.inCHECK);
+ return update(knowledgeElement);
+ }
- public void rename (KnowledgeElement knowledgeElement, String title) throws InvalidPropertyException {
- if (title.length() == 0) throw new InvalidPropertyException("name");
- knowledgeElement.setTitle(title);
- update(knowledgeElement);
- }
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.KnowledgeElementService#rename(org.splat.dal.bo.som.KnowledgeElement, java.lang.String)
+ */
+ public void rename(KnowledgeElement knowledgeElement, String title)
+ throws InvalidPropertyException {
+ if (title.length() == 0)
+ throw new InvalidPropertyException("name");
+ knowledgeElement.setTitle(title);
+ update(knowledgeElement);
+ }
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.KnowledgeElementService#selectKnowledgeElement(long)
+ */
public KnowledgeElement selectKnowledgeElement(long index) {
- // -----------------------------------------------------------------
- StringBuffer query = new StringBuffer(
- "from KnowledgeElement where rid='").append(index).append("'");
- KnowledgeElement result = (KnowledgeElement) Database.getSession()
- .createQuery(query.toString()).uniqueResult();
-
- result.getOwnerScenario().getOwnerStudy().loadWorkflow();
+ KnowledgeElement result = getKnowledgeElementDAO().get(index);
+ getStudyService().loadWorkflow(result.getOwnerScenario().getOwnerStudy());
return result;
}
/**
- * @return
+ * Update the description of the knowledge element.
+ *
+ * @param kelm
+ * the knoledge element to update
+ * @param description
+ * the new description
+ */
+ @Transactional
+ public void update(KnowledgeElement kelm, String description) {
+ kelm.setValue(description.trim());
+ if (!kelm.getValue().startsWith("")) {
+ StringBuffer text = new StringBuffer("
");
+ int index = kelm.getValue().indexOf("
");
+ if (index > 0) {
+ kelm.setValue(text.append(kelm.getValue().substring(0, index))
+ .append("
")
+ .append(kelm.getValue().substring(index)).toString());
+ } else {
+ kelm.setValue(text.append(kelm.getValue()).append("")
+ .toString());
+ }
+ }
+ getKnowledgeElementDAO().update(kelm); // No need to update the Lucene index
+ }
+
+ /**
+ * Get the indexService.
+ *
+ * @return the indexService
*/
public IndexService getIndexService() {
return _indexService;
}
+ /**
+ * Set the indexService.
+ *
+ * @param indexService
+ * the indexService to set
+ */
public void setIndexService(IndexService indexService) {
_indexService = indexService;
}
/**
- * @return
+ * Get the knowledgeElementDAO.
+ *
+ * @return the knowledgeElementDAO
*/
public KnowledgeElementDAO getKnowledgeElementDAO() {
return _knowledgeElementDAO;
}
-
- public void setKnowledgeElementDAO(KnowledgeElementDAO knowledgeElementDAO) {
+
+ /**
+ * Set the knowledgeElementDAO.
+ *
+ * @param knowledgeElementDAO
+ * the knowledgeElementDAO to set
+ */
+ public void setKnowledgeElementDAO(KnowledgeElementDAO knowledgeElementDAO) {
_knowledgeElementDAO = knowledgeElementDAO;
}
+
+ /**
+ * Get the studyService.
+ * @return the studyService
+ */
+ public StudyService getStudyService() {
+ return _studyService;
+ }
+
+ /**
+ * Set the studyService.
+ * @param studyService the studyService to set
+ */
+ public void setStudyService(StudyService studyService) {
+ _studyService = studyService;
+ }
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeService.java b/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeService.java
new file mode 100644
index 0000000..e17cb97
--- /dev/null
+++ b/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeService.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 19.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service;
+
+import java.util.List;
+
+import org.splat.dal.bo.som.KnowledgeElementType;
+import org.splat.dal.bo.som.ProgressState;
+
+/**
+ * The service interface for working with knowledge element types.
+ *
+ * @author Roman Kozlov (RKV)
+ */
+public interface KnowledgeElementTypeService {
+
+ /**
+ * Find a knowledge type by its name.
+ *
+ * @param name
+ * the knowledge type name
+ * @return the found knowledge type
+ */
+ public KnowledgeElementType selectType(String name);
+
+ /**
+ * Create a knowledge element type with the given name.
+ *
+ * @param name
+ * the new type name
+ * @return the created knowledge type
+ */
+ public KnowledgeElementType createType(String name);
+
+ /**
+ * Get all knowledge types from the database.
+ *
+ * @return the list of all knowledge types
+ */
+ public List selectAllTypes();
+
+ /**
+ * Get knowledge types which have the given progress state.
+ *
+ * @param state
+ * the progress state
+ * @return the list of found knowledge types
+ */
+ public List selectTypesWhere(ProgressState state);
+
+ /**
+ * Get a knowledge type by its id.
+ *
+ * @param index
+ * the id of a knowledge type
+ * @return the found knowledge type
+ */
+ public KnowledgeElementType selectType(long index);
+}
diff --git a/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeServiceImpl.java
new file mode 100644
index 0000000..a5dd084
--- /dev/null
+++ b/Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeServiceImpl.java
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 19.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service;
+
+import java.util.List;
+
+import org.hibernate.criterion.Order;
+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;
+
+/**
+ * KnowledgeElementTypeService implementation for working with knowledge types.
+ *
+ * @author Roman Kozlov (RKV)
+ */
+public class KnowledgeElementTypeServiceImpl implements
+ KnowledgeElementTypeService {
+
+ /**
+ * Injected knowledge element type DAO.
+ */
+ private KnowledgeElementTypeDAO _knowledgeElementTypeDAO;
+
+ /**
+ * Create a knowledge element type with the given name.
+ *
+ * @param name
+ * the new type name
+ * @return the created knowledge type
+ */
+ public KnowledgeElementType createType(String name) {
+ // TODO: Check for duplicate definition
+ KnowledgeElementType kelt = new KnowledgeElementType(name);
+ getKnowledgeElementTypeDAO().create(kelt);
+ return kelt;
+ }
+
+ /**
+ * Get all knowledge types from the database.
+ *
+ * @return the list of all knowledge types
+ */
+ public List selectAllTypes() {
+ return getKnowledgeElementTypeDAO().getAll(Order.asc("rid"));
+ }
+
+ /**
+ * Get knowledge types which have the given progress state.
+ *
+ * @param state
+ * the progress state
+ * @return the list of found knowledge types
+ */
+ public List selectTypesWhere(ProgressState state) {
+ return getKnowledgeElementTypeDAO().getFilteredList(
+ Restrictions.eq("state", state), Order.asc("rid"));
+ }
+
+ /**
+ * Find a knowledge type by its name.
+ *
+ * @param name
+ * the knowledge type name
+ * @return the found knowledge type
+ */
+ public KnowledgeElementType selectType(String name) {
+ return getKnowledgeElementTypeDAO().findByCriteria(
+ Restrictions.eq("name", name));
+ }
+
+ /**
+ * Get a knowledge type by its id.
+ *
+ * @param index
+ * the id of a knowledge type
+ * @return the found knowledge type
+ */
+ public KnowledgeElementType selectType(long index) {
+ return getKnowledgeElementTypeDAO().get(index);
+ }
+
+ /**
+ * Get the knowledgeElementTypeDAO.
+ *
+ * @return the knowledgeElementTypeDAO
+ */
+ public KnowledgeElementTypeDAO getKnowledgeElementTypeDAO() {
+ return _knowledgeElementTypeDAO;
+ }
+
+ /**
+ * Set the knowledgeElementTypeDAO.
+ *
+ * @param knowledgeElementTypeDAO
+ * the knowledgeElementTypeDAO to set
+ */
+ public void setKnowledgeElementTypeDAO(
+ KnowledgeElementTypeDAO knowledgeElementTypeDAO) {
+ _knowledgeElementTypeDAO = knowledgeElementTypeDAO;
+ }
+
+}
diff --git a/Workspace/Siman-Common/src/org/splat/service/LockService.java b/Workspace/Siman-Common/src/org/splat/service/LockService.java
index dc5f695..6edf1f7 100644
--- a/Workspace/Siman-Common/src/org/splat/service/LockService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/LockService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File Id:
* Creation date 02.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/LockServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/LockServiceImpl.java
index f4561a4..9df0f08 100644
--- a/Workspace/Siman-Common/src/org/splat/service/LockServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/LockServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 02.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/ProjectElementService.java b/Workspace/Siman-Common/src/org/splat/service/ProjectElementService.java
index 7f9564d..186a048 100644
--- a/Workspace/Siman-Common/src/org/splat/service/ProjectElementService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/ProjectElementService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 07.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/ProjectElementServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/ProjectElementServiceImpl.java
index a8a5080..84fc9df 100644
--- a/Workspace/Siman-Common/src/org/splat/service/ProjectElementServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/ProjectElementServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 07.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/PublicationService.java b/Workspace/Siman-Common/src/org/splat/service/PublicationService.java
index a2eb497..39d8b8e 100644
--- a/Workspace/Siman-Common/src/org/splat/service/PublicationService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/PublicationService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -12,12 +12,14 @@ package org.splat.service;
import java.io.FileNotFoundException;
import java.util.Date;
+import org.splat.dal.bo.som.ConvertsRelation;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.ProgressState;
import org.splat.dal.bo.som.ProjectElement;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.Study;
import org.splat.dal.bo.som.Timestamp;
+import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.NotApplicableException;
import org.splat.som.DocumentRights;
import org.splat.som.Revision;
@@ -172,4 +174,42 @@ public interface PublicationService {
*/
public void saveAs(Publication aPublication, Revision newvers)
throws FileNotFoundException, NotApplicableException;
+
+ /**
+ * Rename the published document.
+ *
+ * @param aPublication
+ * the publication of the document
+ * @param title
+ * the new document title
+ * @throws InvalidPropertyException
+ * if the new title is empty
+ */
+ public void rename(Publication aPublication, String title)
+ throws InvalidPropertyException;
+
+ /**
+ * Create "Converts" relation for the given document publication and format.
+ *
+ * @param aPublication
+ * the document publication
+ * @param format
+ * the format
+ * @return the created "Converts" relation
+ */
+ public ConvertsRelation attach(Publication aPublication, String format);
+
+ /**
+ * Create "Converts" relation for the given document publication, format and description.
+ *
+ * @param aPublication
+ * the document publication
+ * @param format
+ * the format
+ * @param description
+ * the description of the relation
+ * @return the created "Converts" relation
+ */
+ public ConvertsRelation attach(Publication aPublication, String format,
+ String description);
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java
index e2e5302..1516ba4 100644
--- a/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -15,8 +15,8 @@ import java.util.Date;
import java.util.Iterator;
import java.util.List;
-import org.hibernate.Session;
import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.ConvertsRelation;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.ProgressState;
@@ -28,12 +28,15 @@ import org.splat.dal.bo.som.Study;
import org.splat.dal.bo.som.Timestamp;
import org.splat.dal.bo.som.ValidationCycle;
import org.splat.dal.bo.som.ValidationStep;
-import org.splat.dal.dao.som.Database;
+import org.splat.dal.dao.som.ProjectElementDAO;
+import org.splat.dal.dao.som.PublicationDAO;
+import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.NotApplicableException;
import org.splat.manox.Reader;
import org.splat.manox.Toolbox;
import org.splat.som.Revision;
import org.splat.som.Step;
+import org.springframework.transaction.annotation.Transactional;
/**
* Publication service implementation.
@@ -47,21 +50,29 @@ public class PublicationServiceImpl implements PublicationService {
*/
private StudyService _studyService;
/**
- * Injected study service.
+ * Injected step service.
*/
private StepService _stepService;
/**
- * Injected study service.
+ * Injected document service.
*/
- private DocumentTypeService _documentTypeService;
+ private DocumentService _documentService;
/**
- * Injected study service.
+ * Injected project element service.
*/
private ProjectElementService _projectElementService;
/**
* Injected simulation context service.
*/
private SimulationContextService _simulationContextService;
+ /**
+ * Injected publication DAO.
+ */
+ private PublicationDAO _publicationDAO;
+ /**
+ * Injected project element DAO.
+ */
+ private ProjectElementDAO _projectElementDAO;
/**
* {@inheritDoc}
@@ -86,7 +97,6 @@ public class PublicationServiceImpl implements PublicationService {
* @see org.splat.service.PublicationService#approve(org.splat.dal.bo.som.Publication, java.util.Date)
*/
public Timestamp approve(Publication aPublication, Date adate) {
- // -------------------------------------
if (aPublication.isOutdated())
return null;
else if (aPublication.value().getProgressState() != ProgressState.inCHECK)
@@ -94,13 +104,14 @@ public class PublicationServiceImpl implements PublicationService {
DocumentType type = aPublication.value().getType();
Study owner = aPublication.getOwnerStudy();
- ValidationCycle cycle = owner.getValidationCycleOf(type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
+ type);
User approver = cycle.getActor(ValidationStep.APPROVAL);
Timestamp stamp = new Timestamp(ValidationStep.APPROVAL, aPublication
.value(), approver, adate);
- if (!aPublication.value().promote(stamp))
+ if (!getDocumentService().promote(aPublication.value(), stamp))
return null;
- if (getDocumentTypeService().isStudyResult(type)
+ if (getDocumentService().isStudyResult(type)
&& owner.getProgressState() == ProgressState.inCHECK)
getStudyService().promote(owner);
return stamp; // Hoping that promotion of the study succeeded
@@ -112,27 +123,27 @@ public class PublicationServiceImpl implements PublicationService {
* @see org.splat.service.PublicationService#demote(org.splat.dal.bo.som.Publication)
*/
public boolean demote(Publication aPublication) {
- // ------------------------
DocumentType type = aPublication.value().getType();
Study owner = aPublication.getOwnerStudy();
if (aPublication.value().getProgressState() == ProgressState.inCHECK) {
- ValidationCycle cycle = owner.getValidationCycleOf(type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ owner, type);
if (cycle.enables(ValidationStep.REVIEW)) {
- if (!aPublication.value().demote())
+ if (!getDocumentService().demote(aPublication.value()))
return false;
} else {
- if (!aPublication.value().demote())
+ if (!getDocumentService().demote(aPublication.value()))
return false;
- aPublication.value().demote();
+ getDocumentService().demote(aPublication.value());
}
} else if (aPublication.value().getProgressState() == ProgressState.inDRAFT) {
- if (!aPublication.value().demote())
+ if (!getDocumentService().demote(aPublication.value()))
return false;
} else {
return false;
}
- if (getDocumentTypeService().isStudyResult(type)
+ if (getDocumentService().isStudyResult(type)
&& owner.getProgressState() != ProgressState.inWORK)
getStudyService().demote(owner);
return true;
@@ -144,14 +155,13 @@ public class PublicationServiceImpl implements PublicationService {
* @see org.splat.service.PublicationService#invalidate(org.splat.dal.bo.som.Publication)
*/
public boolean invalidate(Publication aPublication) {
- // ----------------------------
if (aPublication.value().getProgressState() != ProgressState.inCHECK)
return false;
- if (!aPublication.value().demote()) // Removes the reviewer if this document is In-Check
+ if (!getDocumentService().demote(aPublication.value())) // Removes the reviewer if this document is In-Check
return false;
DocumentType type = aPublication.value().getType();
Study owner = aPublication.getOwnerStudy();
- if (getDocumentTypeService().isStudyResult(type)
+ if (getDocumentService().isStudyResult(type)
&& owner.getProgressState() == ProgressState.inCHECK)
getStudyService().demote(owner);
return true;
@@ -170,7 +180,8 @@ public class PublicationServiceImpl implements PublicationService {
else {
DocumentType type = aPublication.value().getType();
Study owner = aPublication.getOwnerStudy();
- ValidationCycle cycle = owner.getValidationCycleOf(type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ owner, type);
User promoter = cycle.getActor(ValidationStep.PROMOTION);
if (promoter == null)
promoter = getInvolvedStep(aPublication).getActor();
@@ -179,12 +190,12 @@ public class PublicationServiceImpl implements PublicationService {
Timestamp stamp = new Timestamp(ValidationStep.PROMOTION,
aPublication.value(), promoter, pdate);
- if (!aPublication.value().promote(stamp)) // Promotion to being reviewed
+ if (!getDocumentService().promote(aPublication.value(), stamp)) // Promotion to being reviewed
return null;
if (!cycle.enables(ValidationStep.REVIEW)) {
- aPublication.value().promote(null);
+ getDocumentService().promote(aPublication.value(), null);
}
- if (getDocumentTypeService().isStudyResult(type)
+ if (getDocumentService().isStudyResult(type)
&& owner.getProgressState() == ProgressState.inWORK)
getStudyService().promote(owner);
return stamp; // Hoping that promotion of the study succeeded
@@ -204,13 +215,14 @@ public class PublicationServiceImpl implements PublicationService {
DocumentType type = aPublication.value().getType();
Study owner = aPublication.getOwnerStudy();
- ValidationCycle cycle = owner.getValidationCycleOf(type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
+ type);
User reviewer = cycle.getActor(ValidationStep.REVIEW);
Timestamp stamp = new Timestamp(ValidationStep.REVIEW, aPublication
.value(), reviewer, rdate);
- if (!aPublication.value().promote(stamp))
+ if (!getDocumentService().promote(aPublication.value(), stamp))
return null;
- if (getDocumentTypeService().isStudyResult(type)
+ if (getDocumentService().isStudyResult(type)
&& owner.getProgressState() == ProgressState.inDRAFT)
getStudyService().promote(owner);
return stamp; // Hoping that promotion of the study succeeded
@@ -222,17 +234,17 @@ public class PublicationServiceImpl implements PublicationService {
* @see org.splat.service.PublicationService#saveAs(org.splat.dal.bo.som.Publication, org.splat.som.Revision)
* @deprecated
*/
+ @Transactional
public void saveAs(Publication aPublication, Revision newvers)
throws FileNotFoundException, NotApplicableException {
- // -------------------------------------
if (aPublication.value().isUndefined())
throw new NotApplicableException(
"Cannot save a Publication object refering an undefined Document");
if (!aPublication.value().getSourceFile().exists())
throw new FileNotFoundException();
- Database.getSession().save(aPublication); // Must be done before updating the study in order to fix this final (rid-based) hascode
- aPublication.value().updateAs(newvers); // May change the branch name of given revision
+ getPublicationDAO().create(aPublication); // Must be done before updating the study in order to fix this final (rid-based) hascode
+ getDocumentService().updateAs(aPublication.value(), newvers); // May change the branch name of given revision
updateOwner(aPublication);
}
@@ -241,9 +253,9 @@ public class PublicationServiceImpl implements PublicationService {
*
* @see org.splat.service.PublicationService#saveAs(org.splat.dal.bo.som.Publication, org.splat.dal.bo.som.ProgressState)
*/
+ @Transactional
public void saveAs(Publication aPublication, ProgressState state)
throws FileNotFoundException, NotApplicableException {
- // ----------------------------------------
if (aPublication.value().isUndefined())
throw new NotApplicableException(
"Cannot save a Publication object refering an undefined Document");
@@ -251,13 +263,14 @@ public class PublicationServiceImpl implements PublicationService {
throw new FileNotFoundException();
if (state == ProgressState.inWORK || state == ProgressState.EXTERN) {
- Database.getSession().save(aPublication); // Must be done before updating the study in order to fix this final (rid-based)
+ getPublicationDAO().create(aPublication); // Must be done before updating the study in order to fix this final (rid-based)
// hascode
- aPublication.value().updateAs(state);
+ getDocumentService().updateAs(aPublication.value(), state);
} else {
DocumentType mytype = aPublication.value().getType();
Study owner = aPublication.getOwnerStudy();
- ValidationCycle cycle = owner.getValidationCycleOf(mytype);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ owner, mytype);
boolean review = cycle.enables(ValidationStep.REVIEW);
if (!(state == ProgressState.inDRAFT && review)
&& !(state == ProgressState.inCHECK && !review)) {
@@ -265,9 +278,10 @@ public class PublicationServiceImpl implements PublicationService {
"Cannot save a result document in " + state.toString()
+ " state");
}
- Database.getSession().save(aPublication); // Must be done before updating the study in order to fix this final (rid-based)
+ getPublicationDAO().create(aPublication); // Must be done before updating the study in order to fix this final (rid-based)
// hascode
- aPublication.value().updateAs(ProgressState.inWORK);
+ getDocumentService().updateAs(aPublication.value(),
+ ProgressState.inWORK);
promote(aPublication, aPublication.value()
.getLastModificationDate()); // Promotes to the appropriate state in accordance to the validation cycle
@@ -281,24 +295,24 @@ public class PublicationServiceImpl implements PublicationService {
* @param aPublication
* the document publication
*/
+ @Transactional
private void updateOwner(Publication aPublication) {
- Session session = Database.getSession();
Step step = getInvolvedStep(aPublication);
// Update of involved step
Document previous = aPublication.value().getPreviousVersion();
if (previous != null) {
Publication oldoc = step.getDocument(previous.getIndex());
- boolean done = step.remove(oldoc); // Decrements the configuration tag count of document
+ boolean done = getStepService().remove(step, oldoc); // Decrements the configuration tag count of document
if (done)
- session.delete(oldoc); // WARNING: Potential problem because it's not automatically done as orphan object
+ getPublicationDAO().delete(oldoc); // WARNING: Potential problem because it's not automatically done as orphan object
}
- step.add(aPublication); // Increments the configuration tag count of document
+ getStepService().add(step, aPublication); // Increments the configuration tag count of document
// Import the document properties and update of the study
forwardProperties(aPublication, aPublication.value().getSourceFile()
.asFile(), step);
- session.update(aPublication.getOwner());
+ getProjectElementDAO().update(aPublication.getOwner());
}
/**
@@ -313,7 +327,6 @@ public class PublicationServiceImpl implements PublicationService {
*/
private void forwardProperties(Publication aPublication, java.io.File from,
Step to) {
- // -----------------------------------------------------------
Reader tool = Toolbox.getReader(from);
if (tool == null)
return; // No properties extractor available for this type of document
@@ -380,6 +393,51 @@ public class PublicationServiceImpl implements PublicationService {
return aPublication.getStep();
}
+ /**
+ * Create "Converts" relation for the given document publication and format.
+ *
+ * @param aPublication
+ * the document publication
+ * @param format
+ * the format
+ * @return the created "Converts" relation
+ */
+ public ConvertsRelation attach(Publication aPublication, String format) {
+ return getDocumentService().attach(aPublication.value(), format);
+ }
+
+ /**
+ * Create "Converts" relation for the given document publication, format and description.
+ *
+ * @param aPublication
+ * the document publication
+ * @param format
+ * the format
+ * @param description
+ * the description of the relation
+ * @return the created "Converts" relation
+ */
+ public ConvertsRelation attach(Publication aPublication, String format,
+ String description) {
+ return getDocumentService().attach(aPublication.value(), format,
+ description);
+ }
+
+ /**
+ * Rename the published document.
+ *
+ * @param aPublication
+ * the publication of the document
+ * @param title
+ * the new document title
+ * @throws InvalidPropertyException
+ * if the new title is empty
+ */
+ public void rename(Publication aPublication, String title)
+ throws InvalidPropertyException {
+ getDocumentService().rename(aPublication.value(), title);
+ }
+
/**
* Get the projectElementService.
*
@@ -422,6 +480,7 @@ public class PublicationServiceImpl implements PublicationService {
/**
* Get the studyService.
+ *
* @return the studyService
*/
public StudyService getStudyService() {
@@ -430,7 +489,9 @@ public class PublicationServiceImpl implements PublicationService {
/**
* Set the studyService.
- * @param studyService the studyService to set
+ *
+ * @param studyService
+ * the studyService to set
*/
public void setStudyService(StudyService studyService) {
_studyService = studyService;
@@ -438,6 +499,7 @@ public class PublicationServiceImpl implements PublicationService {
/**
* Get the stepService.
+ *
* @return the stepService
*/
public StepService getStepService() {
@@ -446,25 +508,68 @@ public class PublicationServiceImpl implements PublicationService {
/**
* Set the stepService.
- * @param stepService the stepService to set
+ *
+ * @param stepService
+ * the stepService to set
*/
public void setStepService(StepService stepService) {
_stepService = stepService;
}
/**
- * Get the documentTypeService.
- * @return the documentTypeService
+ * Get the documentService.
+ *
+ * @return the documentService
+ */
+ public DocumentService getDocumentService() {
+ return _documentService;
+ }
+
+ /**
+ * Set the documentService.
+ *
+ * @param documentService
+ * the documentService to set
+ */
+ public void setDocumentService(DocumentService documentService) {
+ _documentService = documentService;
+ }
+
+ /**
+ * Get the publicationDAO.
+ *
+ * @return the publicationDAO
+ */
+ public PublicationDAO getPublicationDAO() {
+ return _publicationDAO;
+ }
+
+ /**
+ * Set the publicationDAO.
+ *
+ * @param publicationDAO
+ * the publicationDAO to set
*/
- public DocumentTypeService getDocumentTypeService() {
- return _documentTypeService;
+ public void setPublicationDAO(PublicationDAO publicationDAO) {
+ _publicationDAO = publicationDAO;
}
/**
- * Set the documentTypeService.
- * @param documentTypeService the documentTypeService to set
+ * Get the projectElementDAO.
+ *
+ * @return the projectElementDAO
+ */
+ public ProjectElementDAO getProjectElementDAO() {
+ return _projectElementDAO;
+ }
+
+ /**
+ * Set the projectElementDAO.
+ *
+ * @param projectElementDAO
+ * the projectElementDAO to set
*/
- public void setDocumentTypeService(DocumentTypeService documentTypeService) {
- _documentTypeService = documentTypeService;
+ public void setProjectElementDAO(ProjectElementDAO projectElementDAO) {
+ _projectElementDAO = projectElementDAO;
}
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/ScenarioService.java b/Workspace/Siman-Common/src/org/splat/service/ScenarioService.java
index df872e7..8c55cfb 100644
--- a/Workspace/Siman-Common/src/org/splat/service/ScenarioService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/ScenarioService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -12,6 +12,7 @@ package org.splat.service;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.Scenario;
+import org.splat.dal.bo.som.Study;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
@@ -24,6 +25,25 @@ import org.splat.som.Step;
*/
public interface ScenarioService {
+ /**
+ * Add a new scenario to the study.
+ *
+ * @param aStudy
+ * the study
+ * @param sprop
+ * scenario properties
+ * @return the added scenario
+ * @throws MissedPropertyException
+ * if a mandatory property is missed
+ * @throws InvalidPropertyException
+ * if some property doesn't exist
+ * @throws MultiplyDefinedException
+ * if some property occurs several times
+ */
+ public Scenario addScenario(Study aStudy, Scenario.Properties sprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException;
+
/**
* Add a new knowledge element to the scenario.
*
diff --git a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
index 01c9843..10b5ba9 100644
--- a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -17,14 +17,18 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.KnowledgeElement;
+import org.splat.dal.bo.som.KnowledgeElementType;
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.Study;
import org.splat.dal.dao.som.KnowledgeElementDAO;
import org.splat.dal.dao.som.ScenarioDAO;
+import org.splat.dal.dao.som.StudyDAO;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
+import org.splat.kernel.UserDirectory;
import org.splat.service.technical.IndexService;
import org.splat.som.Step;
import org.springframework.transaction.annotation.Transactional;
@@ -50,6 +54,10 @@ public class ScenarioServiceImpl implements ScenarioService {
* Injected step service.
*/
private StepService _stepService;
+ /**
+ * Injected study service.
+ */
+ private StudyService _studyService;
/**
* Injected publication service.
*/
@@ -67,6 +75,16 @@ public class ScenarioServiceImpl implements ScenarioService {
*/
private ScenarioDAO _scenarioDAO;
+ /**
+ * Injected study DAO.
+ */
+ private StudyDAO _studyDAO;
+
+ /**
+ * Injected knowledge element service.
+ */
+ private KnowledgeElementTypeService _knowledgeElementTypeService;
+
/**
* Get the projectElementService.
*
@@ -135,18 +153,21 @@ public class ScenarioServiceImpl implements ScenarioService {
public KnowledgeElement addKnowledgeElement(Scenario aScenario,
KnowledgeElement.Properties kprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException {
- KnowledgeElement kelm = new KnowledgeElement(kprop
- .setOwnerScenario(aScenario));
+ KnowledgeElement kelm = null;
try {
+ // Attach the detached scenario to the new hibernate session.
+ aScenario = getScenarioDAO().merge(aScenario); // RKV
+ kelm = new KnowledgeElement(kprop.setOwnerScenario(aScenario));
getKnowledgeElementDAO().create(kelm);
// RKV: commented because of BatchUpdateException during creation of a new study: session.flush(); //RKV
// Update of my persistent data
- aScenario.getKnowledgeElements().add(kelm);
+ // RKV aScenario.getKnowledgeElements().add(kelm);
+ // RKV getKnowledgeElementDAO().flush();
// RKV: commented because of NullPointerException during creation of a new study: session.merge(aScenario); //RKV
// Update of my transient data
List known = aScenario
.getKnowledgeElementsOf(kelm.getType()); // Initializes this.known, if not yet done
- known.add(kelm);
+ // RKV: knowledge is already added into persistent set and "known" is constructed from it in the above call: known.add(kelm);
if (kelm.getType().equals("usecase")) {
aScenario.setUcase(kelm);
} else if (aScenario.getKnowledgeElementsList() != null) { // If null, knowl will be initialized when needed
@@ -202,7 +223,7 @@ public class ScenarioServiceImpl implements ScenarioService {
* @see org.splat.service.ScenarioService#checkout(org.splat.dal.bo.som.Scenario, org.splat.dal.bo.kernel.User)
*/
public boolean checkout(Scenario aScenario, User user) {
- if (!aScenario.getOwnerStudy().isStaffedBy(user))
+ if (!getStudyService().isStaffedBy(aScenario.getOwnerStudy(), user))
return false;
aScenario.setUser(user);
@@ -230,7 +251,7 @@ public class ScenarioServiceImpl implements ScenarioService {
Publication doc = getPublicationService().copy(j.next(),
scenario); // Creation of a new reference to the document
// Database.getSession().save(doc); Publications MUST be saved later through cascading when saving the scenario
- to[i].add(doc);
+ getStepService().add(to[i], doc);
}
List ctex = step.getAllSimulationContexts();
for (Iterator j = ctex.iterator(); j.hasNext();) {
@@ -273,6 +294,46 @@ public class ScenarioServiceImpl implements ScenarioService {
return notempty;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.StudyService#addScenario(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.Scenario.Properties)
+ */
+ @Transactional
+ public Scenario addScenario(Study aStudy, Scenario.Properties sprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException {
+ if (sprop.getManager() == null)
+ sprop.setManager(aStudy.getAuthor());
+
+ Scenario scenario = new Scenario(sprop.setOwnerStudy(aStudy));
+ if (sprop.getBaseStep() != null)
+ copyContentsUpTo(scenario, sprop.getBaseStep());
+ Scenario previous = sprop.getInsertAfter();
+
+ if (previous == null) {
+ aStudy.getScenariiList().add(scenario);
+ } else {
+ aStudy.getScenariiList().add(
+ aStudy.getScenariiList().indexOf(previous) + 1, scenario);
+ }
+ getStudyDAO().update(aStudy); // No need to update the Lucene index
+ getScenarioDAO().create(scenario); // Must be done after updating this study because of the back reference to the study
+ if (sprop.getBaseStep() != null) {
+ // No need to update the Knowledge Element index as Knowledge Elements are not copied
+ scenario.refresh(); // Because saving the scenario changes the hashcode of copied Publications
+ }
+ KnowledgeElementType ucase = getKnowledgeElementTypeService().selectType(
+ "usecase");
+ KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
+ User admin = UserDirectory.selectUser(1); // First user created when creating the database
+ kprop.setType(ucase).setTitle(aStudy.getTitle()).setValue(
+ scenario.getTitle()).setAuthor(admin); // Internal Knowledge Element required by the validation process of
+ // knowledges
+ addKnowledgeElement(scenario, kprop);
+ return scenario;
+ }
+
/**
* Get the knowledgeElementDAO.
*
@@ -330,4 +391,59 @@ public class ScenarioServiceImpl implements ScenarioService {
_scenarioDAO = scenarioDAO;
}
+ /**
+ * Get the studyDAO.
+ *
+ * @return the studyDAO
+ */
+ public StudyDAO getStudyDAO() {
+ return _studyDAO;
+ }
+
+ /**
+ * Set the studyDAO.
+ *
+ * @param studyDAO
+ * the studyDAO to set
+ */
+ public void setStudyDAO(StudyDAO studyDAO) {
+ _studyDAO = studyDAO;
+ }
+
+ /**
+ * Get the knowledgeElementTypeService.
+ *
+ * @return the knowledgeElementTypeService
+ */
+ public KnowledgeElementTypeService getKnowledgeElementTypeService() {
+ return _knowledgeElementTypeService;
+ }
+
+ /**
+ * Set the knowledgeElementTypeService.
+ *
+ * @param knowledgeElementTypeService
+ * the knowledgeElementTypeService to set
+ */
+ public void setKnowledgeElementTypeService(
+ KnowledgeElementTypeService knowledgeElementTypeService) {
+ _knowledgeElementTypeService = knowledgeElementTypeService;
+ }
+
+ /**
+ * Get the studyService.
+ * @return the studyService
+ */
+ public StudyService getStudyService() {
+ return _studyService;
+ }
+
+ /**
+ * Set the studyService.
+ * @param studyService the studyService to set
+ */
+ public void setStudyService(StudyService studyService) {
+ _studyService = studyService;
+ }
+
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/SearchService.java b/Workspace/Siman-Common/src/org/splat/service/SearchService.java
index 2482843..08a8ab8 100644
--- a/Workspace/Siman-Common/src/org/splat/service/SearchService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/SearchService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 05.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java
index 6ed816e..75f3d6a 100644
--- a/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 05.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/ServiceLocator.java b/Workspace/Siman-Common/src/org/splat/service/ServiceLocator.java
new file mode 100644
index 0000000..51c6214
--- /dev/null
+++ b/Workspace/Siman-Common/src/org/splat/service/ServiceLocator.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 19.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service;
+
+/**
+ * The service locator interface.
+ *
+ * @author Roman Kozlov (RKV)
+ */
+@Deprecated
+public interface ServiceLocator {
+ /**
+ * Get study service.
+ * @return study service
+ */
+ StudyService getStudyService();
+}
diff --git a/Workspace/Siman-Common/src/org/splat/service/ServiceLocatorImpl.java b/Workspace/Siman-Common/src/org/splat/service/ServiceLocatorImpl.java
new file mode 100644
index 0000000..6f99f6a
--- /dev/null
+++ b/Workspace/Siman-Common/src/org/splat/service/ServiceLocatorImpl.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 19.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service;
+
+/**
+ * The service locator implementaion. This is a singleton class for providing access to business services.
+ *
+ * @author Roman Kozlov (RKV)
+ */
+@Deprecated
+public class ServiceLocatorImpl implements ServiceLocator {
+
+ /**
+ * The Locator instance.
+ */
+ static ServiceLocator theInstance;
+
+ /**
+ * Get the locator instance.
+ * @return the locator instance
+ */
+ public static ServiceLocator getInstance() {
+ if (theInstance == null) {
+ theInstance = new ServiceLocatorImpl();
+ }
+ return theInstance;
+ }
+
+ /**
+ * Private constructor because this is a singleton class.
+ */
+ private ServiceLocatorImpl() {
+ }
+
+ /**
+ * Injected study service.
+ */
+ private StudyService _studyService;
+
+ /**
+ * Get the studyService.
+ * @return the studyService
+ */
+ public StudyService getStudyService() {
+ return _studyService;
+ }
+
+ /**
+ * Set the studyService.
+ * @param studyService the studyService to set
+ */
+ public void setStudyService(StudyService studyService) {
+ _studyService = studyService;
+ }
+}
diff --git a/Workspace/Siman-Common/src/org/splat/service/SimulationContextService.java b/Workspace/Siman-Common/src/org/splat/service/SimulationContextService.java
index 1cbf05c..dc9cc34 100644
--- a/Workspace/Siman-Common/src/org/splat/service/SimulationContextService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/SimulationContextService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 16.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/SimulationContextServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/SimulationContextServiceImpl.java
index decbcde..81abc66 100644
--- a/Workspace/Siman-Common/src/org/splat/service/SimulationContextServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/SimulationContextServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 16.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/StepService.java b/Workspace/Siman-Common/src/org/splat/service/StepService.java
index 69c96fa..35a8ad0 100644
--- a/Workspace/Siman-Common/src/org/splat/service/StepService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/StepService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -10,8 +10,10 @@
package org.splat.service;
import java.io.IOException;
+import java.util.List;
import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.kernel.InvalidPropertyException;
@@ -23,35 +25,158 @@ import org.splat.som.Step;
/**
* Step service interface.
+ *
* @author Roman Kozlov (RKV)
*/
public interface StepService {
+ /**
+ * Create a new document published in the given study step.
+ *
+ * @param aStep
+ * the target study step
+ * @param dprop
+ * properties of the new document
+ * @return the created publication of the new document
+ * @throws MissedPropertyException
+ * if a mandatory property is missed
+ * @throws InvalidPropertyException
+ * if some property doesn't exist
+ * @throws MultiplyDefinedException
+ * if some property is defined several times
+ * @throws IOException
+ * if a file system error occurs
+ */
public Publication createDocument(Step aStep, Document.Properties dprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException, IOException;
+ /**
+ * Publish an existing document in the given study step.
+ *
+ * @param aStep
+ * the target study step
+ * @param dprop
+ * new properties of the document
+ * @return the created publication of the document
+ * @throws MissedPropertyException
+ * if a mandatory property is missed
+ * @throws InvalidPropertyException
+ * if some property doesn't exist
+ * @throws NotApplicableException
+ * if the document is undefined
+ */
public Publication assignDocument(Step aStep, Document.Properties dprop)
throws MissedPropertyException, InvalidPropertyException,
NotApplicableException;
+ /**
+ * Create a new version of a document in the given study step.
+ *
+ * @param aStep
+ * the study step
+ * @param base
+ * the base document published version
+ * @param dprop
+ * properties of the new version
+ * @return the new version publication
+ * @throws MissedPropertyException
+ * if a mandatory property is missed
+ * @throws InvalidPropertyException
+ * if some property doesn't exist
+ * @throws MultiplyDefinedException
+ * if some property is defined several times
+ * @throws IOException
+ * if a file system error occurs
+ * @throws MismatchException
+ * if the document is not applicable to the given study step
+ */
public Publication versionDocument(Step aStep, Publication base,
Document.Properties dprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException, IOException,
MismatchException;
+ /**
+ * Add simulation context to the study step.
+ *
+ * @param aStep
+ * the study step
+ * @param dprop
+ * properties of the simulation context to add
+ * @return the added simulation context
+ * @throws MissedPropertyException
+ * if a mandatory property is missed
+ * @throws InvalidPropertyException
+ * if some property doesn't exist
+ * @throws MultiplyDefinedException
+ * if some property is defined several times
+ */
public SimulationContext addSimulationContext(Step aStep,
SimulationContext.Properties dprop) throws MissedPropertyException,
- InvalidPropertyException, MultiplyDefinedException,
- RuntimeException;
+ InvalidPropertyException, MultiplyDefinedException;
/**
+ * Add simulation context to the study step.
+ *
* @param firstStep
+ * the study step
* @param context
- * @return
+ * the simulation context to add
+ * @return the added simulation context
*/
public SimulationContext addSimulationContext(Step firstStep,
SimulationContext context);
+ /**
+ * Remove a simulation context from the study step.
+ *
+ * @param aStep
+ * the study step
+ * @param context
+ * the simulation context to remove
+ * @return true if removal succeeded
+ */
public boolean removeSimulationContext(Step aStep, SimulationContext context);
+
+ /**
+ * Add a document publication to the given step.
+ *
+ * @param aStep
+ * the target study step
+ * @param newdoc
+ * the document publication to add
+ * @return true if publication succeeded
+ */
+ public boolean add(Step aStep, Publication newdoc);
+
+ /**
+ * Remove a document publication from the given step.
+ *
+ * @param aStep
+ * the study step
+ * @param oldoc
+ * the document publication to remove
+ * @return true if removing of the publication succeeded
+ */
+ public boolean remove(Step aStep, Publication oldoc);
+
+ /**
+ * Remove a document from the given step.
+ *
+ * @param aStep
+ * the study step
+ * @param doctag
+ * the document publication
+ * @return true if removing of the document succeeded
+ */
+ public boolean removeDocument(Step aStep, Publication doctag);
+
+ /**
+ * Get document types which are applicable for the given study step (activity).
+ *
+ * @param aStep
+ * the study step
+ * @return the list of document types
+ */
+ public List getValidDocumentTypes(Step aStep);
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java
index ccb0fac..d40b87a 100644
--- a/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
@@ -9,13 +9,17 @@
package org.splat.service;
-import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
+import java.util.Vector;
import org.splat.dal.bo.kernel.Relation;
+import org.splat.dal.bo.som.ConvertsRelation;
import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.File;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.Scenario;
@@ -25,6 +29,7 @@ import org.splat.dal.bo.som.UsedByRelation;
import org.splat.dal.bo.som.UsesRelation;
import org.splat.dal.bo.som.VersionsRelation;
import org.splat.dal.dao.som.DocumentDAO;
+import org.splat.dal.dao.som.FileDAO;
import org.splat.dal.dao.som.ProjectElementDAO;
import org.splat.dal.dao.som.SimulationContextDAO;
import org.splat.kernel.InvalidPropertyException;
@@ -58,10 +63,18 @@ public class StepServiceImpl implements StepService {
* Injected document service.
*/
private DocumentService _documentService;
+ /**
+ * Injected document type service.
+ */
+ private DocumentTypeService _documentTypeService;
/**
* Injected document DAO.
*/
private DocumentDAO _documentDAO;
+ /**
+ * Injected file DAO.
+ */
+ private FileDAO _fileDAO;
/**
* Injected simulation context service.
*/
@@ -82,8 +95,7 @@ public class StepServiceImpl implements StepService {
*/
public SimulationContext addSimulationContext(Step aStep,
SimulationContext.Properties dprop) throws MissedPropertyException,
- InvalidPropertyException, MultiplyDefinedException,
- RuntimeException {
+ InvalidPropertyException, MultiplyDefinedException {
SimulationContext context = new SimulationContext(dprop.setStep(aStep
.getStep()));
return addSimulationContext(aStep, context);
@@ -143,7 +155,8 @@ public class StepServiceImpl implements StepService {
updateScenarioIndex(scene);
}
} catch (Exception error) {
- logger.error("Unable to re-index Knowledge Elements, reason:", error);
+ logger.error("Unable to re-index Knowledge Elements, reason:",
+ error);
}
}
@@ -209,14 +222,14 @@ public class StepServiceImpl implements StepService {
getDocumentService().generateDocumentId(newdoc, dprop);
// Creation of the save directory
- File wdir = getDocumentService().getSaveDirectory(newdoc);
+ java.io.File wdir = getDocumentService().getSaveDirectory(newdoc);
if (!wdir.exists())
if (!wdir.mkdirs())
throw new IOException(
"Cannot create the repository vault directory");
// Identification and save
- newdoc.buildReferenceFrom(aStep.getOwnerStudy());
+ getDocumentService().buildReferenceFrom(newdoc, aStep.getOwnerStudy());
getDocumentDAO().create(newdoc);
return new Publication(newdoc, aStep.getOwner());
@@ -247,14 +260,23 @@ public class StepServiceImpl implements StepService {
}
/**
+ * Create a new version of a document in the given study step.
+ *
* @param aStep
+ * the study step
* @param base
- * @return
+ * the base document published version
+ * @return the new version publication
* @throws MissedPropertyException
+ * if a mandatory property is missed
* @throws InvalidPropertyException
+ * if some property doesn't exist
* @throws MultiplyDefinedException
+ * if some property is defined several times
* @throws IOException
+ * if a file system error occurs
* @throws MismatchException
+ * if the document is not applicable to the given study step
*/
public Publication versionDocument(Step aStep, Publication base)
throws MissedPropertyException, InvalidPropertyException,
@@ -263,15 +285,25 @@ public class StepServiceImpl implements StepService {
}
/**
+ * Create a new version of a document in the given study step.
+ *
* @param aStep
+ * the study step
* @param base
+ * the base document published version
* @param reason
- * @return
+ * the comment for the new version
+ * @return the new version publication
* @throws MissedPropertyException
+ * if a mandatory property is missed
* @throws InvalidPropertyException
+ * if some property doesn't exist
* @throws MultiplyDefinedException
+ * if some property is defined several times
* @throws IOException
+ * if a file system error occurs
* @throws MismatchException
+ * if the document is not applicable to the given study step
*/
public Publication versionDocument(Step aStep, Publication base,
String reason) throws MissedPropertyException,
@@ -282,10 +314,25 @@ public class StepServiceImpl implements StepService {
}
/**
- * {@inheritDoc}
+ * Create a new version of a document in the given study step.
*
- * @see org.splat.service.StepService#versionDocument(org.splat.som.Step, org.splat.dal.bo.som.Publication,
- * org.splat.dal.bo.som.Document.Properties)
+ * @param aStep
+ * the study step
+ * @param base
+ * the base document published version
+ * @param dprop
+ * properties of the new version
+ * @return the new version publication
+ * @throws MissedPropertyException
+ * if a mandatory property is missed
+ * @throws InvalidPropertyException
+ * if some property doesn't exist
+ * @throws MultiplyDefinedException
+ * if some property is defined several times
+ * @throws IOException
+ * if a file system error occurs
+ * @throws MismatchException
+ * if the document is not applicable to the given study step
*/
@Transactional
public Publication versionDocument(Step aStep, Publication base,
@@ -306,7 +353,8 @@ public class StepServiceImpl implements StepService {
Document newdoc = new Document(dprop.setOwner(aStep.getOwner())
.setStep(aStep.getStep()));
getDocumentService().generateDocumentId(newdoc, dprop);
- newdoc.buildReferenceFrom(aStep.getOwner(), previous);
+ getDocumentService().buildReferenceFrom(newdoc, aStep.getOwner(),
+ previous);
getDocumentDAO().create(newdoc);
// Versioning
@@ -329,6 +377,91 @@ public class StepServiceImpl implements StepService {
return new Publication(newdoc, aStep.getOwner());
}
+ /**
+ * Get document types which are applicable for the given study step (activity).
+ *
+ * @param aStep
+ * the study step
+ * @return the list of document types
+ */
+ public List getValidDocumentTypes(Step aStep) {
+ return getDocumentTypeService().selectTypesOf(aStep.getStep());
+ }
+
+ /**
+ * Add a document publication to the given step.
+ *
+ * @param aStep
+ * the target study step
+ * @param newdoc
+ * the document publication to add
+ * @return true if publication succeeded
+ */
+ public boolean add(Step aStep, Publication newdoc) {
+ if (!aStep.getOwner().add(newdoc))
+ return false; // Updates the study in memory
+ aStep.getDocuments().add(0, newdoc); // Updates this step
+ getDocumentService().hold(newdoc.value()); // Increments the configuration tag count of document
+ // If not yet saved, the Publication MUST NOT be saved here, although this creates a temporary inconsistent state into the
+ // database (it will be saved later by cascading the update of owner scenario).
+ return true;
+ }
+
+ /**
+ * Remove a document publication from the given step.
+ *
+ * @param aStep
+ * the study step
+ * @param oldoc
+ * the document publication to remove
+ * @return true if removing of the publication succeeded
+ */
+ public boolean remove(Step aStep, Publication oldoc) {
+ if (!aStep.getOwner().remove(oldoc))
+ return false; // Updates the study in memory
+ aStep.getDocuments().remove(oldoc); // Updates this step
+ getDocumentService().release(oldoc.value()); // Decrements the configuration tag count of document
+ // The publication becoming orphan, it should automatically be removed from the database when updating of owner scenario.
+ return true;
+ }
+
+ /**
+ * Remove a document from the given step.
+ *
+ * @param aStep
+ * the study step
+ * @param doctag
+ * the document publication
+ * @return true if removing of the document succeeded
+ */
+ public boolean removeDocument(Step aStep, Publication doctag) {
+ Document value = doctag.value();
+ Publication torem = aStep.getDocument(value.getIndex());
+
+ if (torem == null)
+ return false;
+
+ remove(aStep, torem);
+ getProjectElementDAO().update(aStep.getOwner());
+ if (!value.isPublished() && !value.isVersioned()) { // The referenced document is no more used
+ Set links = value.getAllRelations(); // Get all relation of the document to remove them
+ List using = new Vector();
+ for (Iterator i = links.iterator(); i.hasNext();) {
+ Relation link = i.next();
+ if (link.getClass().equals(ConvertsRelation.class)) { // File conversion
+ getFileDAO().delete((File) link.getTo()); // The corresponding physical file is not removed from the vault
+ } else if (link.getClass().equals(UsesRelation.class)) { // Document dependency
+ using.add((Document) link.getTo());
+ }
+ }
+ for (Iterator i = using.iterator(); i.hasNext();) {
+ i.next().removeRelation(UsedByRelation.class, value); // TODO: RKV: don't use Database.getSession in removeRelation
+ }
+ getDocumentDAO().delete(value); // The corresponding physical file is not removed from the vault
+ }
+ return true;
+ }
+
/**
* Get the documentService.
*
@@ -444,4 +577,42 @@ public class StepServiceImpl implements StepService {
public void setIndexService(IndexService indexService) {
_indexService = indexService;
}
+
+ /**
+ * Get the fileDAO.
+ *
+ * @return the fileDAO
+ */
+ public FileDAO getFileDAO() {
+ return _fileDAO;
+ }
+
+ /**
+ * Set the fileDAO.
+ *
+ * @param fileDAO
+ * the fileDAO to set
+ */
+ public void setFileDAO(FileDAO fileDAO) {
+ _fileDAO = fileDAO;
+ }
+
+ /**
+ * Get the documentTypeService.
+ *
+ * @return the documentTypeService
+ */
+ public DocumentTypeService getDocumentTypeService() {
+ return _documentTypeService;
+ }
+
+ /**
+ * Set the documentTypeService.
+ *
+ * @param documentTypeService
+ * the documentTypeService to set
+ */
+ public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ _documentTypeService = documentTypeService;
+ }
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyService.java b/Workspace/Siman-Common/src/org/splat/service/StudyService.java
index cfcdde0..5059552 100644
--- a/Workspace/Siman-Common/src/org/splat/service/StudyService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/StudyService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File Id:
* Creation date 02.10.2012
@@ -9,6 +9,8 @@
package org.splat.service;
+import java.util.List;
+
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.Publication;
@@ -31,7 +33,9 @@ public interface StudyService {
/**
* Increment total number of study documents including versions (docount) and update it in the study.
- * @param aStudy the study
+ *
+ * @param aStudy
+ * the study
* @return incremented docount value
*/
public int generateLocalIndex(Study aStudy);
@@ -94,28 +98,12 @@ public interface StudyService {
SimulationContext context);
/**
- * Add a new scenario to the study.
+ * Remove a simulation context from a study.
*
* @param aStudy
* the study
- * @param sprop
- * scenario properties
- * @return the added scenario
- * @throws MissedPropertyException
- * if a mandatory property is missed
- * @throws InvalidPropertyException
- * if some property doesn't exist
- * @throws MultiplyDefinedException
- * if some property occurs several times
- */
- public Scenario addScenario(Study aStudy, Scenario.Properties sprop)
- throws MissedPropertyException, InvalidPropertyException,
- MultiplyDefinedException;
-
- /**
- * Remove a simulation context from a study.
- * @param aStudy the study
- * @param context the simulation context to remove
+ * @param context
+ * the simulation context to remove
* @return true if removing succeeded
*/
public boolean removeProjectContext(Study aStudy, SimulationContext context);
@@ -211,4 +199,56 @@ public interface StudyService {
*/
public boolean update(Study aStudy, Properties sprop)
throws InvalidPropertyException;
+
+ /**
+ * Initialize shortcuts of the study as its transient collections.
+ *
+ * @param aStudy
+ * the study
+ */
+ public void loadWorkflow(Study aStudy);
+
+ /**
+ * Returns the validation cycle of the given document type.
+ *
+ * @param aStudy
+ * the study
+ * @param type
+ * the document type being subject of validation
+ * @return the validation cycle of the document, or null if not defined.
+ */
+ public ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
+
+ /**
+ * Checks if the given user participates to this study. The Study staff includes the author and contributors.
+ *
+ * @param aStudy
+ * the study
+ * @param user
+ * the user to look for
+ * @return true if the given user is actor of this study.
+ * @see #getContributors()
+ */
+ public boolean isStaffedBy(Study aStudy, User user);
+
+ /**
+ * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
+ *
+ * @param aStudy
+ * the study
+ * @param user
+ * the user to look for
+ * @return true if the given user is actor of this study.
+ * @see #getActors()
+ */
+ public boolean hasActor(Study aStudy, User user);
+
+ /**
+ * Returns unmodifiable initialized transient list of contributors of this study.
+ *
+ * @param aStudy
+ * the study
+ * @return the unmodifiable not null transient list of contributors of this study
+ */
+ public List getContributors(Study aStudy);
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java
index d120b69..5a0cbce 100644
--- a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File Id:
* Creation date 02.10.2012
@@ -10,12 +10,13 @@
package org.splat.service;
import java.io.IOException;
-import java.text.SimpleDateFormat;
import java.util.Calendar;
+import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.hibernate.criterion.Restrictions;
import org.splat.dal.bo.kernel.Relation;
@@ -27,7 +28,6 @@ import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.IDBuilder;
import org.splat.dal.bo.som.KnowledgeElement;
-import org.splat.dal.bo.som.KnowledgeElementType;
import org.splat.dal.bo.som.ProgressState;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.Scenario;
@@ -35,8 +35,10 @@ import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.Study;
import org.splat.dal.bo.som.ValidationCycle;
import org.splat.dal.bo.som.ValidationCycleRelation;
+import org.splat.dal.bo.som.ValidationStep;
import org.splat.dal.bo.som.Visibility;
import org.splat.dal.bo.som.Study.Properties;
+import org.splat.dal.bo.som.ValidationCycle.Actor;
import org.splat.dal.dao.som.IDBuilderDAO;
import org.splat.dal.dao.som.ScenarioDAO;
import org.splat.dal.dao.som.StudyDAO;
@@ -48,6 +50,7 @@ import org.splat.kernel.UserDirectory;
import org.splat.log.AppLogger;
import org.splat.service.technical.IndexService;
import org.splat.service.technical.ProjectSettingsService;
+import org.splat.service.technical.ProjectSettingsServiceImpl;
import org.splat.som.Revision;
import org.springframework.transaction.annotation.Transactional;
@@ -75,11 +78,6 @@ public class StudyServiceImpl implements StudyService {
*/
private StepService _stepService;
- /**
- * Injected scenario service.
- */
- private ScenarioService _scenarioService;
-
/**
* Injected project service.
*/
@@ -110,6 +108,11 @@ public class StudyServiceImpl implements StudyService {
*/
private IDBuilderDAO _iDBuilderDAO;
+ /**
+ * Injected document type service.
+ */
+ private DocumentTypeService _documentTypeService;
+
/**
* {@inheritDoc}
*
@@ -118,7 +121,7 @@ public class StudyServiceImpl implements StudyService {
@Transactional
public Study selectStudy(long index) {
Study result = getStudyDAO().get(index);
- result.loadWorkflow();
+ loadWorkflow(result);
return result;
}
@@ -133,7 +136,7 @@ public class StudyServiceImpl implements StudyService {
public Study selectStudy(String refid) {
Study result = getStudyDAO().findByCriteria(
Restrictions.eq("sid", refid));
- result.loadWorkflow();
+ loadWorkflow(result);
return result;
}
@@ -195,13 +198,13 @@ public class StudyServiceImpl implements StudyService {
* @see org.splat.service.StudyService#addContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User)
*/
public boolean addContributor(Study aStudy, User user) {
- List contributor = aStudy.getModifiableContributors(); // Initializes contributor
+ List contributor = getModifiableContributors(aStudy); // Initializes contributor
for (Iterator i = contributor.iterator(); i.hasNext();) {
User present = i.next();
if (present.equals(user))
return false;
}
- boolean absent = aStudy.getModifiableActors().add(user); // User may already be a reviewer or an approver
+ boolean absent = getModifiableActors(aStudy).add(user); // User may already be a reviewer or an approver
aStudy.addRelation(new ContributorRelation(aStudy, user));
if (absent)
@@ -276,7 +279,7 @@ public class StudyServiceImpl implements StudyService {
* @see org.splat.service.StudyService#removeContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User[])
*/
public boolean removeContributor(Study aStudy, User... users) {
- List contributor = aStudy.getModifiableContributors(); // Initializes contributor
+ List contributor = getModifiableContributors(aStudy); // Initializes contributor
Boolean done = false;
for (int i = 0; i < users.length; i++) {
User user = users[i];
@@ -317,26 +320,25 @@ public class StudyServiceImpl implements StudyService {
@Transactional
public void setValidationCycle(Study aStudy, DocumentType type,
ValidationCycle.Properties vprop) {
- HashMap validactor = aStudy
- .getValidationCycles();
+ Map validactor = aStudy.getValidationCycles();
if (validactor == null)
- aStudy.setShortCuts(); // Initializes validactor and actor
+ setShortCuts(aStudy); // Initializes validactor and actor
String cname = type.getName();
ValidationCycle cycle = validactor.get(cname);
if (cycle != null && cycle.isAssigned()) {
- cycle.resetActors(vprop);
+ resetActors(cycle, vprop);
} else
try {
cycle = new ValidationCycle(aStudy, vprop.setDocumentType(type));
- getValidationCycleDAO().create(cycle); //RKV
-
+ getValidationCycleDAO().create(cycle); // RKV
+
ValidationCycleRelation link = cycle.getContext();
-//RKV: aStudy.addRelation(link);
- aStudy.getAllRelations().add(link); //RKV
-
+ // RKV: aStudy.addRelation(link);
+ aStudy.getAllRelations().add(link); // RKV
+
validactor.put(cname, link.getTo()); // Replaces the cycle if exists as default,
} catch (Exception error) {
logger.error("Unable to re-index Knowledge Elements, reason:",
@@ -377,46 +379,6 @@ public class StudyServiceImpl implements StudyService {
return aStudy.getLastLocalIndex();
}
- /**
- * {@inheritDoc}
- *
- * @see org.splat.service.StudyService#addScenario(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.Scenario.Properties)
- */
- @Transactional
- public Scenario addScenario(Study aStudy, Scenario.Properties sprop)
- throws MissedPropertyException, InvalidPropertyException,
- MultiplyDefinedException {
- if (sprop.getManager() == null)
- sprop.setManager(aStudy.getAuthor());
-
- Scenario scenario = new Scenario(sprop.setOwnerStudy(aStudy));
- if (sprop.getBaseStep() != null)
- getScenarioService()
- .copyContentsUpTo(scenario, sprop.getBaseStep());
- Scenario previous = sprop.getInsertAfter();
-
- if (previous == null) {
- aStudy.getScenariiList().add(scenario);
- } else {
- aStudy.getScenariiList().add(
- aStudy.getScenariiList().indexOf(previous) + 1, scenario);
- }
- getStudyDAO().update(aStudy); // No need to update the Lucene index
- getScenarioDAO().create(scenario); // Must be done after updating this study because of the back reference to the study
- if (sprop.getBaseStep() != null) {
- // No need to update the Knowledge Element index as Knowledge Elements are not copied
- scenario.refresh(); // Because saving the scenario changes the hashcode of copied Publications
- }
- KnowledgeElementType ucase = KnowledgeElement.selectType("usecase");
- KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
- User admin = UserDirectory.selectUser(1); // First user created when creating the database
- kprop.setType(ucase).setTitle(aStudy.getTitle()).setValue(
- scenario.getTitle()).setAuthor(admin); // Internal Knowledge Element required by the validation process of
- // knowledges
- getScenarioService().addKnowledgeElement(scenario, kprop);
- return scenario;
- }
-
/**
* Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
* final result document of the study.
@@ -474,6 +436,7 @@ public class StudyServiceImpl implements StudyService {
boolean isOk = false;
try {
getStudyDAO().update(aStudy); // Update of relational base
+ setShortCuts(aStudy); //RKV: initialize transient actors set
getIndex().update(aStudy); // Update of Lucene index
isOk = true;
} catch (Exception error) {
@@ -523,14 +486,14 @@ public class StudyServiceImpl implements StudyService {
* the study
*/
private void resetActorsShortCut(Study aStudy) {
- aStudy.getModifiableActors().clear();
+ getModifiableActors(aStudy).clear();
// Get all actors involved in validation cycles
for (Iterator i = aStudy.getValidationCycles()
.values().iterator(); i.hasNext();) {
ValidationCycle cycle = i.next();
User[] user = cycle.getAllActors();
for (int j = 0; j < user.length; j++)
- aStudy.getModifiableActors().add(user[j]);
+ getModifiableActors(aStudy).add(user[j]);
}
// Get all other actors
for (Iterator i = aStudy.getAllRelations().iterator(); i
@@ -539,7 +502,7 @@ public class StudyServiceImpl implements StudyService {
Class> kindof = link.getClass().getSuperclass();
if (!kindof.equals(ActorRelation.class))
continue;
- aStudy.getModifiableActors().add(((ActorRelation) link).getTo());
+ getModifiableActors(aStudy).add(((ActorRelation) link).getTo());
}
}
@@ -586,6 +549,316 @@ public class StudyServiceImpl implements StudyService {
return lucin;
}
+ /**
+ * Create a new validation cycle for documents of the given study.
+ *
+ * @param from
+ * the study
+ * @param cycle
+ * the cycle description
+ * @return the new validation cycle
+ */
+ protected ValidationCycle createValidationCycle(Study from,
+ ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle) {
+ // -----------------------------------------------------------------------------
+ Actor[] actype = cycle.getActorTypes();
+ User.Properties uprop = new User.Properties();
+
+ ValidationCycle aValidationCycle = new ValidationCycle();
+ aValidationCycle.setDocumentType(getDocumentTypeService().selectType(
+ cycle.getName())); // Null in case of default validation cycle
+ // context = new ValidationCycleRelation(from, this);
+ // RKV aValidationCycle.context = null; // Validation cycle defined in the workflow
+ for (int i = 0; i < actype.length; i++) {
+ User actor = null;
+ if (actype[i] != null)
+ try {
+ if (actype[i] == Actor.manager) {
+ actor = from.getAuthor();
+ } else if (actype[i] == Actor.Nx1) {
+ List manager = UserDirectory
+ .selectUsersWhere(uprop
+ .setOrganizationName("Nx1"));
+ if (manager.size() == 1)
+ actor = manager.get(0);
+ } else if (actype[i] == Actor.Nx2) {
+ List manager = UserDirectory
+ .selectUsersWhere(uprop
+ .setOrganizationName("Nx2"));
+ if (manager.size() == 1)
+ actor = manager.get(0);
+ } else { /* Actor.customer */
+ actor = from.getAuthor();
+ // TODO: Get the customer of the study, if exists
+ }
+ } catch (Exception e) { // Should not happen
+ actor = null;
+ }
+ if (i == 0)
+ aValidationCycle.setReviewer(actor);
+ else if (i == 1)
+ aValidationCycle.setApprover(actor);
+ else if (i == 2)
+ aValidationCycle.setSignatory(actor);
+ }
+ return aValidationCycle;
+ }
+
+ /**
+ * Remove a validation step from the validation cycle.
+ *
+ * @param aValidationCycle
+ * the validation cycle
+ * @param step
+ * the validation step to remove
+ */
+ @Transactional
+ protected void remove(ValidationCycle aValidationCycle, ValidationStep step) {
+ // ------------------------------------------
+ if (step == ValidationStep.REVIEW)
+ aValidationCycle.setReviewer(null);
+ else if (step == ValidationStep.APPROVAL)
+ aValidationCycle.setApprover(null);
+ else if (step == ValidationStep.ACCEPTANCE
+ || step == ValidationStep.REFUSAL)
+ aValidationCycle.setSignatory(null);
+ if (aValidationCycle.isSaved()) {
+ getValidationCycleDAO().update(aValidationCycle);
+ }
+ }
+
+ /**
+ * Reset actors for the validation cycle.
+ *
+ * @param aValidationCycle
+ * the validation cycle to update
+ * @param vprop
+ * new validation cycle properties containing new actors
+ */
+ @Transactional
+ public void resetActors(ValidationCycle aValidationCycle,
+ ValidationCycle.Properties vprop) {
+ aValidationCycle.setPublisher(vprop.getPublisher()); // May be null
+ aValidationCycle.setReviewer(vprop.getReviewer()); // May be null
+ aValidationCycle.setApprover(vprop.getApprover()); // May be null
+ aValidationCycle.setSignatory(vprop.getSignatory()); // May be null
+ if (aValidationCycle.isSaved()) {
+ getValidationCycleDAO().update(aValidationCycle);
+ }
+ }
+
+ /**
+ * Set actor for the given validation cycle and validation step.
+ *
+ * @param aValidationCycle
+ * the validation cycle
+ * @param step
+ * the validation step
+ * @param actor
+ * the actor to set
+ */
+ @Transactional
+ protected void setActor(ValidationCycle aValidationCycle,
+ ValidationStep step, User actor) {
+ if (step == ValidationStep.PROMOTION) {
+ aValidationCycle.setPublisher(actor);
+ } else if (step == ValidationStep.REVIEW) {
+ aValidationCycle.setReviewer(actor);
+ } else if (step == ValidationStep.APPROVAL) {
+ aValidationCycle.setApprover(actor);
+ } else if (step == ValidationStep.ACCEPTANCE
+ || step == ValidationStep.REFUSAL) {
+ aValidationCycle.setSignatory(actor);
+ }
+ if (aValidationCycle.isSaved()) {
+ getValidationCycleDAO().update(aValidationCycle);
+ }
+ }
+
+ /**
+ * Returns all actors of this study other than the author, including contributors, reviewers and approvers.
+ *
+ * @param aStudy
+ * the study
+ * @return the actors of this study
+ * @see #hasActor(User)
+ */
+ public Set getActors(Study aStudy) {
+ if (aStudy.getActor() == null)
+ setShortCuts(aStudy);
+ return Collections.unmodifiableSet(aStudy.getActor());
+ }
+
+ /**
+ * Returns all actors of this study other than the author, including contributors, reviewers and approvers.
+ *
+ * @param aStudy
+ * the study
+ * @return the modifiable set of actors of this study
+ * @see #hasActor(User)
+ */
+ public Set getModifiableActors(Study aStudy) {
+ if (aStudy.getActor() == null)
+ setShortCuts(aStudy);
+ return aStudy.getActor();
+ }
+
+ /**
+ * Returns unmodifiable initialized transient list of contributors of this study.
+ *
+ * @param aStudy
+ * the study
+ * @return the unmodifiable not null transient list of contributors of this study
+ */
+ public List getContributors(Study aStudy) {
+ if (aStudy.getContributor() == null)
+ setShortCuts(aStudy);
+ return Collections.unmodifiableList(aStudy.getContributor()); // May be empty
+ }
+
+ /**
+ * Returns modifiable initialized transient list of contributors of this study.
+ *
+ * @param aStudy
+ * the study
+ * @return the modifiable not null transient list of contributors of this study
+ */
+ public List getModifiableContributors(Study aStudy) {
+ if (aStudy.getContributor() == null)
+ setShortCuts(aStudy);
+ return aStudy.getContributor(); // May be empty
+ }
+
+ /**
+ * Returns the validation cycle of the given document type.
+ *
+ * @param aStudy
+ * the study
+ * @param type
+ * the document type being subject of validation
+ * @return the validation cycle of the document, or null if not defined.
+ */
+ public ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type) {
+ if (aStudy.getValidationCycles() == null)
+ setShortCuts(aStudy);
+ ValidationCycle result = aStudy.getValidationCycles().get(
+ type.getName());
+ if (result == null) {
+ if (type.isStepResult())
+ result = aStudy.getValidationCycles().get("default"); // "default" validation cycle defined in the configuration, if exist
+ if (result == null)
+ result = aStudy.getValidationCycles().get("built-in");
+ }
+ return result;
+ }
+
+ /**
+ * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
+ *
+ * @param aStudy
+ * the study
+ * @param user
+ * the user to look for
+ * @return true if the given user is actor of this study.
+ * @see #getActors()
+ */
+ public boolean hasActor(Study aStudy, User user) {
+ if (user == null)
+ return false;
+ for (Iterator i = getActors(aStudy).iterator(); i.hasNext();) {
+ User involved = i.next();
+ if (involved.equals(user))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Checks if the given user participates to this study. The Study staff includes the author and contributors.
+ *
+ * @param aStudy
+ * the study
+ * @param user
+ * the user to look for
+ * @return true if the given user is actor of this study.
+ * @see #getContributors()
+ */
+ public boolean isStaffedBy(Study aStudy, User user) {
+ if (user == null)
+ return false;
+ if (aStudy.getAuthor().equals(user))
+ return true;
+ for (Iterator i = getContributors(aStudy).iterator(); i.hasNext();) {
+ if (i.next().equals(user))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Initialize shortcuts of the study as its transient collections.
+ *
+ * @param aStudy
+ * the study
+ */
+ public void loadWorkflow(Study aStudy) {
+ setShortCuts(aStudy);
+ }
+
+ /**
+ * Initialize shortcuts of the study as its transient collections.
+ *
+ * @param aStudy
+ * the study
+ */
+ public void setShortCuts(Study aStudy) {
+ aStudy.getContributor().clear();
+ aStudy.getValidationCycles().clear();
+ aStudy.getActor().clear();
+
+ // Get the contributors
+ for (Iterator i = aStudy.getRelations(
+ ContributorRelation.class).iterator(); i.hasNext();) {
+ ContributorRelation link = (ContributorRelation) i.next();
+ aStudy.getContributor().add(link.getTo());
+ }
+ // Get the validation cycles specific to this study
+ for (Iterator i = aStudy.getRelations(
+ ValidationCycleRelation.class).iterator(); i.hasNext();) {
+ ValidationCycleRelation link = (ValidationCycleRelation) i.next();
+ aStudy.getValidationCycles().put(link.getDocumentType().getName(),
+ link.getTo()); // The associated document type is necessarily not null in this
+ // context
+ }
+ // Get the validation cycles coming from the configured workflow and not overridden in this study
+ for (Iterator i = ProjectSettingsServiceImpl
+ .getAllValidationCycles().iterator(); i.hasNext();) {
+ ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle = i
+ .next();
+ String type = cycle.getName();
+ if (!aStudy.getValidationCycles().containsKey(type))
+ aStudy.getValidationCycles().put(type,
+ createValidationCycle(aStudy, cycle));
+ }
+ // Get all corresponding actors
+ for (Iterator i = aStudy.getValidationCycles()
+ .values().iterator(); i.hasNext();) {
+ ValidationCycle cycle = i.next();
+ User[] user = cycle.getAllActors();
+ for (int j = 0; j < user.length; j++)
+ aStudy.getActor().add(user[j]);
+ }
+ // Get all other actors
+ for (Iterator i = aStudy.getAllRelations().iterator(); i
+ .hasNext();) {
+ Relation link = i.next();
+ Class> kindof = link.getClass().getSuperclass();
+ if (!kindof.equals(ActorRelation.class))
+ continue;
+ aStudy.getActor().add(((ActorRelation) link).getTo());
+ }
+ }
+
/**
* Get project settings.
*
@@ -701,25 +974,6 @@ public class StudyServiceImpl implements StudyService {
_iDBuilderDAO = builderDAO;
}
- /**
- * Get the scenarioService.
- *
- * @return the scenarioService
- */
- public ScenarioService getScenarioService() {
- return _scenarioService;
- }
-
- /**
- * Set the scenarioService.
- *
- * @param scenarioService
- * the scenarioService to set
- */
- public void setScenarioService(ScenarioService scenarioService) {
- _scenarioService = scenarioService;
- }
-
/**
* Get the scenarioDAO.
*
@@ -741,6 +995,7 @@ public class StudyServiceImpl implements StudyService {
/**
* Get the validationCycleDAO.
+ *
* @return the validationCycleDAO
*/
public ValidationCycleDAO getValidationCycleDAO() {
@@ -749,9 +1004,30 @@ public class StudyServiceImpl implements StudyService {
/**
* Set the validationCycleDAO.
- * @param validationCycleDAO the validationCycleDAO to set
+ *
+ * @param validationCycleDAO
+ * the validationCycleDAO to set
*/
public void setValidationCycleDAO(ValidationCycleDAO validationCycleDAO) {
_validationCycleDAO = validationCycleDAO;
}
+
+ /**
+ * Get the documentTypeService.
+ *
+ * @return the documentTypeService
+ */
+ public DocumentTypeService getDocumentTypeService() {
+ return _documentTypeService;
+ }
+
+ /**
+ * Set the documentTypeService.
+ *
+ * @param documentTypeService
+ * the documentTypeService to set
+ */
+ public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ _documentTypeService = documentTypeService;
+ }
}
diff --git a/Workspace/Siman-Common/src/org/splat/service/UtilService.java b/Workspace/Siman-Common/src/org/splat/service/UtilService.java
index a00f13d..cb19c0b 100644
--- a/Workspace/Siman-Common/src/org/splat/service/UtilService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/UtilService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 08.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/UtilServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/UtilServiceImpl.java
index a4562d6..4bd90ae 100644
--- a/Workspace/Siman-Common/src/org/splat/service/UtilServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/UtilServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 08.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/DatabaseService.java b/Workspace/Siman-Common/src/org/splat/service/technical/DatabaseService.java
index 54d99dc..420bc8a 100644
--- a/Workspace/Siman-Common/src/org/splat/service/technical/DatabaseService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/technical/DatabaseService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 05.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/DatabaseServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/technical/DatabaseServiceImpl.java
index a219f01..122dc1c 100644
--- a/Workspace/Siman-Common/src/org/splat/service/technical/DatabaseServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/technical/DatabaseServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 05.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/IndexService.java b/Workspace/Siman-Common/src/org/splat/service/technical/IndexService.java
index 91c57c4..bdd96ba 100644
--- a/Workspace/Siman-Common/src/org/splat/service/technical/IndexService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/technical/IndexService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 05.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/IndexServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/technical/IndexServiceImpl.java
index be622eb..6f96dc9 100644
--- a/Workspace/Siman-Common/src/org/splat/service/technical/IndexServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/technical/IndexServiceImpl.java
@@ -161,7 +161,8 @@ public class IndexServiceImpl implements IndexService {
}
private void setActorsOf (Study study)
{
- Set actors = study.getActors();
+//RKV: This set is always not null. Let's assume that it must be initialized before reindexing: Set actors = study.getActors();
+ Set actors = study.getActor(); //RKV
for (Iterator i=actors.iterator(); i.hasNext(); ) {
String value = i.next().toString();
entry.add( new Field("actor", value, Field.Store.NO, Field.Index.NOT_ANALYZED) );
diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsService.java b/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsService.java
index 856126f..c9919c6 100644
--- a/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 05.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsServiceImpl.java
index 3d0a6e0..687b8f5 100644
--- a/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsServiceImpl.java
@@ -32,16 +32,23 @@ import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.KnowledgeElementType;
import org.splat.dal.bo.som.ProjectElement;
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.bo.som.Study;
import org.splat.dal.bo.som.ValidationCycle.Actor;
import org.splat.dal.dao.som.Database;
import org.splat.manox.XDOM;
+import org.splat.service.DocumentTypeService;
+import org.splat.service.KnowledgeElementTypeService;
import org.splat.service.SimulationContextService;
public class ProjectSettingsServiceImpl implements ProjectSettingsService {
+ /**
+ * The logger for the service.
+ */
+ protected final static Logger logger = Logger
+ .getLogger(ProjectSettingsServiceImpl.class);
+
// Non persistent configuration information
private Properties reprop; // Repository settings
private String pattern; // Pattern of study references
@@ -64,8 +71,14 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
* Injected simulation context service.
*/
private SimulationContextService _simulationContextService;
- protected final static Logger logger = Logger
- .getLogger(ProjectSettingsServiceImpl.class);
+ /**
+ * Injected knowledge element type service.
+ */
+ private KnowledgeElementTypeService _knowledgeElementTypeService;
+ /**
+ * Injected document type service.
+ */
+ private DocumentTypeService _documentTypeService;
public enum FileNaming {
title, encoded, asis
@@ -456,7 +469,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
tprop.setResult(step);
tprop.disableCheck();
- tdoc = Document.createType(tprop); // Creation of Document Types
+ tdoc = getDocumentTypeService().createType(tprop); // Creation of Document Types
tdoc.approve();
maptype.put(type, tdoc);
}
@@ -468,12 +481,13 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
private void createKnowledgeElementTypes() {
// -------------------------------------------
try {
- KnowledgeElementType ktype = KnowledgeElement.createType("usecase"); // Internal reserved knowledge element type
+ KnowledgeElementType ktype = getKnowledgeElementTypeService()
+ .createType("usecase"); // Internal reserved knowledge element type
ktype.reserve();
for (Iterator i = kname.iterator(); i.hasNext();) {
String type = i.next();
- ktype = KnowledgeElement.createType(type); // Knowledge Elements Types defined in the configuration
+ ktype = getKnowledgeElementTypeService().createType(type); // Knowledge Elements Types defined in the configuration
ktype.approve();
}
} catch (Exception error) {
@@ -554,4 +568,40 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
SimulationContextService simulationContextService) {
_simulationContextService = simulationContextService;
}
+
+ /**
+ * Get the knowledgeElementTypeService.
+ *
+ * @return the knowledgeElementTypeService
+ */
+ public KnowledgeElementTypeService getKnowledgeElementTypeService() {
+ return _knowledgeElementTypeService;
+ }
+
+ /**
+ * Set the knowledgeElementTypeService.
+ *
+ * @param knowledgeElementTypeService
+ * the knowledgeElementTypeService to set
+ */
+ public void setKnowledgeElementTypeService(
+ KnowledgeElementTypeService knowledgeElementTypeService) {
+ _knowledgeElementTypeService = knowledgeElementTypeService;
+ }
+
+ /**
+ * Get the documentTypeService.
+ * @return the documentTypeService
+ */
+ public DocumentTypeService getDocumentTypeService() {
+ return _documentTypeService;
+ }
+
+ /**
+ * Set the documentTypeService.
+ * @param documentTypeService the documentTypeService to set
+ */
+ public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ _documentTypeService = documentTypeService;
+ }
}
\ No newline at end of file
diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryService.java b/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryService.java
index 51e83f5..3965a1a 100644
--- a/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryService.java
+++ b/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryServiceImpl.java
index bc1dd1d..7ad6f13 100644
--- a/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryServiceImpl.java
+++ b/Workspace/Siman-Common/src/org/splat/service/technical/RepositoryServiceImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 06.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/som/DocumentRights.java b/Workspace/Siman-Common/src/org/splat/som/DocumentRights.java
index 6934941..599a32c 100644
--- a/Workspace/Siman-Common/src/org/splat/som/DocumentRights.java
+++ b/Workspace/Siman-Common/src/org/splat/som/DocumentRights.java
@@ -24,6 +24,7 @@ import org.splat.dal.bo.som.UsesRelation;
import org.splat.dal.bo.som.ValidationCycle;
import org.splat.dal.bo.som.ValidationStep;
import org.splat.dal.bo.som.VersionsRelation;
+import org.splat.service.ServiceLocatorImpl;
public class DocumentRights {
@@ -41,7 +42,8 @@ public class DocumentRights {
// --------------------------------------------------
this.user = user;
this.operand = tag;
- this.cycle = operand.getOwnerStudy().getValidationCycleOf(operand.value().getType());
+//RKV this.cycle = operand.getOwnerStudy().getValidationCycleOf(operand.value().getType());
+ this.cycle = ServiceLocatorImpl.getInstance().getStudyService().getValidationCycleOf(operand.getOwnerStudy(), operand.value().getType());
this.isauthor = operand.value().getAuthor().equals(user);
//TODO: all contributors of the given document (when supported) must also behave as author
}
@@ -49,7 +51,7 @@ public class DocumentRights {
// ------------------------------------------
this.user = operand.value().getAuthor();
this.operand = tag;
- this.cycle = operand.getOwnerStudy().getValidationCycleOf(operand.value().getType());
+ this.cycle = ServiceLocatorImpl.getInstance().getStudyService().getValidationCycleOf(operand.getOwnerStudy(), operand.value().getType());
this.isauthor = true; // In order to ignore the author state in the context of any user
//TODO: all contributors of the given document (when supported) must also behave as author
}
diff --git a/Workspace/Siman-Common/src/org/splat/som/Step.java b/Workspace/Siman-Common/src/org/splat/som/Step.java
index 46e4466..385d738 100644
--- a/Workspace/Siman-Common/src/org/splat/som/Step.java
+++ b/Workspace/Siman-Common/src/org/splat/som/Step.java
@@ -1,4 +1,5 @@
package org.splat.som;
+
/**
*
* @author Daniel Brunier-Coulin
@@ -40,231 +41,202 @@ import org.splat.kernel.NotApplicableException;
import org.splat.service.technical.IndexServiceImpl;
import org.splat.service.technical.ProjectSettingsService;
-
public class Step {
-
- private ProjectSettingsService.Step step;
- private ProjectElement owner;
- private List contex;
- private List docums;
- private User actor; // Actor involved in operations on published documents and requiring a time-stamp
-
-// ==============================================================================================================================
-// Constructor
-// ==============================================================================================================================
-
- public Step (ProjectSettingsService.Step step, ProjectElement owner) {
-// ----------------------------------------------------------------
- this.step = step;
- this.owner = owner;
- this.contex = new Vector();
- this.docums = new Vector();
- this.actor = null;
-
-// Filtering of Simulation contexts, if exist
- for (Iterator i=owner.SimulationContextIterator(); i.hasNext();) {
- SimulationContext adoc = i.next();
- if (!adoc.isInto(this)) continue;
- this.contex.add(adoc);
- }
-// Filtering of Documents, if exist
- for (Iterator i=owner.PublicationIterator(); i.hasNext();) {
- Publication mydoc = i.next();
- if (!mydoc.value().isInto(this)) continue;
- this.docums.add(mydoc);
- }
- }
-
-// ==============================================================================================================================
-// Public member functions
-// ==============================================================================================================================
-
- public User getActor () {
-// -----------------------
- return actor;
- }
- public List getAllDocuments () {
-// -------------------------------------------
- return Collections.unmodifiableList(docums);
- }
-
- public List getAllSimulationContexts () {
-// ----------------------------------------------------------
- return Collections.unmodifiableList(contex);
- }
-
- public Publication getDocument (long l) {
-// ------------------------------------------
- for (Iterator i=docums.iterator(); i.hasNext();) {
- Publication found = i.next(); // In a given study step,
- if (found.value().getIndex() == l) return found; // there is only one publication of a given document
- }
- return null;
- }
-
- public int getNumber () {
-// -----------------------
- return step.getNumber();
- }
+ private ProjectSettingsService.Step step;
+ private ProjectElement owner;
+ private List contex;
+ private List docums;
+ private User actor; // Actor involved in operations on published documents and requiring a time-stamp
+
+ // ==============================================================================================================================
+ // Constructor
+ // ==============================================================================================================================
+
+ public Step(ProjectSettingsService.Step step, ProjectElement owner) {
+ // ----------------------------------------------------------------
+ this.step = step;
+ this.owner = owner;
+ this.contex = new Vector();
+ this.docums = new Vector();
+ this.actor = null;
+
+ // Filtering of Simulation contexts, if exist
+ for (Iterator i = owner.SimulationContextIterator(); i
+ .hasNext();) {
+ SimulationContext adoc = i.next();
+ if (!adoc.isInto(this))
+ continue;
+ this.contex.add(adoc);
+ }
+ // Filtering of Documents, if exist
+ for (Iterator i = owner.PublicationIterator(); i.hasNext();) {
+ Publication mydoc = i.next();
+ if (!mydoc.value().isInto(this))
+ continue;
+ this.docums.add(mydoc);
+ }
+ }
- public ProjectElement getOwner () {
-// ---------------------------------
- return owner; // May be a Study or a Scenario
- }
+ // ==============================================================================================================================
+ // Public member functions
+ // ==============================================================================================================================
- public Study getOwnerStudy () {
-// -----------------------------
- if (owner instanceof Study) return (Study)owner;
- else return ((Scenario)owner).getOwnerStudy();
- }
+ public User getActor() {
+ // -----------------------
+ return actor;
+ }
- public String getPath () {
-// ------------------------
- return step.getPath();
- }
+ public List getAllDocuments() {
+ // -------------------------------------------
+ return Collections.unmodifiableList(docums);
+ }
- public List getResultDocuments () {
-// ----------------------------------------------
- List result = new Vector();
-
- if (!docums.isEmpty()) for (Iterator i=docums.iterator(); i.hasNext(); ) {
- Publication content = i.next();
- DocumentType type = content.value().getType();
- if (!type.isResultOf(this.getStep())) continue;
- result.add(content);
- }
- return result;
- }
+ /**
+ * Get the persistent collection of step documents.
+ * @return the list of documents
+ */
+ public List getDocuments() {
+ return docums;
+ }
- public ProjectSettingsService.Step getStep () {
-// --------------------------------------
- return step;
- }
+ public List getAllSimulationContexts() {
+ // ----------------------------------------------------------
+ return Collections.unmodifiableList(contex);
+ }
- public SimulationContext getSimulationContext (long l) {
-// ---------------------------------------------------------
- for (Iterator i=owner.SimulationContextIterator(); i.hasNext();) {
- SimulationContext myctex = i.next();
- if (myctex.getIndex() == l) return myctex;
- }
- return null;
- }
+ public Publication getDocument(long l) {
+ // ------------------------------------------
+ for (Iterator i = docums.iterator(); i.hasNext();) {
+ Publication found = i.next(); // In a given study step,
+ if (found.value().getIndex() == l)
+ return found; // there is only one publication of a given document
+ }
+ return null;
+ }
- public List getSimulationContext (SimulationContextType type) {
-// --------------------------------------------------------------------------------
- Vector result = new Vector();
+ public int getNumber() {
+ // -----------------------
+ return step.getNumber();
+ }
- for (Iterator i=owner.SimulationContextIterator(); i.hasNext();) {
- SimulationContext myctex = i.next();
- if (myctex.getType().equals(type)) result.add(myctex);
- }
- return result;
- }
+ public ProjectElement getOwner() {
+ // ---------------------------------
+ return owner; // May be a Study or a Scenario
+ }
- public List getValidDocumentTypes () {
-// --------------------------------------------------
- return Document.selectTypesOf(step);
- }
+ public Study getOwnerStudy() {
+ // -----------------------------
+ if (owner instanceof Study)
+ return (Study) owner;
+ else
+ return ((Scenario) owner).getOwnerStudy();
+ }
- public boolean isStarted () {
-// ---------------------------
- if (!step.mayContain(KnowledgeElement.class)) return !docums.isEmpty();
+ public String getPath() {
+ // ------------------------
+ return step.getPath();
+ }
- List kelm = ((Scenario)owner).getAllKnowledgeElements();
- if (kelm.isEmpty() && docums.isEmpty()) return false;
- return true;
- }
+ public List getResultDocuments() {
+ // ----------------------------------------------
+ List result = new Vector();
+
+ if (!docums.isEmpty())
+ for (Iterator i = docums.iterator(); i.hasNext();) {
+ Publication content = i.next();
+ DocumentType type = content.value().getType();
+ if (!type.isResultOf(this.getStep()))
+ continue;
+ result.add(content);
+ }
+ return result;
+ }
- public boolean isFinished () {
-// ----------------------------
- if (!step.mayContain(KnowledgeElement.class)) { // Check if all result documents are approved
- if (docums.isEmpty()) return false;
- boolean result = false;
- for (Iterator i=docums.iterator(); i.hasNext(); ) {
- Document content = i.next().value();
- DocumentType type = content.getType();
- if (!type.isResultOf(this.getStep())) continue;
- if (content.getProgressState() == ProgressState.EXTERN) continue;
- result = true; // There is at least 1 non external result document
- if (content.getProgressState() != ProgressState.APPROVED) return false;
- }
- return result;
- }
- else { // Check if all existing knowledges are approved
- List kelm = ((Scenario)owner).getAllKnowledgeElements();
- if (kelm.isEmpty()) return false;
- for (Iterator i=kelm.iterator(); i.hasNext(); ) {
- KnowledgeElement content = i.next();
- if (content.getProgressState() != ProgressState.APPROVED) return false;
- }
- return true;
- }
- }
+ public ProjectSettingsService.Step getStep() {
+ // --------------------------------------
+ return step;
+ }
- public boolean mayContain (@SuppressWarnings("rawtypes") Class type) {
-// --------------------------------------------------------------------
- return step.mayContain(type);
- }
+ public SimulationContext getSimulationContext(long l) {
+ // ---------------------------------------------------------
+ for (Iterator i = owner.SimulationContextIterator(); i
+ .hasNext();) {
+ SimulationContext myctex = i.next();
+ if (myctex.getIndex() == l)
+ return myctex;
+ }
+ return null;
+ }
- public boolean removeDocument (Publication doctag) {
-// --------------------------------------------------
- Document value = doctag.value();
- Publication torem = getDocument(value.getIndex());
- Session session = Database.getSession();
+ public List getSimulationContext(
+ SimulationContextType type) {
+ // --------------------------------------------------------------------------------
+ Vector result = new Vector();
+
+ for (Iterator i = owner.SimulationContextIterator(); i
+ .hasNext();) {
+ SimulationContext myctex = i.next();
+ if (myctex.getType().equals(type))
+ result.add(myctex);
+ }
+ return result;
+ }
- if (torem == null) return false;
+ public boolean isStarted() {
+ // ---------------------------
+ if (!step.mayContain(KnowledgeElement.class))
+ return !docums.isEmpty();
- this.remove(torem);
- session.update(owner);
- if (!value.isPublished() && !value.isVersioned()) { // The referenced document is no more used
- Set links = value.getAllRelations();
- List using = new Vector();
- for (Iterator i=links.iterator(); i.hasNext(); ) {
- Relation link = i.next();
- if (link.getClass().equals(ConvertsRelation.class)) { // File conversion
- session.delete(link.getTo()); // The corresponding physical file is not removed from the vault
- } else
- if (link.getClass().equals(UsesRelation.class)) { // Document dependency
- using.add((Document)link.getTo());
- }
- }
- for (Iterator i=using.iterator(); i.hasNext(); ) {
- i.next().removeRelation(UsedByRelation.class, value);
- }
- session.delete(value); // The corresponding physical file is not removed from the vault
- }
- return true;
- }
+ List kelm = ((Scenario) owner)
+ .getAllKnowledgeElements();
+ if (kelm.isEmpty() && docums.isEmpty())
+ return false;
+ return true;
+ }
- public void setActor (User user) {
-// --------------------------------
- actor = user;
- }
-// ==============================================================================================================================
-// Protected member functions
-// ==============================================================================================================================
+ public boolean isFinished() {
+ // ----------------------------
+ if (!step.mayContain(KnowledgeElement.class)) { // Check if all result documents are approved
+ if (docums.isEmpty())
+ return false;
+ boolean result = false;
+ for (Iterator i = docums.iterator(); i.hasNext();) {
+ Document content = i.next().value();
+ DocumentType type = content.getType();
+ if (!type.isResultOf(this.getStep()))
+ continue;
+ if (content.getProgressState() == ProgressState.EXTERN)
+ continue;
+ result = true; // There is at least 1 non external result document
+ if (content.getProgressState() != ProgressState.APPROVED)
+ return false;
+ }
+ return result;
+ } else { // Check if all existing knowledges are approved
+ List kelm = ((Scenario) owner)
+ .getAllKnowledgeElements();
+ if (kelm.isEmpty())
+ return false;
+ for (Iterator i = kelm.iterator(); i.hasNext();) {
+ KnowledgeElement content = i.next();
+ if (content.getProgressState() != ProgressState.APPROVED)
+ return false;
+ }
+ return true;
+ }
+ }
- public boolean add (Publication newdoc) {
-// ------------------------------------------
- if (!owner.add(newdoc)) return false; // Updates the study in memory
- docums.add(0, newdoc); // Updates this step
- newdoc.value().hold(); // Increments the configuration tag count of document
-// If not yet saved, the Publication MUST NOT be saved here, although this creates a temporary inconsistent state into the
-// database (it will be saved later by cascading the update of owner scenario).
- return true;
- }
+ public boolean mayContain(@SuppressWarnings("rawtypes")
+ Class type) {
+ return step.mayContain(type);
+ }
- public boolean remove (Publication oldoc) {
-// --------------------------------------------
- if (!owner.remove(oldoc)) return false; // Updates the study in memory
- docums.remove(oldoc); // Updates this step
- oldoc.value().release(); // Decrements the configuration tag count of document
-// The publication becoming orphan, it should automatically be removed from the database when updating of owner scenario.
- return true;
- }
+ public void setActor(User user) {
+ actor = user;
+ }
- public List getContex() {
+ public List getContex() {
return contex;
}
diff --git a/Workspace/Siman-Common/src/org/splat/som/StepRights.java b/Workspace/Siman-Common/src/org/splat/som/StepRights.java
index 6a07bc8..22f462b 100644
--- a/Workspace/Siman-Common/src/org/splat/som/StepRights.java
+++ b/Workspace/Siman-Common/src/org/splat/som/StepRights.java
@@ -11,18 +11,14 @@ import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.ProjectElement;
import org.splat.dal.bo.som.Scenario;
import org.splat.dal.bo.som.Study;
+import org.splat.service.ServiceLocatorImpl;
public class StepRights {
private User user;
private Step operand;
-
-// ==============================================================================================================================
-// Construction
-// ==============================================================================================================================
-
- public StepRights (User user, Step step) {
+ public StepRights (User user, Step step) {
// ----------------------------------------
this.user = user;
this.operand = step;
@@ -46,7 +42,7 @@ public class StepRights {
public boolean canAddComment () {
// -------------------------------
Study owner = operand.getOwnerStudy();
- return (owner.getAuthor().equals(user) || owner.hasActor(user));
+ return (owner.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(owner, user));
}
/**
@@ -58,7 +54,7 @@ public class StepRights {
public boolean canCreateDocument () {
// -----------------------------------
if (!isEnabled()) return false;
- return operand.getOwnerStudy().isStaffedBy(user);
+ return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand.getOwnerStudy(), user);
}
/**
@@ -69,7 +65,7 @@ public class StepRights {
*/
public boolean canCreateKnowledge () {
// ------------------------------------
- return operand.getOwnerStudy().isStaffedBy(user);
+ return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand.getOwnerStudy(), user);
}
/**
@@ -81,7 +77,7 @@ public class StepRights {
public boolean canEditSimulationContext () {
// ------------------------------------------
Study owner = operand.getOwnerStudy();
- return (owner.getAuthor().equals(user) || owner.hasActor(user));
+ return (owner.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(owner, user));
}
/**
diff --git a/Workspace/Siman-Common/src/org/splat/som/StudyRights.java b/Workspace/Siman-Common/src/org/splat/som/StudyRights.java
index 2d98eca..f83bf9b 100644
--- a/Workspace/Siman-Common/src/org/splat/som/StudyRights.java
+++ b/Workspace/Siman-Common/src/org/splat/som/StudyRights.java
@@ -11,6 +11,7 @@ package org.splat.som;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.ProgressState;
import org.splat.dal.bo.som.Study;
+import org.splat.service.ServiceLocatorImpl;
public class StudyRights {
@@ -18,12 +19,7 @@ public class StudyRights {
private User user;
private Study operand;
private boolean author = false; // For optimizing
-
-// ==============================================================================================================================
-// Construction
-// ==============================================================================================================================
-
- public StudyRights (User user, Study study) {
+ public StudyRights (User user, Study study) {
// -------------------------------------------
this.user = user;
this.operand = study;
@@ -43,7 +39,7 @@ public class StudyRights {
public boolean canAddScenario () {
// --------------------------------
if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
- return operand.isStaffedBy(user);
+ return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
}
/**
@@ -54,7 +50,7 @@ public class StudyRights {
*/
public boolean canEditDescription () {
// ------------------------------------
- return (operand.getAuthor().equals(user) || operand.hasActor(user));
+ return (operand.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(operand, user));
}
public boolean canEditProperties () {
@@ -89,7 +85,7 @@ public class StudyRights {
public boolean canVersion () {
// ----------------------------
if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
- return operand.isStaffedBy(user);
+ return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
}
// ==============================================================================================================================
diff --git a/Workspace/Siman-Common/src/org/splat/util/BeanHelper.java b/Workspace/Siman-Common/src/org/splat/util/BeanHelper.java
index bc565a0..167d417 100644
--- a/Workspace/Siman-Common/src/org/splat/util/BeanHelper.java
+++ b/Workspace/Siman-Common/src/org/splat/util/BeanHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 05.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/util/TimestampTransformer.java b/Workspace/Siman-Common/src/org/splat/util/TimestampTransformer.java
index 00cdf22..0104fec 100644
--- a/Workspace/Siman-Common/src/org/splat/util/TimestampTransformer.java
+++ b/Workspace/Siman-Common/src/org/splat/util/TimestampTransformer.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 05.10.2012
diff --git a/Workspace/Siman-Common/src/org/splat/util/TimestampTransformerFactory.java b/Workspace/Siman-Common/src/org/splat/util/TimestampTransformerFactory.java
index ef9f2c8..0c19c45 100644
--- a/Workspace/Siman-Common/src/org/splat/util/TimestampTransformerFactory.java
+++ b/Workspace/Siman-Common/src/org/splat/util/TimestampTransformerFactory.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Company EURIWARE
+ * Company OPEN CASCADE
* Application SIMAN
* File $Id$
* Creation date 05.10.2012
diff --git a/Workspace/Siman-Common/src/spring/businessServiceContext.xml b/Workspace/Siman-Common/src/spring/businessServiceContext.xml
index 4592bf7..5368025 100644
--- a/Workspace/Siman-Common/src/spring/businessServiceContext.xml
+++ b/Workspace/Siman-Common/src/spring/businessServiceContext.xml
@@ -11,6 +11,12 @@ http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
+
+
+
+
@@ -18,30 +24,41 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
-
+
-
-
+
+
+
+
+
+
+
+
+
-
+
+
+
ref="projectElementService" />
+
-
+
+
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Workspace/Siman-Common/src/spring/technicalServiceContext.xml b/Workspace/Siman-Common/src/spring/technicalServiceContext.xml
index 2e17609..2c368a5 100644
--- a/Workspace/Siman-Common/src/spring/technicalServiceContext.xml
+++ b/Workspace/Siman-Common/src/spring/technicalServiceContext.xml
@@ -16,8 +16,12 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
-
-
+
+
+
+
menus = null; // Application menus
- private Map bars = null; // Study module-bars structured by steps
- private Map popups = null;
- private Map> filter = null; // Named search filters
- private Map defdoctype = null; // Default document types structured by step.formats
- private Map tempfile = null; // Available template files
- private String[] viewermap = null; // List of file extensions mapped to a viewer
- private Map convertmap = null; // Available document format converters
- private Properties jndprops = null; // JNDI context for launching converters
-
- private static ApplicationSettings my = null; // Singleton instance
/**
* Application settings logger.
*/
- protected final static Logger logger = Logger.getLogger(ApplicationSettings.class);
-
+ protected final static Logger logger = Logger
+ .getLogger(ApplicationSettings.class);
+
+ private String wappserver;
+ private String wappname;
+ private Properties wapprops; // General properties from the application properties files
+ private Locale locale; // Current user locale
+ private Map menus = null; // Application menus
+ private Map bars = null; // Study module-bars structured by steps
+ private Map popups = null;
+ private Map> filter = null; // Named search filters
+ private Map defdoctype = null; // Default document types structured by step.formats
+ private Map tempfile = null; // Available template files
+ private String[] viewermap = null; // List of file extensions mapped to a viewer
+ private Map convertmap = null; // Available document format converters
+ private Properties jndprops = null; // JNDI context for launching converters
+
+ private static ApplicationSettings my = null; // Singleton instance
/**
* Injected project settings service.
*/
- private ProjectSettingsService _projectSettingsService;
+ private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected document type service.
+ */
+ private DocumentTypeService _documentTypeService;
/**
* Get the projectSettingsService.
+ *
* @return the projectSettingsService
*/
public ProjectSettingsService getProjectSettings() {
return _projectSettingsService;
}
+
/**
* Set the projectSettingsService.
- * @param projectSettingsService the projectSettingsService to set
+ *
+ * @param projectSettingsService
+ * the projectSettingsService to set
*/
- public void setProjectSettings(
- ProjectSettingsService projectSettingsService) {
+ public void setProjectSettings(ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
- private static class NewMenu extends SimpleMenu {
-// -----------------------------------------------------------------
- private NewMenu ()
- {
- super("create");
- addItem("new-empty", "menu.new.empty", "image.empty.png", "select?menu=create&item=new-empty");
- addItem("new-copy", new MenuItem("menu.new.copy").icon("image.copy.png") );
- addItem("new-instance", new MenuItem("menu.new.instance").icon("image.hold.gif") );
- addItem("new-import", new MenuItem("menu.new.import").icon("icon.upload.png") );
- this.selects("new-empty");
- }
- }
- private static class SearchMenu extends SimpleMenu {
-// -----------------------------------------------------------------
- private SearchMenu ()
- {
- super("search");
- addItem("search-study", "menu.search.study", "image.study.png", "select?menu=search&item=search-study");
- addItem("search-knowledge", "menu.search.idea", "image.idea.png", "select?menu=search&item=search-knowledge");
- addItem("search-document", new MenuItem("menu.search.document").icon("icon.any.png") );
- this.selects("search-study");
- }
- }
- private static class PropertiesMenu extends SimpleMenu {
-// -----------------------------------------------------------------
- private PropertiesMenu ()
- {
- super("configuration");
- addItem("prop-general", "menu.prop.general", "image.hold.gif", "select?menu=properties&item=prop-general");
- addItem("prop-scenario", "menu.prop.scenario", "image.hold.gif", "select?menu=properties&item=prop-scenario");
- addItem("prop-timestamp", new MenuItem("menu.prop.timestamp").icon("image.stamp.png") );
- addItem("prop-comlog", new MenuItem("menu.prop.comlog").icon("image.hold.gif") );
- addItem("prop-version", new MenuItem("menu.prop.version").icon("image.dirclosed.png") );
- }
- }
- private static class DatadminMenu extends SimpleMenu {
-// -----------------------------------------------------------------
- private DatadminMenu ()
- {
- super("datadmin");
- addItem("admin-scontext", "menu.admin.context", "image.hold.gif", "select?menu=datadmin&item=admin-scontext");
- addItem("admin-knowelm", "menu.admin.knowledge", "image.idea.png", "select?menu=datadmin&item=admin-knowelm");
- addItem("admin-study", new MenuItem("menu.admin.study").icon("image.study.png") );
- }
- }
- private static class SysadminMenu extends SimpleMenu {
-// -----------------------------------------------------------------
- private SysadminMenu ()
- {
- super("sysadmin");
- addItem("admin-indexing", "menu.admin.indexing", "image.index.png", "select?menu=sysadmin&item=admin-indexing");
- addItem("admin-importuser", "menu.admin.importuser", "image.group.png", "select?menu=sysadmin&item=admin-importuser");
- }
- }
- private enum Item { publish, accept, approve, promote, demote, undo, rename, attach, edit, script, version, replace, export, remove, purge };
-// Resources relative to studies
- private static class EditableStudyPopup extends PopupMenu {
-// ----------------------------------------------------------------
- private StudyRights user = null;
-
- private EditableStudyPopup ()
- {
- addItem("publish", new PopupItem("menu.publish").icon("image.publish.png").action("edit-study?action=publish").confirmation("message.publish.study"));
- addItem("promote", new PopupItem("menu.archive"));
- addSeparator();
- addItem("edit", new PopupItem("menu.properties").icon("icon.ed.png").action("../select?menu=properties"));
- addSeparator();
- addItem("script", new PopupItem("menu.newscenario").action("add-scenario"));
- addItem("version", new PopupItem("menu.version").icon("image.version.png").action("notyetimplemented"));
- addSeparator();
- addItem("purge", new PopupItem("menu.purge").confirmation("message.purge.study"));
- addItem("export", new PopupItem("menu.export").icon("image.export.png")); // For future needs
- addItem("remove", new PopupItem("menu.remove.version").icon("icon.delete.png").action("notyetimplemented").confirmation("message.delete.study"));
- }
- public boolean isEnabled (String name)
- {
- if (user == null) return false; // Should not happen
- Item item = Item.valueOf(name);
- if (item == Item.publish) return user.canPublish();
- if (item == Item.edit) return user.canEditProperties();
- if (item == Item.script) return user.canAddScenario();
- if (item == Item.version) return user.canVersion();
- if (item == Item.remove) return user.canRemove();
- if (item == Item.purge) return user.canPurge();
- return false;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof StudyRights) {
- user = (StudyRights)context; // Just for optimizing
- boolean history = user.getOperand().isVersioned();
- PopupItem item = this.item("remove");
- if (history) item.rename("menu.remove.version");
- else item.rename("menu.remove.study");
- }
- }
- }
-// Resources relative to documents
- private static class EditableDocumentPopup extends PopupMenu { // Popup of In-Work documents
-// ----------------------------------------------------------------
- private DocumentRights user = null;
-
- private EditableDocumentPopup ()
- {
- addItem("accept", new PopupItem("menu.accept").icon("image.accept.png").action("setDocument?action=accept").confirmation("message.accept.document"));
- addItem("promote", new PopupItem("menu.promote").icon("image.publish.png").action("setDocument?action=promote").confirmation("message.promote.document"));
- addSeparator();
- addItem("rename", new PopupItem("menu.rename").action("edit-document?action=renameDocument"));
- addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
- addSeparator();
- addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
- addItem("replace", new PopupItem("menu.replace").icon("image.replace.png").action("select-file?nextAction=replace"));
- addSeparator();
- addItem("purge", new PopupItem("menu.purge").action("notyetimplemented").confirmation("message.purge.document"));
- addItem("remove", new PopupItem("menu.remove.version").icon("icon.delete.png").action("remove-document").confirmation("message.delete.document"));
- }
- public boolean isEnabled (String name)
- {
- if (user == null) return false; // Should not happen
- Item item = Item.valueOf(name);
- if (item == Item.accept) return user.canAccept();
- if (item == Item.promote) return user.canPromote();
- if (item == Item.rename) return user.canRename();
- if (item == Item.attach) return user.canAttach();
- if (item == Item.version) return user.canVersion();
- if (item == Item.replace) return user.canReplace();
- if (item == Item.purge) return user.canPurge();
- if (item == Item.remove) return user.canRemove();
- return false;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof DocumentRights) {
- user = (DocumentRights)context; // Just for optimizing
- Document downer = user.getOperand();
- PopupItem item = this.item("remove");
- if (downer.isVersioned()) item.rename("menu.remove.version");
- else item.rename("menu.remove.document");
- }
- }
- }
- private static class ReviewableDocumentPopup extends PopupMenu { // Popup of In-Draft documents
-// ----------------------------------------------------------------
- private DocumentRights user = null;
-
- private ReviewableDocumentPopup ()
- {
- addItem("demote", new PopupItem("menu.demote").icon("image.demote.png").action("setDocument?action=demote").confirmation("message.demote.document"));
- addItem("promote", new PopupItem("menu.review").icon("image.review.png").action("setDocument?action=review").confirmation("message.review.document"));
- addSeparator();
- addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
- addSeparator();
- addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
- addSeparator();
- addItem("purge", new PopupItem("menu.purge").action("notyetimplemented").confirmation("message.purge.document"));
- }
- public boolean isEnabled (String name)
- {
- if (user == null) return false; // Should not happen
- Item item = Item.valueOf(name);
- if (item == Item.demote) return user.canDemote();
- if (item == Item.promote) return user.canReview();
- if (item == Item.attach) return user.canAttach();
- if (item == Item.version) return user.canVersion();
- if (item == Item.purge) return user.canPurge();
- return false;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof DocumentRights) {
- user = (DocumentRights)context; // Just for optimizing
- }
- }
- }
- private static class NotResultDocumentPopup extends PopupMenu {
-// ----------------------------------------------------------------
- private DocumentRights user = null;
-
- private NotResultDocumentPopup ()
- {
- addItem("demote", new PopupItem("menu.demote").icon("image.demote.png").action("setDocument?action=demote").confirmation("message.demote.document"));
- addSeparator();
- addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
- addSeparator();
- addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
- addSeparator();
- addItem("purge", new PopupItem("menu.purge").action("notyetimplemented").confirmation("message.purge.document"));
- addItem("remove", new PopupItem("menu.remove.version").icon("icon.delete.png").action("remove-document").confirmation("message.delete.document"));
- }
- }
- private static class ApprovableDocumentPopup extends PopupMenu { // Popup of In-Check documents
-// ----------------------------------------------------------------
- private DocumentRights user = null;
-
- private ApprovableDocumentPopup ()
- {
- addItem("undo", new PopupItem("menu.demote").icon("image.invalidate.png").action("setDocument?action=invalidate").confirmation("message.demote.document"));
- addItem("demote", new PopupItem("menu.disapprove").icon("image.demote.png").action("setDocument?action=disapprove").confirmation("message.disapprove.document"));
- addItem("approve", new PopupItem("menu.approve").icon("icon.APPROVED.png").action("setDocument?action=approve").confirmation("message.approve.document"));
- }
- public boolean isEnabled (String name)
- {
- if (user == null) return false; // Should not happen
- Item item = Item.valueOf(name);
- if (item == Item.undo) return user.canInvalidate();
- if (item == Item.demote) return user.canDemote();
- if (item == Item.approve) return user.canApprove();
- return false;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof DocumentRights) {
- user = (DocumentRights)context; // Just for optimizing
- }
- }
- }
- private static class ApprovedPopup extends PopupMenu { // Popup of Approved documents
-// ----------------------------------------------------------------
- private ApprovedPopup ()
- {
- addItem("attach", new PopupItem("menu.attach").icon("image.attach.png").action("select-file?nextAction=attach"));
- addSeparator();
- addItem("version", new PopupItem("menu.version").icon("image.version.png").action("select-file?nextAction=version"));
- }
- }
- private static class ExternPopup extends PopupMenu { // Popup of Extern documents
-// ----------------------------------------------------------------
- private DocumentRights user = null;
-
- private ExternPopup ()
- {
- addItem("rename", new PopupItem("menu.rename").action("edit-document?action=renameDocument"));
- addItem("replace", new PopupItem("menu.replace").icon("image.replace.png").action("select-file?nextAction=replace"));
- addSeparator();
- addItem("remove", new PopupItem("menu.remove.document").icon("icon.delete.png").action("remove-document").confirmation("message.delete.document"));
- }
- public boolean isEnabled (String name)
- {
- if (user == null) return false; // Should not happen
- Item item = Item.valueOf(name);
- if (item == Item.rename) return user.canRename();
- if (item == Item.replace) return user.canReplace();
- if (item == Item.remove) return user.canRemove();
- return false;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof DocumentRights) {
- user = (DocumentRights)context; // Just for optimizing
- }
- }
- }
-// Resources relative to simulation contexts
- private static class ScontextPopup extends PopupMenu {
-// --------------------------------------------------------
- private SimulationContextFacade owner = null;
-
- private ScontextPopup ()
- {
- addItem("rename", new PopupItem("menu.rename").action("edit-context?action=renameContext"));
- addItem("edit", new PopupItem("menu.edit").action("edit-context?action=editContext"));
- addSeparator();
- addItem("remove", new PopupItem("menu.remove").icon("icon.delete.png").action("remove-context").confirmation("message.delete.context"));
- }
- public boolean isEnabled (String name)
- {
- Item item = Item.valueOf(name);
-
- if (item == Item.rename) {
- return false;
- } else
- if (item == Item.edit) {
-// if (!owner.isEditable())
- return false;
- }
- return true;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof SimulationContextFacade) {
- owner = (SimulationContextFacade)context; // Just for optimizing
- }
- else {
- super.setContext(name, context);
- }
- }
- }
-// Resources relative to knowledge
- private static class FeedbexPopup extends PopupMenu {
-// --------------------------------------------------------
- private KnowledgeElement owner = null;
-
- private FeedbexPopup ()
- {
- addItem("promote", new PopupItem("menu.promote").icon("image.review.png").action("promote-knowledge").confirmation("message.promote.knowledge"));
- addItem("demote", new PopupItem("menu.demote").icon("image.invalidate.png").action("demote-knowledge").confirmation("message.demote.knowledge"));
- addSeparator();
- addItem("rename", new PopupItem("menu.rename").action("edit-knowledge?action=renameKnowledge"));
- addItem("edit", new PopupItem("menu.edit").action("edit-knowledge?action=editKnowledge"));
- addSeparator();
- addItem("remove", new PopupItem("menu.remove").icon("icon.delete.png").action("remove-knowledge").confirmation("message.delete.knowledge"));
- }
- public boolean isEnabled (String name)
- {
- Item item = Item.valueOf(name);
-
- if (item == Item.promote) {
- if (owner.getProgressState() != ProgressState.inDRAFT) return false;
- } else
- if (item == Item.demote) {
- if (owner.getProgressState() != ProgressState.inCHECK) return false;
- }
- return true;
- }
- public void setContext (String name, Object context)
- {
- if (context instanceof KnowledgeElement) owner = (KnowledgeElement)context; // Just for optimizing
- else {
- super.setContext(name, context);
- }
- }
- }
-
-// ==============================================================================================================================
-// Construction
-// ==============================================================================================================================
-
- public static ApplicationSettings getMe () {
-// ------------------------------------------
- return my; // The application is supposed being previously created below
- }
+ private static class NewMenu extends SimpleMenu {
+ // -----------------------------------------------------------------
+ private NewMenu() {
+ super("create");
+ addItem("new-empty", "menu.new.empty", "image.empty.png",
+ "select?menu=create&item=new-empty");
+ addItem("new-copy", new MenuItem("menu.new.copy")
+ .icon("image.copy.png"));
+ addItem("new-instance", new MenuItem("menu.new.instance")
+ .icon("image.hold.gif"));
+ addItem("new-import", new MenuItem("menu.new.import")
+ .icon("icon.upload.png"));
+ this.selects("new-empty");
+ }
+ }
+
+ private static class SearchMenu extends SimpleMenu {
+ // -----------------------------------------------------------------
+ private SearchMenu() {
+ super("search");
+ addItem("search-study", "menu.search.study", "image.study.png",
+ "select?menu=search&item=search-study");
+ addItem("search-knowledge", "menu.search.idea", "image.idea.png",
+ "select?menu=search&item=search-knowledge");
+ addItem("search-document", new MenuItem("menu.search.document")
+ .icon("icon.any.png"));
+ this.selects("search-study");
+ }
+ }
+
+ private static class PropertiesMenu extends SimpleMenu {
+ // -----------------------------------------------------------------
+ private PropertiesMenu() {
+ super("configuration");
+ addItem("prop-general", "menu.prop.general", "image.hold.gif",
+ "select?menu=properties&item=prop-general");
+ addItem("prop-scenario", "menu.prop.scenario", "image.hold.gif",
+ "select?menu=properties&item=prop-scenario");
+ addItem("prop-timestamp", new MenuItem("menu.prop.timestamp")
+ .icon("image.stamp.png"));
+ addItem("prop-comlog", new MenuItem("menu.prop.comlog")
+ .icon("image.hold.gif"));
+ addItem("prop-version", new MenuItem("menu.prop.version")
+ .icon("image.dirclosed.png"));
+ }
+ }
+
+ private static class DatadminMenu extends SimpleMenu {
+ // -----------------------------------------------------------------
+ private DatadminMenu() {
+ super("datadmin");
+ addItem("admin-scontext", "menu.admin.context", "image.hold.gif",
+ "select?menu=datadmin&item=admin-scontext");
+ addItem("admin-knowelm", "menu.admin.knowledge", "image.idea.png",
+ "select?menu=datadmin&item=admin-knowelm");
+ addItem("admin-study", new MenuItem("menu.admin.study")
+ .icon("image.study.png"));
+ }
+ }
+
+ private static class SysadminMenu extends SimpleMenu {
+ // -----------------------------------------------------------------
+ private SysadminMenu() {
+ super("sysadmin");
+ addItem("admin-indexing", "menu.admin.indexing", "image.index.png",
+ "select?menu=sysadmin&item=admin-indexing");
+ addItem("admin-importuser", "menu.admin.importuser",
+ "image.group.png",
+ "select?menu=sysadmin&item=admin-importuser");
+ }
+ }
+
+ private enum Item {
+ publish, accept, approve, promote, demote, undo, rename, attach, edit, script, version, replace, export, remove, purge
+ };
+
+ // Resources relative to studies
+ private static class EditableStudyPopup extends PopupMenu {
+ // ----------------------------------------------------------------
+ private StudyRights user = null;
+
+ private EditableStudyPopup() {
+ addItem("publish", new PopupItem("menu.publish").icon(
+ "image.publish.png").action("edit-study?action=publish")
+ .confirmation("message.publish.study"));
+ addItem("promote", new PopupItem("menu.archive"));
+ addSeparator();
+ addItem("edit", new PopupItem("menu.properties")
+ .icon("icon.ed.png").action("../select?menu=properties"));
+ addSeparator();
+ addItem("script", new PopupItem("menu.newscenario")
+ .action("add-scenario"));
+ addItem("version", new PopupItem("menu.version").icon(
+ "image.version.png").action("notyetimplemented"));
+ addSeparator();
+ addItem("purge", new PopupItem("menu.purge")
+ .confirmation("message.purge.study"));
+ addItem("export", new PopupItem("menu.export")
+ .icon("image.export.png")); // For future needs
+ addItem("remove", new PopupItem("menu.remove.version").icon(
+ "icon.delete.png").action("notyetimplemented")
+ .confirmation("message.delete.study"));
+ }
+
+ public boolean isEnabled(String name) {
+ if (user == null)
+ return false; // Should not happen
+ Item item = Item.valueOf(name);
+ if (item == Item.publish)
+ return user.canPublish();
+ if (item == Item.edit)
+ return user.canEditProperties();
+ if (item == Item.script)
+ return user.canAddScenario();
+ if (item == Item.version)
+ return user.canVersion();
+ if (item == Item.remove)
+ return user.canRemove();
+ if (item == Item.purge)
+ return user.canPurge();
+ return false;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof StudyRights) {
+ user = (StudyRights) context; // Just for optimizing
+ boolean history = user.getOperand().isVersioned();
+ PopupItem item = this.item("remove");
+ if (history)
+ item.rename("menu.remove.version");
+ else
+ item.rename("menu.remove.study");
+ }
+ }
+ }
+
+ // Resources relative to documents
+ private static class EditableDocumentPopup extends PopupMenu { // Popup of In-Work documents
+ // ----------------------------------------------------------------
+ private DocumentRights user = null;
+
+ private EditableDocumentPopup() {
+ addItem("accept", new PopupItem("menu.accept").icon(
+ "image.accept.png").action("setDocument?action=accept")
+ .confirmation("message.accept.document"));
+ addItem("promote", new PopupItem("menu.promote").icon(
+ "image.publish.png").action("setDocument?action=promote")
+ .confirmation("message.promote.document"));
+ addSeparator();
+ addItem("rename", new PopupItem("menu.rename")
+ .action("edit-document?action=renameDocument"));
+ addItem("attach", new PopupItem("menu.attach").icon(
+ "image.attach.png").action("select-file?nextAction=attach"));
+ addSeparator();
+ addItem("version", new PopupItem("menu.version").icon(
+ "image.version.png").action(
+ "select-file?nextAction=version"));
+ addItem("replace", new PopupItem("menu.replace").icon(
+ "image.replace.png").action(
+ "select-file?nextAction=replace"));
+ addSeparator();
+ addItem("purge", new PopupItem("menu.purge").action(
+ "notyetimplemented").confirmation("message.purge.document"));
+ addItem("remove", new PopupItem("menu.remove.version").icon(
+ "icon.delete.png").action("remove-document").confirmation(
+ "message.delete.document"));
+ }
+
+ public boolean isEnabled(String name) {
+ if (user == null)
+ return false; // Should not happen
+ Item item = Item.valueOf(name);
+ if (item == Item.accept)
+ return user.canAccept();
+ if (item == Item.promote)
+ return user.canPromote();
+ if (item == Item.rename)
+ return user.canRename();
+ if (item == Item.attach)
+ return user.canAttach();
+ if (item == Item.version)
+ return user.canVersion();
+ if (item == Item.replace)
+ return user.canReplace();
+ if (item == Item.purge)
+ return user.canPurge();
+ if (item == Item.remove)
+ return user.canRemove();
+ return false;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof DocumentRights) {
+ user = (DocumentRights) context; // Just for optimizing
+ Document downer = user.getOperand();
+ PopupItem item = this.item("remove");
+ if (downer.isVersioned())
+ item.rename("menu.remove.version");
+ else
+ item.rename("menu.remove.document");
+ }
+ }
+ }
+
+ private static class ReviewableDocumentPopup extends PopupMenu { // Popup of In-Draft documents
+ // ----------------------------------------------------------------
+ private DocumentRights user = null;
+
+ private ReviewableDocumentPopup() {
+ addItem("demote", new PopupItem("menu.demote").icon(
+ "image.demote.png").action("setDocument?action=demote")
+ .confirmation("message.demote.document"));
+ addItem("promote", new PopupItem("menu.review").icon(
+ "image.review.png").action("setDocument?action=review")
+ .confirmation("message.review.document"));
+ addSeparator();
+ addItem("attach", new PopupItem("menu.attach").icon(
+ "image.attach.png").action("select-file?nextAction=attach"));
+ addSeparator();
+ addItem("version", new PopupItem("menu.version").icon(
+ "image.version.png").action(
+ "select-file?nextAction=version"));
+ addSeparator();
+ addItem("purge", new PopupItem("menu.purge").action(
+ "notyetimplemented").confirmation("message.purge.document"));
+ }
+
+ public boolean isEnabled(String name) {
+ if (user == null)
+ return false; // Should not happen
+ Item item = Item.valueOf(name);
+ if (item == Item.demote)
+ return user.canDemote();
+ if (item == Item.promote)
+ return user.canReview();
+ if (item == Item.attach)
+ return user.canAttach();
+ if (item == Item.version)
+ return user.canVersion();
+ if (item == Item.purge)
+ return user.canPurge();
+ return false;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof DocumentRights) {
+ user = (DocumentRights) context; // Just for optimizing
+ }
+ }
+ }
+
+ private static class NotResultDocumentPopup extends PopupMenu {
+ // ----------------------------------------------------------------
+ private DocumentRights user = null;
+
+ private NotResultDocumentPopup() {
+ addItem("demote", new PopupItem("menu.demote").icon(
+ "image.demote.png").action("setDocument?action=demote")
+ .confirmation("message.demote.document"));
+ addSeparator();
+ addItem("attach", new PopupItem("menu.attach").icon(
+ "image.attach.png").action("select-file?nextAction=attach"));
+ addSeparator();
+ addItem("version", new PopupItem("menu.version").icon(
+ "image.version.png").action(
+ "select-file?nextAction=version"));
+ addSeparator();
+ addItem("purge", new PopupItem("menu.purge").action(
+ "notyetimplemented").confirmation("message.purge.document"));
+ addItem("remove", new PopupItem("menu.remove.version").icon(
+ "icon.delete.png").action("remove-document").confirmation(
+ "message.delete.document"));
+ }
+ }
+
+ private static class ApprovableDocumentPopup extends PopupMenu { // Popup of In-Check documents
+ // ----------------------------------------------------------------
+ private DocumentRights user = null;
+
+ private ApprovableDocumentPopup() {
+ addItem("undo", new PopupItem("menu.demote").icon(
+ "image.invalidate.png").action(
+ "setDocument?action=invalidate").confirmation(
+ "message.demote.document"));
+ addItem("demote", new PopupItem("menu.disapprove").icon(
+ "image.demote.png").action("setDocument?action=disapprove")
+ .confirmation("message.disapprove.document"));
+ addItem("approve", new PopupItem("menu.approve").icon(
+ "icon.APPROVED.png").action("setDocument?action=approve")
+ .confirmation("message.approve.document"));
+ }
+
+ public boolean isEnabled(String name) {
+ if (user == null)
+ return false; // Should not happen
+ Item item = Item.valueOf(name);
+ if (item == Item.undo)
+ return user.canInvalidate();
+ if (item == Item.demote)
+ return user.canDemote();
+ if (item == Item.approve)
+ return user.canApprove();
+ return false;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof DocumentRights) {
+ user = (DocumentRights) context; // Just for optimizing
+ }
+ }
+ }
+
+ private static class ApprovedPopup extends PopupMenu { // Popup of Approved documents
+ // ----------------------------------------------------------------
+ private ApprovedPopup() {
+ addItem("attach", new PopupItem("menu.attach").icon(
+ "image.attach.png").action("select-file?nextAction=attach"));
+ addSeparator();
+ addItem("version", new PopupItem("menu.version").icon(
+ "image.version.png").action(
+ "select-file?nextAction=version"));
+ }
+ }
+
+ private static class ExternPopup extends PopupMenu { // Popup of Extern documents
+ // ----------------------------------------------------------------
+ private DocumentRights user = null;
+
+ private ExternPopup() {
+ addItem("rename", new PopupItem("menu.rename")
+ .action("edit-document?action=renameDocument"));
+ addItem("replace", new PopupItem("menu.replace").icon(
+ "image.replace.png").action(
+ "select-file?nextAction=replace"));
+ addSeparator();
+ addItem("remove", new PopupItem("menu.remove.document").icon(
+ "icon.delete.png").action("remove-document").confirmation(
+ "message.delete.document"));
+ }
+
+ public boolean isEnabled(String name) {
+ if (user == null)
+ return false; // Should not happen
+ Item item = Item.valueOf(name);
+ if (item == Item.rename)
+ return user.canRename();
+ if (item == Item.replace)
+ return user.canReplace();
+ if (item == Item.remove)
+ return user.canRemove();
+ return false;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof DocumentRights) {
+ user = (DocumentRights) context; // Just for optimizing
+ }
+ }
+ }
+
+ // Resources relative to simulation contexts
+ private static class ScontextPopup extends PopupMenu {
+ // --------------------------------------------------------
+ private SimulationContextFacade owner = null;
+
+ private ScontextPopup() {
+ addItem("rename", new PopupItem("menu.rename")
+ .action("edit-context?action=renameContext"));
+ addItem("edit", new PopupItem("menu.edit")
+ .action("edit-context?action=editContext"));
+ addSeparator();
+ addItem("remove", new PopupItem("menu.remove").icon(
+ "icon.delete.png").action("remove-context").confirmation(
+ "message.delete.context"));
+ }
+
+ public boolean isEnabled(String name) {
+ Item item = Item.valueOf(name);
+
+ if (item == Item.rename) {
+ return false;
+ } else if (item == Item.edit) {
+ // if (!owner.isEditable())
+ return false;
+ }
+ return true;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof SimulationContextFacade) {
+ owner = (SimulationContextFacade) context; // Just for optimizing
+ } else {
+ super.setContext(name, context);
+ }
+ }
+ }
+
+ // Resources relative to knowledge
+ private static class FeedbexPopup extends PopupMenu {
+ // --------------------------------------------------------
+ private KnowledgeElement owner = null;
+
+ private FeedbexPopup() {
+ addItem("promote", new PopupItem("menu.promote").icon(
+ "image.review.png").action("promote-knowledge")
+ .confirmation("message.promote.knowledge"));
+ addItem("demote", new PopupItem("menu.demote").icon(
+ "image.invalidate.png").action("demote-knowledge")
+ .confirmation("message.demote.knowledge"));
+ addSeparator();
+ addItem("rename", new PopupItem("menu.rename")
+ .action("edit-knowledge?action=renameKnowledge"));
+ addItem("edit", new PopupItem("menu.edit")
+ .action("edit-knowledge?action=editKnowledge"));
+ addSeparator();
+ addItem("remove", new PopupItem("menu.remove").icon(
+ "icon.delete.png").action("remove-knowledge").confirmation(
+ "message.delete.knowledge"));
+ }
+
+ public boolean isEnabled(String name) {
+ Item item = Item.valueOf(name);
+
+ if (item == Item.promote) {
+ if (owner.getProgressState() != ProgressState.inDRAFT)
+ return false;
+ } else if (item == Item.demote) {
+ if (owner.getProgressState() != ProgressState.inCHECK)
+ return false;
+ }
+ return true;
+ }
+
+ public void setContext(String name, Object context) {
+ if (context instanceof KnowledgeElement)
+ owner = (KnowledgeElement) context; // Just for optimizing
+ else {
+ super.setContext(name, context);
+ }
+ }
+ }
+
+ // ==============================================================================================================================
+ // Construction
+ // ==============================================================================================================================
+
+ public static ApplicationSettings getMe() {
+ // ------------------------------------------
+ return my; // The application is supposed being previously created below
+ }
+
/**
* @param wappurl
* @param lang
* @return
*/
- public ApplicationSettings init(String wappurl, Locale lang) throws IOException {
- ClassLoader cloader = getClass().getClassLoader();
- String[] wurl = wappurl.split("/"); // [0]="http:", [1]="", [2]="{server}:{port}", [3]="name"
-
- locale = lang;
- wappserver = wurl[2];
- wappname = wurl[3];
- wapprops = new Properties();
- jndprops = new Properties();
- wapprops.load(cloader.getResourceAsStream(wappname + ".properties"));
- jndprops.load(cloader.getResourceAsStream("jndi.properties"));
-
- logger.info("Application root set to " + wapprops.getProperty("wapp.root"));
- my = this;
- return this;
- }
-
-// ==============================================================================================================================
-// Public member functions
-// ==============================================================================================================================
-
- public void configure (String filename) {
-// ---------------------------------------
-// Non customizable settings
- menus = new HashMap();
- SimpleMenu menu = new NewMenu();
- menus.put( menu.getName(), menu );
- menu = new SearchMenu();
- menus.put( menu.getName(), menu );
- menu = new DatadminMenu();
- menus.put( menu.getName(), menu );
- menu = new SysadminMenu();
- menus.put( menu.getName(), menu );
- menu = new PropertiesMenu();
- menus.put( menu.getName(), menu );
-
- popups = new HashMap();
- popups.put("steditable", new EditableStudyPopup());
- popups.put("editable", new EditableDocumentPopup());
- popups.put("notresult", new NotResultDocumentPopup());
- popups.put("reviewable", new ReviewableDocumentPopup());
- popups.put("approvable", new ApprovableDocumentPopup());
- popups.put("approved", new ApprovedPopup());
- popups.put("extern", new ExternPopup());
- popups.put("scontext", new ScontextPopup());
- popups.put("feedbex", new FeedbexPopup());
-
-// Default customizable mandatory settings
- Map fprop = new HashMap();
- fprop.put("visibility", "PRIVATE");
- fprop.put("matchamong", "all");
- fprop.put("matcontext", "all");
- fprop.put("state", "END");
- fprop.put("author", "0");
- fprop.put("reference", "");
- fprop.put("title", "");
- fprop.put("context", new Vector());
-
- Map gprop = new HashMap();
- gprop.put("visibility", "PUBLIC");
- gprop.put("matchamong", "all");
- gprop.put("matcontext", "all");
- gprop.put("type", "2"); //TODO: Get the index from the type name
- gprop.put("author", "0");
- gprop.put("reference", "");
- gprop.put("title", "");
- gprop.put("context", new Vector());
-
- defdoctype = new LinkedHashMap();
- tempfile = new HashMap();
- viewermap = new String[0];
- convertmap = new HashMap();
- filter = new HashMap>();
- filter.put("study", fprop);
- filter.put("knowledge", gprop);
-
-// Customization (must be done after above default settings)
- File config = new File(filename);
- if (config.exists()) {
- loadCustomization(config); // Sets default document types, installed modules and available templates
- } else {
- logger.info("Could not find the application configuration file \"" + config.getAbsolutePath() + "\", using default settings");
- }
-// Settings based on the customization
- bars = new HashMap(); // May be empty if no module installed
-
- List steps = getProjectSettings().getAllSteps();
- for (Iterator i=steps.iterator(); i.hasNext();) {
- ProjectSettingsService.Step step = i.next();
- List formats = getDefaultFormats(step);
- if (formats.size() == 0) continue;
-
- ToolBar bar = new ToolBar(24); // Height of the module-bar
- HashSet module = new HashSet(); // For not duplicating modules
- for (Iterator j=formats.iterator(); j.hasNext();) {
- String format = j.next();
- String command = getApplicationProperty("executable." + format);
- if (command == null) continue; // Module not installed
- if (module.contains(command)) continue;
- module.add(command);
- String[] parsed = command.split("/");
- String[] name = parsed[parsed.length-1].split("\\x2E");
- String docname = my.defdoctype.get(step.getNumber() + "." + format).getName();
- if (tempfile.get(docname) == null) { // No available template
- String tool = parsed[parsed.length-1];
- String icon = name[0];
- if (icon.equals("index")) {
- tool = parsed[parsed.length-2];
- icon = "tool." + tool.toLowerCase() + ".png";
- }
- else {
- icon = "tool." + icon.toLowerCase() + ".png";
- }
- File image = new File(ApplicationSettings.getApplicationSkinPath() + icon);
- if (!image.exists()) icon = "tool.any.png";
- bar.addTool(tool, icon, command);
- } else {
- docname = "/jsp/newDocument.jsp?type=" + docname;
- String icon = "tool." + name[0].toLowerCase() + ".png";
- File image = new File(ApplicationSettings.getApplicationSkinPath() + icon);
- if (!image.exists()) icon = "tool.any.png";
- bar.addTool(name[0], icon, command, docname);
- }
- }
- if (!bar.isEmpty()) bars.put(step.getNumber(), bar);
- }
- }
-
- public String getApplicationProperty (String name) {
-// --------------------------------------------------
- return wapprops.getProperty(name); // May be null
- }
-
- public String getApplicationRootPath () {
-// ---------------------------------------
- return getApplicationProperty("wapp.root"); // The property is supposed including the Web application name
- }
-
- public String getApplicationURL () {
-// ----------------------------------
- StringBuffer url = new StringBuffer("http://").append(my.wappserver).append("/").append(wappname);
- return url.toString();
- }
-
- public Map getFilter (String name) {
-// --------------------------------------------------
- return filter.get(name);
- }
-
- public ToolBar getModuleBar (Step step) {
-// -----------------------------------------
- return bars.get(step.getNumber());
- }
-
- public Properties getNamingProperties () {
-// ----------------------------------------
- return jndprops;
- }
-
-// ==============================================================================================================================
-// Public services
-// ==============================================================================================================================
-
- public static String getApplicationPluginPath () {
-// ------------------------------------------------
- return my.getApplicationRootPath() + "plugin/";
- }
- public static String getApplicationResourcePath () {
-// --------------------------------------------------
- return my.getApplicationRootPath() + "WEB-INF/classes/";
- }
- public static String getApplicationSkinPath () {
-// ----------------------------------------------
- return my.getApplicationRootPath() + "skin/";
- }
- public static Converter getConverter (DocumentType type, String format) {
-// -----------------------------------------------------------------------
- return my.convertmap.get(format + type.getName()); // May be null;
- }
- public static DocumentType getDefaultDocumentType (Step step, String format) {
-// ----------------------------------------------------------------------------
- String[] table = format.split("\\x2E");
- return my.defdoctype.get(step.getNumber() + "." + table[table.length-1]); // May be null
- }
- public static String getDownloadURL (User user) {
-// --------------------------------------------------
- StringBuffer url = new StringBuffer("http://").append(my.wappserver).append("/download/").append(user.getUsername()).append("/");
- return url.toString(); // The download Tomcat context is supposed being defined
- }
- public static Locale getCurrentLocale () {
-// ----------------------------------------
- return my.locale;
- }
- public static SimpleMenu getMenu (String name) {
-// ----------------------------------------------
- return my.menus.get(name);
- }
- public static PopupMenu getPopupMenu (String name) {
-// --------------------------------------------------
- return my.popups.get(name);
- }
- public static String getRepositoryURL () {
-// ----------------------------------------
- StringBuffer url = new StringBuffer("http://").append(my.wappserver).append("/repository/");
- return url.toString(); // The repository Tomcat context is supposed being defined
- }
- public static Locale[] getSupportedLocales () {
-// ---------------------------------------------
- String[] code = my.wapprops.getProperty("locale.supported").split(",");
- Locale[] result = new Locale[code.length];
- for (int i=0; i getDefaultFormats (ProjectSettingsService.Step step) {
-// ------------------------------------------------------------------
- Set keys = defdoctype.keySet();
- int number = step.getNumber();
- Vector result = new Vector();
-
- for (Iterator i=keys.iterator(); i.hasNext();) {
- String[] key = i.next().split("\\x2E");
- if (Integer.valueOf(key[0]) != number) continue;
- if (key[1].equals("pdf")) continue; // PDF is not an authoring format
- result.add(key[1]); // Formats are unique
- }
- return result;
- }
-
- private void loadCustomization (File config) {
-// --------------------------------------------
- try {
- DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
-
- org.w3c.dom.Document conf = dBuilder.parse(config.getPath());
- HashMap children = XDOM.getNamedChildNodes(conf.getDocumentElement());
-
-// Default document types tag
- Node child = children.get("default-doctypes");
- NodeList nlist = child.getChildNodes();
-
- List listype = Document.selectAllTypes();
- HashMap maptype = new HashMap();
- for (Iterator i=listype.iterator(); i.hasNext();) {
- DocumentType type = i.next();
- maptype.put(type.getName(), type);
- }
- for (int i=0; i();
+ SimpleMenu menu = new NewMenu();
+ menus.put(menu.getName(), menu);
+ menu = new SearchMenu();
+ menus.put(menu.getName(), menu);
+ menu = new DatadminMenu();
+ menus.put(menu.getName(), menu);
+ menu = new SysadminMenu();
+ menus.put(menu.getName(), menu);
+ menu = new PropertiesMenu();
+ menus.put(menu.getName(), menu);
+
+ popups = new HashMap();
+ popups.put("steditable", new EditableStudyPopup());
+ popups.put("editable", new EditableDocumentPopup());
+ popups.put("notresult", new NotResultDocumentPopup());
+ popups.put("reviewable", new ReviewableDocumentPopup());
+ popups.put("approvable", new ApprovableDocumentPopup());
+ popups.put("approved", new ApprovedPopup());
+ popups.put("extern", new ExternPopup());
+ popups.put("scontext", new ScontextPopup());
+ popups.put("feedbex", new FeedbexPopup());
+
+ // Default customizable mandatory settings
+ Map fprop = new HashMap();
+ fprop.put("visibility", "PRIVATE");
+ fprop.put("matchamong", "all");
+ fprop.put("matcontext", "all");
+ fprop.put("state", "END");
+ fprop.put("author", "0");
+ fprop.put("reference", "");
+ fprop.put("title", "");
+ fprop.put("context", new Vector());
+
+ Map gprop = new HashMap();
+ gprop.put("visibility", "PUBLIC");
+ gprop.put("matchamong", "all");
+ gprop.put("matcontext", "all");
+ gprop.put("type", "2"); // TODO: Get the index from the type name
+ gprop.put("author", "0");
+ gprop.put("reference", "");
+ gprop.put("title", "");
+ gprop.put("context", new Vector());
+
+ defdoctype = new LinkedHashMap();
+ tempfile = new HashMap();
+ viewermap = new String[0];
+ convertmap = new HashMap();
+ filter = new HashMap>();
+ filter.put("study", fprop);
+ filter.put("knowledge", gprop);
+
+ // Customization (must be done after above default settings)
+ File config = new File(filename);
+ if (config.exists()) {
+ loadCustomization(config); // Sets default document types, installed modules and available templates
+ } else {
+ logger.info("Could not find the application configuration file \""
+ + config.getAbsolutePath() + "\", using default settings");
+ }
+ // Settings based on the customization
+ bars = new HashMap(); // May be empty if no module installed
+
+ List steps = getProjectSettings()
+ .getAllSteps();
+ for (Iterator i = steps.iterator(); i
+ .hasNext();) {
+ ProjectSettingsService.Step step = i.next();
+ List formats = getDefaultFormats(step);
+ if (formats.size() == 0)
+ continue;
+
+ ToolBar bar = new ToolBar(24); // Height of the module-bar
+ HashSet module = new HashSet(); // For not duplicating modules
+ for (Iterator j = formats.iterator(); j.hasNext();) {
+ String format = j.next();
+ String command = getApplicationProperty("executable." + format);
+ if (command == null)
+ continue; // Module not installed
+ if (module.contains(command))
+ continue;
+ module.add(command);
+ String[] parsed = command.split("/");
+ String[] name = parsed[parsed.length - 1].split("\\x2E");
+ String docname = my.defdoctype.get(
+ step.getNumber() + "." + format).getName();
+ if (tempfile.get(docname) == null) { // No available template
+ String tool = parsed[parsed.length - 1];
+ String icon = name[0];
+ if (icon.equals("index")) {
+ tool = parsed[parsed.length - 2];
+ icon = "tool." + tool.toLowerCase() + ".png";
+ } else {
+ icon = "tool." + icon.toLowerCase() + ".png";
+ }
+ File image = new File(ApplicationSettings
+ .getApplicationSkinPath()
+ + icon);
+ if (!image.exists())
+ icon = "tool.any.png";
+ bar.addTool(tool, icon, command);
+ } else {
+ docname = "/jsp/newDocument.jsp?type=" + docname;
+ String icon = "tool." + name[0].toLowerCase() + ".png";
+ File image = new File(ApplicationSettings
+ .getApplicationSkinPath()
+ + icon);
+ if (!image.exists())
+ icon = "tool.any.png";
+ bar.addTool(name[0], icon, command, docname);
+ }
+ }
+ if (!bar.isEmpty())
+ bars.put(step.getNumber(), bar);
+ }
+ }
+
+ public String getApplicationProperty(String name) {
+ // --------------------------------------------------
+ return wapprops.getProperty(name); // May be null
+ }
+
+ public String getApplicationRootPath() {
+ // ---------------------------------------
+ return getApplicationProperty("wapp.root"); // The property is supposed including the Web application name
+ }
+
+ public String getApplicationURL() {
+ // ----------------------------------
+ StringBuffer url = new StringBuffer("http://").append(my.wappserver)
+ .append("/").append(wappname);
+ return url.toString();
+ }
+
+ public Map getFilter(String name) {
+ // --------------------------------------------------
+ return filter.get(name);
+ }
+
+ public ToolBar getModuleBar(Step step) {
+ // -----------------------------------------
+ return bars.get(step.getNumber());
+ }
+
+ public Properties getNamingProperties() {
+ // ----------------------------------------
+ return jndprops;
+ }
+
+ // ==============================================================================================================================
+ // Public services
+ // ==============================================================================================================================
+
+ public static String getApplicationPluginPath() {
+ // ------------------------------------------------
+ return my.getApplicationRootPath() + "plugin/";
+ }
+
+ public static String getApplicationResourcePath() {
+ // --------------------------------------------------
+ return my.getApplicationRootPath() + "WEB-INF/classes/";
+ }
+
+ public static String getApplicationSkinPath() {
+ // ----------------------------------------------
+ return my.getApplicationRootPath() + "skin/";
+ }
+
+ public static Converter getConverter(DocumentType type, String format) {
+ // -----------------------------------------------------------------------
+ return my.convertmap.get(format + type.getName()); // May be null;
+ }
+
+ public static DocumentType getDefaultDocumentType(Step step, String format) {
+ // ----------------------------------------------------------------------------
+ String[] table = format.split("\\x2E");
+ return my.defdoctype.get(step.getNumber() + "."
+ + table[table.length - 1]); // May be null
+ }
+
+ public static String getDownloadURL(User user) {
+ // --------------------------------------------------
+ StringBuffer url = new StringBuffer("http://").append(my.wappserver)
+ .append("/download/").append(user.getUsername()).append("/");
+ return url.toString(); // The download Tomcat context is supposed being defined
+ }
+
+ public static Locale getCurrentLocale() {
+ // ----------------------------------------
+ return my.locale;
+ }
+
+ public static SimpleMenu getMenu(String name) {
+ // ----------------------------------------------
+ return my.menus.get(name);
+ }
+
+ public static PopupMenu getPopupMenu(String name) {
+ // --------------------------------------------------
+ return my.popups.get(name);
+ }
+
+ public static String getRepositoryURL() {
+ // ----------------------------------------
+ StringBuffer url = new StringBuffer("http://").append(my.wappserver)
+ .append("/repository/");
+ return url.toString(); // The repository Tomcat context is supposed being defined
+ }
+
+ public static Locale[] getSupportedLocales() {
+ // ---------------------------------------------
+ String[] code = my.wapprops.getProperty("locale.supported").split(",");
+ Locale[] result = new Locale[code.length];
+ for (int i = 0; i < code.length; i++)
+ result[i] = new Locale(code[i]);
+ return result;
+ }
+
+ public static String[] getViewersMapping() {
+ // -------------------------------------------
+ return my.viewermap;
+ }
+
+ public static String getWebSiteURL() {
+ // -------------------------------------
+ return my.getApplicationProperty("wapp.website");
+ }
+
+ public static String getHelpURL() {
+ // ----------------------------------
+ return my.getApplicationProperty("wapp.onlinehelp");
+ }
+
+ // ==============================================================================================================================
+ // Private services
+ // ==============================================================================================================================
+
+ private List getDefaultFormats(ProjectSettingsService.Step step) {
+ // ------------------------------------------------------------------
+ Set keys = defdoctype.keySet();
+ int number = step.getNumber();
+ Vector result = new Vector();
+
+ for (Iterator i = keys.iterator(); i.hasNext();) {
+ String[] key = i.next().split("\\x2E");
+ if (Integer.valueOf(key[0]) != number)
+ continue;
+ if (key[1].equals("pdf"))
+ continue; // PDF is not an authoring format
+ result.add(key[1]); // Formats are unique
+ }
+ return result;
+ }
+
+ private void loadCustomization(File config) {
+ // --------------------------------------------
+ try {
+ DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
+
+ org.w3c.dom.Document conf = dBuilder.parse(config.getPath());
+ HashMap children = XDOM.getNamedChildNodes(conf
+ .getDocumentElement());
+
+ // Default document types tag
+ Node child = children.get("default-doctypes");
+ NodeList nlist = child.getChildNodes();
+
+ List listype = getDocumentTypeService()
+ .selectAllTypes();
+ HashMap maptype = new HashMap();
+ for (Iterator i = listype.iterator(); i.hasNext();) {
+ DocumentType type = i.next();
+ maptype.put(type.getName(), type);
+ }
+ for (int i = 0; i < nlist.getLength(); i++) {
+ child = nlist.item(i);
+ if (!child.getNodeName().equals("step"))
+ continue;
+
+ String nstep = child.getAttributes().getNamedItem("number")
+ .getNodeValue();
+ NodeList map = child.getChildNodes();
+ for (int j = 0; j < map.getLength(); j++) {
+ child = map.item(j);
+ if (!child.getNodeName().equals("mapping"))
+ continue;
+ NamedNodeMap natr = child.getAttributes();
+ String dext = natr.getNamedItem("extension").getNodeValue();
+ String type = natr.getNamedItem("type").getNodeValue();
+ defdoctype.put(nstep + "." + dext, maptype.get(type));
+ }
+ }
+ // Modules tag
+ child = children.get("modules");
+ nlist = child.getChildNodes();
+ for (int i = 0; i < nlist.getLength(); i++) {
+ child = nlist.item(i);
+ if (!child.getNodeName().equals("mapping"))
+ continue;
+
+ NamedNodeMap natr = child.getAttributes();
+ String dext = natr.getNamedItem("extension").getNodeValue();
+ String exec = natr.getNamedItem("executable").getNodeValue();
+ wapprops.put("executable." + dext, exec);
+ }
+ // Viewer mappings tag
+ child = children.get("viewers");
+ viewermap = child.getAttributes().getNamedItem("extension")
+ .getNodeValue().split(",");
+
+ // Converters tag
+ child = children.get("converters");
+ nlist = child.getChildNodes();
+ for (int i = 0; i < nlist.getLength(); i++) {
+ child = nlist.item(i);
+
+ if (child.getNodeName().equals("geometry")) {
+ NamedNodeMap natr = child.getAttributes();
+ String from = natr.getNamedItem("from").getNodeValue();
+ String to = natr.getNamedItem("to").getNodeValue();
+ String exec = natr.getNamedItem("executable")
+ .getNodeValue();
+ convertmap.put(from + "geometry", new Converter("geometry",
+ from, to, exec));
+ }
+ }
+
+ // Templates tag
+ child = children.get("templates");
+ nlist = child.getChildNodes();
+ for (int i = 0; i < nlist.getLength(); i++) {
+ child = nlist.item(i);
+ if (!child.getNodeName().equals("document"))
+ continue;
+
+ NamedNodeMap natr = child.getAttributes();
+ String type = natr.getNamedItem("type").getNodeValue();
+ String file = natr.getNamedItem("file").getNodeValue();
+ tempfile.put(type, file);
+ }
+ } catch (Exception error) {
+ logger.info("Error in customization", error);
+ }
+ }
+
+ /**
+ * Get the documentTypeService.
+ *
+ * @return the documentTypeService
+ */
+ public DocumentTypeService getDocumentTypeService() {
+ return _documentTypeService;
+ }
+
+ /**
+ * Set the documentTypeService.
+ *
+ * @param documentTypeService
+ * the documentTypeService to set
+ */
+ public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ _documentTypeService = documentTypeService;
+ }
}
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/EditDocumentAction.java b/Workspace/Siman/src/org/splat/simer/EditDocumentAction.java
index 3738cf4..69edf20 100644
--- a/Workspace/Siman/src/org/splat/simer/EditDocumentAction.java
+++ b/Workspace/Siman/src/org/splat/simer/EditDocumentAction.java
@@ -12,6 +12,7 @@ import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.ConvertsRelation;
import org.splat.service.PublicationService;
+import org.splat.service.StepService;
import org.splat.service.technical.RepositoryService;
import org.splat.som.Step;
@@ -32,6 +33,10 @@ public class EditDocumentAction extends DisplayStudyStepAction {
* Injected publication service.
*/
private PublicationService _publicationService;
+ /**
+ * Injected step service.
+ */
+ private StepService _stepService;
/**
* Injected repository service.
*/
@@ -70,7 +75,7 @@ public class EditDocumentAction extends DisplayStudyStepAction {
Publication doc = step.getDocument(Integer.valueOf(index));
if (todo == Execute.renameDocument) {
- doc.rename(title);
+ getPublicationService().rename(doc, title);
// Useless to update the document presentation
} else if (todo == Execute.accept) {
doc.actualize();
@@ -128,7 +133,7 @@ public class EditDocumentAction extends DisplayStudyStepAction {
String[] parse = filename.split("\\x2E");
Publication edited = step.getDocument(Integer.valueOf(index));
- ConvertsRelation export = edited.attach(parse[parse.length - 1]);
+ ConvertsRelation export = getPublicationService().attach(edited, parse[parse.length - 1]);
if (logger.isInfoEnabled())
logger.info("Moving \"" + upfile.getName() + "\" to \""
@@ -154,7 +159,7 @@ public class EditDocumentAction extends DisplayStudyStepAction {
Step step = mystudy.getSelectedStep();
Publication doctag = step.getDocument(Integer.valueOf(index));
- step.removeDocument(doctag); // Updates the data structure
+ getStepService().removeDocument(step, doctag); // Updates the data structure
transax.commit();
mystudy.remove(doctag); // Updates the presentation
@@ -229,4 +234,20 @@ public class EditDocumentAction extends DisplayStudyStepAction {
public void setRepositoryService(RepositoryService repositoryService) {
_repositoryService = repositoryService;
}
+
+ /**
+ * Get the stepService.
+ * @return the stepService
+ */
+ public StepService getStepService() {
+ return _stepService;
+ }
+
+ /**
+ * Set the stepService.
+ * @param stepService the stepService to set
+ */
+ public void setStepService(StepService stepService) {
+ _stepService = stepService;
+ }
}
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java b/Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java
index 38f2f17..99ae151 100644
--- a/Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java
+++ b/Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java
@@ -1,157 +1,185 @@
package org.splat.simer;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.KnowledgeElementType;
import org.splat.dal.bo.som.Scenario;
import org.splat.service.KnowledgeElementService;
+import org.splat.service.KnowledgeElementTypeService;
import org.splat.service.ScenarioService;
import org.splat.som.Step;
-
+/**
+ * Action for addition and modification of knowledge elements in the selected scenario.
+ */
public class EditKnowledgeElementAction extends DisplayStudyStepAction {
- private String type = null; // Edited knowledge type
- private String title = null;
- private String value = null;
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 4636919137087687068L;
+
+ /**
+ * Edited knowledge element type.
+ */
+ private String type = null; // Edited knowledge type
+ /**
+ * Edited knowledge element title.
+ */
+ private String title = null;
+ /**
+ * Edited knowledge element value.
+ */
+ private String value = null;
+ /**
+ * Injected scenario service.
+ */
private ScenarioService _scenarioService;
+ /**
+ * Injected knowledge element service.
+ */
private KnowledgeElementService _knowledgeElementService;
+ /**
+ * Injected knowledge element type service.
+ */
+ private KnowledgeElementTypeService _knowledgeElementTypeService;
+
+ // ==============================================================================================================================
+ // Action methods
+ // ==============================================================================================================================
/**
- * Serial version ID.
+ * Initialize the action. Get selected study from the session.
+ *
+ * @return SUCCESS if no exceptions
*/
- private static final long serialVersionUID = 4636919137087687068L;
-
-// ==============================================================================================================================
-// Action methods
-// ==============================================================================================================================
-
- public String doInitialize () {
-// -----------------------------
-// Session connex = Database.getSession();
-// Transaction transax = connex.beginTransaction();
-
- mystudy = getOpenStudy();
-
-// transax.commit();
- return SUCCESS;
- }
-
- public String doSetKnowledge () {
-// -------------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
- try {
- User user = getConnectedUser();
- mystudy = getOpenStudy();
-
- Step step = mystudy.getSelectedStep();
- Scenario scene = (Scenario)step.getOwner(); // It is necessarily a Scenario
-
- if (title != null && value != null) { // Addition of a new Knowledge Element
- KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
- KnowledgeElementType ktype = KnowledgeElement.selectType(Integer.valueOf(type));
- kprop.setType(ktype)
- .setTitle(title)
- .setValue(value)
- .setAuthor(user);
- mystudy.add( getScenarioService().addKnowledgeElement(scene, kprop) );
- getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of first added document
- } else
- if (title != null) { // Renaming of an existing Knowledge Element
- KnowledgeElement kelm = scene.getKnowledgeElement(Integer.valueOf(type));
- getKnowledgeElementService().rename(kelm, title);
-// Useless to update the open study
- } else
- if (value != null) { // Edition of a knowledge
- KnowledgeElement kelm = scene.getKnowledgeElement(Integer.valueOf(type));
- kelm.update(value);
- mystudy.update(kelm); // For updating the truncated value
- }
- transax.commit();
- return SUCCESS;
- }
- catch (RuntimeException saverror) {
- logger.error("Reason:", saverror);
- if (transax != null && transax.isActive()) {
-// Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
- return ERROR;
- }
- catch (Exception error) {
- transax.commit();
- return INPUT;
- }
- }
-
- public String doDeleteKnowledge () {
-// ----------------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
- try {
- mystudy = getOpenStudy();
- Step step = mystudy.getSelectedStep();
- Scenario scene = (Scenario)step.getOwner(); // It is necessarily a Scenario
-
- KnowledgeElement kelm = scene.getKnowledgeElement(Integer.valueOf(myindex));
- scene.removeKnowledgeElement(kelm); // The knowledge element necessarily exists
-
- mystudy.remove(kelm);
- getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of last removed document
-
- transax.commit();
- return SUCCESS;
- }
- catch (RuntimeException saverror) {
- logger.error("Reason:", saverror);
- if (transax != null && transax.isActive()) {
-// Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
- return ERROR;
- }
- }
-
-// ==============================================================================================================================
-// Getters and setters
-// ==============================================================================================================================
-
- public String getKnowledgeType () {
-// ---------------------------------
- return type;
- }
- public String getSelectedKnowledge () {
-// -------------------------------------
- return myindex;
- }
-
- public void setKnowledgeType (String type) {
-// ------------------------------------------
- this.type = type;
- }
- public void setKnowledgeTitle (String title) {
-// --------------------------------------------
- this.title = title;
- }
- public void setKnowledgeValue (String value) {
-// --------------------------------------------
- this.value = value;
- }
+ public String doInitialize() {
+ mystudy = getOpenStudy();
+ return SUCCESS;
+ }
+
+ /**
+ * Add a new or update an existing knowledge element of the selected scenario in the open study.
+ *
+ * @return SUCCESS if operation succeeded, ERROR if Runtime exception, otherwise INPUT
+ */
+ public String doSetKnowledge() {
+ try {
+ User user = getConnectedUser();
+ mystudy = getOpenStudy();
+
+ Step step = mystudy.getSelectedStep();
+ Scenario scene = (Scenario) step.getOwner(); // It is necessarily a Scenario
+
+ if (title != null && value != null) { // Addition of a new Knowledge Element
+ KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
+ KnowledgeElementType ktype = getKnowledgeElementTypeService()
+ .selectType(Integer.valueOf(type));
+ kprop.setType(ktype).setTitle(title).setValue(value).setAuthor(
+ user);
+ mystudy.add(getScenarioService().addKnowledgeElement(scene,
+ kprop));
+ getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of first added document
+ } else if (title != null) { // Renaming of an existing Knowledge Element
+ KnowledgeElement kelm = scene.getKnowledgeElement(Integer
+ .valueOf(type));
+ getKnowledgeElementService().rename(kelm, title);
+ // Useless to update the open study
+ } else if (value != null) { // Edition of a knowledge
+ KnowledgeElement kelm = scene.getKnowledgeElement(Integer
+ .valueOf(type));
+ getKnowledgeElementService().update(kelm, value);
+ mystudy.update(kelm); // For updating the truncated value
+ }
+ return SUCCESS;
+ } catch (RuntimeException saverror) {
+ logger.error("Reason:", saverror);
+ return ERROR;
+ } catch (Exception error) {
+ return INPUT;
+ }
+ }
+
+ /**
+ * Delete a knowledge element from the current scenario.
+ *
+ * @return SUCCESS if no exceptions
+ */
+ public String doDeleteKnowledge() {
+ mystudy = getOpenStudy();
+ Step step = mystudy.getSelectedStep();
+ Scenario scene = (Scenario) step.getOwner(); // It is necessarily a Scenario
+
+ KnowledgeElement kelm = scene.getKnowledgeElement(Integer
+ .valueOf(myindex));
+ scene.removeKnowledgeElement(kelm); // The knowledge element necessarily exists
+
+ mystudy.remove(kelm);
+ getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of last removed document
+
+ return SUCCESS;
+ }
+
+ // ==============================================================================================================================
+ // Getters and setters
+ // ==============================================================================================================================
+
+ /**
+ * Get the type of the modified knowledge element.
+ *
+ * @return the knowledge type name
+ */
+ public String getKnowledgeType() {
+ // ---------------------------------
+ return type;
+ }
+
+ /**
+ * Get the id of the modified knowledge element.
+ *
+ * @return the knowledge element id
+ */
+ public String getSelectedKnowledge() {
+ // -------------------------------------
+ return myindex;
+ }
+
+ /**
+ * Set the type of the modified knowledge element.
+ *
+ * @param type
+ * the knowledge type name
+ */
+ public void setKnowledgeType(String type) {
+ // ------------------------------------------
+ this.type = type;
+ }
+
+ /**
+ * Set the title of the modified knowledge element.
+ *
+ * @param title
+ * the new knowledge title
+ */
+ public void setKnowledgeTitle(String title) {
+ // --------------------------------------------
+ this.title = title;
+ }
+
+ /**
+ * Set the value of the modified knowledge element.
+ *
+ * @param value
+ * the knowledge value
+ */
+ public void setKnowledgeValue(String value) {
+ // --------------------------------------------
+ this.value = value;
+ }
+
/**
* Get the scenarioService.
+ *
* @return the scenarioService
*/
public ScenarioService getScenarioService() {
@@ -160,7 +188,9 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
/**
* Set the scenarioService.
- * @param scenarioService the scenarioService to set
+ *
+ * @param scenarioService
+ * the scenarioService to set
*/
public void setScenarioService(ScenarioService scenarioService) {
_scenarioService = scenarioService;
@@ -168,6 +198,7 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
/**
* Get the knowledgeElementService.
+ *
* @return the knowledgeElementService
*/
public KnowledgeElementService getKnowledgeElementService() {
@@ -176,10 +207,29 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
/**
* Set the knowledgeElementService.
- * @param knowledgeElementService the knowledgeElementService to set
+ *
+ * @param knowledgeElementService
+ * the knowledgeElementService to set
*/
public void setKnowledgeElementService(
KnowledgeElementService knowledgeElementService) {
_knowledgeElementService = knowledgeElementService;
}
+
+ /**
+ * Get the knowledgeElementTypeService.
+ * @return the knowledgeElementTypeService
+ */
+ public KnowledgeElementTypeService getKnowledgeElementTypeService() {
+ return _knowledgeElementTypeService;
+ }
+
+ /**
+ * Set the knowledgeElementTypeService.
+ * @param knowledgeElementTypeService the knowledgeElementTypeService to set
+ */
+ public void setKnowledgeElementTypeService(
+ KnowledgeElementTypeService knowledgeElementTypeService) {
+ _knowledgeElementTypeService = knowledgeElementTypeService;
+ }
}
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java b/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java
index 47957e5..02d9070 100644
--- a/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java
+++ b/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java
@@ -20,6 +20,7 @@ import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.ProgressState;
import org.splat.service.DocumentService;
+import org.splat.service.DocumentTypeService;
import org.splat.service.PublicationService;
import org.splat.service.StepService;
import org.splat.service.technical.ProjectSettingsService;
@@ -57,7 +58,10 @@ public class ImportDocumentAction extends UploadBaseNextAction {
* Injected document service.
*/
private DocumentService _documentService;
-
+ /**
+ * Injected document type service.
+ */
+ private DocumentTypeService _documentTypeService;
/**
* Injected repository service.
*/
@@ -83,7 +87,7 @@ public class ImportDocumentAction extends UploadBaseNextAction {
mystudy = getOpenStudy();
Step step = mystudy.getSelectedStep();
- doctypes = step.getValidDocumentTypes();
+ doctypes = getStepService().getValidDocumentTypes(step);
deftype = ApplicationSettings.getDefaultDocumentType(step, filext);
defuses = new Vector();
state = ProgressState.inWORK;
@@ -185,7 +189,7 @@ public class ImportDocumentAction extends UploadBaseNextAction {
mystudy = getOpenStudy();
User user = getConnectedUser();
Step step = mystudy.getSelectedStep();
- DocumentType type = Document.selectType((int)doctype);
+ DocumentType type = getDocumentTypeService().selectType((int)doctype);
File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
String[] table = filename.split("\\x2E");
@@ -438,4 +442,20 @@ public class ImportDocumentAction extends UploadBaseNextAction {
public void setRepositoryService(RepositoryService repositoryService) {
_repositoryService = repositoryService;
}
+
+ /**
+ * Get the documentTypeService.
+ * @return the documentTypeService
+ */
+ public DocumentTypeService getDocumentTypeService() {
+ return _documentTypeService;
+ }
+
+ /**
+ * Set the documentTypeService.
+ * @param documentTypeService the documentTypeService to set
+ */
+ public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ _documentTypeService = documentTypeService;
+ }
}
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/NewScenarioAction.java b/Workspace/Siman/src/org/splat/simer/NewScenarioAction.java
index 9ff3ed6..68f98e2 100644
--- a/Workspace/Siman/src/org/splat/simer/NewScenarioAction.java
+++ b/Workspace/Siman/src/org/splat/simer/NewScenarioAction.java
@@ -12,7 +12,7 @@ import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.Scenario;
import org.splat.service.ProjectElementService;
-import org.splat.service.StudyService;
+import org.splat.service.ScenarioService;
import org.splat.som.Step;
import org.splat.dal.bo.som.Study;
import org.splat.wapp.Menu;
@@ -27,7 +27,13 @@ public class NewScenarioAction extends Action {
private long scindex;
private int bastep;
private ToDo action;
- private StudyService _studyService;
+ /**
+ * Injected scenario service.
+ */
+ private ScenarioService _scenarioService;
+ /**
+ * Injected project element service.
+ */
private ProjectElementService _projectElementService;
private Menu _menu;
@@ -105,7 +111,7 @@ public class NewScenarioAction extends Action {
step = getProjectElementService().getSteps(bascene);
sprop.setBaseStep(step[number-bastep]);
}
- bascene = getStudyService().addScenario(study, sprop);
+ bascene = getScenarioService().addScenario(study, sprop);
transax.commit();
// Update of the display
@@ -184,24 +190,6 @@ public class NewScenarioAction extends Action {
// ----------------------------
return (Integer.valueOf(getSharedStep()) > bastep);
}
- /**
- * Get the studyService.
- *
- * @return the studyService
- */
- public StudyService getStudyService() {
- return _studyService;
- }
-
- /**
- * Set the studyService.
- *
- * @param studyService
- * the studyService to set
- */
- public void setStudyService(StudyService studyService) {
- _studyService = studyService;
- }
/**
* Get the projectElementService.
*
@@ -237,4 +225,20 @@ public class NewScenarioAction extends Action {
public void setMenu(Menu menu) {
_menu = menu;
}
+
+ /**
+ * Get the scenarioService.
+ * @return the scenarioService
+ */
+ public ScenarioService getScenarioService() {
+ return _scenarioService;
+ }
+
+ /**
+ * Set the scenarioService.
+ * @param scenarioService the scenarioService to set
+ */
+ public void setScenarioService(ScenarioService scenarioService) {
+ _scenarioService = scenarioService;
+ }
}
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/NewStudyAction.java b/Workspace/Siman/src/org/splat/simer/NewStudyAction.java
index 05da635..82755c5 100644
--- a/Workspace/Siman/src/org/splat/simer/NewStudyAction.java
+++ b/Workspace/Siman/src/org/splat/simer/NewStudyAction.java
@@ -11,6 +11,7 @@ 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.bo.som.Study;
+import org.splat.service.ScenarioService;
import org.splat.service.SimulationContextService;
import org.splat.service.StudyService;
@@ -31,6 +32,10 @@ public class NewStudyAction extends Action {
*/
private StudyService _studyService;
private SimulationContextService _simulationContextService;
+ /**
+ * Injected scenario service.
+ */
+ private ScenarioService _scenarioService;
// ==============================================================================================================================
// Action methods
@@ -90,7 +95,7 @@ public class NewStudyAction extends Action {
ApplicationSettings.getCurrentLocale());
Scenario.Properties oprop = new Scenario.Properties();
oprop.setTitle(locale.getString("label.scenario") + " 1");
- getStudyService().addScenario(study, oprop);
+ getScenarioService().addScenario(study, oprop);
// Addition of the entered project context
if (valid == 0) { // Input of new project context
@@ -190,4 +195,20 @@ public class NewStudyAction extends Action {
SimulationContextService simulationContextService) {
_simulationContextService = simulationContextService;
}
+
+ /**
+ * Get the scenarioService.
+ * @return the scenarioService
+ */
+ public ScenarioService getScenarioService() {
+ return _scenarioService;
+ }
+
+ /**
+ * Set the scenarioService.
+ * @param scenarioService the scenarioService to set
+ */
+ public void setScenarioService(ScenarioService scenarioService) {
+ _scenarioService = scenarioService;
+ }
}
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/OpenKnowledge.java b/Workspace/Siman/src/org/splat/simer/OpenKnowledge.java
index 81202a4..702f62b 100644
--- a/Workspace/Siman/src/org/splat/simer/OpenKnowledge.java
+++ b/Workspace/Siman/src/org/splat/simer/OpenKnowledge.java
@@ -20,8 +20,6 @@ public class OpenKnowledge extends OpenObject {
private KnowledgeElement myknelm;
private String credate;
- private ProjectElementService _projectElementService;
-
public class Menu extends SimpleMenu {
// ------------------------------------
public Menu(List context) {
@@ -181,24 +179,4 @@ public class OpenKnowledge extends OpenObject {
return result;
}
- /**
- * Get the projectElementService.
- *
- * @return the projectElementService
- */
- public ProjectElementService getProjectElementService() {
- return _projectElementService;
- }
-
- /**
- * Set the projectElementService.
- *
- * @param projectElementService
- * the projectElementService to set
- */
- public void setProjectElementService(
- ProjectElementService projectElementService) {
- _projectElementService = projectElementService;
- }
-
}
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/OpenObject.java b/Workspace/Siman/src/org/splat/simer/OpenObject.java
index ce6bc8c..05d9289 100644
--- a/Workspace/Siman/src/org/splat/simer/OpenObject.java
+++ b/Workspace/Siman/src/org/splat/simer/OpenObject.java
@@ -11,6 +11,9 @@ import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.KnowledgeElementType;
import org.splat.dal.bo.som.ProgressState;
+import org.splat.service.KnowledgeElementService;
+import org.splat.service.KnowledgeElementTypeService;
+import org.splat.service.ProjectElementService;
import org.splat.service.PublicationService;
import org.splat.service.dto.Proxy;
import org.splat.service.technical.ProjectSettingsService;
@@ -20,258 +23,291 @@ import org.splat.som.Step;
import org.splat.wapp.Menu;
import org.splat.wapp.PopupMenu;
-
public abstract class OpenObject implements Proxy {
- protected User cuser = null; // Connected user
- protected String selection = null; // Menu selected by the user
- protected Step ustep = null; // Corresponding selected step
- protected String description = null; // Object description (rich text)
- protected List