Salome HOME
Refactoring of Database, replacing SQL by DAOs calls. Methods for search by criteria...
authorrkv <rkv@opencascade.com>
Wed, 17 Oct 2012 04:44:30 +0000 (04:44 +0000)
committerrkv <rkv@opencascade.com>
Wed, 17 Oct 2012 04:44:30 +0000 (04:44 +0000)
105 files changed:
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Persistent.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/SimulationContext.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/SimulationContextType.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/Database.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/Database.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/kernel/UserDirectory.java
Workspace/Siman-Common/src/org/splat/service/DocumentService.java
Workspace/Siman-Common/src/org/splat/service/DocumentServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/ProjectElementService.java
Workspace/Siman-Common/src/org/splat/service/ProjectElementServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/PublicationService.java
Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/SimulationContextService.java [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/service/SimulationContextServiceImpl.java [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/service/StepService.java
Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/StudyService.java
Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsServiceImpl.java
Workspace/Siman-Common/src/spring/businessServiceContext.xml
Workspace/Siman-Common/src/spring/daoContext.xml
Workspace/Siman-Common/src/spring/technicalServiceContext.xml
Workspace/Siman/src/org/splat/module/SaveDocumentAction.java
Workspace/Siman/src/org/splat/simer/Action.java
Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Workspace/Siman/src/org/splat/simer/ConnectionAction.java
Workspace/Siman/src/org/splat/simer/Converter.java
Workspace/Siman/src/org/splat/simer/DisplayBaseAction.java
Workspace/Siman/src/org/splat/simer/EditDocumentAction.java
Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java
Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java
Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java
Workspace/Siman/src/org/splat/simer/EditStudyAction.java
Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java
Workspace/Siman/src/org/splat/simer/MenuAction.java
Workspace/Siman/src/org/splat/simer/NewScenarioAction.java
Workspace/Siman/src/org/splat/simer/NewStudyAction.java
Workspace/Siman/src/org/splat/simer/NotYetImplementedAction.java
Workspace/Siman/src/org/splat/simer/OpenStudy.java
Workspace/Siman/src/org/splat/simer/SearchBaseAction.java
Workspace/Siman/src/org/splat/simer/SearchDocumentAction.java
Workspace/Siman/src/org/splat/simer/SearchKnowledgeAction.java
Workspace/Siman/src/org/splat/simer/SearchStudyAction.java
Workspace/Siman/src/org/splat/simer/StartAction.java
Workspace/Siman/src/org/splat/simer/StudyPropertiesAction.java
Workspace/Siman/src/org/splat/simer/UploadAction.java
Workspace/Siman/src/org/splat/simer/UploadBaseNextAction.java
Workspace/Siman/src/org/splat/simer/VersionDocumentAction.java
Workspace/Siman/src/org/splat/simer/admin/DatabaseIndexingAction.java
Workspace/Siman/src/org/splat/simer/admin/ImportUserAction.java
Workspace/Siman/src/org/splat/simer/admin/KnowledgeElementAction.java
Workspace/Siman/src/org/splat/simer/admin/SimulationContextAction.java
Workspace/Siman/src/org/splat/wapp/Item.java
Workspace/Siman/src/org/splat/wapp/MenuItem.java
Workspace/Siman/src/org/splat/wapp/TabBar.java
Workspace/Siman/src/spring/applicationContext.xml

index 11aa5c432a6d7a64cda966e270d8ec2a05c7cd07..42629f251affcbab6394d7d14ededace60add091 100644 (file)
@@ -138,4 +138,20 @@ public abstract class Persistent {
       if (oid == 0) oid = super.hashCode();               //WARNING: Must not call super.toString() as it goes back here (this.toString())
       return new StringBuffer("object ").append(getClass().getName()).append("@").append(oid).toString();
     }
+
+/**
+ * Get the rid.
+ * @return the rid
+ */
+public long getRid() {
+       return rid;
+}
+
+/**
+ * Set the rid.
+ * @param rid the rid to set
+ */
+public void setRid(long rid) {
+       this.rid = rid;
+}
 }
\ No newline at end of file
index ec7fcb3c890709472d3ce06d753ca088794a8d5c..d998f3ec6e509e8f4dd4b017390fffa7d33c24ac 100644 (file)
@@ -391,19 +391,6 @@ public class Document extends Entity {
                return did;
        }
 
-       public java.io.File getSaveDirectory() {
-               // ---------------------------------------
-               String mypath = Database.getRepositoryVaultPath()
-                               + myfile.getRelativePath();
-               String[] table = mypath.split("/");
-
-               // Cutting the filename
-               StringBuffer path = new StringBuffer(table[0]);
-               for (int i = 1; i < table.length - 1; i++)
-                       path = path.append("/").append(table[i]);
-               return new java.io.File(path.append("/").toString());
-       }
-
        public File getSourceFile() {
                // ----------------------------
                return myfile;
index a91d0af5ef4c6ff602d6b6931d9d7a513bdcf399..828033b883a0dcf893b8dcdbeafc43719a74900f 100644 (file)
@@ -154,91 +154,18 @@ public class SimulationContext extends Persistent implements Serializable {
 //  --------------------------
       return (counter > 1);
     }
-
-//  ==============================================================================================================================
-//  Public services
-//  ==============================================================================================================================
-
-    public static SimulationContextType createType (String name, ProjectSettingsService.Step step) throws InvalidPropertyException, RuntimeException {
-//  ---------------------------------------------------------------------------------------
-//TODO: Check for duplicate definition
-      SimulationContextType type    = new SimulationContextType(name, step);
-      Session               session = Database.getSession();
-      session.save(type);
-          
-      return type;
-    }
-
-    @SuppressWarnings("unchecked")
-       public static List<SimulationContextType> selectAllTypes () {
-//  -----------------------------------------------------------
-         StringBuffer  query = new StringBuffer("from SimulationContextType");  // Useless to order by names as the result mixes localized and non localized types
-                       query = query.append(" order by step asc");
-      return  Database.getSession().createQuery(query.toString()).list();
-    }
-
-    @SuppressWarnings("unchecked")
-       public static List<SimulationContextType> selectTypesOf (ProjectSettingsService.Step... step) {
-//  --------------------------------------------------------------------------------------
-         StringBuffer  query = new StringBuffer("from SimulationContextType where step='").append(step[0].getNumber()).append("'");      
-         for (int i=1; i<step.length; i++) {           // Useless to order as the result mixes localized and non localized types
-        query = query.append(" or step='").append(step[i].getNumber()).append("'");
-         }
-         query = query.append(" order by step asc");
-      return  Database.getSession().createQuery(query.toString()).list();
-    }
-
-       @SuppressWarnings("unchecked")
-       public static List<SimulationContextType> selectTypesWhere (SimulationContextType.Properties sprop) {
-//  ---------------------------------------------------------------------------------------------------
-      StringBuffer         query     = new StringBuffer("from SimulationContextType");
-      String               separator = " where";
-      ProjectSettingsService.Step step      = sprop.getStep();
-      ProgressState        state     = sprop.getProgressState();
-      String               order     = " order by step asc";
-
-      if (step != null) {
-        query     = query.append(separator).append(" step='").append(step.getNumber()).append("'");
-        separator = " and";
-        order     = " order by state desc";         // APPROVED (upper case A) is grater than inCHECK (lower case i)
-      }
-      if (state != null) {
-        query     = query.append(separator).append(" state='").append(state.toString()).append("'");
-//      separator = " and";
-        if (step != null) {
-          if (state != ProgressState.APPROVED) order = " order by name asc";
-          else  order = "";                         // Approved types are localized
-        }
-      }
-      query = query.append(order);
-      return  Database.getSession().createQuery(query.toString()).list();
-    }
-
-    public static SimulationContextType selectType (String name) {
-//  ------------------------------------------------------------
-         StringBuffer  query = new StringBuffer("from SimulationContextType where name='").append(name).append("'");     
-         return (SimulationContextType)Database.getSession().createQuery(query.toString()).uniqueResult();
-    }
-    
-    public static SimulationContextType selectType (int index) {
-//  ----------------------------------------------------------
-         StringBuffer  query = new StringBuffer("from SimulationContextType where rid='").append(index).append("'");     
-         return (SimulationContextType)Database.getSession().createQuery(query.toString()).uniqueResult();
-    }
-    
-//  ==============================================================================================================================
-//  Protected services
-//  ==============================================================================================================================
-
-    public void hold () {
-//  ----------------------
-      counter += 1;
-      if (this.isSaved()) Database.getSession().update(this);
-    }
-
-    public void release () {
-//  -------------------------
-      counter -= 1;
-      if (this.isSaved()) Database.getSession().update(this);
-    }
+       /**
+        * Get counter.
+        * @return counter
+        */
+       public int getCounter() {
+               return counter;
+       }
+       /**
+        * Set counter.
+        * @param aValue a counter value to set
+        */
+       public void setCounter(int aValue) {
+               counter = aValue;
+       }
 }
\ No newline at end of file
index 881d086a9bbb732157785ae64ea0191d5992f46b..c275cb87988b462e6cd41b36e4cdd0226340e911 100644 (file)
@@ -35,10 +35,10 @@ public class SimulationContextType extends Persistent implements Serializable {
       private ProgressState         state = null;
       private ProjectSettingsService.Step  step  = null;
 
-      protected ProgressState getProgressState () {
+      public ProgressState getProgressState () {
        return state;
       }
-      protected ProjectSettingsService.Step getStep () {
+      public ProjectSettingsService.Step getStep () {
        return step;
       }
       public Properties setState (ProgressState state) {
@@ -54,7 +54,7 @@ public class SimulationContextType extends Persistent implements Serializable {
     protected SimulationContextType () {
     }
 //  Initialization constructor
-    protected SimulationContextType (String name, ProjectSettingsService.Step step) throws InvalidPropertyException {
+    public SimulationContextType (String name, ProjectSettingsService.Step step) throws InvalidPropertyException {
 //  ------------------------------------------------------------------------
       super();
       this.name  = name;
index 9ebba991a994d7316a302023ef0c991480170b8f..08642029c5841b005420e2179093d61bd052806c 100644 (file)
@@ -5,16 +5,11 @@ package org.splat.dal.dao.kernel;
  * @copyright OPEN CASCADE 2012
  */
 
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
-import org.hibernate.jdbc.Work;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
 import org.apache.log4j.Logger;
 
 
@@ -45,73 +40,6 @@ public abstract class Database implements ApplicationContextAware {
 //     private   static  String          CONFIG_FILE      = "/hibernate.cfg.xml";
     private   static  SessionFactory  mySessionFactory = null;
 
-    protected class CreateTables    implements Work {
-//  -----------------------------------------------
-      protected Statement request;
-      
-      public void execute(Connection connex) throws SQLException
-      {          
-        request = connex.createStatement();
-
-//      Last identifier of Any objects
-        String create = "CREATE TABLE `any` (" +
-          "`rid`     int(10)  UNSIGNED NOT NULL," +
-          "`version` tinytext NOT NULL," +
-          "PRIMARY KEY (`rid`)" +
-          ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-        request.execute(create);
-
-//      Relation from entities
-        create = "CREATE TABLE `relation` (" +
-          "`rid`   int(10)  UNSIGNED NOT NULL," +
-          "`name`  tinytext NOT NULL," +
-          "`owner` int(10)  NOT NULL," +
-          "`refer` int(10)  NOT NULL," +
-          "PRIMARY KEY (`rid`)" +
-          ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-        request.execute(create);
-
-//      Attribute objects
-        create = "CREATE TABLE `attribute` (" +
-          "`rid`   int(10)  UNSIGNED NOT NULL auto_increment," +
-          "`type`  tinytext NOT NULL," +
-          "`owner` int(10)  NOT NULL," +
-          "`value` int(10)  NOT NULL," +
-          "PRIMARY KEY (`rid`)" +
-          ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-        request.execute(create);
-
-//      Java String objects
-        create = "CREATE TABLE `text` (" +
-          "`rid`   int(10)  UNSIGNED NOT NULL auto_increment," +
-          "`value` longtext NOT NULL," +
-          "PRIMARY KEY (`rid`)" +
-          ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-        request.execute(create);
-
-//      User and role objects
-        create = "CREATE TABLE `user` (" +
-          "`rid` int(10) UNSIGNED NOT NULL auto_increment," +
-          "`username` varchar(32) NOT NULL," +
-          "`password` varchar(32)," +
-          "`first`    tinytext NOT NULL," +
-          "`last`     tinytext NOT NULL," +
-          "`display`  tinytext," +
-          "`email`    tinytext," +
-          "`organid`  tinytext," +
-          "PRIMARY KEY (`rid`)" +
-          ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-        request.execute(create);
-
-        create = "CREATE TABLE `role` (" +
-          "`username` varchar(32) NOT NULL," +
-          "`role`     varchar(32) NOT NULL," +
-          "PRIMARY KEY (`username`)" +
-          ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-        request.execute(create);
-      }        
-    }
-
     protected final static Logger   logger = Logger.getLogger(Database.class);
     
 //  ==============================================================================================================================
index ee62febf2a9d7bc6c5a59fdfdd32b70e70ffb48a..9ae2887d9287711adfbb627eff7926d7adcbaa72 100644 (file)
 package org.splat.dal.dao.kernel;
 
 import java.io.Serializable;
+import java.util.List;
+
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
 
 /**
  * Generic DAO interface.
@@ -41,13 +45,48 @@ public interface GenericDAO<T, PK extends Serializable> {
         */
        T get(PK id);
 
-       /** Save changes made to a persistent object.
-        * @param transientObject transient instance of the object to update
+       /**
+        * Save changes made to a persistent object.
+        * 
+        * @param transientObject
+        *            transient instance of the object to update
         */
        void update(T transientObject);
 
-       /** Remove an object from persistent storage in the database.
-        * @param persistentObject a persistent object to delete from the database
+       /**
+        * Remove an object from persistent storage in the database.
+        * 
+        * @param persistentObject
+        *            a persistent object to delete from the database
         */
        void delete(T persistentObject);
+
+       /**
+        * Retrieve an object that was previously persisted to the database using the given criteria.
+        * 
+        * @param aCondition
+        *            a search condition
+        * @return an object found according to the given criteria
+        */
+       public T findByCriteria(Criterion aCondition);
+
+       /**
+        * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+        * 
+        * @param aCondition
+        *            a search condition
+        * @return a list of objects filtered according to the given criteria
+        */
+       public List<T> getFilteredList(Criterion aCondition);
+       /**
+        * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+        * 
+        * @param aCondition
+        *            a search condition
+        * @param anOrder
+        *            a result list order. Null is ignored and in such case the result list is unordered.
+        * @return a list of objects filtered according to the given criteria
+        */
+       @SuppressWarnings("unchecked")
+       public List<T> getFilteredList(Criterion aCondition, Order anOrder);
 }
index bc94999e82e44986c1ebc086528278a421b468dd..d76653b7be14998d2cca2b9166f274fbcde0f171 100644 (file)
 package org.splat.dal.dao.kernel;
 
 import java.io.Serializable;
+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;
 
 /**
@@ -23,8 +28,8 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
  * @param <PK>
  *            Primary key class
  */
-public abstract class GenericDAOImpl<T, PK extends Serializable> extends HibernateDaoSupport implements
-               GenericDAO<T, PK> {
+public abstract class GenericDAOImpl<T, PK extends Serializable> extends
+               HibernateDaoSupport implements GenericDAO<T, PK> {
        /**
         * Persist the newInstance object into database.
         * 
@@ -49,15 +54,65 @@ public abstract class GenericDAOImpl<T, PK extends Serializable> extends Hiberna
                return (T) getSession().get(getType(), id);
        }
 
-       /** Save changes made to a persistent object.
-        * @param transientObject transient instance of the object to update
+       /**
+        * Retrieve an object that was previously persisted to the database using the given criteria.
+        * 
+        * @param aCondition
+        *            a search condition
+        * @return an object found according to the given criteria
+        */
+       @SuppressWarnings("unchecked")
+       public T findByCriteria(Criterion aCondition) {
+               return (T) getSession().createCriteria(getType()).add(aCondition)
+                               .uniqueResult();
+       }
+
+       /**
+        * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+        * 
+        * @param aCondition
+        *            a search condition
+        * @return a list of objects filtered according to the given criteria
+        */
+       @SuppressWarnings("unchecked")
+       public List<T> getFilteredList(Criterion aCondition) {
+               return getSession().createCriteria(getType()).add(aCondition).list();
+       }
+
+       /**
+        * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+        * 
+        * @param aCondition
+        *            a search condition
+        * @param anOrder
+        *            a result list order. Null is ignored and in such case the result list is unordered.
+        * @return a list of objects filtered according to the given criteria
+        */
+       @SuppressWarnings("unchecked")
+       public List<T> getFilteredList(Criterion aCondition, Order anOrder) {
+               Criteria aCriteria = getSession().createCriteria(getType()).add(
+                               aCondition);
+               if (anOrder != null) {
+                       aCriteria.addOrder(anOrder);
+               }
+               return aCriteria.list();
+       }
+
+       /**
+        * Save changes made to a persistent object.
+        * 
+        * @param transientObject
+        *            transient instance of the object to update
         */
        public void update(T transientObject) {
                getSession().update(transientObject);
        }
 
-       /** Remove an object from persistent storage in the database.
-        * @param persistentObject a persistent object to delete from the database
+       /**
+        * Remove an object from persistent storage in the database.
+        * 
+        * @param persistentObject
+        *            a persistent object to delete from the database
         */
        public void delete(T persistentObject) {
                getSession().delete(persistentObject);
@@ -65,6 +120,7 @@ public abstract class GenericDAOImpl<T, PK extends Serializable> extends Hiberna
 
        /**
         * Get persistent object type.
+        * 
         * @return Persistent object class to be processed by this DAO
         */
        abstract protected Class<T> getType();
index 08d087b1577ec349396194276889373c340bc918..c122d766a3da680e78df6518c761b711b7f2717f 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel; 
index 44a8b5fad90c4c1e4fafb4dc1c68bdad24e1b122..9a860d99e446008d0c1c874729f1519f1059a818 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel;
index 53a4b723be042b9bfd32c19bae1e580166bf3466..91ff888fd9c33130d23e3391dee0b833bb25b046 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel; 
index b81fd7fe9322a5d5a55faa1b4f31a6b769652a63..8b1a68da9be118ec05321a97cccbe97e1011d4f1 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel;
index 459bd528894ed7be594788594690f70e11935f68..27a0ec7d46e120333a150ab3aecb3c33f69f76bd 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel; 
index 84a226b2f8fff5a5b57de1970a82599f9f5bdbf1..702772a53acb4021f7ef5f5d38dc26b860495ce4 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel;
index 3e5068bee905932d5bc2278b492d4adec6022352..da8cc46f1a06cc1f88f5dd587cdda6b00501744a 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 2fc75b00084aa9a09719ae924fdd32b38c31289c..dfa44024303b9ac12253fa796b4cb0df020894e8 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 98128452d8f3a66c01019523c753cf52dbd0c00e..e655bca9e14f72a932561ea26dea9c51885bee15 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 70c1b620cb2601fe22cfe3042309ae559751e906..dbc56cf8bea2bd5a27fa3d1c60e1e5450d6c8c89 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 9daff682d28fdeefbbbc5f30f9632c16ba4f3c49..3d5790a3a0f763457e83ee749a87208a83b085fd 100644 (file)
@@ -24,13 +24,10 @@ import org.hibernate.jdbc.Work;
 import org.apache.log4j.Logger;
 
 import org.splat.dal.bo.kernel.User;
-import org.splat.dal.bo.som.Document;
 import org.splat.dal.bo.som.IDBuilder;
-import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
-import org.splat.dal.bo.som.Study;
 import org.splat.kernel.UserDirectory;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.service.technical.IndexService;
@@ -39,169 +36,22 @@ import org.splat.service.technical.RepositoryService;
 public class Database extends org.splat.dal.dao.kernel.Database {
 
        private int uplevel = 0; // Level of database upgrade
-       private String basepath = null; // Path of the root directory of repository
        private RepositoryService _repositoryService;
        private IndexService _indexService;
        private SessionFactory _sessionFactory;
 
        private static Database my = null; // Singleton instance
 
-       protected class CreateTables extends
-                       org.splat.dal.dao.kernel.Database.CreateTables {
-               // ---------------------------------------------------------------------------
-               public void execute(Connection connex) throws SQLException {
-                       super.execute(connex);
-
-                       // Study Entity
-                       String create = "CREATE TABLE `study` ("
-                                       + "`rid`      int(10)  UNSIGNED NOT NULL,"
-                                       + "`sid`      tinytext NOT NULL,"
-                                       + "`title`    tinytext NOT NULL,"
-                                       + "`state`    enum('inWORK','inDRAFT','inCHECK','APPROVED', 'TEMPLATE') NOT NULL default 'inWORK',"
-                                       + "`area`     enum('PRIVATE','PUBLIC','REFERENCE')                      NOT NULL default 'PRIVATE',"
-                                       + "`manager`  int(10)  NOT NULL,"
-                                       + "`version`  tinytext NOT NULL,"
-                                       + "`docount`  int(10)  UNSIGNED NOT NULL,"
-                                       + "`history`  int(10)  UNSIGNED NOT NULL,"
-                                       + "`credate`  date     NOT NULL,"
-                                       + "`lasdate`  date     NOT NULL," + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-
-                       // Scenario Entity
-                       create = "CREATE TABLE `scenario` ("
-                                       + "`rid`     int(10)  UNSIGNED NOT NULL,"
-                                       + "`sid`     int(10)  UNSIGNED NOT NULL,"
-                                       + "`owner`   int(10)  NOT NULL,"
-                                       + "`scendex` int(3)   NOT NULL,"
-                                       + "`title`   tinytext NOT NULL,"
-                                       + "`manager` int(10)  NOT NULL," + "`cuser`   int(10),"
-                                       + "`credate` date     NOT NULL,"
-                                       + "`lasdate` date     NOT NULL," + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-
-                       // Document Entity and document tag (Publication)
-                       create = "CREATE TABLE `document` ("
-                                       + "`rid`     int(10)  UNSIGNED NOT NULL,"
-                                       + "`did`     tinytext NOT NULL,"
-                                       + "`type`    int(10)  NOT NULL,"
-                                       + "`step`    int(10)  NOT NULL,"
-                                       + "`state`   enum('inWORK','inDRAFT','inCHECK','APPROVED','EXTERN') NOT NULL default 'inWORK',"
-                                       + "`name`    tinytext NOT NULL,"
-                                       + "`author`  int(10)  NOT NULL," + "`version` tinytext,"
-                                       + "`countag` int(10)  UNSIGNED NOT NULL,"
-                                       + "`history` int(10)  NOT NULL,"
-                                       + "`myfile`  int(10)  NOT NULL,"
-                                       + "`lasdate` date  NOT NULL," + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-                       create = "CREATE TABLE `doctag` ("
-                                       + "`rid`     int(10)  UNSIGNED NOT NULL auto_increment,"
-                                       + "`doc`     int(10)  NOT NULL,"
-                                       + "`owner`   int(10)  NOT NULL,"
-                                       + "`isnew`   char(1)  NOT NULL," + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-                       // Document types
-                       create = "CREATE TABLE `doctype` ("
-                                       + "`rid`    int(10)  UNSIGNED NOT NULL auto_increment,"
-                                       + "`name`   tinytext NOT NULL,"
-                                       + "`state`  enum('inCHECK','APPROVED') NOT NULL default 'inCHECK',"
-                                       + "`step`   tinytext NOT NULL," + "`result` tinytext,"
-                                       + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-                       // Document types dependencies
-                       create = "CREATE TABLE `docuse` (" + "`owner` int(10) NOT NULL,"
-                                       + "`rid`   int(10) NOT NULL"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-
-                       // ValidationCycle related object
-                       create = "CREATE TABLE `cycle` ("
-                                       + "`rid`   int(10)  UNSIGNED NOT NULL auto_increment,"
-                                       + "`type`      int(10)  NOT NULL," + "`publisher` int(10),"
-                                       + "`reviewer`  int(10)," + "`approver`  int(10),"
-                                       + "`signatory` int(10)," + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-
-                       // Timestamp related object
-                       create = "CREATE TABLE `stamp` ("
-                                       + "`rid`     int(10)  UNSIGNED NOT NULL auto_increment,"
-                                       + "`type`    enum('PROMOTION','REVIEW','APPROVAL','ACCEPTANCE','DISTRIBUTION','REFUSAL') NOT NULL,"
-                                       + "`author`  int(10)  NOT NULL,"
-                                       + "`date`    datetime NOT NULL," + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-
-                       // KnowledgeElements objects
-                       create = "CREATE TABLE `knowelm` ("
-                                       + "`rid`    int(10)  UNSIGNED NOT NULL auto_increment,"
-                                       + "`type`   int(10)  NOT NULL,"
-                                       + "`owner`  int(10)  NOT NULL,"
-                                       + "`state`  enum('inWORK','inDRAFT','inCHECK','APPROVED') NOT NULL default 'inDRAFT',"
-                                       + "`title`  tinytext NOT NULL,"
-                                       + "`value`  text     NOT NULL,"
-                                       + "`author` int(10)  NOT NULL,"
-                                       + "`date`   date     NOT NULL," + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-                       // KnowledgeElement types
-                       create = "CREATE TABLE `knowtype` ("
-                                       + "`rid`  int(10) UNSIGNED NOT NULL auto_increment,"
-                                       + "`name` tinytext NOT NULL,"
-                                       + "`state`  enum('inWORK','inCHECK','APPROVED') NOT NULL default 'inCHECK',"
-                                       + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-
-                       // SimulationContext objects
-                       create = "CREATE TABLE `contelm` ("
-                                       + "`rid`     int(10) UNSIGNED NOT NULL auto_increment,"
-                                       + "`type`    int(10) NOT NULL,"
-                                       + "`step`    int(10) NOT NULL,"
-                                       + "`state`   enum('inCHECK','APPROVED') NOT NULL default 'inCHECK',"
-                                       + "`value`   text NOT NULL,"
-                                       + "`counter` int(10)  UNSIGNED NOT NULL,"
-                                       + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-                       // SimulationContext types
-                       create = "CREATE TABLE `contype` ("
-                                       + "`rid`  int(10)  UNSIGNED NOT NULL auto_increment,"
-                                       + "`name` tinytext NOT NULL,"
-                                       + "`state`  enum('inCHECK','APPROVED') NOT NULL default 'inCHECK',"
-                                       + "`step` int(10)  NOT NULL," + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-
-                       // Many-to-many association between ProjectElement (Study and Scenario) and SimulationContext
-                       create = "CREATE TABLE `projext` (" + "`owner` int(10) NOT NULL,"
-                                       + "`ordex` int(10) NOT NULL," + "`rid`   int(10) NOT NULL"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-
-                       // File objects
-                       create = "CREATE TABLE `file` ("
-                                       + "`rid`     int(10)  UNSIGNED NOT NULL,"
-                                       + "`format`  tinytext NOT NULL,"
-                                       + "`path`    tinytext NOT NULL,"
-                                       + "`date`    date     NOT NULL," + "PRIMARY KEY (`rid`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-
-                       // Reference objects
-                       create = "CREATE TABLE `refid` (" + "`cycle` int(10) NOT NULL,"
-                                       + "`base`  int(10) NOT NULL," + "PRIMARY KEY (`cycle`)"
-                                       + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
-                       request.execute(create);
-               }
-       }
-
+       /**
+        * The job-class for database schema version ckeck.
+        * @author dbc
+        *
+        */
        protected class CheckVersion implements Work {
-               // --------------------------------------------
+               /** 
+                * {@inheritDoc}
+                * @see org.hibernate.jdbc.Work#execute(java.sql.Connection)
+                */
                public void execute(Connection connex) throws SQLException {
                        DatabaseMetaData dbmdata = connex.getMetaData();
                        String dbname = connex.getCatalog();
@@ -235,6 +85,9 @@ public class Database extends org.splat.dal.dao.kernel.Database {
        private Database() {
        }
 
+       /**
+        * Check version of the database schema.
+        */
        private void checkVersion() {
                getSessionFactory().getCurrentSession().doWork(new CheckVersion());
        }
@@ -257,8 +110,6 @@ public class Database extends org.splat.dal.dao.kernel.Database {
 
                // Creation of the SIMER SQL tables
                Session session = Database.getSession();
-               session.doWork(new CreateTables()); // May throw SQLException if the SIMER database does not exist
-               session.flush();
 
                // Population of the database with customized data
                this.populate();
@@ -273,7 +124,7 @@ public class Database extends org.splat.dal.dao.kernel.Database {
 
        public void configure(Properties reprop) throws IOException {
                // --------------------------------------------
-               basepath = reprop.getProperty("repository");
+               String basepath = reprop.getProperty("repository");
                getRepositoryService().setBasepath(basepath);
                getIndexService().configure();
        }
@@ -302,117 +153,10 @@ public class Database extends org.splat.dal.dao.kernel.Database {
        // Public services
        // ==============================================================================================================================
 
-       public static File getDownloadDirectory(User user) {
-               return my.getRepositoryService().getDownloadDirectory(user);
-       }
-
-       public static String getTemplatePath() {
-               return my.getRepositoryService().getTemplatePath();
-       }
-
        public static String getRepositoryVaultPath() {
                return my.getRepositoryService().getRepositoryVaultPath();
        }
 
-       public static Document selectDocument(int index) {
-               // -------------------------------------------------
-               StringBuffer query = new StringBuffer("from Document where rid='")
-                               .append(index).append("'");
-               return (Document) Database.getSession().createQuery(query.toString())
-                               .uniqueResult();
-       }
-
-       public static Document selectDocument(String refid, String version) {
-               // --------------------------------------------------------------------
-               StringBuffer query = new StringBuffer("from Document where did='")
-                               .append(refid).append("' and version='").append(version)
-                               .append("'");
-               return (Document) Database.getSession().createQuery(query.toString())
-                               .uniqueResult();
-       }
-
-       public static SimulationContext selectSimulationContext(int index) {
-               // -------------------------------------------------------------------
-               StringBuffer query = new StringBuffer(
-                               "from SimulationContext where rid='").append(index).append("'");
-               return (SimulationContext) Database.getSession().createQuery(
-                               query.toString()).uniqueResult();
-       }
-
-       public static SimulationContext selectSimulationContext(
-                       SimulationContextType celt, String value) {
-               // --------------------------------------------------------------------------------------------------
-               SimulationContext result = null;
-               try {
-                       SimulationContext.Properties cprop = new SimulationContext.Properties();
-                       List<SimulationContext> clist = selectSimulationContextsWhere(cprop
-                                       .setType(celt).setValue(value));
-                       if (!clist.isEmpty())
-                               result = clist.get(0); // Supposed being the most used one if many exist
-               } catch (InvalidPropertyException error) {
-                       logger.info("Attempt to select a simulation context \""
-                                       + celt.getName() + "\" with an invalid value.");
-               }
-               return result;
-       }
-
-       @SuppressWarnings("unchecked")
-       public static List<SimulationContext> selectSimulationContextsWhere(
-                       SimulationContext.Properties cprop) {
-               // --------------------------------------------------------------------------------------------------------
-               StringBuffer query = new StringBuffer("from SimulationContext");
-               String separator = " where";
-               SimulationContextType celt = cprop.getType();
-               String value = cprop.getValue();
-               ProgressState state = cprop.getProgressState();
-               String order = "";
-
-               if (celt != null) {
-                       query = query.append(separator).append(" type='").append(
-                                       celt.getIndex()).append("'");
-                       separator = " and";
-                       order = " order by value asc";
-               }
-               if (value != null) {
-                       query = query.append(separator).append(" value='").append(value)
-                                       .append("'");
-                       separator = " and";
-               }
-               if (state != null) {
-                       query = query.append(separator).append(" state='").append(state)
-                                       .append("'");
-                       if (celt == null)
-                               order = " order by type asc";
-               }
-               query.append(order);
-               return (List<SimulationContext>) Database.getSession().createQuery(
-                               query.toString()).list();
-       }
-
-       protected static IDBuilder selectIDBuilder(int cycle) {
-               // ------------------------------------------------------
-               StringBuffer buffer = new StringBuffer("from IDBuilder where cycle='")
-                               .append(cycle).append("'");
-               String qstring = buffer.toString();
-               Query query = Database.getSession().createQuery(qstring);
-               IDBuilder result = (IDBuilder) query.uniqueResult();
-
-               return result;
-       }
-
-       public static IDBuilder selectIDBuilder(Date date) {
-               // ------------------------------------------------------
-               SimpleDateFormat year = new SimpleDateFormat("yyyy");
-               String cycle = year.format(date);
-               StringBuffer buffer = new StringBuffer("from IDBuilder where cycle='")
-                               .append(cycle).append("'");
-               String qstring = buffer.toString();
-               Query query = Database.getSession().createQuery(qstring);
-               IDBuilder result = (IDBuilder) query.uniqueResult();
-
-               return result;
-       }
-
        /**
         * @return
         */
index 7fdc84a0c92dc74b66a9a630f5b1afc5864c173f..61d6169858be7a5c21d743eaa45c47a3fce9b75c 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 7726eeefa6d7e27bb57b30c590b362e71ed6c25a..65c5fb851b64625efea00bc21412d6147e67375c 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 5f7e7950470282c25435c6ce8046961cb5a455b9..7ee70a896bb17d5f0db020ee658a9e6f641cc05c 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index dfc5e90fb5a723542a1e5f79f751adf12054e801..5f774341b0b2677a0745682c39c50f99ea615aaf 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 1bf937ff388bd8ab9e9b08327cb0ffa8f451b79a..9f8eb48966e3a0677046a53b0a502aa96f4b13ea 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 420e9ba0e69d0ee137e4f60e5a04d691cd23e9b3..52eac134c0a0e0cf990d06b8c6ea2dc011ae43bc 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 38e5ad6e765921b9cdaef7cbcede63c60a1bef85..a719d1ef9c6af695b93550ee18ed371c8954ff58 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index e59e606d246758471397b89aeca618184a9c3db5..08557addbc63b992ce1405c929218b4bf1db8dc4 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index ccf72ec4b9ec2d1390c136a1422a5c87e060cc61..18db28db54c46a0e277c07534be906d0275373f7 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 6e3d918662240f2c192a0523ab350d24f19f4068..2cd87ae8bb20956687239cc96987c9f69bcb7c7f 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 264d5b4e9080ae6f8e53b757b7975fb20f3b7db6..960c226cce612065d2907a59ffaa64e6ff6fc5c0 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index c7634f63562d95491e42860a3ee5c4094bb08488..2e5a78ce8539c41d76f284a4e9a992981145c50c 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 0122d217e6cf0a42440aa86e8b55832aa61ad1f8..e2cdd326c2e30a76cfd5572e2f4d244fd4c06a2b 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 33bcd15044099edc721c4c28eb65699d0d6648e4..7342d7240f6ea5923cc826647aab15bcb0c0118e 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 404d80b953527e9bcdcbb3d8523b2873c50e86ad..bcf19377f1c184b8e9ec26fcd98aa5860449ef56 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index a26718156ff2d226629ed27b59d22f4808dd259e..f43e4bb28b50f8f6f5ea2e76433c136fcfb819e2 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 8305e689addccf9e04360428d6d2c32ade105df5..2333ff237bdf03a41521924e03346fc0316f986e 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 7c9782155c7ecf4cc0cd4580a848a25b4c7a873a..3abd7cfb91a003f95ac5d6763751fd55238f7b15 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 48d6e4c62d5fb070b850530fddddcc87b43177be..268554d8f94d4bae48da7a0d85ac0abbf089dfe0 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 10dfb52cf48a5ce6936879c0983257ce02316c66..68dc7f32a793fe605f208ad835701e0e53119146 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 6ae5c646ff8e056f6226ae9fc535570e057bf5ab..13990157af9c4d56c1b1345eb2bd14bd28755db2 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 93aa81ff7340a220eed4df901bba729db4eb7d9c..95ac8ff3527c3e8e7a4ae5962d4f7cbbba36ab70 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index b3c530c649cfdde0019c96efd604fcc3653827cc..9a90f508260282f28253b8478e493f468161e0f3 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 95c195f0ffb9d3500e70ea15cdcce6599221c747..d67e01a27e9095bb3c064323bd367c55af1fbe79 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 99e1da51a839e448237142ab7cfa9303eb93b781..f4d743f6e5a45dcae807a3d85daac5e53b24a42a 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index c2e51a45234a41df8f94cf5187bd308d7d9af4b3..a1d1654848d5f566f0117b431e141967c49f6ae3 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 6a8251641d2ec4917a2920963299b1dd9265f3aa..4090e077cd47af2d51cc8cb47cf093a38022a8e0 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 5c8fe48b095863d109320f7317181d946897d7d5..7d96c49da8777fe3c99e7beb090115518fdfa598 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 47e13a3dfdd126954215393941c05291232b195c..c281679347058ac81b74a17c4f67f6572c26c81e 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 35700be7fcebe62f6315b4239ad74a72d1f41af0..2e84f015a2881926be88eb2d1a351e762e7bc811 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index 34091d15a38ff0a7bce6a7203dfc764d153f558d..ab14a5025a51a0f1635fd2c4fb8dfaa0df07d16a 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index a15006ee5c4b4ce48d2a400252b8c20d461d93ca..53f73d849fe6fec296d09834611e9f171384bce9 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index b4c0024a8c2ef34460af8d0fcb41ce754ddd399c..dc811732b9a7085c60013648459c3dfa95fa7801 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 7d59b81921cfcee8f525aa680361b7a2d48d8192..ca27e8b045361bdd6a2230e6e7e4b85cfaf1cc3c 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index f91231f8185c3133957741687e09a05369e9084e..fd26e260618cc75e36870ad2aa471a8405f33ff0 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 86bf5b60960f9c42c29e2d8b4e58bb77f36770b1..3f73af8f9b803775cd69974a25bea15f09bb33dc 100644 (file)
@@ -5,6 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
index e9eefeb66405989e0cad0241ca750b8982cd0e2d..e0fa88e75da57c085cafcc45be368a2776afcc6f 100644 (file)
@@ -155,13 +155,13 @@ public class UserDirectory {
        @SuppressWarnings("unchecked")                            // For the casting List<User>
        public static List<User> selectAllUsers () {
 //  ------------------------------------------
-         String query = "FROM users order by last asc, first asc";
+         String query = "FROM User order by last asc, first asc";
          return (List<User>)Database.getSession().createQuery(query).list();
        }
 
        public static User selectUser (String username) {
 //  -----------------------------------------------
-         StringBuffer  query = new StringBuffer("FROM users where username='").append(username).append("'");
+         StringBuffer  query = new StringBuffer("FROM User where username='").append(username).append("'");
          return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
        }
 
@@ -169,7 +169,7 @@ public class UserDirectory {
 //  ----------------------------------------------------------------
 //WARNING: For not encoding the password here, we better call a selectUsersWhere(User.Properties),
 //         but this requires a getPassword in User.Properties nested class.
-         StringBuffer  query = new StringBuffer("FROM users where username='").append(username).append("' and password");
+         StringBuffer  query = new StringBuffer("FROM User where username='").append(username).append("' and password");
          if (password == null) query = query.append(" is null");
          else                  query = query.append("='").append(String.valueOf(password.hashCode())).append("'");
          
@@ -178,14 +178,14 @@ public class UserDirectory {
 
     public static User selectUser (int index) {
 //  -----------------------------------------
-      StringBuffer  query = new StringBuffer("FROM users where rid='").append(index).append("'");
+      StringBuffer  query = new StringBuffer("FROM User where rid='").append(index).append("'");
       return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
        }
 
     @SuppressWarnings("unchecked")
        public static List<User> selectUsersWhere (User.Properties... uprop) {
 //  --------------------------------------------------------------------
-      StringBuffer query     = new StringBuffer("FROM users");
+      StringBuffer query     = new StringBuffer("FROM User");
       String       separator = " where (";
       String       value;
 
index a956b69b1e3991080b04cbce751c969dad27827c..952f52954354777c0bb9fdf0d95ceeae2c9f1987 100644 (file)
@@ -10,7 +10,6 @@
 package org.splat.service;
 
 import org.splat.dal.bo.som.Document;
-import org.splat.dal.bo.som.Publication;
 import org.splat.dal.bo.som.Document.Properties;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
@@ -18,6 +17,8 @@ import org.splat.kernel.NotApplicableException;
 import org.splat.som.Step;
 
 /**
+ * Document service interface.
+ * 
  * @author RKV
  * 
  */
@@ -26,9 +27,16 @@ public interface DocumentService {
        /**
         * Defines this document.
         * 
+        * @param aDoc
+        *            the document to define
         * @param dprop
         *            the properties of the document
-        * 
+        * @throws MissedPropertyException
+        *             if a mandatory property is missed
+        * @throws InvalidPropertyException
+        *             if a property doesn't exist
+        * @throws NotApplicableException
+        *             if the document is undefined
         * @see Step#createDocument(Properties)
         * @see #isUndefined()
         */
@@ -36,5 +44,40 @@ public interface DocumentService {
                        throws MissedPropertyException, InvalidPropertyException,
                        NotApplicableException;
 
+       /**
+        * Find a document by its id.
+        * 
+        * @param index
+        *            document id
+        * @return found document
+        */
+       public Document selectDocument(long index);
+
+       /**
+        * Find a document by its reference and version.
+        * 
+        * @param refid
+        *            document reference
+        * @param version
+        *            document version
+        * @return found document
+        */
+       public Document selectDocument(String refid, String version);
+
+       /**
+        * Generate document reference.
+        * 
+        * @param aDoc
+        *            the document
+        * @param dprop
+        *            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
+        * @return a directory
+        */
+       public java.io.File getSaveDirectory(Document aDoc);
 }
index fef0b9931e8e160367f3a7df3a902348a4c151d5..d922281e761e42f555d9645acd96a83b36d4a5b9 100644 (file)
@@ -7,7 +7,7 @@
  * @version        $Revision$
  *****************************************************************************/
 
-package org.splat.service; 
+package org.splat.service;
 
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
@@ -18,23 +18,66 @@ import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.Document.Properties;
 import org.splat.dal.dao.som.Database;
+import org.splat.dal.dao.som.DocumentDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.NotApplicableException;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.service.technical.ProjectSettingsServiceImpl;
 import org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming;
-import org.splat.som.Step;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
+ * Document service implementation.
+ * 
  * @author RKV
- *
+ * 
  */
 public class DocumentServiceImpl implements DocumentService {
 
+       /**
+        * Injected study service.
+        */
        private StudyService _studyService;
+       /**
+        * Injected project settings service.
+        */
        private ProjectSettingsService _projectSettingsService;
+       /**
+        * Injected document service.
+        */
+       private DocumentDAO _documentDAO;
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.DocumentService#selectDocument(long)
+        */
+       @Transactional(readOnly = true)
+       public Document selectDocument(long index) {
+               // -------------------------------------------------
+               return getDocumentDAO().get(index);
+       }
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.DocumentService#selectDocument(java.lang.String, java.lang.String)
+        */
+       public Document selectDocument(String refid, String version) {
+               // --------------------------------------------------------------------
+               StringBuffer query = new StringBuffer("from Document where did='")
+                               .append(refid).append("' and version='").append(version)
+                               .append("'");
+               return (Document) Database.getSession().createQuery(query.toString())
+                               .uniqueResult();
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.DocumentService#generateDocumentId(org.splat.dal.bo.som.Document, org.splat.dal.bo.som.Document.Properties)
+        */
        public void generateDocumentId(Document aDoc, Properties dprop) {
                Study owner = null;
                if (dprop.getOwner() instanceof Study)
@@ -48,19 +91,31 @@ public class DocumentServiceImpl implements DocumentService {
                String path = owner.getReference();
                ProjectSettingsService.Step step = ProjectSettingsServiceImpl
                                .getStep(aDoc.getStep());
-               aDoc.setDid( new StringBuffer(path).append(".%").append(aDoc.suformat).toString()); // Document reference
+               aDoc.setDid(new StringBuffer(path).append(".%").append(
+                               Document.suformat).toString()); // Document reference
                path = new StringBuffer(year).append("/").append(path).append("/")
-                               .append(step.getPath()) // File path relative to the repository vault
-                               .append(filename).append(".").append(aDoc.getFile().getFormat()) // File name and extension
+                               .append(step.getPath())
+                               // File path relative to the repository vault
+                               .append(filename).append(".")
+                               .append(aDoc.getFile().getFormat()) // File name and extension
                                .toString();
                aDoc.getFile().changePath(path);
        }
 
+       /**
+        * Generate encoded document file name according to the naming scheme from project settings.
+        * 
+        * @param aDoc
+        *            the document
+        * @param scope
+        *            the study
+        * @return document reference name
+        */
        private String generateEncodedName(Document aDoc, Study scope) {
                // ------------------------------------------------
                StringBuffer encoding = new StringBuffer();
                FileNaming scheme = getProjectSettings().getFileNamingScheme();
-               DecimalFormat tostring = new DecimalFormat(aDoc.suformat);
+               DecimalFormat tostring = new DecimalFormat(Document.suformat);
 
                int number = getStudyService().generateLocalIndex(scope);
 
@@ -68,11 +123,21 @@ public class DocumentServiceImpl implements DocumentService {
                        encoding.append(scope.getReference()).append(".").append(
                                        tostring.format(number));
                } else { // title and (temporarily) asis
-                       encoding.append(aDoc.getTitle()).append(".").append(tostring.format(number));
+                       encoding.append(aDoc.getTitle()).append(".").append(
+                                       tostring.format(number));
                }
                return encoding.toString();
        }
 
+       /**
+        * Get encoded root name for a document file.
+        * 
+        * @param aDoc
+        *            the document
+        * @param scope
+        *            the study
+        * @return file name
+        */
        private String getEncodedRootName(Document aDoc, Study scope) {
                // -----------------------------------------------
                FileNaming scheme = getProjectSettings().getFileNamingScheme();
@@ -84,16 +149,13 @@ public class DocumentServiceImpl implements DocumentService {
        }
 
        /**
-        * Defines this document.
-        * 
-        * @param dprop
-        *            the properties of the document
+        * {@inheritDoc}
         * 
-        * @see Step#createDocument(Properties)
-        * @see #isUndefined()
+        * @see org.splat.service.DocumentService#initialize(org.splat.dal.bo.som.Document, org.splat.dal.bo.som.Document.Properties)
         */
-       public void initialize(Document aDoc, Properties dprop) throws MissedPropertyException,
-                       InvalidPropertyException, NotApplicableException {
+       public void initialize(Document aDoc, Properties dprop)
+                       throws MissedPropertyException, InvalidPropertyException,
+                       NotApplicableException {
                // --------------------------------------------
                if (!aDoc.isUndefined())
                        throw new NotApplicableException(
@@ -108,10 +170,11 @@ public class DocumentServiceImpl implements DocumentService {
                // throw new InvalidPropertyException("step");
                // }
                aDoc.setTitle(dprop.getName());
-               aDoc.getFile().changePath(aDoc.getFile().getRelativePath().replace("%n",
-                               getEncodedRootName(aDoc, (Study) dprop.getOwner())));
+               aDoc.getFile().changePath(
+                               aDoc.getFile().getRelativePath().replace("%n",
+                                               getEncodedRootName(aDoc, (Study) dprop.getOwner())));
                if (aDoc.getHistory() == -1)
-                       aDoc.setHistory( 0 );
+                       aDoc.setHistory(0);
                if (dprop.getDate() == null) {
                        Calendar current = Calendar.getInstance();
                        aDoc.setLastModificationDate(current.getTime()); // Today
@@ -121,8 +184,21 @@ public class DocumentServiceImpl implements DocumentService {
                Database.getSession().update(aDoc);
        }
 
+       public java.io.File getSaveDirectory(Document aDoc) {
+               String mypath = Database.getRepositoryVaultPath()
+                               + aDoc.getSourceFile().getRelativePath();
+               String[] table = mypath.split("/");
+
+               // Cutting the filename
+               StringBuffer path = new StringBuffer(table[0]);
+               for (int i = 1; i < table.length - 1; i++)
+                       path = path.append("/").append(table[i]);
+               return new java.io.File(path.append("/").toString());
+       }
+
        /**
         * Get the studyService.
+        * 
         * @return the studyService
         */
        public StudyService getStudyService() {
@@ -131,7 +207,9 @@ public class DocumentServiceImpl implements DocumentService {
 
        /**
         * Set the studyService.
-        * @param studyService the studyService to set
+        * 
+        * @param studyService
+        *            the studyService to set
         */
        public void setStudyService(StudyService studyService) {
                _studyService = studyService;
@@ -156,4 +234,23 @@ public class DocumentServiceImpl implements DocumentService {
                _projectSettingsService = projectSettingsService;
        }
 
+       /**
+        * Get the documentDAO.
+        * 
+        * @return the documentDAO
+        */
+       public DocumentDAO getDocumentDAO() {
+               return _documentDAO;
+       }
+
+       /**
+        * Set the documentDAO.
+        * 
+        * @param documentDAO
+        *            the documentDAO to set
+        */
+       public void setDocumentDAO(DocumentDAO documentDAO) {
+               _documentDAO = documentDAO;
+       }
+
 }
index b9fd9d5e536cd043cd96ac8e3a2a4dbc692de571..7f9564d1fd2fd0e303500e92abe8c26b39d82ced 100644 (file)
@@ -13,12 +13,23 @@ import org.splat.dal.bo.som.ProjectElement;
 import org.splat.som.Step;
 
 /**
+ * Project element service interface.
  * @author RKV
  * 
  */
 public interface ProjectElementService {
 
+       /**
+        * Get the first activity of the project element.
+        * @param elem a study or a scenario 
+        * @return the first activity (step) of the project element
+        */
        public Step getFirstStep(ProjectElement elem);
 
+       /**
+        * Get activities of the project element.
+        * @param elem a study or a scenario
+        * @return array of activities (steps).
+        */
        public Step[] getSteps(ProjectElement elem);
 }
index 031b2ee2f51432fb4f1aaa3432437c5532a46f9e..a8a5080d6b7c24767ca825cf089f8e88204f5c7a 100644 (file)
@@ -14,30 +14,38 @@ import java.util.List;
 
 import org.splat.dal.bo.som.ProjectElement;
 import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.technical.ProjectSettingsServiceImpl;
 import org.splat.som.Step;
 
 /**
+ * Project element service implementation.
  * @author RKV
  * 
  */
 public class ProjectElementServiceImpl implements ProjectElementService {
 
+       /**
+        * Injected project settings service.
+        */
        private ProjectSettingsService _projectSettingsService;
 
+       /** 
+        * {@inheritDoc}
+        * @see org.splat.service.ProjectElementService#getFirstStep(org.splat.dal.bo.som.ProjectElement)
+        */
        public Step getFirstStep(ProjectElement elem) {
-               // ---------------------------
                return getSteps(elem)[0];
        }
 
        public Step getLastStep(ProjectElement elem) {
-               // --------------------------
                Step[] mystep = getSteps(elem); // For getting the folders length, if null
                return mystep[mystep.length - 1];
        }
 
+       /** 
+        * {@inheritDoc}
+        * @see org.splat.service.ProjectElementService#getSteps(org.splat.dal.bo.som.ProjectElement)
+        */
        public Step[] getSteps(ProjectElement elem) {
-               // -------------------------
                if (elem.getFolders() == null) {
                        List<ProjectSettingsService.Step> steps = getProjectSettings()
                                        .getStepsOf(elem.getClass());
index 2b629c07eabbe54fd0ed79428d9a99f20e2f86f0..a2eb497db5698c532ba1f01f097190aeb071ec9f 100644 (file)
@@ -24,24 +24,40 @@ import org.splat.som.Revision;
 import org.splat.som.Step;
 
 /**
- * @author RKV
+ * Publication service interface.
  * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 public interface PublicationService {
 
+       /**
+        * Copy the publication to the given project element.
+        * 
+        * @param aPublication
+        *            the publication to copy
+        * @param publisher
+        *            the target project element
+        * @return the created copy of the publication
+        */
        public Publication copy(Publication aPublication, ProjectElement publisher);
 
        /**
         * Returns the study Step into which the document version referenced by this publication has been published.
+        * 
+        * @param aPublication
+        *            the document publication
+        * @return study step
         */
        public Step getInvolvedStep(Publication aPublication);
 
        /**
         * Promotes the document referenced by this publication from In-Check to Approved state, if not out-dated, and attaches the
-        * corresponding time-stamp to the document.</br> If the promoted document is the final result of the owner study, the study is itself
-        * is promoted as well.</br> </br> Limitation: the way this promotion is propagated to the study supposes that the study has only ONE
+        * corresponding time-stamp to the document.<br/> If the promoted document is the final result of the owner study, the study is itself
+        * is promoted as well.<br/> <br/> Limitation: the way this promotion is propagated to the study supposes that the study has only ONE
         * final result document.
         * 
+        * @param aPublication
+        *            the document publication
         * @param adate
         *            the date of approval
         * @return true if the approval succeeded
@@ -53,11 +69,13 @@ public interface PublicationService {
        public Timestamp approve(Publication aPublication, Date adate);
 
        /**
-        * Demotes the document referenced by this publication to In-Work state, and removes the Promoter of the document, if exist.</br> The
-        * In-Draft state is skipped (direct demotion to In-Work) if the validation cycle of the document does not include the review step.</br>
-        * If the demoted document is the final result of the owner study, the study is itself is demoted as well.</br> </br> Limitation: the
+        * Demotes the document referenced by this publication to In-Work state, and removes the Promoter of the document, if exist.<br/> The
+        * In-Draft state is skipped (direct demotion to In-Work) if the validation cycle of the document does not include the review step.<br/>
+        * If the demoted document is the final result of the owner study, the study is itself is demoted as well.<br/> <br/> Limitation: the
         * way this demotion is propagated to the study supposes that the study has only ONE final result document.
         * 
+        * @param aPublication
+        *            the document publication
         * @return true if the demotion succeeded
         * @see #getProgressState()
         * @see DocumentRights#canDemote()
@@ -67,9 +85,11 @@ public interface PublicationService {
 
        /**
         * Undo the review operation by demoting the document referenced by this publication from In-Check to In-Draft state and removing the
-        * Reviewer.</br> If the demoted document is the final result of the owner study, the study is itself is demoted as well.</br> </br>
+        * Reviewer.<br/> If the demoted document is the final result of the owner study, the study is itself is demoted as well.<br/> <br/>
         * Limitation: the way this demotion is propagated to the study supposes that the study has only ONE final result document.
         * 
+        * @param aPublication
+        *            the document publication
         * @return true if the demotion succeeded
         * @see #getProgressState()
         * @see #review()
@@ -80,11 +100,15 @@ public interface PublicationService {
 
        /**
         * Promotes the document referenced by this publication from In-Work to In-Draft or In-Check state, if not out-dated, and attaches the
-        * corresponding time-stamp to the document.</br> The In-Draft state is skipped (direct promotion to In-Check) if the validation cycle
-        * of the document does not include the review step.</br> Also, if the promoted document is the final result of the owner study, the
-        * study is itself promoted as well.</br> This operation can be undo-ed by demote().</br> </br> Limitation: the way this promotion is
+        * corresponding time-stamp to the document.<br/> The In-Draft state is skipped (direct promotion to In-Check) if the validation cycle
+        * of the document does not include the review step.<br/> Also, if the promoted document is the final result of the owner study, the
+        * study is itself promoted as well.<br/> This operation can be undo-ed by demote().<br/> <br/> Limitation: the way this promotion is
         * propagated to the study supposes that the study has only ONE final result document.
         * 
+        * @param aPublication
+        *            the document publication
+        * @param pdate
+        *            the date of promotion
         * @return true if the promotion succeeded
         * @see #getProgressState()
         * @see #demote()
@@ -95,10 +119,12 @@ public interface PublicationService {
 
        /**
         * Promotes the document referenced by this publication from In-Draft to In-Check state, if not out-dated, and attaches the
-        * corresponding time-stamp to the document.</br> If the promoted document is the final result of the owner study, the study is itself
-        * is promoted as well.</br> This operation can be undo-ed by invalidate().</br> </br> Limitation: the way this promotion is propagated
-        * to the study supposes that the study has only ONE final result document.
+        * corresponding time-stamp to the document.<br/> If the promoted document is the final result of the owner study, the study is itself
+        * is promoted as well.<br/> This operation can be undo-ed by invalidate().<br/> <br/> Limitation: the way this promotion is
+        * propagated to the study supposes that the study has only ONE final result document.
         * 
+        * @param aPublication
+        *            the document publication
         * @param rdate
         *            the date of review
         * @return true if the review succeeded
@@ -115,6 +141,8 @@ public interface PublicationService {
         * the document being automatically set accordingly. If the given state is In-Draft and the document is final result of the owner study,
         * this automatically promotes the study to In-Draft.
         * 
+        * @param aPublication
+        *            the document publication
         * @param state
         *            the required progress state
         * @throws FileNotFoundException
@@ -126,12 +154,14 @@ public interface PublicationService {
                        throws FileNotFoundException, NotApplicableException;
 
        /**
-        * Publishes the document referenced by this publication into the owner Project Element under the given revision number.<br/>
-        * The state of the referenced document is supposed being automatically set according to the given revision number, but, due to the
-        * versioning scheme, as it is not possible to differentiate In-Work and In-Draft states, this function has been deprecated (it is
-        * currently used only for the need of integration of Microsoft Office which anyway has to be redesigned). <br/>
-        * Note: in the context of branch versioning, the given revision may be modified by an update of the branch name.
+        * Publishes the document referenced by this publication into the owner Project Element under the given revision number.<br/> The state
+        * of the referenced document is supposed being automatically set according to the given revision number, but, due to the versioning
+        * scheme, as it is not possible to differentiate In-Work and In-Draft states, this function has been deprecated (it is currently used
+        * only for the need of integration of Microsoft Office which anyway has to be redesigned). <br/> Note: in the context of branch
+        * versioning, the given revision may be modified by an update of the branch name.
         * 
+        * @param aPublication
+        *            the document publication
         * @param newvers
         *            the required revision number
         * @throws FileNotFoundException
index 7fb730ba70bb0d6210f438641b1b4fc7997c9138..e2e530214d12c71196bf1c657701e1edeff93e41 100644 (file)
@@ -32,23 +32,43 @@ import org.splat.dal.dao.som.Database;
 import org.splat.kernel.NotApplicableException;
 import org.splat.manox.Reader;
 import org.splat.manox.Toolbox;
-import org.splat.som.DocumentRights;
 import org.splat.som.Revision;
 import org.splat.som.Step;
 
 /**
- * @author RKV
+ * Publication service implementation.
  * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 public class PublicationServiceImpl implements PublicationService {
 
+       /**
+        * Injected study service.
+        */
        private StudyService _studyService;
+       /**
+        * Injected study service.
+        */
        private StepService _stepService;
+       /**
+        * Injected study service.
+        */
        private DocumentTypeService _documentTypeService;
+       /**
+        * Injected study service.
+        */
        private ProjectElementService _projectElementService;
+       /**
+        * Injected simulation context service.
+        */
+       private SimulationContextService _simulationContextService;
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.PublicationService#copy(org.splat.dal.bo.som.Publication, org.splat.dal.bo.som.ProjectElement)
+        */
        public Publication copy(Publication aPublication, ProjectElement publisher) {
-               // -----------------------------------------------------
                Publication copy = new Publication();
                copy.setValue(aPublication.value());
                copy.setStep(aPublication.getStep()); // May not be initialized yet
@@ -61,18 +81,9 @@ public class PublicationServiceImpl implements PublicationService {
        }
 
        /**
-        * Promotes the document referenced by this publication from In-Check to Approved state, if not out-dated, and attaches the
-        * corresponding time-stamp to the document.</br> If the promoted document is the final result of the owner study, the study is itself
-        * is promoted as well.</br> </br> Limitation: the way this promotion is propagated to the study supposes that the study has only ONE
-        * final result document.
+        * {@inheritDoc}
         * 
-        * @param adate
-        *            the date of approval
-        * @return true if the approval succeeded
-        * @see #getProgressState()
-        * @see DocumentRights#canApprove()
-        * @see DocumentType#isStudyResult()
-        * @see Study#getApproverOf(Publication)
+        * @see org.splat.service.PublicationService#approve(org.splat.dal.bo.som.Publication, java.util.Date)
         */
        public Timestamp approve(Publication aPublication, Date adate) {
                // -------------------------------------
@@ -85,8 +96,8 @@ public class PublicationServiceImpl implements PublicationService {
                Study owner = aPublication.getOwnerStudy();
                ValidationCycle cycle = owner.getValidationCycleOf(type);
                User approver = cycle.getActor(ValidationStep.APPROVAL);
-               Timestamp stamp = new Timestamp(ValidationStep.APPROVAL,
-                               aPublication.value(), approver, adate);
+               Timestamp stamp = new Timestamp(ValidationStep.APPROVAL, aPublication
+                               .value(), approver, adate);
                if (!aPublication.value().promote(stamp))
                        return null;
                if (getDocumentTypeService().isStudyResult(type)
@@ -96,15 +107,9 @@ public class PublicationServiceImpl implements PublicationService {
        }
 
        /**
-        * Demotes the document referenced by this publication to In-Work state, and removes the Promoter of the document, if exist.</br> The
-        * In-Draft state is skipped (direct demotion to In-Work) if the validation cycle of the document does not include the review step.</br>
-        * If the demoted document is the final result of the owner study, the study is itself is demoted as well.</br> </br> Limitation: the
-        * way this demotion is propagated to the study supposes that the study has only ONE final result document.
+        * {@inheritDoc}
         * 
-        * @return true if the demotion succeeded
-        * @see #getProgressState()
-        * @see DocumentRights#canDemote()
-        * @see DocumentType#isStudyResult()
+        * @see org.splat.service.PublicationService#demote(org.splat.dal.bo.som.Publication)
         */
        public boolean demote(Publication aPublication) {
                // ------------------------
@@ -134,15 +139,9 @@ public class PublicationServiceImpl implements PublicationService {
        }
 
        /**
-        * Undo the review operation by demoting the document referenced by this publication from In-Check to In-Draft state and removing the
-        * Reviewer.</br> If the demoted document is the final result of the owner study, the study is itself is demoted as well.</br> </br>
-        * Limitation: the way this demotion is propagated to the study supposes that the study has only ONE final result document.
+        * {@inheritDoc}
         * 
-        * @return true if the demotion succeeded
-        * @see #getProgressState()
-        * @see #review()
-        * @see DocumentRights#canInvalidate()
-        * @see DocumentType#isStudyResult()
+        * @see org.splat.service.PublicationService#invalidate(org.splat.dal.bo.som.Publication)
         */
        public boolean invalidate(Publication aPublication) {
                // ----------------------------
@@ -159,17 +158,9 @@ public class PublicationServiceImpl implements PublicationService {
        }
 
        /**
-        * Promotes the document referenced by this publication from In-Work to In-Draft or In-Check state, if not out-dated, and attaches the
-        * corresponding time-stamp to the document.</br> The In-Draft state is skipped (direct promotion to In-Check) if the validation cycle
-        * of the document does not include the review step.</br> Also, if the promoted document is the final result of the owner study, the
-        * study is itself promoted as well.</br> This operation can be undo-ed by demote().</br> </br> Limitation: the way this promotion is
-        * propagated to the study supposes that the study has only ONE final result document.
+        * {@inheritDoc}
         * 
-        * @return true if the promotion succeeded
-        * @see #getProgressState()
-        * @see #demote()
-        * @see DocumentRights#canPromote()
-        * @see DocumentType#isStudyResult()
+        * @see org.splat.service.PublicationService#promote(org.splat.dal.bo.som.Publication, java.util.Date)
         */
        public Timestamp promote(Publication aPublication, Date pdate) {
                if (aPublication.isOutdated())
@@ -201,19 +192,9 @@ public class PublicationServiceImpl implements PublicationService {
        }
 
        /**
-        * Promotes the document referenced by this publication from In-Draft to In-Check state, if not out-dated, and attaches the
-        * corresponding time-stamp to the document.</br> If the promoted document is the final result of the owner study, the study is itself
-        * is promoted as well.</br> This operation can be undo-ed by invalidate().</br> </br> Limitation: the way this promotion is propagated
-        * to the study supposes that the study has only ONE final result document.
+        * {@inheritDoc}
         * 
-        * @param rdate
-        *            the date of review
-        * @return true if the review succeeded
-        * @see #getProgressState()
-        * @see #invalidate()
-        * @see DocumentRights#canReview()
-        * @see DocumentType#isStudyResult()
-        * @see Study#getReviewerOf(Publication)
+        * @see org.splat.service.PublicationService#review(org.splat.dal.bo.som.Publication, java.util.Date)
         */
        public Timestamp review(Publication aPublication, Date rdate) {
                if (aPublication.isOutdated())
@@ -225,8 +206,8 @@ public class PublicationServiceImpl implements PublicationService {
                Study owner = aPublication.getOwnerStudy();
                ValidationCycle cycle = owner.getValidationCycleOf(type);
                User reviewer = cycle.getActor(ValidationStep.REVIEW);
-               Timestamp stamp = new Timestamp(ValidationStep.REVIEW,
-                               aPublication.value(), reviewer, rdate);
+               Timestamp stamp = new Timestamp(ValidationStep.REVIEW, aPublication
+                               .value(), reviewer, rdate);
                if (!aPublication.value().promote(stamp))
                        return null;
                if (getDocumentTypeService().isStudyResult(type)
@@ -236,18 +217,9 @@ public class PublicationServiceImpl implements PublicationService {
        }
 
        /**
-        * Publishes the document referenced by this publication into the owner Project Element under the given revision number.<br/>
-        * The state of the referenced document is supposed being automatically set according to the given revision number, but, due to the
-        * versioning scheme, as it is not possible to differentiate In-Work and In-Draft states, this function has been deprecated (it is
-        * currently used only for the need of integration of Microsoft Office which anyway has to be redesigned). <br/>
-        * Note: in the context of branch versioning, the given revision may be modified by an update of the branch name.
+        * {@inheritDoc}
         * 
-        * @param newvers
-        *            the required revision number
-        * @throws FileNotFoundException
-        *             If the referenced document is empty
-        * @throws NotApplicableException
-        *             If the referenced document is undefined
+        * @see org.splat.service.PublicationService#saveAs(org.splat.dal.bo.som.Publication, org.splat.som.Revision)
         * @deprecated
         */
        public void saveAs(Publication aPublication, Revision newvers)
@@ -265,16 +237,9 @@ public class PublicationServiceImpl implements PublicationService {
        }
 
        /**
-        * Publishes the document referenced by this publication into the owner Project Element under the given state, the revision number of
-        * the document being automatically set accordingly. If the given state is In-Draft and the document is final result of the owner study,
-        * this automatically promotes the study to In-Draft.
+        * {@inheritDoc}
         * 
-        * @param state
-        *            the required progress state
-        * @throws FileNotFoundException
-        *             If the referenced document is empty
-        * @throws NotApplicableException
-        *             If the referenced document is undefined
+        * @see org.splat.service.PublicationService#saveAs(org.splat.dal.bo.som.Publication, org.splat.dal.bo.som.ProgressState)
         */
        public void saveAs(Publication aPublication, ProgressState state)
                        throws FileNotFoundException, NotApplicableException {
@@ -286,7 +251,8 @@ 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) hascode
+                       Database.getSession().save(aPublication); // Must be done before updating the study in order to fix this final (rid-based)
+                       // hascode
                        aPublication.value().updateAs(state);
                } else {
                        DocumentType mytype = aPublication.value().getType();
@@ -300,7 +266,7 @@ public class PublicationServiceImpl implements PublicationService {
                                                                + " state");
                        }
                        Database.getSession().save(aPublication); // Must be done before updating the study in order to fix this final (rid-based)
-                                                                                                               // hascode
+                       // hascode
                        aPublication.value().updateAs(ProgressState.inWORK);
 
                        promote(aPublication, aPublication.value()
@@ -309,8 +275,13 @@ public class PublicationServiceImpl implements PublicationService {
                updateOwner(aPublication);
        }
 
-       public void updateOwner(Publication aPublication) {
-               // ---------------------------
+       /**
+        * Update an owner of the publication.
+        * 
+        * @param aPublication
+        *            the document publication
+        */
+       private void updateOwner(Publication aPublication) {
                Session session = Database.getSession();
                Step step = getInvolvedStep(aPublication);
 
@@ -330,6 +301,16 @@ public class PublicationServiceImpl implements PublicationService {
                session.update(aPublication.getOwner());
        }
 
+       /**
+        * Propagate simulation contexts from the given config file to the publication's owner (study or step).
+        * 
+        * @param aPublication
+        *            the document publication
+        * @param from
+        *            the config file
+        * @param to
+        *            the study step
+        */
        private void forwardProperties(Publication aPublication, java.io.File from,
                        Step to) {
                // -----------------------------------------------------------
@@ -339,7 +320,7 @@ public class PublicationServiceImpl implements PublicationService {
 
                SimulationContextType.Properties sprop = new SimulationContextType.Properties()
                                .setStep(to.getStep()).setState(ProgressState.APPROVED);
-               List<SimulationContextType> contype = SimulationContext
+               List<SimulationContextType> contype = getSimulationContextService()
                                .selectTypesWhere(sprop);
                if (contype.isEmpty())
                        return; // No approved property type configured at this step
@@ -381,10 +362,15 @@ public class PublicationServiceImpl implements PublicationService {
 
        /**
         * Returns the study Step into which the document version referenced by this publication has been published.
+        * 
+        * @param aPublication
+        *            the document publication
+        * @return the study step where the document is published
         */
        public Step getInvolvedStep(Publication aPublication) {
                if (aPublication.getStep() == null) {
-                       Step[] step = getProjectElementService().getSteps(aPublication.getOwner());
+                       Step[] step = getProjectElementService().getSteps(
+                                       aPublication.getOwner());
                        for (int i = 0; i < step.length; i++) {
                                aPublication.setStep(step[i]); // The involved step necessarily exists
                                if (aPublication.value().isInto(aPublication.getStep()))
@@ -395,51 +381,90 @@ public class PublicationServiceImpl implements PublicationService {
        }
 
        /**
-        * @return
+        * Get the projectElementService.
+        * 
+        * @return the projectElementService
         */
-       private StepService getStepService() {
-               return _stepService;
+       public ProjectElementService getProjectElementService() {
+               return _projectElementService;
        }
 
-       public void setStepService(StepService stepService) {
-               _stepService = stepService;
+       /**
+        * Set the projectElementService.
+        * 
+        * @param projectElementService
+        *            the projectElementService to set
+        */
+       public void setProjectElementService(
+                       ProjectElementService projectElementService) {
+               _projectElementService = projectElementService;
+       }
+
+       /**
+        * Get the simulationContextService.
+        * 
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * 
+        * @param simulationContextService
+        *            the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
        }
 
        /**
-        * @return
+        * 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;
        }
 
        /**
-        * @return
+        * Get the stepService.
+        * @return the stepService
         */
-       public DocumentTypeService getDocumentTypeService() {
-               return _documentTypeService;
+       public StepService getStepService() {
+               return _stepService;
        }
 
-       public void setDocumentTypeService(DocumentTypeService documentTypeService) {
-               _documentTypeService = documentTypeService;
+       /**
+        * Set the stepService.
+        * @param stepService the stepService to set
+        */
+       public void setStepService(StepService stepService) {
+               _stepService = stepService;
        }
 
        /**
-        * Get the projectElementService.
-        * @return the projectElementService
+        * Get the documentTypeService.
+        * @return the documentTypeService
         */
-       public ProjectElementService getProjectElementService() {
-               return _projectElementService;
+       public DocumentTypeService getDocumentTypeService() {
+               return _documentTypeService;
        }
 
        /**
-        * Set the projectElementService.
-        * @param projectElementService the projectElementService to set
+        * Set the documentTypeService.
+        * @param documentTypeService the documentTypeService to set
         */
-       public void setProjectElementService(ProjectElementService projectElementService) {
-               _projectElementService = projectElementService;
+       public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+               _documentTypeService = documentTypeService;
        }
 }
diff --git a/Workspace/Siman-Common/src/org/splat/service/SimulationContextService.java b/Workspace/Siman-Common/src/org/splat/service/SimulationContextService.java
new file mode 100644 (file)
index 0000000..1cbf05c
--- /dev/null
@@ -0,0 +1,136 @@
+/*****************************************************************************
+ * Company         EURIWARE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   16.10.2012
+ * @author         $Author$
+ * @version        $Revision$
+ *****************************************************************************/
+
+package org.splat.service;
+
+import java.util.List;
+
+import org.splat.dal.bo.som.SimulationContext;
+import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.service.technical.ProjectSettingsService;
+
+/**
+ * Simulation context service interface.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ * 
+ */
+public interface SimulationContextService {
+
+       /**
+        * Get simulation context by its id.
+        * 
+        * @param index
+        *            simulation context id.
+        * @return found context
+        */
+       public SimulationContext selectSimulationContext(long index);
+
+       /**
+        * Find simulation context by its type and value.
+        * 
+        * @param celt
+        *            context type
+        * @param value
+        *            context value
+        * @return found context
+        */
+       public SimulationContext selectSimulationContext(
+                       SimulationContextType celt, String value);
+
+       /**
+        * Find simulation contexts by example.
+        * 
+        * @param cprop
+        *            example properties
+        * @return list of contexts
+        */
+       public List<SimulationContext> selectSimulationContextsWhere(
+                       SimulationContext.Properties cprop);
+
+       /**
+        * Create a simulation context type.
+        * 
+        * @param name
+        *            context type name
+        * @param step
+        *            activity related to this context type
+        * @return the created context type
+        * @throws InvalidPropertyException
+        *             if some property of the type to be created is invalid
+        */
+       public SimulationContextType createType(String name,
+                       ProjectSettingsService.Step step) throws InvalidPropertyException;
+
+       /**
+        * Get all simulation context types.
+        * 
+        * @return list of context types
+        */
+       public List<SimulationContextType> selectAllTypes();
+
+       /**
+        * Get simulation context types related to given activities.
+        * 
+        * @param step
+        *            the activity
+        * @return list of found context types
+        */
+       public List<SimulationContextType> selectTypesOf(
+                       ProjectSettingsService.Step... step);
+
+       /**
+        * Get simulation context types by example.
+        * @param sprop the example
+        * @return list of found context types
+        */
+       public List<SimulationContextType> selectTypesWhere(
+                       SimulationContextType.Properties sprop);
+
+       /**
+        * Get a simulation context type by its name.
+        * @param name name of the context type
+        * @return found context type
+        */
+       public SimulationContextType selectType(String name);
+
+       /**
+        * Get simulation context type by its id.
+        * 
+        * @param index
+        *            simulation context type id.
+        * @return found context type
+        */
+       public SimulationContextType selectType(long index);
+
+       /**
+        * Hold the simulation context.
+        * 
+        * @param simCtx
+        *            the context to hold.
+        */
+       public void hold(SimulationContext simCtx);
+
+       /**
+        * Release the simulation context.
+        * 
+        * @param simCtx
+        *            the context to release
+        */
+       public void release(SimulationContext simCtx);
+
+       /**
+        * Get the simulation context list for displaying drop-down list values populating on the "Create new study" screen.
+        * 
+        * @return List of the simulation contexts.
+        */
+       List<SimulationContext> getSimulationContextList();
+
+}
diff --git a/Workspace/Siman-Common/src/org/splat/service/SimulationContextServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/SimulationContextServiceImpl.java
new file mode 100644 (file)
index 0000000..729e7d4
--- /dev/null
@@ -0,0 +1,312 @@
+/*****************************************************************************
+ * Company         EURIWARE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   16.10.2012
+ * @author         $Author$
+ * @version        $Revision$
+ *****************************************************************************/
+
+package org.splat.service;
+
+import java.util.List;
+
+import org.hibernate.Criteria;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Example;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.PropertyExpression;
+import org.hibernate.criterion.Restrictions;
+import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.SimulationContext;
+import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.dal.dao.som.Database;
+import org.splat.dal.dao.som.SimulationContextDAO;
+import org.splat.dal.dao.som.SimulationContextTypeDAO;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.log.AppLogger;
+import org.splat.service.technical.ProjectSettingsService;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Simulation context service implementation.
+ * 
+ * @author rkv
+ * 
+ */
+public class SimulationContextServiceImpl implements SimulationContextService {
+
+       /**
+        * logger for the service.
+        */
+       public final static AppLogger logger = AppLogger
+                       .getLogger(SimulationContextServiceImpl.class);
+       /**
+        * Injected simulation context DAO.
+        */
+       private SimulationContextDAO _simulationContextDAO;
+
+       /**
+        * Injected simulation context type DAO.
+        */
+       private SimulationContextTypeDAO _simulationContextTypeDAO;
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#selectSimulationContext(int)
+        */
+       public SimulationContext selectSimulationContext(long index) {
+               return getSimulationContextDAO().get(index);
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#selectSimulationContext(org.splat.dal.bo.som.SimulationContextType, java.lang.String)
+        */
+       public SimulationContext selectSimulationContext(
+                       SimulationContextType celt, String value) {
+               SimulationContext result = null;
+               try {
+                       SimulationContext.Properties cprop = new SimulationContext.Properties();
+                       List<SimulationContext> clist = selectSimulationContextsWhere(cprop
+                                       .setType(celt).setValue(value));
+                       if (!clist.isEmpty())
+                               result = clist.get(0); // Supposed being the most used one if many exist
+               } catch (InvalidPropertyException error) {
+                       logger.info("Attempt to select a simulation context \""
+                                       + celt.getName() + "\" with an invalid value.");
+               }
+               return result;
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#selectSimulationContextsWhere(org.splat.dal.bo.som.SimulationContext.Properties)
+        */
+       @Transactional(readOnly=true)
+       public List<SimulationContext> selectSimulationContextsWhere(
+                       SimulationContext.Properties cprop) {
+//             StringBuffer query = new StringBuffer("from SimulationContext");
+//             String separator = " where";
+               SimulationContextType celt = cprop.getType();
+               String value = cprop.getValue();
+               ProgressState state = cprop.getProgressState();
+//             String order = "";
+               Criterion aCondition = null;
+               Order anOrder = null;
+
+               if (celt != null) {
+//                     query = query.append(separator).append(" type='").append(
+//                                     celt.getIndex()).append("'");
+//                     separator = " and";
+//                     order = " order by value asc";
+                       aCondition = Restrictions.eq("type", celt);
+                       anOrder = Order.asc("value");
+               }
+               if (value != null) {
+//                     query = query.append(separator).append(" value='").append(value)
+//                                     .append("'");
+//                     separator = " and";
+                       
+                       aCondition = Restrictions.and(aCondition, Restrictions.eq("value", value));
+               }
+               if (state != null) {
+//                     query = query.append(separator).append(" state='").append(state)
+//                                     .append("'");
+                       if (celt == null) {
+//                             order = " order by type asc";
+                               anOrder = Order.asc("type");
+                       }
+                       aCondition = Restrictions.and(aCondition, Restrictions.eq("state", state));
+               }
+//             query.append(order);
+//             return (List<SimulationContext>) Database.getSession().createQuery(
+//                             query.toString()).list();
+               return getSimulationContextDAO().getFilteredList(aCondition, anOrder);
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#getSimulationContextList()
+        */
+       @Transactional(readOnly = true)
+       public List<SimulationContext> getSimulationContextList() {
+               SimulationContext.Properties cprop = new SimulationContext.Properties();
+               SimulationContextType product = selectType("product");
+               List<SimulationContext> resList = selectSimulationContextsWhere(cprop
+                               .setType(product));
+               return resList;
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#createType(java.lang.String, org.splat.service.technical.ProjectSettingsService.Step)
+        */
+       @Transactional
+       public SimulationContextType createType(String name,
+                       ProjectSettingsService.Step step) throws InvalidPropertyException {
+               // TODO: Check for duplicate definition
+               SimulationContextType type = new SimulationContextType(name, step);
+               getSimulationContextTypeDAO().create(type);
+
+               return type;
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#selectAllTypes()
+        */
+       @SuppressWarnings("unchecked")
+       public List<SimulationContextType> selectAllTypes() {
+               // -----------------------------------------------------------
+               StringBuffer query = new StringBuffer("from SimulationContextType"); // Useless to order by names as the result mixes localized
+               // and non localized types
+               query = query.append(" order by step asc");
+               return Database.getSession().createQuery(query.toString()).list();
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#selectTypesOf(org.splat.service.technical.ProjectSettingsService.Step[])
+        */
+       @SuppressWarnings("unchecked")
+       public List<SimulationContextType> selectTypesOf(
+                       ProjectSettingsService.Step... step) {
+               // --------------------------------------------------------------------------------------
+               StringBuffer query = new StringBuffer(
+                               "from SimulationContextType where step='").append(
+                               step[0].getNumber()).append("'");
+               for (int i = 1; i < step.length; i++) { // Useless to order as the result mixes localized and non localized types
+                       query = query.append(" or step='").append(step[i].getNumber())
+                                       .append("'");
+               }
+               query = query.append(" order by step asc");
+               return Database.getSession().createQuery(query.toString()).list();
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#selectTypesWhere(org.splat.dal.bo.som.SimulationContextType.Properties)
+        */
+       @SuppressWarnings("unchecked")
+       public List<SimulationContextType> selectTypesWhere(
+                       SimulationContextType.Properties sprop) {
+               StringBuffer query = new StringBuffer("from SimulationContextType");
+               String separator = " where";
+               ProjectSettingsService.Step step = sprop.getStep();
+               ProgressState state = sprop.getProgressState();
+               String order = " order by step asc";
+
+               if (step != null) {
+                       query = query.append(separator).append(" step='").append(
+                                       step.getNumber()).append("'");
+                       separator = " and";
+                       order = " order by state desc"; // APPROVED (upper case A) is grater than inCHECK (lower case i)
+               }
+               if (state != null) {
+                       query = query.append(separator).append(" state='").append(
+                                       state.toString()).append("'");
+                       // separator = " and";
+                       if (step != null) {
+                               if (state != ProgressState.APPROVED)
+                                       order = " order by name asc";
+                               else
+                                       order = ""; // Approved types are localized
+                       }
+               }
+               query = query.append(order);
+               return Database.getSession().createQuery(query.toString()).list();
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#selectType(java.lang.String)
+        */
+       @Transactional(readOnly=true)
+       public SimulationContextType selectType(String name) {
+               return getSimulationContextTypeDAO().findByCriteria(
+                               Restrictions.eq("name", name));
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#selectType(long)
+        */
+       public SimulationContextType selectType(long index) {
+               return getSimulationContextTypeDAO().get(index);
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#hold(org.splat.dal.bo.som.SimulationContext)
+        */
+       public void hold(SimulationContext simCtx) {
+               simCtx.setCounter(simCtx.getCounter() + 1);
+               if (simCtx.isSaved()) {
+                       getSimulationContextDAO().update(simCtx);
+               }
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SimulationContextService#release(org.splat.dal.bo.som.SimulationContext)
+        */
+       public void release(SimulationContext simCtx) {
+               simCtx.setCounter(simCtx.getCounter() - 1);
+               if (simCtx.isSaved()) {
+                       getSimulationContextDAO().update(simCtx);
+               }
+       }
+
+       /**
+        * Get the simulationContextDAO.
+        * 
+        * @return the simulationContextDAO
+        */
+       public SimulationContextDAO getSimulationContextDAO() {
+               return _simulationContextDAO;
+       }
+
+       /**
+        * Set the simulationContextDAO.
+        * 
+        * @param simulationContextDAO
+        *            the simulationContextDAO to set
+        */
+       public void setSimulationContextDAO(
+                       SimulationContextDAO simulationContextDAO) {
+               _simulationContextDAO = simulationContextDAO;
+       }
+
+       /**
+        * Get the simulationContextTypeDAO.
+        * 
+        * @return the simulationContextTypeDAO
+        */
+       public SimulationContextTypeDAO getSimulationContextTypeDAO() {
+               return _simulationContextTypeDAO;
+       }
+
+       /**
+        * Set the simulationContextTypeDAO.
+        * 
+        * @param simulationContextTypeDAO
+        *            the simulationContextTypeDAO to set
+        */
+       public void setSimulationContextTypeDAO(
+                       SimulationContextTypeDAO simulationContextTypeDAO) {
+               _simulationContextTypeDAO = simulationContextTypeDAO;
+       }
+}
index 871a0b9aa1d8937b60d1b9e1b702e91ec204bedf..69c96fae708dc2f0b4481cb8e9be2cbb3e80f774 100644 (file)
@@ -22,8 +22,8 @@ import org.splat.kernel.NotApplicableException;
 import org.splat.som.Step;
 
 /**
- * @author RKV
- * 
+ * Step service interface.
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 public interface StepService {
 
index 353477ebf7f01266720ca822ad8aa8c3c725f166..d4373877c23a6064d1dbfb4228450084f951792e 100644 (file)
@@ -37,13 +37,23 @@ import org.splat.som.Revision;
 import org.splat.som.Step;
 
 /**
- * @author RKV
- * 
+ * Step service implementation.
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 public class StepServiceImpl implements StepService {
 
+       /**
+        * Injected index service.
+        */
        private IndexService _indexService;
+       /**
+        * Injected document service.
+        */
        private DocumentService _documentService;
+       /**
+        * Injected simulation context service.
+        */
+       private SimulationContextService _simulationContextService;
 
        public SimulationContext addSimulationContext(Step aStep,
                        SimulationContext.Properties dprop) throws MissedPropertyException,
@@ -58,7 +68,7 @@ public class StepServiceImpl implements StepService {
        public SimulationContext addSimulationContext(Step aStep,
                        SimulationContext context) {
                // -------------------------------------------------------------------------
-               context.hold(); // Increments the reference count of simulation context
+               getSimulationContextService().hold(context); // Increments the reference count of simulation context
                if (aStep.getOwner().isSaved())
                        try {
                                Session session = Database.getSession();
@@ -117,7 +127,7 @@ public class StepServiceImpl implements StepService {
       aStep.getContex().remove(torem);
       session.update(aStep.getOwner());
       if (torem.isShared()) {
-        torem.release();
+        getSimulationContextService().release(torem);
         session.update(torem);
       } else {
        session.delete(torem);
@@ -131,7 +141,7 @@ public class StepServiceImpl implements StepService {
           getDocumentService().generateDocumentId(newdoc, dprop);
 
 //        Creation of the save directory      
-          File wdir = newdoc.getSaveDirectory();
+          File wdir = getDocumentService().getSaveDirectory(newdoc);
          if (!wdir.exists()) if (!wdir.mkdirs()) throw new IOException("Cannot create the repository vault directory");
 
 //        Identification and save
@@ -146,7 +156,7 @@ public class StepServiceImpl implements StepService {
           String refid = dprop.getReference();
           if    (refid == null)    return null;
 
-          Document  slot = Database.selectDocument(refid, new Revision().toString());
+          Document  slot = getDocumentService().selectDocument(refid, new Revision().toString());
           if ( slot == null )      return null;
           if (!slot.isUndefined()) return null;     // Should not happen
 
@@ -222,4 +232,21 @@ public class StepServiceImpl implements StepService {
        public void setDocumentService(DocumentService documentService) {
                _documentService = documentService;
        }
+
+       /**
+        * Get the simulationContextService.
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * @param simulationContextService the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
+       }
 }
index 1c00bf7ec84516249d912178d90ae25884f96324..bd249d7c31ebc5e4b40f60a54e3f247a23879e76 100644 (file)
@@ -9,7 +9,6 @@
 
 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;
@@ -29,13 +28,6 @@ import org.splat.kernel.MultiplyDefinedException;
  */
 public interface StudyService {
        
-       /**
-        * Get the simulation context list for displaying drop-down list values populating
-        * on the "Create new study" screen.
-        * @return List of the simulation contexts.
-        */
-       List<SimulationContext> getSimulationContextList();
-       
        public int generateLocalIndex(Study aStudy);
 
        public Study selectStudy(long index);
index ef71552cc0e829f95739f0626cbd1b3ebedd8376..99e22cd67750051956e9e8aa195dc651dab4fd84 100644 (file)
 package org.splat.service;
 
 import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.hibernate.Query;
 import org.hibernate.Session;
-import org.hibernate.Transaction;
 import org.splat.dal.bo.kernel.Relation;
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.ActorRelation;
@@ -32,13 +32,13 @@ import org.splat.dal.bo.som.ProgressState;
 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.SimulationContextType;
 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.Visibility;
 import org.splat.dal.bo.som.Study.Properties;
 import org.splat.dal.dao.som.Database;
+import org.splat.dal.dao.som.StudyDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
@@ -47,56 +47,59 @@ import org.splat.log.AppLogger;
 import org.splat.service.technical.IndexService;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.som.Revision;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * This class defines all methods for creation, modification the study.
+ * 
  * @author Maria KRUCHININA
- *
+ * 
  */
 public class StudyServiceImpl implements StudyService {
 
        /**
         * logger for the service.
         */
-       public final static AppLogger logger = AppLogger.getLogger(StudyServiceImpl.class);
+       public final static AppLogger logger = AppLogger
+                       .getLogger(StudyServiceImpl.class);
 
+       /**
+        * Injected index service.
+        */
        private IndexService _indexService;
 
+       /**
+        * Injected step service.
+        */
        private StepService _stepService;
 
+       /**
+        * Injected scenario service.
+        */
        private ScenarioService _scenarioService;
 
+       /**
+        * Injected project service.
+        */
        private ProjectSettingsService _projectSettingsService;
 
+       /**
+        * Injected project element service.
+        */
        private ProjectElementService _projectElementService;
-       
+
        /**
-        * Get the simulation context list for displaying drop-down list values populating
-        * on the "Create new study" screen.
+        * Injected study DAO.
+        */
+       private StudyDAO _studyDAO;
+
+       /** 
         * {@inheritDoc}
-        * @see org.splat.service.StudyService#getSimulationContextList()
+        * @see org.splat.service.StudyService#selectStudy(long)
         */
-       public List<SimulationContext> getSimulationContextList() {
-               //TODO: remove the commit transaction ...
-               Session      connex  = Database.getSession();
-               Transaction  transax = connex.beginTransaction();
-               
-               SimulationContext.Properties cprop   = new SimulationContext.Properties();
-           SimulationContextType        product = SimulationContext.selectType("product");
-           List<SimulationContext> resList = Database.selectSimulationContextsWhere(cprop.setType(product));
-           
-           transax.commit();
-                 
-           return resList;
-       }
-       
+       @Transactional
        public Study selectStudy(long index) {
-               // -------------------------------------------
-               StringBuffer query = new StringBuffer("from Study where rid='").append(
-                               index).append("'");
-               Study result = (Study) Database.getSession().createQuery(
-                               query.toString()).uniqueResult();
-
+               Study result = getStudyDAO().get(index);
                result.loadWorkflow();
                return result;
        }
@@ -112,6 +115,7 @@ public class StudyServiceImpl implements StudyService {
                return result;
        }
 
+       @Transactional
        public Study createStudy(Study.Properties sprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        MultiplyDefinedException, RuntimeException {
@@ -119,7 +123,7 @@ public class StudyServiceImpl implements StudyService {
                Study study = new Study(sprop);
 
                buildReference(study);
-               Database.getSession().save(study); // TODO: use StudyDAO and throw out Database.
+               getStudyDAO().create(study);
                try {
                        IndexService lucin = getIndex();
                        lucin.add(study);
@@ -211,7 +215,7 @@ public class StudyServiceImpl implements StudyService {
 
        public boolean buildReference(Study aStudy) {
                String pattern = aStudy.getReference(); // The study being supposed just created, its reference is the reference pattern
-               IDBuilder tool = Database.selectIDBuilder(aStudy.getDate());
+               IDBuilder tool = selectIDBuilder(aStudy.getDate());
                if (tool == null) {
                        tool = new IDBuilder(aStudy.getDate());
                        Database.getSession().save(tool);
@@ -220,6 +224,19 @@ public class StudyServiceImpl implements StudyService {
                return true;
        }
 
+       public IDBuilder selectIDBuilder(Date date) {
+               // ------------------------------------------------------
+               SimpleDateFormat year = new SimpleDateFormat("yyyy");
+               String cycle = year.format(date);
+               StringBuffer buffer = new StringBuffer("from IDBuilder where cycle='")
+                               .append(cycle).append("'");
+               String qstring = buffer.toString();
+               Query query = Database.getSession().createQuery(qstring);
+               IDBuilder result = (IDBuilder) query.uniqueResult();
+
+               return result;
+       }
+
        public boolean publishes(Study aStudy, Document doc) {
                // ---------------------------------------
                if (!aStudy.publishes(doc)) {
@@ -367,9 +384,9 @@ public class StudyServiceImpl implements StudyService {
                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
+               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;
        }
@@ -462,17 +479,6 @@ public class StudyServiceImpl implements StudyService {
                }
        }
 
-       /**
-        * @return
-        */
-       public IndexService getIndexService() {
-               return _indexService;
-       }
-
-       public void setIndexService(IndexService indexService) {
-               _indexService = indexService;
-       }
-
        /**
         * Get project settings.
         * 
@@ -514,6 +520,7 @@ public class StudyServiceImpl implements StudyService {
 
        /**
         * Get the stepService.
+        * 
         * @return the stepService
         */
        public StepService getStepService() {
@@ -522,9 +529,43 @@ public class StudyServiceImpl implements StudyService {
 
        /**
         * Set the stepService.
-        * @param stepService the stepService to set
+        * 
+        * @param stepService
+        *            the stepService to set
         */
        public void setStepService(StepService stepService) {
                _stepService = stepService;
        }
+
+       /**
+        * 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;
+       }
+
+       /**
+        * 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;
+       }
 }
index 35b0665518eb483d994f2151469d702cdc2f98b5..3d0a6e0b245f4448715d4be5b0b91f5ddfbc66e5 100644 (file)
@@ -1,4 +1,5 @@
 package org.splat.service.technical;
+
 /**
  * 
  * @author    Daniel Brunier-Coulin
@@ -37,434 +38,520 @@ 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.SimulationContextService;
 
 public class ProjectSettingsServiceImpl implements ProjectSettingsService {
 
-//  Non persistent configuration information
-       private  Properties                            reprop;       // Repository settings
-       private  String                                pattern;      // Pattern of study references
-       private  FileNaming                            naming;       // Scheme of file names stored into the repository
-       private  String                                versioning;   // Pattern of the presentation of version numbers 
-       private  Vector<ProjectSettingsService.Step>                          steps;        // Ordered list of (transient) study steps
-       private  Vector<ProjectSettingsValidationCycle>               concycles;    // Configuration document validation cycles
-
-//  Temporary attributes initialized from the configuration file for populating the database with object types
-    private  LinkedHashMap<String,String>          mapuse;       // Document type names and uses mapping
-    private  Vector<String>                        context;      // Simulation Context type names
-    private  Vector<String>                        kname;        // Knowledge Element type names
-    private  Vector<NamedNodeMap>                  flows;        // Document flows
-    private  Vector<NamedNodeMap>                  sclass;       // Study classifications
-
-//  Other resources
-       private         static ProjectSettingsServiceImpl  my     = null;       // Singleton instance
+       // Non persistent configuration information
+       private Properties reprop; // Repository settings
+       private String pattern; // Pattern of study references
+       private FileNaming naming; // Scheme of file names stored into the repository
+       private String versioning; // Pattern of the presentation of version numbers
+       private Vector<ProjectSettingsService.Step> steps; // Ordered list of (transient) study steps
+       private Vector<ProjectSettingsValidationCycle> concycles; // Configuration document validation cycles
+
+       // Temporary attributes initialized from the configuration file for populating the database with object types
+       private LinkedHashMap<String, String> mapuse; // Document type names and uses mapping
+       private Vector<String> context; // Simulation Context type names
+       private Vector<String> kname; // Knowledge Element type names
+       private Vector<NamedNodeMap> flows; // Document flows
+       private Vector<NamedNodeMap> sclass; // Study classifications
+
+       // Other resources
+       private static ProjectSettingsServiceImpl my = null; // Singleton instance
        private Database _database;
-    protected final static Logger           logger = Logger.getLogger(ProjectSettingsServiceImpl.class);
+       /**
+        * Injected simulation context service.
+        */
+       private SimulationContextService _simulationContextService;
+       protected final static Logger logger = Logger
+                       .getLogger(ProjectSettingsServiceImpl.class);
+
+       public enum FileNaming {
+               title, encoded, asis
+       }
 
-    public enum FileNaming { title, encoded, asis }
        public static class ProjectSettingsValidationCycle {
-//  -----------------------------------
-      private String  name;
-      private Actor[] actor;
-
-      private ProjectSettingsValidationCycle () {
-       this.name  = "built-in";
-       this.actor = new Actor[] { null, null, null };
-      }
-      private ProjectSettingsValidationCycle (String name, Actor[] actor) {
-        this.name  = name;
-        this.actor = actor;
-      }
-      public String getName () {
-        return name;
-      }
-      public Actor[] getActorTypes () {
-        return actor;
-      }
-    }
-
-//  ==============================================================================================================================
-//  Construction
-//  ==============================================================================================================================
-       protected ProjectSettingsServiceImpl () {
-//  ----------------------------
-         reprop = new Properties();
-      steps  = new Vector<ProjectSettingsService.Step>();
-      my = this;
-       }       
-    
-//  ==============================================================================================================================
-//  Public functions
-//  ==============================================================================================================================
-
-       public void configure (String filename) throws IOException, SQLException {
-//  ---------------------------------------
-      if (!steps.isEmpty()) return;       // Project already configured
-
-      Database base   = getDatabase().getMe();
-         File     config = new File(filename);
-         if  (config.exists()) {
-        loadCustomization(config);
-         } else {
-        logger.fatal("Could not find the database configuration file \"" + config.getAbsolutePath() + "\"");
-        throw new FileNotFoundException();
-         }
-         base.configure(reprop);
-      if (!base.isInitialized()) {
-        base.initialize();
-        initialize();   // Populates the database with all necessary stuff
-      }
+               // -----------------------------------
+               private String name;
+               private Actor[] actor;
+
+               private ProjectSettingsValidationCycle() {
+                       this.name = "built-in";
+                       this.actor = new Actor[] { null, null, null };
+               }
+
+               private ProjectSettingsValidationCycle(String name, Actor[] actor) {
+                       this.name = name;
+                       this.actor = actor;
+               }
+
+               public String getName() {
+                       return name;
+               }
+
+               public Actor[] getActorTypes() {
+                       return actor;
+               }
        }
 
-    public List<ProjectSettingsService.Step> getAllSteps () {
-//  ---------------------------------------
-      return steps;
-    }
+       // ==============================================================================================================================
+       // Construction
+       // ==============================================================================================================================
+       protected ProjectSettingsServiceImpl() {
+               // ----------------------------
+               reprop = new Properties();
+               steps = new Vector<ProjectSettingsService.Step>();
+               my = this;
+       }
+
+       // ==============================================================================================================================
+       // Public functions
+       // ==============================================================================================================================
+
+       public void configure(String filename) throws IOException, SQLException {
+               // ---------------------------------------
+               if (!steps.isEmpty())
+                       return; // Project already configured
+
+               Database base = getDatabase().getMe();
+               File config = new File(filename);
+               if (config.exists()) {
+                       loadCustomization(config);
+               } else {
+                       logger.fatal("Could not find the database configuration file \""
+                                       + config.getAbsolutePath() + "\"");
+                       throw new FileNotFoundException();
+               }
+               base.configure(reprop);
+               if (!base.isInitialized()) {
+                       base.initialize();
+                       initialize(); // Populates the database with all necessary stuff
+               }
+       }
+
+       public List<ProjectSettingsService.Step> getAllSteps() {
+               // ---------------------------------------
+               return steps;
+       }
+
+       /**
+        * Return the validation cycles of result documents defined in the workflow, ordered by study activities and ending by the default
+        * validation cycle, if defined.
+        * 
+        * @return the validation cycles of the workflow
+        */
+       public static List<ProjectSettingsValidationCycle> getAllValidationCycles() {
+               // -------------------------------------------------------------
+               return my.concycles;
+       }
+
+       public FileNaming getFileNamingScheme() {
+               // -----------------------------------------------
+               return naming;
+       }
+
+       public static ProjectSettingsValidationCycle getNewValidationCycle() {
+               // ------------------------------------------------------
+               return new ProjectSettingsValidationCycle();
+       }
+
+       public String getReferencePattern() {
+               return pattern;
+       }
+
+       public String getRevisionPattern() {
+               // ------------------------------------------
+               return versioning;
+       }
+
+       public static ProjectSettingsService.Step getStep(int number) {
+               // ---------------------------------------
+               for (int i = 0; i < my.steps.size(); i++) {
+                       ProjectSettingsService.Step step = my.steps.get(i);
+                       if (step.number == number)
+                               return step;
+               }
+               return null;
+       }
+
+       public List<ProjectSettingsService.Step> getStepsOf(
+                       Class<? extends ProjectElement> level) {
+               // ---------------------------------------------------------------------------
+               Vector<ProjectSettingsService.Step> result = new Vector<ProjectSettingsService.Step>();
+
+               for (int i = 0; i < steps.size(); i++) {
+                       ProjectSettingsService.Step step = steps.get(i);
+                       if (step.appliesTo(level))
+                               result.add(step);
+               }
+               return result;
+       }
+
+       // ==============================================================================================================================
+       // Protected member function
+       // ==============================================================================================================================
+
+       public void initialize() {
+               // ----------------------------
+               createDocumentTypes();
+               createSimulationContextTypes();
+               createKnowledgeElementTypes();
+       }
+
+       // ==============================================================================================================================
+       // Private member function
+       // ==============================================================================================================================
+
+       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<String, Node> children = XDOM.getNamedChildNodes(conf
+                                       .getDocumentElement());
+
+                       // Repository tag initializing the reprop attribute
+                       Node child = children.get("database");
+                       HashMap<String, Node> datag = XDOM.getNamedChildNodes(child);
+
+                       String disk = datag.get("repository").getAttributes().getNamedItem(
+                                       "disk").getNodeValue();
+                       if (!disk.endsWith("/"))
+                               disk = disk + "/";
+                       logger.info("Database root set to " + disk);
+                       reprop.setProperty("repository", disk);
+
+                       // Formats tag initializing the reference pattern and date attributes
+                       child = children.get("formats");
+                       datag = XDOM.getNamedChildNodes(child);
+
+                       NamedNodeMap natr = datag.get("references").getAttributes();
+                       pattern = natr.getNamedItem("study").getNodeValue();
+
+                       natr = datag.get("files").getAttributes();
+                       naming = FileNaming.valueOf(natr.getNamedItem("name")
+                                       .getNodeValue());
+
+                       natr = datag.get("versions").getAttributes();
+                       versioning = natr.getNamedItem("pattern").getNodeValue();
+
+                       // Activities tag initializing the steps and rex attributes
+                       child = children.get("activities");
+                       NodeList nlist = child.getChildNodes();
+                       Vector<NamedNodeMap> flist = new Vector<NamedNodeMap>();
+                       Vector<String> resultype = new Vector<String>();
+                       Vector<NamedNodeMap> clist = new Vector<NamedNodeMap>();
+
+                       int snum = 1; // Base number of steps
+                       for (int i = 0; i < nlist.getLength(); i++) {
+                               child = nlist.item(i);
+                               if (child.getNodeName().equals("scenario")) {
+                                       NodeList slist = child.getChildNodes();
+                                       for (int j = 0; j < slist.getLength(); j++) {
+                                               child = slist.item(j);
+                                               if (!child.getNodeName().equals("step"))
+                                                       continue;
+                                               HashMap<String, Node> tags = XDOM
+                                                               .getNamedChildNodes(child);
+
+                                               natr = tags.get("storage").getAttributes();
+                                               ProjectSettingsService.Step step = new ProjectSettingsService.Step(
+                                                               snum, Scenario.class, natr.getNamedItem("path")
+                                                                               .getNodeValue());
+
+                                               // Keeping flow and classification information for eventual later use
+                                               natr = tags.get("flow").getAttributes();
+                                               flist.add(natr);
+                                               child = natr.getNamedItem("result");
+                                               if (child != null)
+                                                       resultype.add(child.getNodeValue());
+
+                                               child = tags.get("classification");
+                                               if (child != null)
+                                                       clist.add(child.getAttributes());
+                                               else
+                                                       clist.add(null);
+
+                                               if (natr.getNamedItem("contents").getNodeValue()
+                                                               .equals("knowledge")) {
+                                                       // TODO In a given scenario, only one step must contain knowledges
+                                                       step.contents.add(KnowledgeElement.class);
+                                               } else {
+                                                       step.contents.add(Document.class);
+                                               }
+                                               steps.add(step);
+                                               snum += 1;
+                                       }
+                               } else {
+                                       if (!child.getNodeName().equals("step"))
+                                               continue;
+                                       HashMap<String, Node> tags = XDOM.getNamedChildNodes(child);
+
+                                       natr = tags.get("storage").getAttributes(); // Mandatory information
+                                       ProjectSettingsService.Step step = new ProjectSettingsService.Step(
+                                                       snum, Study.class, natr.getNamedItem("path")
+                                                                       .getNodeValue());
+
+                                       // Keeping flow and classification information for eventual later use
+                                       natr = tags.get("flow").getAttributes();
+                                       flist.add(natr);
+                                       child = natr.getNamedItem("result");
+                                       if (child != null)
+                                               resultype.add(child.getNodeValue());
+
+                                       child = tags.get("classification"); // Optional information
+                                       if (child != null)
+                                               clist.add(child.getAttributes());
+                                       else
+                                               clist.add(null);
+
+                                       if (natr.getNamedItem("contents").getNodeValue().equals(
+                                                       "knowledge")) {
+                                               // TODO Error: knowledges must be attached to scenarios
+                                       } else {
+                                               step.contents.add(Document.class);
+                                       }
+                                       steps.add(step);
+                                       snum += 1;
+                               }
+                       }
+                       // Validations tag
+                       child = children.get("validations");
+                       concycles = new Vector<ProjectSettingsValidationCycle>();
+                       datag = XDOM.getNamedChildNodes(child);
+
+                       String[] step = { "review", "approval", "acceptance" };
+                       resultype.add("default");
+                       for (Iterator<String> i = resultype.iterator(); i.hasNext();) {
+                               Actor[] actor = { null, null, null };
+                               String name = i.next();
+                               child = datag.get(name);
+                               if (child == null)
+                                       continue; // Document type not subject of any validation
+                               natr = child.getAttributes();
+                               for (int j = 0; j < step.length; j++) {
+                                       child = natr.getNamedItem(step[j]);
+                                       if (child == null)
+                                               continue; // Validation step not required
+                                       actor[j] = Actor.valueOf(child.getNodeValue());
+                               }
+                               concycles.add(new ProjectSettingsValidationCycle(name, actor));
+                       }
+                       concycles.add(new ProjectSettingsValidationCycle()); // Adds the built-in validation cycle
+
+                       if (getDatabase().getMe().isInitialized())
+                               return; // No need to load object type definitions as they are already stored
+
+                       // Documents tag
+                       child = children.get("documents");
+                       nlist = child.getChildNodes();
+
+                       flows = flist; // Kept for later use in document type definition
+                       sclass = clist; // Kept for later use in simulation context type definition
+                       mapuse = new LinkedHashMap<String, String>();
+                       for (int i = 0; i < nlist.getLength(); i++) {
+                               child = nlist.item(i);
+                               if (!child.getNodeName().equals("article"))
+                                       continue;
+
+                               natr = child.getAttributes();
+                               String type = natr.getNamedItem("type").getNodeValue();
+                               String uses = null;
+                               child = natr.getNamedItem("uses");
+                               if (child != null)
+                                       uses = child.getNodeValue();
+                               mapuse.put(type, uses); // Must be added to the map even if no (null) uses
+                       }
+                       // Simulation Contexts tag
+                       child = children.get("contexts");
+                       nlist = child.getChildNodes();
+
+                       context = new Vector<String>();
+                       for (int i = 0; i < nlist.getLength(); i++) {
+                               child = nlist.item(i);
+                               if (!child.getNodeName().equals("article"))
+                                       continue;
+
+                               context.add(child.getAttributes().getNamedItem("type")
+                                               .getNodeValue());
+                       }
+                       // Knowledge Elements tag
+                       child = children.get("knowledges");
+                       nlist = child.getChildNodes();
+
+                       kname = new Vector<String>();
+                       for (int i = 0; i < nlist.getLength(); i++) {
+                               child = nlist.item(i);
+                               if (!child.getNodeName().equals("article"))
+                                       continue;
+
+                               kname.add(child.getAttributes().getNamedItem("type")
+                                               .getNodeValue());
+                       }
+               } catch (Exception error) {
+                       logger.info("Error in customization", error);
+               }
+       }
+
+       private void createDocumentTypes() {
+               // -----------------------------------
+               DocumentType.Properties tprop = new DocumentType.Properties();
+               HashMap<String, Vector<ProjectSettingsService.Step>> mapsteps = new HashMap<String, Vector<ProjectSettingsService.Step>>();
+               HashMap<String, ProjectSettingsService.Step> mapresult = new HashMap<String, ProjectSettingsService.Step>();
+               HashMap<String, DocumentType> maptype = new HashMap<String, DocumentType>();
+
+               Vector<ProjectSettingsService.Step> slist = null; // List of Steps to which each document type is valid
+               int snum = 0; // Step number
+               String type = null;
+               String uses = null;
+               for (Iterator<NamedNodeMap> i = flows.iterator(); i.hasNext(); snum++) {
+                       NamedNodeMap flow = i.next();
+                       ProjectSettingsService.Step step = steps.get(snum);
+                       String[] contents = flow.getNamedItem("contents").getNodeValue()
+                                       .split(",");
+                       for (int j = 0; j < contents.length; j++) {
+                               type = contents[j];
+                               if (!mapuse.containsKey(type)) {
+                                       logger.warn("Undefined \"" + type + "\" document type.");
+                                       continue;
+                               }
+                               slist = mapsteps.get(type);
+                               if (slist == null)
+                                       slist = new Vector<ProjectSettingsService.Step>();
+                               slist.add(step);
+                               mapsteps.put(type, slist);
+                       }
+                       Node result = flow.getNamedItem("result");
+                       if (result != null)
+                               mapresult.put(result.getNodeValue(), step);
+               }
+               try {
+                       DocumentType tdoc = null;
+                       Set<String> tset = mapuse.keySet();
+                       ProjectSettingsService.Step step;
+                       for (Iterator<String> i = tset.iterator(); i.hasNext();) {
+                               type = i.next();
+                               slist = mapsteps.get(type);
+                               uses = mapuse.get(type);
+                               step = mapresult.get(type);
+
+                               tprop.clear();
+                               tprop.setName(type).setStep(
+                                               slist.toArray(new ProjectSettingsService.Step[slist
+                                                               .size()]));
+                               if (uses != null) {
+                                       tdoc = maptype.get(uses);
+                                       if (tdoc == null)
+                                               logger
+                                                               .warn("Undefined \"" + uses
+                                                                               + "\" document type.");
+                                       else
+                                               tprop.setUses(tdoc);
+                               }
+                               if (step != null)
+                                       tprop.setResult(step);
+
+                               tprop.disableCheck();
+                               tdoc = Document.createType(tprop); // Creation of Document Types
+                               tdoc.approve();
+                               maptype.put(type, tdoc);
+                       }
+               } catch (Exception error) {
+                       logger.warn("Error creating document types, reason:", error); // Should not happen
+               }
+       }
+
+       private void createKnowledgeElementTypes() {
+               // -------------------------------------------
+               try {
+                       KnowledgeElementType ktype = KnowledgeElement.createType("usecase"); // Internal reserved knowledge element type
+                       ktype.reserve();
+                       for (Iterator<String> i = kname.iterator(); i.hasNext();) {
+                               String type = i.next();
+
+                               ktype = KnowledgeElement.createType(type); // Knowledge Elements Types defined in the configuration
+                               ktype.approve();
+                       }
+               } catch (Exception error) {
+                       logger.warn("Error creating knowledge types, reason:", error); // Should not happen
+               }
+       }
+
+       private void createSimulationContextTypes() {
+               // --------------------------------------------
+               HashMap<String, ProjectSettingsService.Step> mapstep = new HashMap<String, ProjectSettingsService.Step>();
+               int snum = 0;
+               for (Iterator<NamedNodeMap> i = sclass.iterator(); i.hasNext(); snum++) {
+                       NamedNodeMap clatr = i.next();
+                       if (clatr == null)
+                               continue;
+
+                       String[] clist = clatr.getNamedItem("context").getNodeValue()
+                                       .split(",");
+                       for (int j = 0; j < clist.length; j++) {
+                               mapstep.put(clist[j], steps.get(snum));
+                       }
+               }
+               try {
+                       SimulationContextType tctex = null;
+                       for (Iterator<String> i = context.iterator(); i.hasNext();) {
+                               String type = i.next();
+                               if (!mapstep.containsKey(type)) {
+                                       logger
+                                                       .warn("Could not find \""
+                                                                       + type
+                                                                       + "\" classification. Simulation Context type ignored.");
+                                       continue;
+                               }
+                               tctex = getSimulationContextService().createType(type,
+                                               mapstep.get(type)); // Creation of Simulation Context Types
+                               tctex.approve();
+                       }
+               } catch (Exception error) {
+                       logger.warn("Error creating context types, reason:", error); // Should not happen
+               }
+       }
 
-/**
- * Return the validation cycles of result documents defined in the workflow, ordered by study activities
- * and ending by the default validation cycle, if defined.
- * 
- * @return the validation cycles of the workflow
- */
-    public static List<ProjectSettingsValidationCycle> getAllValidationCycles () {
-//  -------------------------------------------------------------
-      return my.concycles;
-    }
-
-    public FileNaming getFileNamingScheme () {
-//  -----------------------------------------------
-      return naming;
-    }
-
-    public static ProjectSettingsValidationCycle getNewValidationCycle () {
-//  ------------------------------------------------------
-      return  new ProjectSettingsValidationCycle();
-    }
-
-    public String getReferencePattern () {
-      return pattern;
-    }
-
-    public String getRevisionPattern () {
-//  ------------------------------------------
-      return versioning;
-    }
-
-    public static ProjectSettingsService.Step getStep (int number) {
-//  ---------------------------------------
-      for (int i=0; i<my.steps.size(); i++) {
-       ProjectSettingsService.Step step = my.steps.get(i);
-       if  (step.number == number)  return step;
-      }
-      return null;
-    }
-
-       public List<ProjectSettingsService.Step> getStepsOf (Class<? extends ProjectElement> level) {
-//  ---------------------------------------------------------------------------
-      Vector<ProjectSettingsService.Step> result = new Vector<ProjectSettingsService.Step>();
-      
-      for (int i=0; i<steps.size(); i++) {
-       ProjectSettingsService.Step step = steps.get(i);
-        if  (step.appliesTo(level)) result.add(step);         
-      }
-      return result;
-    }
-
-//  ==============================================================================================================================
-//  Protected member function
-//  ==============================================================================================================================
-
-    public void initialize () {
-//  ----------------------------
-      createDocumentTypes();
-      createSimulationContextTypes();
-      createKnowledgeElementTypes();
-    }
-
-//  ==============================================================================================================================
-//  Private member function
-//  ==============================================================================================================================
-    
-    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<String, Node>  children = XDOM.getNamedChildNodes(conf.getDocumentElement());
-
-//      Repository tag initializing the reprop attribute
-        Node                   child = children.get("database");
-        HashMap<String, Node>  datag = XDOM.getNamedChildNodes(child);
-
-        String disk = datag.get("repository").getAttributes().getNamedItem("disk").getNodeValue();
-        if (!disk.endsWith("/")) disk = disk + "/";
-        logger.info("Database root set to " + disk);
-        reprop.setProperty("repository", disk);
-
-//      Formats tag initializing the reference pattern and date attributes
-        child = children.get("formats");
-        datag = XDOM.getNamedChildNodes(child);
-
-        NamedNodeMap natr = datag.get("references").getAttributes();
-        pattern    = natr.getNamedItem("study").getNodeValue();
-        
-        natr       = datag.get("files").getAttributes();
-        naming     = FileNaming.valueOf(natr.getNamedItem("name").getNodeValue());
-        
-        natr       = datag.get("versions").getAttributes();
-        versioning = natr.getNamedItem("pattern").getNodeValue();
-
-//      Activities tag initializing the steps and rex attributes
-                               child     = children.get("activities");
-        NodeList               nlist     = child.getChildNodes();
-        Vector<NamedNodeMap>   flist     = new Vector<NamedNodeMap>();
-        Vector<String>         resultype = new Vector<String>();
-        Vector<NamedNodeMap>   clist     = new Vector<NamedNodeMap>();
-
-        int snum = 1;                                        // Base number of steps
-        for (int i=0; i<nlist.getLength(); i++) {
-          child = nlist.item(i);
-          if (child.getNodeName().equals("scenario")) {
-               NodeList slist = child.getChildNodes();
-            for (int j=0; j<slist.getLength(); j++) {
-              child = slist.item(j);
-              if (!child.getNodeName().equals("step")) continue;
-              HashMap<String, Node>  tags = XDOM.getNamedChildNodes(child);
-
-              natr = tags.get("storage").getAttributes();
-              ProjectSettingsService.Step step = new ProjectSettingsService.Step(snum, Scenario.class, natr.getNamedItem("path").getNodeValue());
-
-//            Keeping flow and classification information for eventual later use
-              natr = tags.get("flow").getAttributes();
-              flist.add(natr);              
-              child = natr.getNamedItem("result");
-              if (child != null) resultype.add(child.getNodeValue());
-
-              child = tags.get("classification");
-              if (child != null) clist.add( child.getAttributes() );
-              else               clist.add( null );
-
-              if (natr.getNamedItem("contents").getNodeValue().equals("knowledge")) {
-//TODO            In a given scenario, only one step must contain knowledges
-                 step.contents.add(KnowledgeElement.class);
-              } else {
-               step.contents.add(Document.class);
-              }
-              steps.add(step);
-              snum += 1;
-            }
-          } else {
-            if (!child.getNodeName().equals("step")) continue;
-            HashMap<String, Node>  tags = XDOM.getNamedChildNodes(child);
-
-            natr = tags.get("storage").getAttributes();      // Mandatory information
-            ProjectSettingsService.Step step = new ProjectSettingsService.Step(snum, Study.class, natr.getNamedItem("path").getNodeValue());
-
-//          Keeping flow and classification information for eventual later use
-            natr = tags.get("flow").getAttributes();
-            flist.add(natr);              
-            child = natr.getNamedItem("result");
-            if (child != null) resultype.add(child.getNodeValue());
-
-            child = tags.get("classification");              // Optional information
-            if (child != null) clist.add( child.getAttributes() );
-            else               clist.add( null );
-
-            if (natr.getNamedItem("contents").getNodeValue().equals("knowledge")) {
-//TODO        Error: knowledges must be attached to scenarios
-            } else {
-              step.contents.add(Document.class);
-            }
-            steps.add(step);
-            snum += 1;
-          }
-        }
-//      Validations tag
-        child     = children.get("validations");
-        concycles = new Vector<ProjectSettingsValidationCycle>();
-        datag     = XDOM.getNamedChildNodes(child);
-
-        String[]  step   = { "review", "approval", "acceptance" };
-        resultype.add("default");
-        for (Iterator<String> i=resultype.iterator(); i.hasNext(); ) {
-          Actor[] actor = {  null,     null,       null        };
-          String  name  = i.next();
-          child = datag.get(name);
-          if (child == null) continue;                        // Document type not subject of any validation
-          natr = child.getAttributes();
-          for (int j=0; j<step.length; j++) {
-            child = natr.getNamedItem(step[j]);
-            if (child == null) continue;                      // Validation step not required
-            actor[j] = Actor.valueOf(child.getNodeValue());
-          }
-          concycles.add( new ProjectSettingsValidationCycle(name, actor) );
-        }
-        concycles.add( new ProjectSettingsValidationCycle() );               // Adds the built-in validation cycle
-
-        if (getDatabase().getMe().isInitialized()) return;         // No need to load object type definitions as they are already stored
-
-//      Documents tag
-        child  = children.get("documents");
-           nlist  = child.getChildNodes();
-
-           flows  = flist;             // Kept for later use in document type definition
-           sclass = clist;             // Kept for later use in simulation context type definition
-        mapuse = new LinkedHashMap<String,String>();
-        for (int i=0; i<nlist.getLength(); i++) {
-          child = nlist.item(i);
-          if (!child.getNodeName().equals("article")) continue;
-
-                       natr = child.getAttributes();
-          String       type = natr.getNamedItem("type").getNodeValue();
-          String       uses = null;
-          child = natr.getNamedItem("uses");
-          if (child != null) uses = child.getNodeValue();
-          mapuse.put(type, uses);   // Must be added to the map even if no (null) uses
-        }
-//      Simulation Contexts tag
-        child  = children.get("contexts");
-           nlist  = child.getChildNodes();
-
-           context  = new Vector<String>();
-        for (int i=0; i<nlist.getLength(); i++) {
-          child = nlist.item(i);
-          if (!child.getNodeName().equals("article")) continue;
-          
-          context.add(child.getAttributes().getNamedItem("type").getNodeValue());
-        }
-//      Knowledge Elements tag
-        child  = children.get("knowledges");
-           nlist  = child.getChildNodes();
-
-           kname  = new Vector<String>();
-        for (int i=0; i<nlist.getLength(); i++) {
-          child = nlist.item(i);
-          if (!child.getNodeName().equals("article")) continue;
-          
-          kname.add(child.getAttributes().getNamedItem("type").getNodeValue());
-        }
-      }
-      catch (Exception error) {
-               logger.info("Error in customization", error);
-      }
-    }
-
-    private void createDocumentTypes () {
-//  -----------------------------------
-      DocumentType.Properties       tprop     = new DocumentType.Properties();
-      HashMap<String,Vector<ProjectSettingsService.Step>>  mapsteps  = new HashMap<String,Vector<ProjectSettingsService.Step>>();
-      HashMap<String,ProjectSettingsService.Step>          mapresult = new HashMap<String,ProjectSettingsService.Step>();
-      HashMap<String,DocumentType>  maptype   = new HashMap<String,DocumentType>();
-        
-      Vector<ProjectSettingsService.Step> slist = null;     // List of Steps to which each document type is valid
-      int          snum  = 0;        // Step number
-      String       type  = null;
-      String       uses  = null;
-      for (Iterator<NamedNodeMap> i=flows.iterator(); i.hasNext(); snum++) {
-           NamedNodeMap    flow     = i.next();
-           ProjectSettingsService.Step            step     = steps.get(snum);
-        String[]        contents = flow.getNamedItem("contents").getNodeValue().split(",");
-        for (int j=0; j<contents.length; j++) {
-             type = contents[j];
-                 if (!mapuse.containsKey(type)) {
-            logger.warn("Undefined \"" + type + "\" document type.");
-            continue;
-          }                  slist = mapsteps.get(type);
-          if (slist == null) slist = new Vector<ProjectSettingsService.Step>();
-          slist.add(step);
-          mapsteps.put(type, slist);
-        }
-        Node result = flow.getNamedItem("result");
-        if  (result != null)  mapresult.put(result.getNodeValue(), step);
-      }
-      try {
-        DocumentType tdoc = null;
-        Set<String>  tset = mapuse.keySet();
-        ProjectSettingsService.Step         step;
-        for (Iterator<String> i=tset.iterator(); i.hasNext(); ) {
-          type  = i.next();
-          slist = mapsteps.get(type);
-          uses  = mapuse.get(type);
-          step  = mapresult.get(type);
-
-          tprop.clear();
-          tprop.setName(type).setStep(slist.toArray(new ProjectSettingsService.Step[slist.size()]));
-          if (uses != null) {
-               tdoc = maptype.get(uses);
-               if (tdoc == null) logger.warn("Undefined \"" + uses + "\" document type.");
-               else              tprop.setUses(tdoc);
-          }
-          if (step != null)   tprop.setResult(step);
-
-          tprop.disableCheck();
-          tdoc = Document.createType(tprop);                                  // Creation of Document Types
-          tdoc.approve();
-          maptype.put(type, tdoc);
-        }
-      } catch (Exception error) {
-        logger.warn("Error creating document types, reason:", error);         // Should not happen
-      }
-    }
-
-    private void createKnowledgeElementTypes () {
-//  -------------------------------------------
-      try {
-        KnowledgeElementType ktype = KnowledgeElement.createType("usecase");  // Internal reserved knowledge element type
-        ktype.reserve();
-        for (Iterator<String> i=kname.iterator(); i.hasNext(); ) {
-          String  type = i.next();
-
-          ktype = KnowledgeElement.createType(type);                          // Knowledge Elements Types defined in the configuration
-          ktype.approve();
-        }
-      } catch (Exception error) {
-        logger.warn("Error creating knowledge types, reason:", error);        // Should not happen
-      }
-    }
-
-    private void createSimulationContextTypes () {
-//  --------------------------------------------
-      HashMap<String,ProjectSettingsService.Step>  mapstep = new HashMap<String,ProjectSettingsService.Step>();
-      int snum = 0;
-      for (Iterator<NamedNodeMap> i=sclass.iterator(); i.hasNext(); snum++) {
-        NamedNodeMap clatr = i.next();
-        if (clatr == null) continue;
-
-        String[]        clist = clatr.getNamedItem("context").getNodeValue().split(",");
-        for (int j=0; j<clist.length; j++) {
-          mapstep.put(clist[j], steps.get(snum));
-        }
-      }
-      try {
-       SimulationContextType tctex = null;
-        for (Iterator<String> i=context.iterator(); i.hasNext(); ) {
-          String type = i.next();
-             if (!mapstep.containsKey(type)) {
-            logger.warn("Could not find \"" + type + "\" classification. Simulation Context type ignored.");
-            continue;
-             }
-             tctex = SimulationContext.createType(type, mapstep.get(type));   // Creation of Simulation Context Types
-             tctex.approve();
-        }
-      } catch (Exception error) {
-        logger.warn("Error creating context types, reason:", error);       // Should not happen
-      }
-    }
        /**
         * Get the database.
+        * 
         * @return the database
         */
        public Database getDatabase() {
                return _database;
        }
+
        /**
         * Set the database.
-        * @param database the database to set
+        * 
+        * @param database
+        *            the database to set
         */
        public void setDatabase(Database database) {
                _database = database;
        }
+
+       /**
+        * Get the simulationContextService.
+        * 
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * 
+        * @param simulationContextService
+        *            the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
+       }
 }
\ No newline at end of file
index 337c839f4780d7043d032561d1ef55a0823e031f..0e2805f78be722d999041c8947167c7d259fa796 100644 (file)
@@ -25,6 +25,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                class="org.splat.service.DocumentServiceImpl">
                <property name="projectSettings" ref="projectSettings" />
                <property name="studyService" ref="studyService" />
+               <property name="documentDAO" ref="documentDAO" />
        </bean>
 
        <bean id="knowledgeElementService"
@@ -60,6 +61,16 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
        <bean id="stepService" class="org.splat.service.StepServiceImpl">
                <property name="indexService" ref="indexService" />
                <property name="documentService" ref="documentService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
+       </bean>
+
+       <bean id="simulationContextService"
+               class="org.splat.service.SimulationContextServiceImpl">
+               <property name="simulationContextDAO"
+                       ref="simulationContextDAO" />
+               <property name="simulationContextTypeDAO"
+                       ref="simulationContextTypeDAO" />
        </bean>
 
        <bean id="studyService"
@@ -69,7 +80,8 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                        ref="projectElementService" />
                <property name="projectSettings" ref="projectSettings" />
                <property name="scenarioService" ref="scenarioService" />
-               <property name="stepService" ref="stepService" />
+        <property name="stepService" ref="stepService" />
+        <property name="studyDAO" ref="studyDAO" />
        </bean>
 
 </beans>
\ No newline at end of file
index 0a54b951856298a5302ab1fcbd98dd2d9e8cd16b..fb558d89c05e9c57abe935a565fbe676bcadc259 100644 (file)
@@ -4,6 +4,7 @@
        xsi:schemaLocation="
 http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+<!-- Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012 -->
 
     <bean id="textAttributeDAO" parent="genericDAO"
         class="org.splat.dal.dao.kernel.TextAttributeDAOImpl">
index 2f8d9b5dec7d8787f1cd3c86bcca2a55536061f2..2e17609a083f0ff1964032efe14c9bb2fcfee354 100644 (file)
@@ -16,7 +16,8 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
 
        <bean id="projectSettings"
                class="org.splat.service.technical.ProjectSettingsServiceImpl">
-               <property name="database" ref="database" />
+        <property name="database" ref="database" />
+        <property name="simulationContextService" ref="simulationContextService" />
        </bean>
 
        <bean id="indexService"
index d9d7bf1e72d810b89b1afe2814b7837089a101c4..a534902b1aefc45cb2979bb862d475de690cd774 100644 (file)
@@ -13,7 +13,9 @@ import org.splat.kernel.Do;
 import org.splat.dal.bo.kernel.User;
 import org.splat.service.PublicationService;
 import org.splat.service.ScenarioService;
+import org.splat.service.SimulationContextService;
 import org.splat.service.StepService;
+import org.splat.service.technical.RepositoryService;
 import org.splat.simer.Action;
 import org.splat.simer.OpenStudy;
 import org.splat.dal.bo.som.ConvertsRelation;
@@ -29,6 +31,14 @@ import org.splat.som.Step;
 
 public class SaveDocumentAction extends Action {
 
+       /**
+        * Serial version ID.
+        */
+       private static final long serialVersionUID = -3364960833373200115L;
+
+       /**
+        * Current open study.
+        */
        private OpenStudy mystudy = null;
        private int doctype = 0;
        private String filename = null;
@@ -36,11 +46,26 @@ public class SaveDocumentAction extends Action {
        private ProgressState state = null;
        private List<Document> defuses = null;
        private String summary = null; // Summary of changes in the new version
+       /**
+        * Injected scenario service.
+        */
        private ScenarioService _scenarioService;
+       /**
+        * Injected publication service.
+        */
        private PublicationService _publicationService;
+       /**
+        * Injected step service.
+        */
        private StepService _stepService;
-
-       private static final long serialVersionUID = -3364960833373200115L;
+       /**
+        * Injected repository service.
+        */
+       private RepositoryService _repositoryService;
+       /**
+        * Injected simulation context service.
+        */
+       private SimulationContextService _simulationContextService;
 
        // ==============================================================================================================================
        // Action methods
@@ -58,7 +83,8 @@ public class SaveDocumentAction extends Action {
                        DocumentType type = Document.selectType(doctype);
                        // File updir = Database.getDownloadDirectory(user);
                        // File upfile = new File(updir.getPath() + "/" + filename);
-                       String upath = Database.getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file between users
+                       String upath = getRepositoryService().getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file
+                                                                                                                                               // between users
                        File upfile = new File(upath + filename);
                        String[] table = filename.split("\\x2E");
                        String format = table[table.length - 1];
@@ -68,8 +94,10 @@ public class SaveDocumentAction extends Action {
                        connex.flush();
 
                        Document.Properties dprop = new Document.Properties();
-                       Publication credoc = getStepService().createDocument(step, dprop.setName(docname)
-                                       .setType(type).setFormat(format).setAuthor(user));
+                       Publication credoc = getStepService().createDocument(
+                                       step,
+                                       dprop.setName(docname).setType(type).setFormat(format)
+                                                       .setAuthor(user));
                        // Writing the uploaded file into the created document
                        File target = credoc.getSourceFile().asFile();
                        if (target.exists())
@@ -102,26 +130,28 @@ public class SaveDocumentAction extends Action {
                        // 2. Addition of simulation contexts
                        if (type.equals("model")) { // Set the characteristics of the mesh
                                SimulationContext.Properties cprop = new SimulationContext.Properties();
-                               SimulationContextType ctype = SimulationContext
+                               SimulationContextType ctype = getSimulationContextService()
                                                .selectType("model");
-                               SimulationContext context = Database.selectSimulationContext(
-                                               ctype, "Éléments finis");
+                               SimulationContext context = getSimulationContextService()
+                                               .selectSimulationContext(ctype, "Éléments finis");
                                if (context == null) {
                                        getStepService().addSimulationContext(step,
                                                        cprop.setType(ctype).setValue("Éléments finis"));
                                } else {
                                        getStepService().addSimulationContext(step, context);
                                }
-                               ctype = SimulationContext.selectType("element");
-                               context = Database.selectSimulationContext(ctype, "Surfacique");
+                               ctype = getSimulationContextService().selectType("element");
+                               context = getSimulationContextService()
+                                               .selectSimulationContext(ctype, "Surfacique");
                                if (context == null) {
                                        getStepService().addSimulationContext(step,
                                                        cprop.setType(ctype).setValue("Surfacique"));
                                } else {
                                        getStepService().addSimulationContext(step, context);
                                }
-                               ctype = SimulationContext.selectType("shape");
-                               context = Database.selectSimulationContext(ctype, "Triangles");
+                               ctype = getSimulationContextService().selectType("shape");
+                               context = getSimulationContextService()
+                                               .selectSimulationContext(ctype, "Triangles");
                                if (context == null) {
                                        getStepService().addSimulationContext(step,
                                                        cprop.setType(ctype).setValue("Triangles"));
@@ -222,7 +252,8 @@ public class SaveDocumentAction extends Action {
                        Step step = mystudy.getSelectedStep();
                        // File updir = Database.getDownloadDirectory(user);
                        // File upfile = new File(updir.getPath() + "/" + filename);
-                       String upath = Database.getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file between users
+                       String upath = getRepositoryService().getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file
+                                                                                                                                               // between users
                        File upfile = new File(upath + filename);
                        String[] table = filename.split("\\x2E");
                        String format = table[table.length - 1];
@@ -234,7 +265,8 @@ public class SaveDocumentAction extends Action {
                        if (summary.length() > 0)
                                dprop.setDescription(summary);
 
-                       Publication next = getStepService().versionDocument(step, current, dprop);
+                       Publication next = getStepService().versionDocument(step, current,
+                                       dprop);
 
                        // Writing the uploaded file into the created document
                        File target = next.getSourceFile().asFile();
@@ -338,4 +370,43 @@ public class SaveDocumentAction extends Action {
                                defuses.addAll(usedoc);
                }
        }
+
+       /**
+        * Get the repositoryService.
+        * 
+        * @return the repositoryService
+        */
+       public RepositoryService getRepositoryService() {
+               return _repositoryService;
+       }
+
+       /**
+        * Set the repositoryService.
+        * 
+        * @param repositoryService
+        *            the repositoryService to set
+        */
+       public void setRepositoryService(RepositoryService repositoryService) {
+               _repositoryService = repositoryService;
+       }
+
+       /**
+        * Get the simulationContextService.
+        * 
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * 
+        * @param simulationContextService
+        *            the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
+       }
 }
\ No newline at end of file
index 1606a892e1deff67862652fbc01c10750a06e39b..cf3137d0dfe1cf63516421ab5825775c6a8c5adf 100644 (file)
@@ -26,7 +26,13 @@ public class Action extends ActionSupport implements SessionAware {
        private OpenStudy _openStudy;
        private OpenKnowledge _openKnowledge;
 
+       /**
+        * Serial version ID.
+        */
        private   static final long    serialVersionUID = -895295026709526501L;
+       /**
+        * Action logger.
+        */
     protected static final Logger  logger           = Logger.getLogger(Action.class);
 
     public class DocumentTypeComparator implements Comparator<DocumentType> {
index 27ec0ac765e5b665ab52131a4a8f6ef5676a7e4a..ebf3e06d37f7c1b69bbe53ba653c5d2fcfab8a08 100644 (file)
@@ -55,8 +55,14 @@ public class ApplicationSettings {
     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);
 
+       /**
+        * Injected project settings service.
+        */
     private ProjectSettingsService _projectSettingsService;
 
        /**
index 1e90a55ef9ae33d0e19544237620b7b878d850c2..dae99b3b4a741364c22a51af5bd4931bde82e186 100644 (file)
@@ -23,6 +23,9 @@ public class ConnectionAction extends Action {
     private String             password = null;
     private String             backmenu = null;
 
+       /**
+        * Serial version ID.
+        */
        private static final long  serialVersionUID = 6095471616361606231L;
        
        private class Handler implements CallbackHandler {
index 57210220ee5e0b89315b8d28fd3de43bdbcdf7ec..c687485ced9ac73cf5ef4f7bc0b2e55ce0cff82f 100644 (file)
@@ -20,14 +20,17 @@ import org.apache.log4j.Logger;
 
 public class Converter implements MessageListener {
 
+       /**
+        * Converter logger.
+        */
+    final static Logger logger = Logger.getLogger(Converter.class);
+
     private String  type;     // Type of document to be converted (e.g. geometry, model)
     private String  from;     // Source format (e.g. py, sldprt)
     private String  to;       // Target format (e.g. brep)
     private String  exec;     // Command line launching the actual converter
     private String  fname;    // Absolute path of the source file to be converted
 
-    final static Logger logger = Logger.getLogger(Converter.class);
-
 //  ==============================================================================================================================
 //  Constructor
 //  ==============================================================================================================================
index 4985f7bc2e973ecd11d3193682510417f2919a79..58b66ab875ec9debc2c9bd950ff7deb13f93af89 100644 (file)
@@ -7,6 +7,9 @@ public abstract class DisplayBaseAction extends Action {
     protected  String          selection = null;    // User activity selection
     protected  String          action    = null;
 
+       /**
+        * Serial version ID.
+        */
     private static final long serialVersionUID = 3003902258668626946L;
 
        protected enum Execute { popup, develop, reduce, reduceall }
index 80d1dc71f151129264cd7f1cbae779a5197deceb..3738cf43cf432fdbcb1288a06d2ee26c9ecc250c 100644 (file)
@@ -12,171 +12,186 @@ 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.technical.RepositoryService;
 import org.splat.som.Step;
 
-
+/**
+ * Document modification action.
+ */
 public class EditDocumentAction extends DisplayStudyStepAction {
 
-    private String  index    = null;
-       private String  title    = null;
-    private String  filename = null;
+       /**
+        * Serial version ID.
+        */
+       private static final long serialVersionUID = 4573036736137033679L;
+
+       private String index = null;
+       private String title = null;
+       private String filename = null;
+       /**
+        * Injected publication service.
+        */
        private PublicationService _publicationService;
+       /**
+        * Injected repository service.
+        */
+       private RepositoryService _repositoryService;
 
-       private static final long serialVersionUID = 4573036736137033679L;
+       /**
+        * Operations enumeration.
+        */
+       private enum Execute {
+               renameDocument, accept, promote, demote, review, invalidate, approve, disapprove
+       };
+
+       // ==============================================================================================================================
+       // Action methods
+       // ==============================================================================================================================
+
+       /**
+        * Open a study.
+        * 
+        * @return SUCCESS
+        */
+       public String doInitialize() {
+               mystudy = getOpenStudy();
+               return SUCCESS;
+       }
+
+       public String doSetDocument() {
+               // ------------------------------
+               Session connex = Database.getSession();
+               Transaction transax = connex.beginTransaction();
+               try {
+                       mystudy = getOpenStudy();
+
+                       Execute todo = Execute.valueOf(action);
+                       Step step = mystudy.getSelectedStep();
+                       Publication doc = step.getDocument(Integer.valueOf(index));
+
+                       if (todo == Execute.renameDocument) {
+                               doc.rename(title);
+                               // Useless to update the document presentation
+                       } else if (todo == Execute.accept) {
+                               doc.actualize();
+                               mystudy.update(doc);
+                       } else if (todo == Execute.promote) {
+                               getPublicationService().promote(doc,
+                                               Calendar.getInstance().getTime());
+                               mystudy.update(doc);
+                       } else if (todo == Execute.demote) {
+                               getPublicationService().demote(doc);
+                               mystudy.update(doc);
+                       } else if (todo == Execute.review) {
+                               getPublicationService().review(doc,
+                                               Calendar.getInstance().getTime());
+                               mystudy.update(doc);
+                       } else if (todo == Execute.invalidate) {
+                               getPublicationService().invalidate(doc);
+                               mystudy.update(doc);
+                       } else if (todo == Execute.approve) {
+                               getPublicationService().approve(doc,
+                                               Calendar.getInstance().getTime());
+                               mystudy.update(doc);
+                               mystudy.getMenu().refreshSelectedItem(); // Updates the menu icon, in case of other documents in approved state
+                       }
+                       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 (InvalidPropertyException error) {
+                       transax.commit();
+                       return INPUT;
+               }
+       }
+
+       public String doAttach() {
+               // -------------------------
+               Session connex = Database.getSession();
+               Transaction transax = connex.beginTransaction();
+               try {
+                       // Getting user inputs
+                       mystudy = getOpenStudy();
+                       User user = getConnectedUser();
+                       Step step = mystudy.getSelectedStep();
+                       File updir = getRepositoryService().getDownloadDirectory(user);
+                       File upfile = new File(updir.getPath() + "/" + filename);
+                       String[] parse = filename.split("\\x2E");
+
+                       Publication edited = step.getDocument(Integer.valueOf(index));
+                       ConvertsRelation export = edited.attach(parse[parse.length - 1]);
+
+                       if (logger.isInfoEnabled())
+                               logger.info("Moving \"" + upfile.getName() + "\" to \""
+                                               + updir.getPath() + "\".");
+                       upfile.renameTo(export.getTo().asFile());
+
+                       mystudy.update(edited);
+                       transax.commit();
+                       return SUCCESS;
+               } catch (Exception error) {
+                       logger.error("Reason:", error);
+                       return ERROR;
+               }
+       }
+
+       public String doDeleteDocument() {
+               // ---------------------------------
+               Session connex = Database.getSession();
+               Transaction transax = connex.beginTransaction();
+               try {
+                       mystudy = getOpenStudy();
+
+                       Step step = mystudy.getSelectedStep();
+                       Publication doctag = step.getDocument(Integer.valueOf(index));
+
+                       step.removeDocument(doctag); // Updates the data structure
+                       transax.commit();
+
+                       mystudy.remove(doctag); // Updates the presentation
+                       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 void setDocumentTitle(String title) {
+               // -------------------------------------------
+               this.title = title;
+       }
+
+       public void setFileName(String filename) {
+               // -----------------------------------------
+               this.filename = filename;
+       }
+
+       public void setIndex(String index) {
+               // -----------------------------------
+               this.index = index;
+       }
 
-       private enum Execute { renameDocument, accept, promote, demote, review, invalidate, approve, disapprove };
-
-//  ==============================================================================================================================
-//  Action methods
-//  ==============================================================================================================================
-
-    public String doInitialize () {
-//  -----------------------------
-//    Session      connex  = Database.getSession();
-//       Transaction  transax = connex.beginTransaction();
-
-         mystudy = getOpenStudy();
-        
-//    transax.commit();
-      return SUCCESS;
-    }
-
-    public String doSetDocument () {
-//  ------------------------------
-      Session      connex  = Database.getSession();
-      Transaction  transax = connex.beginTransaction();
-      try {
-           mystudy = getOpenStudy();
-
-        Execute      todo = Execute.valueOf(action);
-               Step         step = mystudy.getSelectedStep();
-               Publication  doc  = step.getDocument(Integer.valueOf(index));
-        
-        if (todo == Execute.renameDocument) {
-                 doc.rename(title);
-//        Useless to update the document presentation
-        } else
-        if (todo == Execute.accept) {
-          doc.actualize();
-          mystudy.update(doc);
-        } else
-        if (todo == Execute.promote) {
-               getPublicationService().promote(doc, Calendar.getInstance().getTime());
-          mystudy.update(doc);
-        } else
-        if (todo == Execute.demote) {
-               getPublicationService().demote(doc);
-          mystudy.update(doc);
-        } else
-        if (todo == Execute.review) {
-               getPublicationService().review(doc, Calendar.getInstance().getTime());
-          mystudy.update(doc);
-        } else
-        if (todo == Execute.invalidate) {
-               getPublicationService().invalidate(doc);
-          mystudy.update(doc);
-        } else
-        if (todo == Execute.approve) {
-               getPublicationService().approve(doc, Calendar.getInstance().getTime());
-          mystudy.update(doc);
-          mystudy.getMenu().refreshSelectedItem();   // Updates the menu icon, in case of other documents in approved state
-        }
-        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 (InvalidPropertyException error) {
-        transax.commit();
-       return INPUT;
-      }
-    }
-
-    public String doAttach () {
-//  -------------------------
-      Session      connex  = Database.getSession();
-         Transaction  transax = connex.beginTransaction();
-      try {
-//      Getting user inputs
-                 mystudy = getOpenStudy();
-        User     user    = getConnectedUser();
-        Step     step    = mystudy.getSelectedStep();
-       File     updir   = Database.getDownloadDirectory(user);
-       File     upfile  = new File(updir.getPath() + "/" + filename);
-        String[] parse   = filename.split("\\x2E");
-
-        Publication       edited = step.getDocument(Integer.valueOf(index));
-        ConvertsRelation  export = edited.attach(parse[parse.length-1]);
-
-               if (logger.isInfoEnabled()) logger.info("Moving \"" + upfile.getName() + "\" to \"" + updir.getPath() + "\".");
-        upfile.renameTo(export.getTo().asFile());
-
-        mystudy.update(edited);
-        transax.commit();
-        return  SUCCESS;
-      }
-      catch (Exception error) {
-        logger.error("Reason:", error);
-        return ERROR;
-      }
-    }
-
-    public String doDeleteDocument () {
-//  ---------------------------------
-      Session     connex  = Database.getSession();
-         Transaction transax = connex.beginTransaction();
-         try {
-               mystudy = getOpenStudy();
-           
-               Step         step   = mystudy.getSelectedStep();
-        Publication  doctag = step.getDocument(Integer.valueOf(index));
-
-        step.removeDocument(doctag);   // Updates the data structure
-        transax.commit();
-
-        mystudy.remove(doctag);        // Updates the presentation
-        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 void setDocumentTitle (String title) {
-//  -------------------------------------------
-      this.title = title;
-    }
-    public void setFileName (String filename) {
-//  -----------------------------------------
-      this.filename = filename;
-    }
-    public void setIndex (String index) {
-//  -----------------------------------
-      this.index = index;
-    }
        /**
         * Get the publicationService.
         * 
@@ -195,4 +210,23 @@ public class EditDocumentAction extends DisplayStudyStepAction {
        public void setPublicationService(PublicationService publicationService) {
                _publicationService = publicationService;
        }
+
+       /**
+        * Get the repositoryService.
+        * 
+        * @return the repositoryService
+        */
+       public RepositoryService getRepositoryService() {
+               return _repositoryService;
+       }
+
+       /**
+        * Set the repositoryService.
+        * 
+        * @param repositoryService
+        *            the repositoryService to set
+        */
+       public void setRepositoryService(RepositoryService repositoryService) {
+               _repositoryService = repositoryService;
+       }
 }
\ No newline at end of file
index 4b13620e6e665375213d0cc1d5992a9873ffccb1..38f2f1741a9967765fb941c996a94f19d0da7077 100644 (file)
@@ -21,6 +21,9 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
        private ScenarioService _scenarioService;
        private KnowledgeElementService _knowledgeElementService;
 
+       /**
+        * Serial version ID.
+        */
        private static final long    serialVersionUID = 4636919137087687068L;
 
 //  ==============================================================================================================================
index a3f3d25e63e67b9cebff57fd4b03779874210c9d..cb27c9aa8a0a7399650104c9cfd4ae811504bd76 100644 (file)
@@ -21,6 +21,9 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
        private ScenarioService _scenarioService;
        private ProjectElementService _projectElementService;
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = 4964740932426016171L;
 
        // ==============================================================================================================================
index 3dba784337c16c204d76a7be2058c2b22f01b759..d133314ec4b1719456cdc4cce7ecc81751d521ac 100644 (file)
@@ -10,6 +10,7 @@ import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.ProjectElement;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.service.SimulationContextService;
 import org.splat.service.StepService;
 import org.splat.service.StudyService;
 import org.splat.som.Step;
@@ -23,8 +24,18 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        private String newtype = null; // Context type, if newed
        private SimulationContextType type = null; // Corresponding context type object
        private String value = null; // Context value
+       /**
+        * Injected study service.
+        */
        private StudyService _studyService;
+       /**
+        * Injected step service.
+        */
        private StepService _stepService;
+       /**
+        * Injected simulation context service.
+        */
+       private SimulationContextService _simulationContextService;
 
        /**
         * Get the stepService.
@@ -77,11 +88,11 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                                return "create";
 
                        SimulationContext.Properties cprop = new SimulationContext.Properties();
-                       type = SimulationContext.selectType(typid);
+                       type = getSimulationContextService().selectType(typid);
                        newtype = type.getName();
                        contype = getInvolvedContexts();
-                       contelm = Database.selectSimulationContextsWhere(cprop
-                                       .setType(type));
+                       contelm = getSimulationContextService()
+                                       .selectSimulationContextsWhere(cprop.setType(type));
 
                        return "set";
                } finally {
@@ -103,7 +114,8 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
 
                        SimulationContext.Properties cprop = new SimulationContext.Properties();
                        SimulationContext contex = null;
-                       type = SimulationContext.createType(newtype, step.getStep());
+                       type = getSimulationContextService().createType(newtype,
+                                       step.getStep());
                        cprop.setType(type).setValue(value);
                        if (owner instanceof Study)
                                contex = getStudyService().addProjectContext(((Study) owner),
@@ -181,7 +193,8 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                                        || (input.length == 2 && input[1].equals(" "))) {
                                // Setting an existing simulation context identified by value (input = rid," ")
                                int valid = Integer.valueOf(input[0]);
-                               contex = Database.selectSimulationContext(valid);
+                               contex = getSimulationContextService().selectSimulationContext(
+                                               valid);
                                if (owner instanceof Study)
                                        getStudyService()
                                                        .addProjectContext(((Study) owner), contex);
@@ -191,8 +204,8 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                                // Setting a new simulation context value (input = 0,"new context value")
                                int typid = Integer.valueOf(selectype);
                                SimulationContext.Properties cprop = new SimulationContext.Properties();
-                               cprop.setType(SimulationContext.selectType(typid)).setValue(
-                                               input[1].trim());
+                               cprop.setType(getSimulationContextService().selectType(typid))
+                                               .setValue(input[1].trim());
                                if (owner instanceof Study)
                                        contex = getStudyService().addProjectContext(
                                                        ((Study) owner), cprop); // Re-indexes knowledges and the study
@@ -273,7 +286,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                // ----------------------------------------------------------
                SimulationContextType.Properties sprop = new SimulationContextType.Properties()
                                .setStep(mystudy.getSelectedStep().getStep());
-               List<SimulationContextType> contype = SimulationContext
+               List<SimulationContextType> contype = getSimulationContextService()
                                .selectTypesWhere(sprop);
 
                if (!contype.isEmpty()) {
@@ -319,4 +332,24 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        public void setStudyService(StudyService studyService) {
                _studyService = studyService;
        }
+
+       /**
+        * Get the simulationContextService.
+        * 
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * 
+        * @param simulationContextService
+        *            the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
+       }
 }
\ No newline at end of file
index 79c48426aa4e590ffaf8be83e9ffbbf1a750f455..a494f1afb21078a5573d193ae3238d7fc57504fd 100644 (file)
@@ -10,6 +10,9 @@ import org.splat.service.StudyService;
 
 public class EditStudyAction extends DisplayStudyStepAction {
     
+       /**
+        * Serial version ID.
+        */
     private static final long serialVersionUID = -4865668290514118396L;
 
        private enum Execute { publish, promote }
index 6508745562dde7e78c4204f4a5e51cd7dc32deb9..47957e5b3622163054cbe745801dada692ee2eb7 100644 (file)
@@ -19,9 +19,11 @@ import org.splat.manox.Toolbox;
 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.PublicationService;
 import org.splat.service.StepService;
 import org.splat.service.technical.ProjectSettingsService;
+import org.splat.service.technical.RepositoryService;
 import org.splat.dal.bo.som.Publication;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.som.Revision;
@@ -29,27 +31,52 @@ import org.splat.som.Step;
 
 public class ImportDocumentAction extends UploadBaseNextAction {
 
+       /**
+        * Serial version ID.
+        */
+       private static final long serialVersionUID = 2587822564883588556L;
+
        private List<DocumentType> doctypes = null;
        private long doctype = 0;
        private String docref = null; // Reference extracted from the imported file, if exist
        private String docver = ""; // Version number extracted from the imported file, if exist
        private String date = ""; // Date extracted from the imported file, if exist
+       /**
+        * Injected project settings service.
+        */
        private ProjectSettingsService _projectSettingsService;
+       /**
+        * Injected publication service.
+        */
        private PublicationService _publicationService;
+       /**
+        * Injected step service.
+        */
        private StepService _stepService;
+       /**
+        * Injected document service.
+        */
+       private DocumentService _documentService;
 
-       private static final long serialVersionUID = 2587822564883588556L;
+       /**
+        * Injected repository service.
+        */
+       private RepositoryService _repositoryService;
 
        // ==============================================================================================================================
        // Action methods
        // ==============================================================================================================================
 
+       /**
+        * Initialize the operation.
+        * @return SUCCESS in success, otherwise - ERROR
+        */
        public String doInitialize() {
                // -----------------------------
                Session connex = Database.getSession();
                Transaction transax = connex.beginTransaction();
                User user = getConnectedUser();
-               File updir = Database.getDownloadDirectory(user);
+               File updir = getRepositoryService().getDownloadDirectory(user);
                File upfile = new File(updir.getPath() + "/" + filename);
                String[] table = filename.split("\\x2E");
                String filext = table[table.length - 1].toLowerCase();
@@ -75,7 +102,7 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                                break;
                        }
                        if (fileref != null) {
-                               Document slot = Database.selectDocument(fileref,
+                               Document slot = getDocumentService().selectDocument(fileref,
                                                new Revision().toString());
                                if (slot == null) {
                                        setErrorCode("reference.undefined");
@@ -139,6 +166,10 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                return SUCCESS;
        }
 
+       /**
+        * Perform import of a document.
+        * @return SUCCESS if ok, "cancel" - if canceled, ERROR - if error
+        */
        public String doImport() {
                // -------------------------
                if (action == ToDo.cancel)
@@ -155,7 +186,7 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                        User user = getConnectedUser();
                        Step step = mystudy.getSelectedStep();
                        DocumentType type = Document.selectType((int)doctype);
-                       File updir = Database.getDownloadDirectory(user);
+                       File updir = getRepositoryService().getDownloadDirectory(user);
                        File upfile = new File(updir.getPath() + "/" + filename);
                        String[] table = filename.split("\\x2E");
 
@@ -375,4 +406,36 @@ public class ImportDocumentAction extends UploadBaseNextAction {
        public void setStepService(StepService stepService) {
                _stepService = stepService;
        }
+
+       /**
+        * 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 repositoryService.
+        * @return the repositoryService
+        */
+       public RepositoryService getRepositoryService() {
+               return _repositoryService;
+       }
+
+       /**
+        * Set the repositoryService.
+        * @param repositoryService the repositoryService to set
+        */
+       public void setRepositoryService(RepositoryService repositoryService) {
+               _repositoryService = repositoryService;
+       }
 }
\ No newline at end of file
index 951a8371c3598b26256f6cd57f9cc1289a873183..1c026e32d0d4622031e670e3bc42f176e543d2bd 100644 (file)
@@ -8,6 +8,9 @@ public class MenuAction extends Action {
     private String menuname;
        private String selection;
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = 5904292225286579036L;
 
 //  ==============================================================================================================================
index bc9b0ba781dacdc0218f8b60454dd613874b1b86..85adabda9bf91fd4fef0e1f315481007d16fa5e0 100644 (file)
@@ -30,6 +30,9 @@ public class NewScenarioAction extends Action {
        private StudyService _studyService;
        private ProjectElementService _projectElementService;
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = -5586724442986956861L;
 
     protected enum  ToDo { cancel, save };
index 7d81c008366924739d9815eb1c1b8f47757c0ead..05da635e63b716178bdd23be896c30ae9086390b 100644 (file)
@@ -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.SimulationContextService;
 import org.splat.service.StudyService;
 
 public class NewStudyAction extends Action {
@@ -20,30 +21,35 @@ public class NewStudyAction extends Action {
        private String context = null;
 
        private static int number = 0;
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = 693943641800113782L;
 
-       
        /**
-        * The Study service.
+        * The injected Study service.
         */
        private StudyService _studyService;
+       private SimulationContextService _simulationContextService;
 
        // ==============================================================================================================================
        // Action methods
        // ==============================================================================================================================
 
-       //Fill the values of the drop-down list. 
-    public String doInitialize () {            
-       
-      //get the list of the simulation contexts of the study
-      contelm = _studyService.getSimulationContextList();
-       
-      //set the default name of the new study
-      ResourceBundle locale  = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale());
-      title = locale.getString("label.study") + " " + String.valueOf(number + 1);
-               
-      return SUCCESS;
-    }
+       // Fill the values of the drop-down list.
+       public String doInitialize() {
+
+               // get the list of the simulation contexts of the study
+               contelm = getSimulationContextService().getSimulationContextList();
+
+               // set the default name of the new study
+               ResourceBundle locale = ResourceBundle.getBundle("labels",
+                               ApplicationSettings.getCurrentLocale());
+               title = locale.getString("label.study") + " "
+                               + String.valueOf(number + 1);
+
+               return SUCCESS;
+       }
 
        public String doCreate() throws Exception {
                // -------------------------
@@ -69,10 +75,10 @@ public class NewStudyAction extends Action {
                        sprop.disableCheck();
                } catch (Exception error) {
                        SimulationContext.Properties cprop = new SimulationContext.Properties();
-                       SimulationContextType product = SimulationContext
+                       SimulationContextType product = getSimulationContextService()
                                        .selectType("product");
-                       contelm = Database.selectSimulationContextsWhere(cprop
-                                       .setType(product));
+                       contelm = getSimulationContextService()
+                                       .selectSimulationContextsWhere(cprop.setType(product));
                        transax.commit();
                        return INPUT; // Title empty, simply wait for input without error message
                }
@@ -89,11 +95,12 @@ public class NewStudyAction extends Action {
                        // Addition of the entered project context
                        if (valid == 0) { // Input of new project context
                                SimulationContext.Properties cprop = new SimulationContext.Properties();
-                               cprop.setType(SimulationContext.selectType("product"))
+                               cprop.setType(
+                                               getSimulationContextService().selectType("product"))
                                                .setValue(value);
                                getStudyService().addProjectContext(study, cprop);
                        } else { // Selection of existing project context
-                               SimulationContext context = Database
+                               SimulationContext context = getSimulationContextService()
                                                .selectSimulationContext(valid);
                                getStudyService().addProjectContext(study, context);
                        }
@@ -163,4 +170,24 @@ public class NewStudyAction extends Action {
        public void setStudyService(StudyService studyService) {
                _studyService = studyService;
        }
+
+       /**
+        * Get the simulationContextService.
+        * 
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * 
+        * @param simulationContextService
+        *            the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
+       }
 }
\ No newline at end of file
index 091fb7977b87d4203be9b78948d91cf1305595a0..9f5666e31053bf0bdcd53f1ddae67fcfcba440f1 100644 (file)
@@ -3,6 +3,9 @@ package org.splat.simer;
 
 public class NotYetImplementedAction extends Action {
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = 3131921588316476454L;
 
 //  ==============================================================================================================================
index 9d1edc110641d5cbf98f2fe90b7a3b5889dd138a..0e19bf08ac32a845a49418a8d973d297af48c349 100644 (file)
@@ -27,10 +27,9 @@ import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.service.ProjectElementService;
-import org.splat.service.PublicationService;
 import org.splat.service.ScenarioService;
 import org.splat.service.StepService;
-import org.splat.service.technical.ProjectSettingsService;
+import org.splat.service.technical.RepositoryService;
 import org.splat.dal.bo.som.Publication;
 import org.splat.som.Revision;
 import org.splat.dal.bo.som.Scenario;
@@ -44,6 +43,11 @@ import org.splat.wapp.ToolBar;
 
 public class OpenStudy extends OpenObject implements OpenStudyServices {
 
+       /**
+        * Serial version ID.
+        */
+       protected final static Logger   logger = org.splat.simer.Action.logger;
+    
     private  Study       mystudy;
     private  StudyRights urightstudy;              // User rights on the open study
        private  StepRights  urightstep;               // User rights on the selected step
@@ -51,15 +55,32 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
     private  String      credate;
     private  String      lasdate;
     private  Publication selecdoc;
+       /**
+        * Injected project element service.
+        */
        private ProjectElementService _projectElementService;
+       /**
+        * Injected scenario service.
+        */
        private ScenarioService _scenarioService;
+       /**
+        * Injected step service.
+        */
        private StepService _stepService;
-       protected final static Logger   logger = org.splat.simer.Action.logger;
-    
+       /**
+        * Injected repository service.
+        */
+       private RepositoryService _repositoryService;
 //  ==============================================================================================================================
 //  Constructor
 //  ==============================================================================================================================
 
+    /**
+     * Open the given study in the current http session.
+     * @param user the current user
+     * @param study the study to open
+     * @return this open study object
+     */
     public OpenStudy open (User user, Study study) {
 //  -----------------------------------------
       ResourceBundle    custom    = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
@@ -178,13 +199,13 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
     public URL newTemplateBasedDocument (String typename, User author) {
 //  ------------------------------------------------------------------
       String filename = typename + ".xml";     // Only XML templates are writeable
-      File   template = new File(Database.getTemplatePath() + filename);      
+      File   template = new File(getRepositoryService().getTemplatePath() + filename);      
       if   (!template.exists()) return null;
       
       Session      connex  = Database.getSession();
          Transaction  transax = connex.beginTransaction();
       try {
-        File  udir   = Database.getDownloadDirectory(author);
+        File  udir   = getRepositoryService().getDownloadDirectory(author);
         File  credoc = new File(udir.getPath() + "/" + filename);
 
 //      Creation of the meta-document
@@ -476,4 +497,20 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        public void setStepService(StepService stepService) {
                _stepService = stepService;
        }
+
+       /**
+        * Get the repositoryService.
+        * @return the repositoryService
+        */
+       public RepositoryService getRepositoryService() {
+               return _repositoryService;
+       }
+
+       /**
+        * Set the repositoryService.
+        * @param repositoryService the repositoryService to set
+        */
+       public void setRepositoryService(RepositoryService repositoryService) {
+               _repositoryService = repositoryService;
+       }
 }
\ No newline at end of file
index 6258bbf24fa6a1fbf12f0b92681d32a8fc5ecf8b..2c321176fc3a7b51ea54aaa5ff84e6e6b11f7228 100644 (file)
@@ -13,222 +13,271 @@ import org.splat.dal.bo.kernel.User;
 import org.splat.kernel.UserDirectory;
 import org.splat.som.ApplicationRights;
 import org.splat.dal.dao.som.Database;
+import org.splat.service.SimulationContextService;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.service.dto.Proxy;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
 
-
 public abstract class SearchBaseAction extends Action {
 
-       protected String                      ctype    = null;   // Context type  index, when selected
-       protected String                      cvalue   = null;   // Context value index, when selected
-       protected String                      cindex   = "";     // Context index, when removed
-    protected String                      author  = null;
-    protected List<Name>                  manager = null;
-       protected SimulationContextType       newtype;           // Context type  to be valued
-       protected List<SimulationContext>     newvalue;          // Context value to be selected
-       protected List<SimulationContextType> critext;           // Addable context types
-       protected List<SimulationContext>     context;           // Current contexts search criteria
-       protected List<Proxy>                 result;
-
-       private static final long   serialVersionUID = 7863055790228544510L;
-
-    enum UserAction { refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext }
-
-//  ==============================================================================================================================
-//  Action methods
-//  ==============================================================================================================================
-
-       public String doSubmitForm () {
-//  -----------------------------
-//  Identification of the user action
-      UserAction                                              action = UserAction.refreshResult; 
-      if      (ctype  != null && Integer.valueOf(ctype)  > 0) action = UserAction.selectContextType;
-      else if (cvalue != null && Integer.valueOf(cvalue) > 0) action = UserAction.selectContextValue;
-      else if (cindex.length() > 0) {
-       int      index = Integer.valueOf(cindex);
-        if      (index > 0)                                   action = UserAction.removeContext;
-        else if (index < 0)                                   action = UserAction.cancelSelect;
-      }
-//  Execution of the user action
-      Session      connex  = Database.getSession();
-      Transaction  transax = connex.beginTransaction();
-      String       done;
-      try {
-        saveFilter();                                      // Also reinitializes the form, if needed
-
-        if (action == UserAction.selectContextType) {
-          done = doSelectContextType();
-        } else
-        if (action == UserAction.selectContextValue) {
-          done = doAddContext();
-        } else
-        if (action == UserAction.removeContext) {
-          done = doRemoveContext();
-        } else
-        if (action == UserAction.cancelSelect) {
-          done = doCancel();
-        }
-        else {     // UserAction.refreshResult
-          done = doSearch();
-          setContextTypeOptions(getInvolvedContexts());    // Done in other do functions, when required
-        }
-        setCandidates();
-        transax.commit();
-        return done;
-      }
-      catch (Exception error) {
-//      No need to roll back the transaction as it is read only
-       logger.error("Reason: ", error);
-        return ERROR;
-      }
-       }
-
-    @SuppressWarnings("unchecked")
-       protected String doSelectContextType () {
-//  ---------------------------------------
-      SimulationContext.Properties  sprop = new SimulationContext.Properties();
-
-      newtype  = SimulationContext.selectType(Integer.valueOf(ctype));
-      newvalue = Database.selectSimulationContextsWhere(sprop.setType(newtype));
-      if (cindex.length() > 0 && Integer.valueOf(cindex) == 0)
-       getSession().remove("search.result");
-      else
-        result = (List<Proxy>)getSession().get("search.result");   // We keep the previous result search, if valid
-      return "selectype";
-    }
-
-    protected String doAddContext () {
-//  --------------------------------
-      SimulationContext  selected = Database.selectSimulationContext(Integer.valueOf(cvalue));
-
-      context.add(selected);
-      setContextTypeOptions(getInvolvedContexts());                // Sets critext
-      getSession().remove("search.result");                        // The current result is obsolete
-      return "refresh";
-    }
-
-    protected String doRemoveContext () {
-//  -----------------------------------
-      int  index = Integer.valueOf(cindex);
-      for (Iterator<SimulationContext> selected=context.iterator(); selected.hasNext();) {
-       if (selected.next().getIndex() == index) {
-          selected.remove();
-          break;
-       }
-      }
-      setContextTypeOptions(getInvolvedContexts());                // Sets critext
-      getSession().remove("search.result");                        // The current result is obsolete
-      return "refresh";
-    }
-
-    @SuppressWarnings("unchecked")
-       protected String doCancel () {
-//  ----------------------------
-      result = (List<Proxy>)getSession().get("search.result");     // Current result search
-      setContextTypeOptions(getInvolvedContexts());                // Sets critext
-      return "refresh";
-    }
-
-//  ==============================================================================================================================
-//  Getters
-//  ==============================================================================================================================
-
-    public String getAuthor () {
-//  --------------------------
-      return author;
-    }
-    public List<Name> getCandidates () {
-//  ----------------------------------
-      return manager;
-    }
-    public List<SimulationContextType> getContextTypeOptions () {
-//  -----------------------------------------------------------
-      return critext;
-    }
-    public List<SimulationContext> getContextValueOptions () {
-//  --------------------------------------------------------
-      return newvalue;
-    }
-    public SimulationContextType getSelectedContextType () {
-//  ------------------------------------------------------
-      return newtype;
-    }
-    public List<SimulationContext> getSimulationContexts () {
-//  -------------------------------------------------------
-      return context;
-    }
-    public List<Proxy> getResult () {
-//  -------------------------------
-      return result;
-    }
-
-//  ==============================================================================================================================
-//  Setters
-//  ==============================================================================================================================
-    
-    public void setAuthor (String index) {
-//  ------------------------------------
-      this.author = index;
-    }
-    public void setContextType (String type) {
-//  ----------------------------------------
-      this.ctype = type;
-    }
-    public void setContextValue (String value) {
-//  ------------------------------------------
-      this.cvalue = value;
-    }
-    public void setContextIndex (String value) {
-//  ------------------------------------------
-      this.cindex = value;
-    }
-
-    protected void setCandidates () {
-//  -------------------------------
-      manager = new Vector<Name>();
-      List<User> users = UserDirectory.selectAllUsers();
-      User       me    = getConnectedUser();        // May be null
-      for (Iterator<User> i=users.iterator(); i.hasNext(); ) {
-        User               next = i.next();
-        ApplicationRights  he   = new ApplicationRights(next);
-        if (he.canCreateStudy()) {
-          if (next.equals(me)) manager.add(0, new ValidationFacade.ByManager(me));
-          else                 manager.add(next);
-        }
-      }
-    }
-
-    protected void setContextTypeOptions (List<SimulationContextType> critext) {
-//  --------------------------------------------------------------------------
-      for (Iterator<SimulationContext> i=context.iterator(); i.hasNext();) {
-        critext.remove(i.next().getType());                        // Already used context type
-      }
-//    Ordering by alphabetical order of localized context types
-      SimulationContextType[] types   = critext.toArray( new SimulationContextType[critext.size()] );
-      ContextTypeComparator   compare = new ContextTypeComparator();
-      ProjectSettingsService.Step    step    = types[0].getAttachedStep();
-      int  from = 0;
-      int  to   = 0;
-      while (to < types.length-1) {
-        to += 1;
-       if (types[to].isAttachedTo(step)) continue;
-
-        if (to > from+1) Arrays.sort(types, from, to, compare);
-        from = to;
-       step = types[to].getAttachedStep();
-      }
-      if (to > from) Arrays.sort(types, from, to+1, compare);
-      this.critext  =  Arrays.asList(types);
-    }
-
-//  ==============================================================================================================================
-//  Abstract services
-//  ==============================================================================================================================
-
-       protected abstract String                      doSearch () throws InvalidPropertyException;
-       protected abstract List<SimulationContextType> getInvolvedContexts ();
-       protected abstract void                        loadFilter ();
-       protected abstract void                        saveFilter ();
+       /**
+        * Serial version ID.
+        */
+       private static final long serialVersionUID = 7863055790228544510L;
+
+       protected String ctype = null; // Context type index, when selected
+       protected String cvalue = null; // Context value index, when selected
+       protected String cindex = ""; // Context index, when removed
+       protected String author = null;
+       protected List<Name> manager = null;
+       protected SimulationContextType newtype; // Context type to be valued
+       protected List<SimulationContext> newvalue; // Context value to be selected
+       protected List<SimulationContextType> critext; // Addable context types
+       protected List<SimulationContext> context; // Current contexts search criteria
+       protected List<Proxy> result;
+       /**
+        * Injected simulation context service.
+        */
+       private SimulationContextService _simulationContextService;
+
+       enum UserAction {
+               refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext
+       }
+
+       // ==============================================================================================================================
+       // Action methods
+       // ==============================================================================================================================
+
+       public String doSubmitForm() {
+               // -----------------------------
+               // Identification of the user action
+               UserAction action = UserAction.refreshResult;
+               if (ctype != null && Integer.valueOf(ctype) > 0)
+                       action = UserAction.selectContextType;
+               else if (cvalue != null && Integer.valueOf(cvalue) > 0)
+                       action = UserAction.selectContextValue;
+               else if (cindex.length() > 0) {
+                       int index = Integer.valueOf(cindex);
+                       if (index > 0)
+                               action = UserAction.removeContext;
+                       else if (index < 0)
+                               action = UserAction.cancelSelect;
+               }
+               // Execution of the user action
+               Session connex = Database.getSession();
+               Transaction transax = connex.beginTransaction();
+               String done;
+               try {
+                       saveFilter(); // Also reinitializes the form, if needed
+
+                       if (action == UserAction.selectContextType) {
+                               done = doSelectContextType();
+                       } else if (action == UserAction.selectContextValue) {
+                               done = doAddContext();
+                       } else if (action == UserAction.removeContext) {
+                               done = doRemoveContext();
+                       } else if (action == UserAction.cancelSelect) {
+                               done = doCancel();
+                       } else { // UserAction.refreshResult
+                               done = doSearch();
+                               setContextTypeOptions(getInvolvedContexts()); // Done in other do functions, when required
+                       }
+                       setCandidates();
+                       transax.commit();
+                       return done;
+               } catch (Exception error) {
+                       // No need to roll back the transaction as it is read only
+                       logger.error("Reason: ", error);
+                       return ERROR;
+               }
+       }
+
+       @SuppressWarnings("unchecked")
+       protected String doSelectContextType() {
+               // ---------------------------------------
+               SimulationContext.Properties sprop = new SimulationContext.Properties();
+
+               newtype = getSimulationContextService().selectType(Integer.valueOf(ctype));
+               newvalue = getSimulationContextService().selectSimulationContextsWhere(
+                               sprop.setType(newtype));
+               if (cindex.length() > 0 && Integer.valueOf(cindex) == 0)
+                       getSession().remove("search.result");
+               else
+                       result = (List<Proxy>) getSession().get("search.result"); // We keep the previous result search, if valid
+               return "selectype";
+       }
+
+       protected String doAddContext() {
+               // --------------------------------
+               SimulationContext selected = getSimulationContextService()
+                               .selectSimulationContext(Integer.valueOf(cvalue));
+
+               context.add(selected);
+               setContextTypeOptions(getInvolvedContexts()); // Sets critext
+               getSession().remove("search.result"); // The current result is obsolete
+               return "refresh";
+       }
+
+       protected String doRemoveContext() {
+               // -----------------------------------
+               int index = Integer.valueOf(cindex);
+               for (Iterator<SimulationContext> selected = context.iterator(); selected
+                               .hasNext();) {
+                       if (selected.next().getIndex() == index) {
+                               selected.remove();
+                               break;
+                       }
+               }
+               setContextTypeOptions(getInvolvedContexts()); // Sets critext
+               getSession().remove("search.result"); // The current result is obsolete
+               return "refresh";
+       }
+
+       @SuppressWarnings("unchecked")
+       protected String doCancel() {
+               // ----------------------------
+               result = (List<Proxy>) getSession().get("search.result"); // Current result search
+               setContextTypeOptions(getInvolvedContexts()); // Sets critext
+               return "refresh";
+       }
+
+       // ==============================================================================================================================
+       // Getters
+       // ==============================================================================================================================
+
+       public String getAuthor() {
+               // --------------------------
+               return author;
+       }
+
+       public List<Name> getCandidates() {
+               // ----------------------------------
+               return manager;
+       }
+
+       public List<SimulationContextType> getContextTypeOptions() {
+               // -----------------------------------------------------------
+               return critext;
+       }
+
+       public List<SimulationContext> getContextValueOptions() {
+               // --------------------------------------------------------
+               return newvalue;
+       }
+
+       public SimulationContextType getSelectedContextType() {
+               // ------------------------------------------------------
+               return newtype;
+       }
+
+       public List<SimulationContext> getSimulationContexts() {
+               // -------------------------------------------------------
+               return context;
+       }
+
+       public List<Proxy> getResult() {
+               // -------------------------------
+               return result;
+       }
+
+       // ==============================================================================================================================
+       // Setters
+       // ==============================================================================================================================
+
+       public void setAuthor(String index) {
+               // ------------------------------------
+               this.author = index;
+       }
+
+       public void setContextType(String type) {
+               // ----------------------------------------
+               this.ctype = type;
+       }
+
+       public void setContextValue(String value) {
+               // ------------------------------------------
+               this.cvalue = value;
+       }
+
+       public void setContextIndex(String value) {
+               // ------------------------------------------
+               this.cindex = value;
+       }
+
+       protected void setCandidates() {
+               // -------------------------------
+               manager = new Vector<Name>();
+               List<User> users = UserDirectory.selectAllUsers();
+               User me = getConnectedUser(); // May be null
+               for (Iterator<User> i = users.iterator(); i.hasNext();) {
+                       User next = i.next();
+                       ApplicationRights he = new ApplicationRights(next);
+                       if (he.canCreateStudy()) {
+                               if (next.equals(me))
+                                       manager.add(0, new ValidationFacade.ByManager(me));
+                               else
+                                       manager.add(next);
+                       }
+               }
+       }
+
+       protected void setContextTypeOptions(List<SimulationContextType> critext) {
+               // --------------------------------------------------------------------------
+               for (Iterator<SimulationContext> i = context.iterator(); i.hasNext();) {
+                       critext.remove(i.next().getType()); // Already used context type
+               }
+               // Ordering by alphabetical order of localized context types
+               SimulationContextType[] types = critext
+                               .toArray(new SimulationContextType[critext.size()]);
+               ContextTypeComparator compare = new ContextTypeComparator();
+               ProjectSettingsService.Step step = types[0].getAttachedStep();
+               int from = 0;
+               int to = 0;
+               while (to < types.length - 1) {
+                       to += 1;
+                       if (types[to].isAttachedTo(step))
+                               continue;
+
+                       if (to > from + 1)
+                               Arrays.sort(types, from, to, compare);
+                       from = to;
+                       step = types[to].getAttachedStep();
+               }
+               if (to > from)
+                       Arrays.sort(types, from, to + 1, compare);
+               this.critext = Arrays.asList(types);
+       }
+
+       // ==============================================================================================================================
+       // Abstract services
+       // ==============================================================================================================================
+
+       protected abstract String doSearch() throws InvalidPropertyException;
+
+       protected abstract List<SimulationContextType> getInvolvedContexts();
+
+       protected abstract void loadFilter();
+
+       protected abstract void saveFilter();
+
+       /**
+        * Get the simulationContextService.
+        * 
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * 
+        * @param simulationContextService
+        *            the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
+       }
 }
\ No newline at end of file
index df2cbda2ca1b803eb96e755875c98895029afba3..a97e6fff2d6c200781cf385f7bd82d76e115cdb4 100644 (file)
@@ -3,6 +3,9 @@ package org.splat.simer;
 
 public class SearchDocumentAction extends Action {
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = 4347921635793712836L;
 
 //  ==============================================================================================================================
index a442c3e4c4735f6d63ba1199378daf1db99cedc4..096b5ed4d07a23a42abe57bdfb4cb95f4a35be53 100644 (file)
@@ -9,6 +9,7 @@ import org.splat.kernel.InvalidPropertyException;
 import org.splat.dal.bo.kernel.User;
 import org.splat.kernel.UserDirectory;
 import org.splat.service.SearchService;
+import org.splat.service.SimulationContextService;
 import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.KnowledgeElementType;
@@ -28,7 +29,14 @@ public class SearchKnowledgeAction extends SearchBaseAction {
     private String                       words      = null;   // Full text search words
     private List<KnowledgeElementType>   types;            // Available knowledge types filter (initialized below)
     private SearchService                _searchService;
+       /**
+        * Injected simulation context service.
+        */
+       private SimulationContextService _simulationContextService;
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = -3104321907432838476L;
 
 //  ==============================================================================================================================
@@ -166,7 +174,7 @@ public class SearchKnowledgeAction extends SearchBaseAction {
 
        protected List<SimulationContextType> getInvolvedContexts () {
 //  ------------------------------------------------------------
-      return SimulationContext.selectAllTypes();
+      return getSimulationContextService().selectAllTypes();
        }
 
     @SuppressWarnings("unchecked")
@@ -224,4 +232,24 @@ public class SearchKnowledgeAction extends SearchBaseAction {
        public void setSearchService(SearchService searchService) {
                _searchService = searchService;
        }
+
+       /**
+        * Get the simulationContextService.
+        * 
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * 
+        * @param simulationContextService
+        *            the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
+       }
 }
\ No newline at end of file
index 26bd2dda4efee44887c05fa8968b09f6b72fabb6..58a7718e5effa9d5f9737339b6572cf281e1bc9b 100644 (file)
@@ -11,6 +11,7 @@ import org.splat.kernel.UserDirectory;
 import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.service.SearchService;
+import org.splat.service.SimulationContextService;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
@@ -28,7 +29,14 @@ public class SearchStudyAction extends SearchBaseAction {
     private String            words      = null;   // Full text search words
        private SearchService _searchService;
        private ProjectSettingsService _projectSettingsService;
+       /**
+        * Injected simulation context service.
+        */
+       private SimulationContextService _simulationContextService;
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = -1910481357051393077L;
 
     enum UserAction { refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext }
@@ -166,7 +174,7 @@ public class SearchStudyAction extends SearchBaseAction {
       List<ProjectSettingsService.Step>  steps  = getProjectSettings().getStepsOf(Study.class);
       ProjectSettingsService.Step[]      number = steps.toArray(new ProjectSettingsService.Step[steps.size()]);
       
-      return SimulationContext.selectTypesOf(number);
+      return getSimulationContextService().selectTypesOf(number);
        }
 
     @SuppressWarnings("unchecked")
@@ -238,4 +246,24 @@ public class SearchStudyAction extends SearchBaseAction {
                        ProjectSettingsService projectSettingsService) {
                _projectSettingsService = projectSettingsService;
        }
+
+       /**
+        * Get the simulationContextService.
+        * 
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * 
+        * @param simulationContextService
+        *            the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
+       }
 }
\ No newline at end of file
index 90665711b77651f06d5f7fdff40afebcf018885a..e38e02d52cc60a46c735d1cd1349488df433d300 100644 (file)
@@ -20,6 +20,9 @@ public class StartAction extends Action implements ServletRequestAware {
 
        private ProjectSettingsService _projectSettingsService;
        private ApplicationSettings _ApplicationSettings;
+       /**
+        * Serial version ID.
+        */
        private static final long   serialVersionUID = 5875058140682652964L;
 
 //  ==============================================================================================================================
index 4f348c5de519f9206363a3e522cc6a2c57ffbccb..c946aefbc45c9509510ac007df6c08a336fb9d74 100644 (file)
@@ -43,6 +43,9 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
     private int                    approver;
        private StudyService _studyService;
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = 4210696018741092900L;
 
     private enum Save { title, contributor, cycle }
index 923a120f78010035f0c9366c3d00eb27f69f4665..ad513195f7bb45f8eb49288f071b6a8c17cd29ad 100644 (file)
@@ -3,6 +3,7 @@ package org.splat.simer;
 import java.io.File;
 
 import org.splat.kernel.Do;
+import org.splat.service.technical.RepositoryService;
 import org.splat.dal.dao.som.Database;
 
 
@@ -15,6 +16,10 @@ public class UploadAction extends Action {
     private ToDo    action;                  // Action to do
     private String  next           = null;   // Action to which the uploaded file is passed
        private String  index          = null;   // Depending on the next action, document index to which the action applies
+       /**
+        * Injected repository service.
+        */
+       private RepositoryService _repositoryService;
 
        private static final long serialVersionUID = 6003880772275115923L;
 
@@ -33,7 +38,7 @@ public class UploadAction extends Action {
 //  -------------------------
       if (action == ToDo.cancel) return "cancel";
       try {
-       File    udir = Database.getDownloadDirectory(getConnectedUser());
+       File    udir = getRepositoryService().getDownloadDirectory(getConnectedUser());
        String  path = udir.getPath() + "/" + uploadFileName;
        File    file = new File(path);
 
@@ -96,4 +101,20 @@ public class UploadAction extends Action {
 //  ----------------------------------------------
       this.uploadMimeType = mime;
     }
+
+       /**
+        * Get the repositoryService.
+        * @return the repositoryService
+        */
+       public RepositoryService getRepositoryService() {
+               return _repositoryService;
+       }
+
+       /**
+        * Set the repositoryService.
+        * @param repositoryService the repositoryService to set
+        */
+       public void setRepositoryService(RepositoryService repositoryService) {
+               _repositoryService = repositoryService;
+       }
 }
\ No newline at end of file
index 2aacb56d64d172b6a13c0fa381b211833b8553cc..c47b322e205c21155419d33eb9ff770a40feddf2 100644 (file)
@@ -22,6 +22,9 @@ public abstract class UploadBaseNextAction extends Action {
     protected String         docuses  = null;
     protected ToDo           action   = null;
 
+       /**
+        * Serial version ID.
+        */
     private static final long serialVersionUID = -6925961099244461039L;
 
     protected enum  ToDo { cancel, save };
index a5503b38f32d9ab1745725cb4546fdebc34f8754..e56c4dbace4b39d469875e859538d0f19a545f18 100644 (file)
@@ -24,6 +24,7 @@ import org.splat.dal.bo.som.ProgressState;
 import org.splat.service.PublicationService;
 import org.splat.service.StepService;
 import org.splat.service.technical.ProjectSettingsService;
+import org.splat.service.technical.RepositoryService;
 import org.splat.dal.bo.som.Publication;
 import org.splat.som.Revision;
 import org.splat.som.Step;
@@ -41,7 +42,14 @@ public class VersionDocumentAction extends UploadBaseNextAction {
        private ProjectSettingsService _projectSettingsService;
        private PublicationService _publicationService;
        private StepService _stepService;
+       /**
+        * Injected repository service.
+        */
+       private RepositoryService _repositoryService;
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = -5702264003232132168L;
 
        // ==============================================================================================================================
@@ -53,7 +61,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                Session connex = Database.getSession();
                Transaction transax = connex.beginTransaction();
                User user = getConnectedUser();
-               File updir = Database.getDownloadDirectory(user);
+               File updir = getRepositoryService().getDownloadDirectory(user);
                File upfile = new File(updir.getPath() + "/" + filename);
 
                mystudy = getOpenStudy();
@@ -136,7 +144,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                        mystudy = getOpenStudy();
                        User user = getConnectedUser();
                        Step step = mystudy.getSelectedStep();
-                       File updir = Database.getDownloadDirectory(user);
+                       File updir = getRepositoryService().getDownloadDirectory(user);
                        File upfile = new File(updir.getPath() + "/" + filename);
 
                        // Versioning of the document
@@ -346,4 +354,20 @@ public class VersionDocumentAction extends UploadBaseNextAction {
        public void setStepService(StepService stepService) {
                _stepService = stepService;
        }
+
+       /**
+        * Get the repositoryService.
+        * @return the repositoryService
+        */
+       public RepositoryService getRepositoryService() {
+               return _repositoryService;
+       }
+
+       /**
+        * Set the repositoryService.
+        * @param repositoryService the repositoryService to set
+        */
+       public void setRepositoryService(RepositoryService repositoryService) {
+               _repositoryService = repositoryService;
+       }
 }
\ No newline at end of file
index b3b00415ab399722e2d42658c726a29833e4defb..931e0b8f5887782deab6739b262767b1c68da760 100644 (file)
@@ -15,14 +15,17 @@ import org.splat.dal.bo.som.Study;
 
 public class DatabaseIndexingAction extends Action {
 
+       /**
+        * Serial version ID.
+        */
+    private static final long serialVersionUID = 4194268823457749655L;
+
     private List<ImportedStudy> newstudies;
     private String              indices;
        private SearchService _searchService;
        private ImportedStudy _importedStudy;
        private StudyService _studyService;
 
-    private static final long serialVersionUID = 4194268823457749655L;
-
 //  ==============================================================================================================================
 //  Action methods
 //  ==============================================================================================================================
index f4073e9f86dd37caea4e5ce2b5512000ed0b0520..444cff8faaad22bab963be447a2c3cca87f25739 100644 (file)
@@ -9,16 +9,24 @@ import org.hibernate.Session;
 import org.hibernate.Transaction;
 import org.splat.dal.bo.kernel.User;
 import org.splat.kernel.UserDirectory;
+import org.splat.service.technical.RepositoryService;
 import org.splat.simer.UploadBaseNextAction;
 import org.splat.dal.dao.som.Database;
 
 
 public class ImportUserAction extends UploadBaseNextAction {
 
+       /**
+        * Serial version ID.
+        */
+    private static final long serialVersionUID = 1516715800624817965L;
+
     private List<User> users;
     private Set<User>  newsers;
-
-    private static final long serialVersionUID = 1516715800624817965L;
+       /**
+        * Injected repository service.
+        */
+       private RepositoryService _repositoryService;
 
 //  ==============================================================================================================================
 //  Action methods
@@ -30,7 +38,7 @@ public class ImportUserAction extends UploadBaseNextAction {
       Transaction  transax = connex.beginTransaction();
       try {
         User       user    = getConnectedUser();     // The database administrator
-       File       updir   = Database.getDownloadDirectory(user);
+       File       updir   = getRepositoryService().getDownloadDirectory(user);
        File       upfile  = new File(updir.getPath() + "/" + filename);
 
         newsers = UserDirectory.importUsers(upfile);
@@ -62,4 +70,20 @@ public class ImportUserAction extends UploadBaseNextAction {
 //  --------------------------------
       return newsers.contains(user);
     }
+
+       /**
+        * Get the repositoryService.
+        * @return the repositoryService
+        */
+       public RepositoryService getRepositoryService() {
+               return _repositoryService;
+       }
+
+       /**
+        * Set the repositoryService.
+        * @param repositoryService the repositoryService to set
+        */
+       public void setRepositoryService(RepositoryService repositoryService) {
+               _repositoryService = repositoryService;
+       }
 }
\ No newline at end of file
index 01707dc4c060fc7bb6cbcad8e91a8ead59a50670..cc22a80c93b60e48f2b959d840e35cad0130524e 100644 (file)
@@ -5,6 +5,9 @@ import org.splat.simer.Action;
 
 public class KnowledgeElementAction extends Action {
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = 2416672950671183384L;
 
 //  ==============================================================================================================================
index 9d65a2f24ae6c6d255b850f1b84d52b693681402..232e52c9dc9b78b5908a53d4e37e6bcfcf85fc0b 100644 (file)
@@ -21,176 +21,214 @@ import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.service.KnowledgeElementService;
 import org.splat.service.SearchService;
+import org.splat.service.SimulationContextService;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.service.dto.Proxy;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
 import org.splat.dal.bo.som.Study;
 
-
+/**
+ * Action for operations on simulation contexts.
+ */
 public class SimulationContextAction extends Action {
 
-    private List<SimulationContextFacade> tocheck;     // Simulation contexts to be approved
-    private int                           selection;   // Index of the selected simulation context presented in the approval form
-    private SimulationContext             edition;     // Corresponding simulation context object
-    private ProjectSettingsService.Step          step;        // Study step to which the selected simulation context is attached
-    private Set<ProjectElementFacade>     owner;       // Study scenarios indexed by this simulation context
-    private List<LocalizedContextTypes>   existype;    // Existing approved simulation context types ordered by localized names
-    private List<SimulationContextType>   exisname;    // Existing approved simulation context types ordered by internal codes
-    private List<SimulationContext>       existing;    // Existing simulation contexts of selected type
+       /**
+        * Serial version ID.
+        */
+       private static final long serialVersionUID = 7083323229359094699L;
+
+       private List<SimulationContextFacade> tocheck; // Simulation contexts to be approved
+       private int selection; // Index of the selected simulation context presented in the approval form
+       private SimulationContext edition; // Corresponding simulation context object
+       private ProjectSettingsService.Step step; // Study step to which the selected simulation context is attached
+       private Set<ProjectElementFacade> owner; // Study scenarios indexed by this simulation context
+       private List<LocalizedContextTypes> existype; // Existing approved simulation context types ordered by localized names
+       private List<SimulationContextType> exisname; // Existing approved simulation context types ordered by internal codes
+       private List<SimulationContext> existing; // Existing simulation contexts of selected type
+       /**
+        * Injected search service.
+        */
        private SearchService _searchService;
+       /**
+        * Injected project settings service.
+        */
        private ProjectSettingsService _projectSettingsService;
+       /**
+        * Injected knowledge element service.
+        */
        private KnowledgeElementService _knowledgeElementService;
+       /**
+        * Injected simulation context service.
+        */
+       private SimulationContextService _simulationContextService;
 
-       private static final long serialVersionUID = 7083323229359094699L;
-
-    private class ContextNameComparator  implements Comparator<SimulationContextType> {
-//  ---------------------------------------------------------------------------------
-      public int compare(SimulationContextType t1, SimulationContextType t2)
-      {
-        String  name1  = t1.getName();
-        String  name2  = t2.getName();
-
-        return name1.compareToIgnoreCase(name2);
-      }
-    }
-
-    public class LocalizedContextTypes {
-//  ----------------------------------
-      private Locale       locale;
-      private List<String> sortype;    // Existing approved simulation context types ordered by localized names
-
-      public LocalizedContextTypes (List<SimulationContextType> types, Locale lang)
-      {
-        ResourceBundle          bundle = ResourceBundle.getBundle("som", lang);
-        SimulationContextType[] tosort = types.toArray( new SimulationContextType[types.size()] );
-        String[]                name   = new String[types.size()];
-
-        for (int i=0; i<name.length; i++) name[i] = bundle.getString("type.context." + tosort[i].getName());
-        Arrays.sort(name);
-        sortype = Arrays.asList(name);
-        locale  = lang;
-      }
-      public String getLocale ()
-      {
-        return locale.toString();
-      }
-      public List<String> getTypeNames ()
-      {
-        return sortype;
-      }
-      public boolean isCurrent ()
-      {
-        return (locale.equals(ApplicationSettings.getCurrentLocale()));
-      }
-    }
-
-//  ==============================================================================================================================
-//  Action methods
-//  ==============================================================================================================================
-
-    public String doInitialize () {
-//  -----------------------------
-      Session      connex  = Database.getSession();
-      Transaction  transax = connex.beginTransaction();
-      try {
-        SimulationContext.Properties  cprop   = new SimulationContext.Properties();
-        List<SimulationContext>       context = Database.selectSimulationContextsWhere(cprop.setState(ProgressState.inCHECK));
-
-        tocheck = new Vector<SimulationContextFacade>(context.size());
-        for (Iterator<SimulationContext> i=context.iterator(); i.hasNext(); ) {
-          tocheck.add( new SimulationContextFacade(i.next(), getProjectSettings().getAllSteps()) );
-        }
-        selection = 0;
-        edition   = null;
-        owner     = null;
-
-        transax.commit();
-        return SUCCESS;
-      }
-      catch (Exception error) {
-       logger.error("Reason:", error);
-        return ERROR;     // No need to roll-back the transaction as it is read-only
-      }
-    }
-
-    public String doSelect () {
-//  -------------------------
-      Session      connex  = Database.getSession();
-      Transaction  transax = connex.beginTransaction();
-      try {
-        SimulationContext.Properties  cprop    = new SimulationContext.Properties();
-        List<SimulationContext>       context  = Database.selectSimulationContextsWhere(cprop.setState(ProgressState.inCHECK));
-        List<SimulationContext>       selected = new ArrayList<SimulationContext>(1);
-
-        tocheck = new Vector<SimulationContextFacade>(context.size());
-        for (Iterator<SimulationContext> i=context.iterator(); i.hasNext(); ) {
-          SimulationContext next = i.next();
-          if (next.getIndex() == selection) {
-               edition = next;
-               selected.add(edition);
-          }
-          tocheck.add( new SimulationContextFacade(next, getProjectSettings().getAllSteps()) );
-        }
-        KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
-        List<Proxy>                 kelm  = getSearchService().selectKnowledgeElementsWhere(kprop.setSimulationContexts(selected).setState(ProgressState.inWORK));
-
-        step  = edition.getType().getAttachedStep();
-        owner = new HashSet<ProjectElementFacade>();
-        for (Iterator<Proxy> i=kelm.iterator(); i.hasNext(); ) {
-          KnowledgeElement      next = getKnowledgeElementService().selectKnowledgeElement(i.next().getIndex());
-          ProjectElementFacade  facade;
-          if (step.appliesTo(Study.class)) facade = new ProjectElementFacade(next.getOwnerScenario().getOwnerStudy(), step);
-          else                             facade = new ProjectElementFacade(next.getOwnerScenario(), step);
-          owner.add(facade);
-        }
-        SimulationContextType.Properties  sprop    = new SimulationContextType.Properties();
-        List<SimulationContextType>       types    = SimulationContext.selectTypesWhere(sprop.setState(ProgressState.APPROVED));
-        Locale[]                          support  = ApplicationSettings.getSupportedLocales();
-
-//      Sort localized type names
-        existype = new ArrayList<LocalizedContextTypes>(support.length);
-        for (int i=0; i<support.length; i++) {
-          existype.add( new LocalizedContextTypes(types, support[i]) );
-        }
-        SimulationContextType[] names = types.toArray( new SimulationContextType[types.size()] );
-        
-        Arrays.sort(names, new ContextNameComparator() );
-        exisname = Arrays.asList(names);
-        
-        existing = Database.selectSimulationContextsWhere(cprop.setType(edition.getType()).setState(ProgressState.APPROVED));
-
-        transax.commit();
-        return SUCCESS;
-      }
-      catch (Exception error) {
-        logger.error("Reason:", error);
-        return ERROR;     // No need to roll-back the transaction as it is read-only
-      }
-    }
-
-//  ==============================================================================================================================
-//  Getters and setters
-//  ==============================================================================================================================
-
-    /**
-        * @return
+       /**
+        * Context name comparator.
         */
-       public SearchService getSearchService() {
-               // TODO Auto-generated method stub
-               return _searchService;
+       private class ContextNameComparator implements
+                       Comparator<SimulationContextType> {
+               /**
+                * {@inheritDoc}
+                * 
+                * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+                */
+               public int compare(SimulationContextType t1, SimulationContextType t2) {
+                       String name1 = t1.getName();
+                       String name2 = t2.getName();
+
+                       return name1.compareToIgnoreCase(name2);
+               }
        }
 
-       public void setSearchService(SearchService searchService) {
-               _searchService = searchService;
+       public class LocalizedContextTypes {
+               // ----------------------------------
+               private Locale locale;
+               private List<String> sortype; // Existing approved simulation context types ordered by localized names
+
+               public LocalizedContextTypes(List<SimulationContextType> types,
+                               Locale lang) {
+                       ResourceBundle bundle = ResourceBundle.getBundle("som", lang);
+                       SimulationContextType[] tosort = types
+                                       .toArray(new SimulationContextType[types.size()]);
+                       String[] name = new String[types.size()];
+
+                       for (int i = 0; i < name.length; i++)
+                               name[i] = bundle.getString("type.context."
+                                               + tosort[i].getName());
+                       Arrays.sort(name);
+                       sortype = Arrays.asList(name);
+                       locale = lang;
+               }
+
+               public String getLocale() {
+                       return locale.toString();
+               }
+
+               public List<String> getTypeNames() {
+                       return sortype;
+               }
+
+               public boolean isCurrent() {
+                       return (locale.equals(ApplicationSettings.getCurrentLocale()));
+               }
+       }
+
+       // ==============================================================================================================================
+       // Action methods
+       // ==============================================================================================================================
+
+       public String doInitialize() {
+               // -----------------------------
+               Session connex = Database.getSession();
+               Transaction transax = connex.beginTransaction();
+               try {
+                       SimulationContext.Properties cprop = new SimulationContext.Properties();
+                       List<SimulationContext> context = getSimulationContextService()
+                                       .selectSimulationContextsWhere(
+                                                       cprop.setState(ProgressState.inCHECK));
+
+                       tocheck = new Vector<SimulationContextFacade>(context.size());
+                       for (Iterator<SimulationContext> i = context.iterator(); i
+                                       .hasNext();) {
+                               tocheck.add(new SimulationContextFacade(i.next(),
+                                               getProjectSettings().getAllSteps()));
+                       }
+                       selection = 0;
+                       edition = null;
+                       owner = null;
+
+                       transax.commit();
+                       return SUCCESS;
+               } catch (Exception error) {
+                       logger.error("Reason:", error);
+                       return ERROR; // No need to roll-back the transaction as it is read-only
+               }
+       }
+
+       public String doSelect() {
+               // -------------------------
+               Session connex = Database.getSession();
+               Transaction transax = connex.beginTransaction();
+               try {
+                       SimulationContext.Properties cprop = new SimulationContext.Properties();
+                       List<SimulationContext> context = getSimulationContextService()
+                                       .selectSimulationContextsWhere(
+                                                       cprop.setState(ProgressState.inCHECK));
+                       List<SimulationContext> selected = new ArrayList<SimulationContext>(
+                                       1);
+
+                       tocheck = new Vector<SimulationContextFacade>(context.size());
+                       for (Iterator<SimulationContext> i = context.iterator(); i
+                                       .hasNext();) {
+                               SimulationContext next = i.next();
+                               if (next.getIndex() == selection) {
+                                       edition = next;
+                                       selected.add(edition);
+                               }
+                               tocheck.add(new SimulationContextFacade(next,
+                                               getProjectSettings().getAllSteps()));
+                       }
+                       KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
+                       List<Proxy> kelm = getSearchService().selectKnowledgeElementsWhere(
+                                       kprop.setSimulationContexts(selected).setState(
+                                                       ProgressState.inWORK));
+
+                       step = edition.getType().getAttachedStep();
+                       owner = new HashSet<ProjectElementFacade>();
+                       for (Iterator<Proxy> i = kelm.iterator(); i.hasNext();) {
+                               KnowledgeElement next = getKnowledgeElementService()
+                                               .selectKnowledgeElement(i.next().getIndex());
+                               ProjectElementFacade facade;
+                               if (step.appliesTo(Study.class))
+                                       facade = new ProjectElementFacade(next.getOwnerScenario()
+                                                       .getOwnerStudy(), step);
+                               else
+                                       facade = new ProjectElementFacade(next.getOwnerScenario(),
+                                                       step);
+                               owner.add(facade);
+                       }
+                       SimulationContextType.Properties sprop = new SimulationContextType.Properties();
+                       List<SimulationContextType> types = getSimulationContextService()
+                                       .selectTypesWhere(sprop.setState(ProgressState.APPROVED));
+                       Locale[] support = ApplicationSettings.getSupportedLocales();
+
+                       // Sort localized type names
+                       existype = new ArrayList<LocalizedContextTypes>(support.length);
+                       for (int i = 0; i < support.length; i++) {
+                               existype.add(new LocalizedContextTypes(types, support[i]));
+                       }
+                       SimulationContextType[] names = types
+                                       .toArray(new SimulationContextType[types.size()]);
+
+                       Arrays.sort(names, new ContextNameComparator());
+                       exisname = Arrays.asList(names);
+
+                       existing = getSimulationContextService()
+                                       .selectSimulationContextsWhere(
+                                                       cprop.setType(edition.getType()).setState(
+                                                                       ProgressState.APPROVED));
+
+                       transax.commit();
+                       return SUCCESS;
+               } catch (Exception error) {
+                       logger.error("Reason:", error);
+                       return ERROR; // No need to roll-back the transaction as it is read-only
+               }
+       }
+
+       // ==============================================================================================================================
+       // Getters and setters
+       // ==============================================================================================================================
+
+       public List<ProjectSettingsService.Step> getAllStudySteps() {
+               // -----------------------------------------------------
+               return getProjectSettings().getAllSteps();
        }
 
-       public List<ProjectSettingsService.Step> getAllStudySteps () {
-//  -----------------------------------------------------
-      return  getProjectSettings().getAllSteps();
-    }
-    /**
-     * Get project settings.
+       /**
+        * Get project settings.
+        * 
         * @return Project settings service
         */
        private ProjectSettingsService getProjectSettings() {
@@ -199,53 +237,62 @@ public class SimulationContextAction extends Action {
 
        /**
         * Set project settings service.
-        * @param projectSettingsService project settings service
+        * 
+        * @param projectSettingsService
+        *            project settings service
         */
-       public void setProjectSettings(
-                       ProjectSettingsService projectSettingsService) {
+       public void setProjectSettings(ProjectSettingsService projectSettingsService) {
                _projectSettingsService = projectSettingsService;
        }
 
-       public ProjectSettingsService.Step getAttachedStep () {
-//  ----------------------------------------------
-      return  step;
-    }
-    public List<SimulationContextFacade> getContextsToBeApproved () {
-//  ---------------------------------------------------------------
-      return  tocheck;
-    }
-    public SimulationContext getEdited () {
-//  -------------------------------------
-      return  edition;
-    }
-    public List<SimulationContext> getExistingContexts () {
-//  -----------------------------------------------------
-      return  existing;
-    }
-    public List<SimulationContextType> getExistingNames () {
-//  ------------------------------------------------------
-      return exisname;
-    }
-    public List<LocalizedContextTypes> getSupportedLocales () {
-//  ---------------------------------------------------------
-      return existype;
-    }
-    public Set<ProjectElementFacade> getIndexedElements () {
-//  ------------------------------------------------------
-      return  owner;
-    }
-    public int getSelection () {
-//  --------------------------
-      return  selection;
-    }
-
-    public void setSelection (String index) {
-//  ---------------------------------------
-      selection = Integer.valueOf(index);
-    }
+       public ProjectSettingsService.Step getAttachedStep() {
+               // ----------------------------------------------
+               return step;
+       }
+
+       public List<SimulationContextFacade> getContextsToBeApproved() {
+               // ---------------------------------------------------------------
+               return tocheck;
+       }
+
+       public SimulationContext getEdited() {
+               // -------------------------------------
+               return edition;
+       }
+
+       public List<SimulationContext> getExistingContexts() {
+               // -----------------------------------------------------
+               return existing;
+       }
+
+       public List<SimulationContextType> getExistingNames() {
+               // ------------------------------------------------------
+               return exisname;
+       }
+
+       public List<LocalizedContextTypes> getSupportedLocales() {
+               // ---------------------------------------------------------
+               return existype;
+       }
+
+       public Set<ProjectElementFacade> getIndexedElements() {
+               // ------------------------------------------------------
+               return owner;
+       }
+
+       public int getSelection() {
+               // --------------------------
+               return selection;
+       }
+
+       public void setSelection(String index) {
+               // ---------------------------------------
+               selection = Integer.valueOf(index);
+       }
 
        /**
         * Get the knowledgeElementService.
+        * 
         * @return the knowledgeElementService
         */
        public KnowledgeElementService getKnowledgeElementService() {
@@ -254,10 +301,48 @@ public class SimulationContextAction extends Action {
 
        /**
         * Set the knowledgeElementService.
-        * @param knowledgeElementService the knowledgeElementService to set
+        * 
+        * @param knowledgeElementService
+        *            the knowledgeElementService to set
         */
        public void setKnowledgeElementService(
                        KnowledgeElementService knowledgeElementService) {
                _knowledgeElementService = knowledgeElementService;
        }
+
+       /**
+        * Get the simulationContextService.
+        * 
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * 
+        * @param simulationContextService
+        *            the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
+       }
+
+       /**
+        * Get the searchService.
+        * @return the searchService
+        */
+       public SearchService getSearchService() {
+               return _searchService;
+       }
+
+       /**
+        * Set the searchService.
+        * @param searchService the searchService to set
+        */
+       public void setSearchService(SearchService searchService) {
+               _searchService = searchService;
+       }
 }
\ No newline at end of file
index 929f399035f16b01853f6a5e0fad5d81e4425073..e68dc43c92c1dd8d3195fd4ac0516af122a2d64e 100644 (file)
@@ -10,6 +10,9 @@ public class Item implements Serializable {
     private String  myurl;
     private boolean selected = false;
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = -3505572710372809913L;
 
 //  ==============================================================================================================================
index 0a78e878e5498cde3d793c00a112480949fea0f4..fafbac53d40053666d4c8013ea1d0286f1c3c356 100644 (file)
@@ -8,6 +8,9 @@ public class MenuItem extends Item {
        protected static class Group extends MenuItem {
 //  ---------------------------------------------
       private boolean open = false;
+       /**
+        * Serial version ID.
+        */
       private static final long serialVersionUID = 8319750643667219000L;
 
       protected Group (String label)                            { super(label); }
@@ -18,6 +21,9 @@ public class MenuItem extends Item {
     }
     protected static class SubItem extends MenuItem {
 //  -----------------------------------------------
+       /**
+        * Serial version ID.
+        */
       private static final long serialVersionUID = -4793172296421132566L;
 
       protected SubItem (String label)                          { super(label); }
index b362d4e08231b19bf0c7fb44c7ce5c31255deab1..0698691e2ea057367442de9a31d586a3ab742311 100644 (file)
@@ -13,6 +13,9 @@ public class TabBar implements Serializable {
        protected HashMap<String,String>  disabled;           // Actions of disabled item
     protected String                  selection;
 
+       /**
+        * Serial version ID.
+        */
        private static final long serialVersionUID = 1851786085512439549L;
 
 //  ==============================================================================================================================
index 16e6b0a4d3b27881d7240c5dd44759a9cc5cc825..ad3192f2f21a9d87d008fee9822407b168161240 100644 (file)
@@ -2,7 +2,7 @@
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:aop="http://www.springframework.org/schema/aop"
-    xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans  
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/aop  
@@ -10,14 +10,13 @@ http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
-           
-    <context:property-placeholder
-        location="classpath:siman.properties,classpath:jdbc.properties"
-        ignore-unresolvable="true" />
 
-       <!-- configuration i18n -->
-       <bean id="i18nUtils"
-               class="org.splat.i18n.I18nUtils">
+       <context:property-placeholder
+               location="classpath:siman.properties,classpath:jdbc.properties"
+               ignore-unresolvable="true" />
+
+       <!-- configuration i18n -->
+       <bean id="i18nUtils" class="org.splat.i18n.I18nUtils">
                <property name="resourceBundleMessageSource"
                        ref="messageSource" />
        </bean>
@@ -31,10 +30,10 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                        </list>
                </property>
        </bean>
-    <!-- ref 'baseMessageSource' into Siman-common\src\spring\globalContext.xml -->
+       <!-- ref 'baseMessageSource' into Siman-common\src\spring\globalContext.xml -->
        <!-- property name="parentMessageSource" ref="baseMessageSource"/-->
-       
-               <bean id="applicationSettings"
+
+       <bean id="applicationSettings"
                class="org.splat.simer.ApplicationSettings">
                <property name="projectSettings" ref="projectSettings" />
        </bean>
@@ -50,6 +49,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="publicationService" ref="publicationService" />
                <property name="scenarioService" ref="scenarioService" />
                <property name="stepService" ref="stepService" />
+               <property name="repositoryService" ref="repositoryService" />
        </bean>
 
        <bean id="openKnowledge" class="org.splat.simer.OpenKnowledge"
@@ -65,12 +65,14 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="openKnowledge" ref="openKnowledge" />
        </bean>
 
-    <!--========= Inherited from baseAction =========-->
-    
-    <bean id="newStudyAction" class="org.splat.simer.NewStudyAction"
-        parent="baseAction" scope="prototype">
-        <property name="studyService" ref="studyService" />
-    </bean>
+       <!--========= Inherited from baseAction =========-->
+
+       <bean id="newStudyAction" class="org.splat.simer.NewStudyAction"
+               parent="baseAction" scope="prototype">
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
+               <property name="studyService" ref="studyService" />
+       </bean>
 
        <bean id="displayStudyStepAction"
                class="org.splat.simer.DisplayStudyStepAction" parent="baseAction"
@@ -78,8 +80,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="studyService" ref="studyService" />
        </bean>
 
-    <!--========= Inherited from displayStudyStepAction =========-->
-    
+       <!--========= Inherited from displayStudyStepAction =========-->
+
        <bean id="studyPropertiesAction"
                class="org.splat.simer.StudyPropertiesAction" scope="prototype"
                parent="displayStudyStepAction">
@@ -101,12 +103,15 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                class="org.splat.simer.EditSimulationContextAction" scope="prototype"
                parent="displayStudyStepAction">
                <property name="stepService" ref="stepService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
        </bean>
 
        <bean id="editDocumentAction"
                class="org.splat.simer.EditDocumentAction" scope="prototype"
                parent="displayStudyStepAction">
                <property name="publicationService" ref="publicationService" />
+               <property name="repositoryService" ref="repositoryService" />
        </bean>
 
        <bean id="editKnowledgeElementAction"
@@ -117,8 +122,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="scenarioService" ref="scenarioService" />
        </bean>
 
-    <!-- End of Inherited from displayStudyStepAction -->
-    
+       <!-- End of Inherited from displayStudyStepAction -->
+
        <bean id="startAction" class="org.splat.simer.StartAction"
                scope="prototype">
                <property name="applicationSettings" ref="applicationSettings" />
@@ -140,11 +145,15 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                class="org.splat.simer.SearchStudyAction" scope="prototype">
                <property name="projectSettings" ref="projectSettings" />
                <property name="searchService" ref="searchService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
        </bean>
 
        <bean id="searchKnowledgeAction"
                class="org.splat.simer.SearchKnowledgeAction" scope="prototype">
                <property name="searchService" ref="searchService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
        </bean>
 
        <bean id="searchDocumentAction"
@@ -166,6 +175,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
        <bean id="uploadAction" class="org.splat.simer.UploadAction"
                scope="prototype">
+               <property name="repositoryService" ref="repositoryService" />
        </bean>
 
        <bean id="importDocumentAction"
@@ -173,6 +183,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="stepService" ref="stepService" />
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
+               <property name="repositoryService" ref="repositoryService" />
        </bean>
 
        <bean id="versionDocumentAction"
@@ -180,6 +191,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
                <property name="stepService" ref="stepService" />
+               <property name="repositoryService" ref="repositoryService" />
        </bean>
 
        <bean id="databaseIndexingAction"
@@ -192,6 +204,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
        <bean id="importUserAction"
                class="org.splat.simer.admin.ImportUserAction" scope="prototype">
+               <property name="repositoryService" ref="repositoryService" />
        </bean>
 
        <bean id="simulationContextAction"
@@ -201,6 +214,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                        ref="knowledgeElementService" />
                <property name="searchService" ref="searchService" />
                <property name="projectSettings" ref="projectSettings" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
        </bean>
 
        <bean id="knowledgeElementAction"
@@ -211,8 +226,11 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        <bean id="saveDocumentAction"
                class="org.splat.module.SaveDocumentAction" scope="prototype">
                <property name="publicationService" ref="publicationService" />
+               <property name="repositoryService" ref="repositoryService" />
                <property name="scenarioService" ref="scenarioService" />
                <property name="stepService" ref="stepService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
        </bean>
 
 </beans>