]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Refactoring continues: UserService is created instead of UserDirectory. Database...
authorrkv <rkv@opencascade.com>
Mon, 22 Oct 2012 05:34:39 +0000 (05:34 +0000)
committerrkv <rkv@opencascade.com>
Mon, 22 Oct 2012 05:34:39 +0000 (05:34 +0000)
71 files changed:
Workspace/Siman-Common/lib/postgresql-9.1-901.jdbc4.jar [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Any.java
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Entity.java
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Relation.java
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/TextAttribute.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/DocumentType.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/IDBuilder.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/KnowledgeElementType.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/ProjectElement.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/Publication.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/Scenario.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/bo/som/ValidationCycle.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/som/Database.java
Workspace/Siman-Common/src/org/splat/kernel/RealmLoginModule.java
Workspace/Siman-Common/src/org/splat/kernel/UserDirectory.java [deleted file]
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/DocumentTypeService.java
Workspace/Siman-Common/src/org/splat/service/DocumentTypeServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeService.java
Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeServiceImpl.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/ScenarioService.java
Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/ServiceLocator.java
Workspace/Siman-Common/src/org/splat/service/ServiceLocatorImpl.java
Workspace/Siman-Common/src/org/splat/service/SimulationContextService.java
Workspace/Siman-Common/src/org/splat/service/SimulationContextServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/UserService.java [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/service/UserServiceImpl.java [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsServiceImpl.java
Workspace/Siman-Common/src/spring/businessServiceContext.xml
Workspace/Siman-Common/src/spring/globalContext.xml
Workspace/Siman-Common/src/test/Test.java
Workspace/Siman/WebContent/sgeom/index.jsp
Workspace/Siman/WebContent/smesh/index.jsp
Workspace/Siman/conf/debug_pg.properties [new file with mode: 0644]
Workspace/Siman/src/org/splat/module/SaveDocumentAction.java
Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Workspace/Siman/src/org/splat/simer/ConnectionAction.java
Workspace/Siman/src/org/splat/simer/DisplayKnowledgeAction.java
Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.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/NewScenarioAction.java
Workspace/Siman/src/org/splat/simer/NewStudyAction.java
Workspace/Siman/src/org/splat/simer/OpenStudy.java
Workspace/Siman/src/org/splat/simer/SearchBaseAction.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/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/ImportedStudy.java
Workspace/Siman/src/org/splat/simer/admin/SimulationContextAction.java
Workspace/Siman/src/spring/applicationContext.xml

diff --git a/Workspace/Siman-Common/lib/postgresql-9.1-901.jdbc4.jar b/Workspace/Siman-Common/lib/postgresql-9.1-901.jdbc4.jar
new file mode 100644 (file)
index 0000000..203d5a1
Binary files /dev/null and b/Workspace/Siman-Common/lib/postgresql-9.1-901.jdbc4.jar differ
index 1992ed5a9a7b46a6d424c1075bd8e8d8e998c686..b047d8fa0c52aa7da6ca0476f50f7406dd3a6d32 100644 (file)
@@ -13,8 +13,6 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
-import org.hibernate.Session;
-import org.splat.dal.dao.som.Database;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
@@ -69,7 +67,7 @@ public abstract class Any extends Persistent {
       for (Iterator<Attribute> i=attributes.iterator(); i.hasNext(); ) {
         if (!i.next().equals(field)) continue;
        i.remove();
-        if (this.isSaved()) Database.getSession().update(this);
+       //RKV        if (this.isSaved()) Database.getCurSession().update(this);
        return true;
       }
       return false;
@@ -78,7 +76,7 @@ public abstract class Any extends Persistent {
     public boolean setAttribute (Attribute field) {
 //  ------------------------------------------------
       Class<?> type    = field.getClass();
-      Session  session = Database.getSession();
+//RKV      Session  session = Database.getCurSession();
 
       if (!field.getFrom().equals(this)) return false;
       for (Iterator<Attribute> i=attributes.iterator(); i.hasNext(); ) {
@@ -88,8 +86,8 @@ public abstract class Any extends Persistent {
       }
       attributes.add(field);
       if (this.isSaved()) {
-        if (!field.isSaved()) session.save(field);
-        session.update(this);
+       //RKV        if (!field.isSaved()) session.save(field);
+       //RKV           session.update(this);
       }     // Else, when saving this, Hibernate will propagate the operation
       return true;
     }
index 52f06cb5059538131f9473a29e777000287fbc92..d423d2507d6d22ec53387c3aeeeed7aea265de3f 100644 (file)
@@ -16,8 +16,6 @@ import java.util.List;
 import java.util.Set;
 import java.util.Vector;
 
-import org.hibernate.Session;
-import org.splat.dal.dao.kernel.Database;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
@@ -102,7 +100,7 @@ public abstract class Entity extends Any {
        if (!link.getClass().equals(type)) continue;
        if (!link.getTo().equals(to))      continue;
        i.remove();
-        if (this.isSaved()) Database.getSession().update(this);
+       //RKV        if (this.isSaved()) Database.getCurSession().update(this);
        return;
       }
     }
index 9d8d22df54beddf8b511af3b1dd57bc22a41fe2f..9f8964fb6bb8dd1ea392d57e53a663f5a8c72066 100644 (file)
@@ -18,10 +18,6 @@ package org.splat.dal.bo.kernel;
 
 import java.util.Iterator;
 
-import org.hibernate.Session;
-import org.splat.dal.dao.kernel.Database;
-
-
 public abstract class Relation extends Any {
 
 //  Persistent fields
@@ -90,19 +86,18 @@ public abstract class Relation extends Any {
  * @param nowner the document to which this relation is moved
  * */
     public void moveTo (Entity nowner) {
-//  ----------------------------------
-      Session  session = Database.getSession();
+       //RKV      Session  session = Database.getCurSession();
 
       this.owner = nowner;
       nowner.getAllRelations().add(this);
 //    myold.getAllRelations().remove(this);  Harmful as it leads to remove this relation from the database (!?)
-      session.update(this);
-      session.update(nowner);
+    //RKV      session.update(this);
+    //RKV      session.update(nowner);
 
       if (this.isBidirectional()) {
        Relation  link = this.getReverse();
        link.setTo(nowner);
-       session.update(link);
+       //RKV  session.update(link);
       }
     }
 
index 4e797eb5471996543d979c8d20947c906e7d7282..36c6fa0d6961298b52002725b3a02c45455f1d9c 100644 (file)
@@ -1,7 +1,5 @@
 package org.splat.dal.bo.kernel;
 
-import org.splat.dal.dao.kernel.Database;
-
 /**
  * 
  * @author    Daniel Brunier-Coulin
@@ -45,6 +43,6 @@ public abstract class TextAttribute extends Attribute {
     protected void setValue (String value) {
 //  --------------------------------------
       mytext = value;
-      if (this.isSaved()) Database.getSession().update(this);
+//RKV      if (this.isSaved()) Database.getCurSession().update(this);
     }
 }
\ No newline at end of file
index 3f68472f5e40a4c46186ced2fb88c59955f9379b..2a55dd138411083ffd763cadd68c0bbc3b4ca472 100644 (file)
@@ -9,7 +9,6 @@ import java.util.Set;
 import java.util.HashSet;
 
 import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.som.Database;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
@@ -21,7 +20,7 @@ public class DocumentType extends Persistent {
 //  Persistent fields
     private String            name;
     private ProgressState     state;
-    private String            step;     // List of (dash separated) steps (numbers) containing this type
+       private String            step;     // List of (dash separated) steps (numbers) containing this type
     private String            result;   // Step (number ) having this type as result
     private Set<DocumentType> uses;
 
@@ -98,14 +97,6 @@ public class DocumentType extends Persistent {
 //  Public member functions
 //  ==============================================================================================================================
 
-    public boolean approve () {
-//  -------------------------
-      if  (state != ProgressState.inCHECK) return false;      
-      this.state =  ProgressState.APPROVED;        // The type name is supposed being localized
-      Database.getSession().update(this);
-         return true;
-    }
-
     public boolean equals(Object entity) {
 //  ------------------------------------
       if (entity == null) return false;
@@ -182,4 +173,19 @@ public class DocumentType extends Persistent {
       if (result == null) return false;
       return (Integer.valueOf(result) == step.getNumber());
     }
+    
+    /**
+        * Get the state.
+        * @return the state
+        */
+       public ProgressState getState() {
+               return state;
+       }
+       /**
+        * Set the state.
+        * @param state the state to set
+        */
+       public void setState(ProgressState state) {
+               this.state = state;
+       }
 }
\ No newline at end of file
index 294ae8e5216b54c871f11541ea3d8a20f28f421a..5ca4f8683acf2bff31d08a84d66dcfa0f861a9de 100644 (file)
@@ -1,92 +1,51 @@
 package org.splat.dal.bo.som;
+
 /**
  * 
  * @author    Daniel Brunier-Coulin
  * @copyright OPEN CASCADE 2012
  */
 
-import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
-import org.splat.dal.dao.som.Database;
-
-
 public class IDBuilder {
 
-    @SuppressWarnings("unused")
-       private int  cycle;
-    private int  base;                // Number of studies created in this cycle
-
-//  ==============================================================================================================================
-//  Constructors
-//  ==============================================================================================================================
-
-    protected IDBuilder () {
-    }
-    public IDBuilder (Date date) {
-//  -------------------------------
-         SimpleDateFormat get  = new SimpleDateFormat("yyyy");
-         String           year = get.format(date);
-         cycle = Integer.valueOf(year);
-      base  = 0;
-    }
-
-//  ==============================================================================================================================
-//  Public member functions
-//  ==============================================================================================================================
-
-    public String buildReference (String pattern, Study study) {
-//  -------------------------------------------------------------
-         char[] format = pattern.toCharArray();
-         char[] ref    = new char[80];   // Better evaluate the length of the generated string
-      int    next   = base + 1;
-
-         int count = 0;
-         for (int i=0; i<format.length; i++) {
-
-//    Insertion of attribute values              
-        if (format[i] == '%') {
-                 i += 1;
-                       
-                 if (format[i] == 'y') {     // Insertion of year in format 2 (e.g. 09) or 4 (e.g. 2009) digits
-                   int n = i;
-                   while (format[i] == 'y') {
-                         i += 1;
-                         if (i == format.length) break;
-                   }
-            SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
-                       String year = tostring.format(study.getDate());
-                   year = year.substring(4-(i-n), 4);   // 4-(i-n) must be equal to either 0 or 2
-                   for (int j=0; j<year.length(); j++) {
-                         ref[count] =  year.charAt(j);
-                         count += 1;
-                   }
-                   i -= 1;  // Back to the last 'y' character
-                 } else
-                 if (format[i] == '0') {     // Insertion of the index
-                   int n = i;
-                   while (format[i] == '0') {
-                         i += 1;
-                         if (i == format.length) break;
-                   }
-                   DecimalFormat tostring = new DecimalFormat(pattern.substring(n, i));
-                   String        number   = tostring.format(next);
-                   for (int j=0; j<number.length(); j++) {
-                         ref[count] =  number.charAt(j);
-                         count += 1;
-                   }
-                   i -= 1;  // Back to the last '0' character
-                 }
-//    Keep the character                 
-               } else {
-                 ref[count] = format[i];
-                 count += 1;             
-               }
-         }
-//    Incrementation of the number of study
-         base = next;
-         Database.getSession().update(this);
-         return String.copyValueOf(ref, 0, count);
-    }
+       @SuppressWarnings("unused")
+       private int cycle;
+       private int base; // Number of studies created in this cycle
+
+       // ==============================================================================================================================
+       // Constructors
+       // ==============================================================================================================================
+
+       protected IDBuilder() {
+       }
+
+       public IDBuilder(Date date) {
+               // -------------------------------
+               SimpleDateFormat get = new SimpleDateFormat("yyyy");
+               String year = get.format(date);
+               cycle = Integer.valueOf(year);
+               base = 0;
+       }
+
+       /**
+        * Get the base.
+        * 
+        * @return the base
+        */
+       public int getBase() {
+               return base;
+       }
+
+       /**
+        * Set the base.
+        * 
+        * @param base
+        *            the base to set
+        */
+       public void setBase(int base) {
+               this.base = base;
+       }
 }
\ No newline at end of file
index 41cad5a429d9ceb74f2c359452189af6b9e0869f..720944890976b9473c393667e46a98fddaa8fd32 100644 (file)
@@ -6,7 +6,6 @@ package org.splat.dal.bo.som;
  */
 
 import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.som.Database;
 
 
 public class KnowledgeElementType extends Persistent {
@@ -18,7 +17,7 @@ public class KnowledgeElementType extends Persistent {
 //  Constructors
 //  ==============================================================================================================================
 
-//  Database fetch constructor
+       //  Database fetch constructor
     protected KnowledgeElementType () {
     }
 //  Initialization constructor
@@ -33,14 +32,6 @@ public class KnowledgeElementType extends Persistent {
 //  Public member functions
 //  ==============================================================================================================================
 
-    public boolean approve () {
-//  -------------------------
-      if  (state != ProgressState.inCHECK) return false;      
-      this.state =  ProgressState.APPROVED;     // The type name is supposed being localized
-      if (this.isSaved()) Database.getSession().update(this);
-         return true;
-    }
-
     public boolean equals(Object entity) {
 //  ------------------------------------
       if (entity == null) return false;
@@ -72,20 +63,18 @@ public class KnowledgeElementType extends Persistent {
 //  ----------------------------
       return (state == ProgressState.inWORK);
     }
-
-//  ==============================================================================================================================
-//  Protected service
-//  ==============================================================================================================================
-/**
- * Reserves this type for the management of simulation contexts.
- * For being able to get the studies in which simulation contexts are used, all study scenarios are indexed through this
- * knowledge element type, whether they include knowledge elements or not.
- */
-    public boolean reserve () {
-//  ----------------------------
-      if  (state != ProgressState.inCHECK) return false;      
-      this.state =  ProgressState.inWORK;
-      if (this.isSaved()) Database.getSession().update(this);
-      return true;
-    }
+    /**
+        * Get the state.
+        * @return the state
+        */
+       public ProgressState getState() {
+               return state;
+       }
+       /**
+        * Set the state.
+        * @param state the state to set
+        */
+       public void setState(ProgressState state) {
+               this.state = state;
+       }
 }
\ No newline at end of file
index 7bf47337a1619cf1ae7034da60ff138283bc1460..9e8655d23ad4203e7443867d00a9dd9589e4e64d 100644 (file)
@@ -16,7 +16,6 @@ import java.util.Vector;
 import org.apache.log4j.Logger;
 
 import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
 import org.splat.kernel.ObjectProperties;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
@@ -178,21 +177,11 @@ public abstract class ProjectElement extends Entity {
 //  --------------------------------------------------
       return  contex.remove(oldoc);
     }
-
-/**
- * Refreshes the internal data potentially out-of-date.
- * This function needs to be called when Publication objects are added to this Project Element before being saved. The reason is,
- * as saving a persistent object changes its hashcode, hashed data need to be rebuilt after saving for making functions based
- * on this hashcode such as remove(), working.
- */
-    public void refresh () {
-//  -------------------------
-      Publication[] curdoc = docums.toArray(new Publication[docums.size()]);
-
-      folders = null;                 // Just in case
-      docums.clear();
-      for (int i=0; i<curdoc.length; i++) docums.add(curdoc[i]);
-//    No need to rebuild the list of SimulationContext as it does not use hashcodes
-      Database.getSession().update(this);
-    }
+       /**
+        * Get the docums.
+        * @return the docums
+        */
+       public Set<Publication> getDocums() {
+               return docums;
+       }
 }
\ No newline at end of file
index c869da1c22d36d54f8900a7350b99586a671ce79..6dafc733cd1b74f0ba1e2f0866825d5a514e380c 100644 (file)
@@ -17,23 +17,12 @@ package org.splat.dal.bo.som;
  * @copyright OPEN CASCADE 2012
  */
 
-import java.io.FileNotFoundException;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 
-import org.hibernate.Session;
 import org.splat.dal.bo.kernel.Persistent;
 import org.splat.dal.bo.kernel.Relation;
-import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
-import org.splat.kernel.InvalidPropertyException;
-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;
 
 
@@ -93,21 +82,6 @@ public class Publication extends Persistent {
       else            return mydoc.addRelation( new UsesRelation(mydoc, to) );
     }
 
-/**
- * Undo the out-date operation.
- * 
- * @return true if the acceptance succeeds
- * @see    #outdate()
- * @see    DocumentRights#canAccept()
- */
-    public boolean actualize () {
-//  ---------------------------
-      if (!this.isOutdated()) return false;
-      isnew = 'Y';
-      Database.getSession().update(this);
-      return true;
-    }
-
 /**
  * Returns either the Study Scenario or the Study itself to which this publication belongs, depending on the Study Step into
  * which the referenced document has been published.<br/>
@@ -199,26 +173,7 @@ public class Publication extends Persistent {
        public void setIsnew(char isnew) {
                this.isnew = isnew;
        }
-/**
- * Out-dates this publication and recursively all publications using this one.
- * Typically, a publication is out-dated when modifying a document to which it depends.
- * 
- * @see #isOutdated()
- * @see #getProgressState()
- * @see #actualize()
- */
-    public void outdate () {
-//  ----------------------
-      if (this.isOutdated()) return;
-
-      List<Publication> relist = this.getRelations(UsedByRelation.class);
-      for (Iterator<Publication> i = relist.iterator(); i.hasNext(); ) {
-       i.next().outdate();
-      }
-      isnew = 'O';
-      Database.getSession().update(this);
-    }
-
+       
 /**
  * Returns the document version referenced by this Publication.
  */
index 362e169074d8cec615a1f1f7454d83e9ea7839aa..f8f475cc127a96af530304192d8b563eb1ced5e9 100644 (file)
@@ -1,4 +1,5 @@
 package org.splat.dal.bo.som;
+
 /**
  * 
  * @author    Daniel Brunier-Coulin
@@ -17,281 +18,315 @@ import java.util.Vector;
 
 import org.splat.dal.bo.kernel.Persistent;
 import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
 import org.splat.som.Step;
 
-
+/**
+ * Scenario persistent object.
+ */
 public class Scenario extends ProjectElement {
 
-//  Persistent fields
-    private Study                 owner;
-       private int                   sid;               // Identifier unique in the scope of owner study
-       private User                  cuser;             // User having checked-out the scenario, if done
-    /**
-     * The persistent set of scenario knowledge elements.
-     */
-    private Set<KnowledgeElement> kelms;
-
-//  Transient fields
-    /**
-     * The transient map of knowledge elements grouped by types.
-     */
-    transient private HashMap<Long, List<KnowledgeElement>> known;
-    /**
-     * The scenario transient list of knowledge elements.
-     */
-    transient private List<KnowledgeElement>                   knowl;  // Copy of kelms excluding the internal Knowledge Element (ucase below)
+       // Persistent fields
+       /**
+        * Persistent property owner. It is a parent study of the scenario.
+        */
+       private Study owner;
+       /**
+        * Persistent property sid. It is an unique identifier in the scope of owner study.
+        */
+       private int sid;
+       /**
+        * Persistent property cuser. It is a user having checked-out the scenario, if done.
+        */
+       private User cuser;
+       /**
+        * The persistent set of scenario knowledge elements.
+        */
+       private Set<KnowledgeElement> kelms;
+
+       // Transient fields
+       /**
+        * The transient map of knowledge elements grouped by types.
+        */
+       transient private HashMap<Long, List<KnowledgeElement>> known;
+       /**
+        * The scenario transient list of knowledge elements.
+        */
+       transient private List<KnowledgeElement> knowl; // Copy of kelms excluding the internal Knowledge Element (ucase below)
        /**
         * The scenario transient "use case" knowledge element.
         */
-       transient private KnowledgeElement                         ucase;  // Internal Knowledge Element for accessing to all used simulation contexts
-
-
-//  ==============================================================================================================================
-//  Construction
-//  ==============================================================================================================================
-
-
-    /**
-     *   Fields initialization class.
-     */
-    public static class Properties extends Persistent.Properties {
-//  ------------------------------------------------------------
-      private Study    owner    = null;
-      private Scenario previous = null;
-      private Step     base     = null;
-      private String   title    = null;
-      private String   summary  = null;
-      private User     manager  = null;
-      private Date     date     = null;
-
-//  - Public services
-
-      public void clear () {
-        super.clear();
-        owner    = null;
-        previous = null;
-        base     = null;
-        title    = null;
-        summary  = null;
-        manager  = null;
-        date     = null;
-      }
-//  - Protected services
-
-      public Step getBaseStep () {
-       return base;         // May be null
-      }
-      public Scenario getInsertAfter () {
-       return previous;     // May be null
-      }
-         public User getManager () {
-               return manager;
-         }
-      public Properties setOwnerStudy (Study owner)
-      {
-        this.owner = owner;
-        return this;
-      }
-//  - Setters of Scenario properties
-
-      public Properties setBaseStep (Step base) throws InvalidPropertyException
-      {
-       if (!(base.getOwner() instanceof Scenario)) throw new InvalidPropertyException("step");
-        this.base = base;
-        return this;
-      }
-      public Properties setDate (Date date)
-      {
-       this.date = date;
-        return this;
-      }
-      public Properties setDescription (String summary)
-      {
-       if (summary.length() > 0) this.summary = summary;
-       return this;
-      }
-      public Properties setInsertAfter (Scenario previous)
-      {
-        this.previous = previous;
-        return this;
-      }
-      public Properties setManager (User user)
-      {
-       this.manager = user;
-        return this;
-      }
-      public Properties setTitle (String title) throws InvalidPropertyException
-      {
-        if (title.length() == 0) throw new InvalidPropertyException("title");
-        this.title = title;
-        return this;
-      }
-//  - Global validity check
-      
-      public void checkValidity() throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException
-      {
-        if (owner == null)   throw new MissedPropertyException("owner");
-        if (title == null)   throw new MissedPropertyException("title");
-        if (manager == null) throw new MissedPropertyException("manager");
-      }
-    }
-//  Database fetch constructor
-    protected Scenario () {
-//  ---------------------
-      known = null;
-      knowl = null;
-      ucase = null;
-    }
-//  Internal constructor
-    public Scenario (Properties sprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
-//  -------------------------------------
-      super(sprop);                // Throws one of the above exception if not valid
-      owner   = sprop.owner;
-      sid     = 0;
-      cuser   = null;
-      title   = sprop.title;       // Inherited attribute
-      known   = null;
-      knowl   = null;              // Initialized when getting all Knowledge Elements
-      ucase   = null;
-      kelms   = new HashSet<KnowledgeElement>();
-
-      manager = sprop.manager;
-//RKV: The business logic is moved to business services:      if (!owner.isStaffedBy(manager)) throw new InvalidPropertyException("manager");
-
-      credate = sprop.date;        // Inherited attribute
-      if (credate == null) {
-        Calendar current = Calendar.getInstance();
-        credate = current.getTime();  // Today
-      }
-      lasdate = credate;           // Inherited attribute
-
-      if (sprop.summary != null) this.setAttribute( new DescriptionAttribute(this, sprop.summary) );
-
-      Scenario[] scene = owner.getScenarii();
-      for (int i=0; i<scene.length; i++) if (scene[i].sid > this.sid) this.sid = scene[i].sid;
-      sid += 1;
-    }
-
-//  ==============================================================================================================================
-//  Public member functions
-//  ==============================================================================================================================
-
-    public List<KnowledgeElement> getAllKnowledgeElements () {
-//  --------------------------------------------------------
-      if (knowl == null) {
-       knowl = new Vector<KnowledgeElement>(kelms.size());
-       for (Iterator<KnowledgeElement> i=kelms.iterator(); i.hasNext(); ) {
-          KnowledgeElement  kelm = i.next();
-          if (kelm.getType().equals("usecase")) ucase = kelm;
-          else                                  knowl.add(kelm);
-       }
-      }
-      return  Collections.unmodifiableList(knowl);
-    }
-
-    public KnowledgeElement getKnowledgeElement (long l) {
-//  -------------------------------------------------------
-      for (Iterator<KnowledgeElement> i=kelms.iterator(); i.hasNext();) {
-           KnowledgeElement mykelm = i.next();
-        if (mykelm.getIndex() == l) return mykelm;
-      }
-      return null;
-    }
-
-    public List<KnowledgeElement> getKnowledgeElementsOf (KnowledgeElementType type) {
-//  --------------------------------------------------------------------------------
-      if (kelms.isEmpty()) return  new Vector<KnowledgeElement>();   // Smarter than returning null
-      if (known == null)   known = new HashMap<Long, List<KnowledgeElement>>();
-
-      long                    numtype = type.getIndex();
-      List<KnowledgeElement> listype = known.get(numtype);
-      if (listype == null) {
-        listype = new Vector<KnowledgeElement>();
-        for (Iterator<KnowledgeElement> i=kelms.iterator(); i.hasNext();) {
-          KnowledgeElement kelm = i.next();
-          if (kelm.getType().getIndex() == numtype) listype.add(kelm);
-        }
-        known.put(numtype, listype);
-      }
-      return listype;   // No protection against this object corruption as it would not corrupt the database
-    }
-
-    public Study getOwnerStudy () {
-//  -----------------------------
-      return  owner;
-    }
-/**
- * Returns the local reference of this scenario. This reference is unique in the scope of the owner study.
- */
-    public String getReference () {
-//  -----------------------------
-      return  String.valueOf(sid);
-    }
-
-    public User getUser () {
-      return  cuser;    // Null if the scenario has not been checked-out
-    }
-
-    public void setUser (User aUser) {
-      cuser = aUser;    // Null if the scenario has not been checked-out
-    }
-
-    public boolean removeKnowledgeElement (KnowledgeElement kelm) {
-//  -------------------------------------------------------------
-         KnowledgeElement torem = getKnowledgeElement(kelm.getIndex());
-      if (torem == null) return false;
-      boolean done = kelms.remove(torem);
-      if (done) {
-//      Update of my transient data
-        List<KnowledgeElement> kelms = known.get(kelm.getType().getIndex());
-        kelms.remove(torem);
-        if (knowl != null) knowl.remove(torem);
-        Database.getSession().update(this);
-//TODO: If the owner study is not private, remove the knowledge from the Lucene index
-        return true;
-      } else {
-        return false;
-      }
-    }
-
-    public boolean isCheckedout () {
-//  ------------------------------
-      return (cuser != null);
-    }
-
-//  ==============================================================================================================================
-//  Private services
-//  ==============================================================================================================================
+       transient private KnowledgeElement ucase; // Internal Knowledge Element for accessing to all used simulation contexts
+
+       // ==============================================================================================================================
+       // Construction
+       // ==============================================================================================================================
+
+       /**
+        * Fields initialization class.
+        */
+       public static class Properties extends Persistent.Properties {
+               // ------------------------------------------------------------
+               private Study owner = null;
+               private Scenario previous = null;
+               private Step base = null;
+               private String title = null;
+               private String summary = null;
+               private User manager = null;
+               private Date date = null;
+
+               // - Public services
+
+               public void clear() {
+                       super.clear();
+                       owner = null;
+                       previous = null;
+                       base = null;
+                       title = null;
+                       summary = null;
+                       manager = null;
+                       date = null;
+               }
+
+               // - Protected services
+
+               public Step getBaseStep() {
+                       return base; // May be null
+               }
+
+               public Scenario getInsertAfter() {
+                       return previous; // May be null
+               }
+
+               public User getManager() {
+                       return manager;
+               }
+
+               public Properties setOwnerStudy(Study owner) {
+                       this.owner = owner;
+                       return this;
+               }
+
+               // - Setters of Scenario properties
+
+               public Properties setBaseStep(Step base)
+                               throws InvalidPropertyException {
+                       if (!(base.getOwner() instanceof Scenario))
+                               throw new InvalidPropertyException("step");
+                       this.base = base;
+                       return this;
+               }
+
+               public Properties setDate(Date date) {
+                       this.date = date;
+                       return this;
+               }
+
+               public Properties setDescription(String summary) {
+                       if (summary.length() > 0)
+                               this.summary = summary;
+                       return this;
+               }
+
+               public Properties setInsertAfter(Scenario previous) {
+                       this.previous = previous;
+                       return this;
+               }
+
+               public Properties setManager(User user) {
+                       this.manager = user;
+                       return this;
+               }
+
+               public Properties setTitle(String title)
+                               throws InvalidPropertyException {
+                       if (title.length() == 0)
+                               throw new InvalidPropertyException("title");
+                       this.title = title;
+                       return this;
+               }
+
+               // - Global validity check
+
+               public void checkValidity() throws MissedPropertyException,
+                               InvalidPropertyException, MultiplyDefinedException {
+                       if (owner == null)
+                               throw new MissedPropertyException("owner");
+                       if (title == null)
+                               throw new MissedPropertyException("title");
+                       if (manager == null)
+                               throw new MissedPropertyException("manager");
+               }
+       }
+
+       // Database fetch constructor
+       protected Scenario() {
+               // ---------------------
+               known = null;
+               knowl = null;
+               ucase = null;
+       }
+
+       // Internal constructor
+       public Scenario(Properties sprop) throws MissedPropertyException,
+                       InvalidPropertyException, MultiplyDefinedException {
+               // -------------------------------------
+               super(sprop); // Throws one of the above exception if not valid
+               owner = sprop.owner;
+               sid = 0;
+               cuser = null;
+               title = sprop.title; // Inherited attribute
+               known = null;
+               knowl = null; // Initialized when getting all Knowledge Elements
+               ucase = null;
+               kelms = new HashSet<KnowledgeElement>();
+
+               manager = sprop.manager;
+               // RKV: The business logic is moved to business services: if (!owner.isStaffedBy(manager)) throw new
+               // InvalidPropertyException("manager");
+
+               credate = sprop.date; // Inherited attribute
+               if (credate == null) {
+                       Calendar current = Calendar.getInstance();
+                       credate = current.getTime(); // Today
+               }
+               lasdate = credate; // Inherited attribute
+
+               if (sprop.summary != null)
+                       this.setAttribute(new DescriptionAttribute(this, sprop.summary));
+
+               Scenario[] scene = owner.getScenarii();
+               for (int i = 0; i < scene.length; i++)
+                       if (scene[i].sid > this.sid)
+                               this.sid = scene[i].sid;
+               sid += 1;
+       }
+
+       // ==============================================================================================================================
+       // Public member functions
+       // ==============================================================================================================================
+
+       public List<KnowledgeElement> getAllKnowledgeElements() {
+               // --------------------------------------------------------
+               if (knowl == null) {
+                       knowl = new Vector<KnowledgeElement>(kelms.size());
+                       for (Iterator<KnowledgeElement> i = kelms.iterator(); i.hasNext();) {
+                               KnowledgeElement kelm = i.next();
+                               if (kelm.getType().equals("usecase"))
+                                       ucase = kelm;
+                               else
+                                       knowl.add(kelm);
+                       }
+               }
+               return Collections.unmodifiableList(knowl);
+       }
+
+       public KnowledgeElement getKnowledgeElement(long l) {
+               // -------------------------------------------------------
+               for (Iterator<KnowledgeElement> i = kelms.iterator(); i.hasNext();) {
+                       KnowledgeElement mykelm = i.next();
+                       if (mykelm.getIndex() == l)
+                               return mykelm;
+               }
+               return null;
+       }
+
+       public List<KnowledgeElement> getKnowledgeElementsOf(
+                       KnowledgeElementType type) {
+               // --------------------------------------------------------------------------------
+               if (kelms.isEmpty())
+                       return new Vector<KnowledgeElement>(); // Smarter than returning null
+               if (known == null)
+                       known = new HashMap<Long, List<KnowledgeElement>>();
+
+               long numtype = type.getIndex();
+               List<KnowledgeElement> listype = known.get(numtype);
+               if (listype == null) {
+                       listype = new Vector<KnowledgeElement>();
+                       for (Iterator<KnowledgeElement> i = kelms.iterator(); i.hasNext();) {
+                               KnowledgeElement kelm = i.next();
+                               if (kelm.getType().getIndex() == numtype)
+                                       listype.add(kelm);
+                       }
+                       known.put(numtype, listype);
+               }
+               return listype; // No protection against this object corruption as it would not corrupt the database
+       }
+
+       public Study getOwnerStudy() {
+               // -----------------------------
+               return owner;
+       }
+
+       /**
+        * Returns the local reference of this scenario. This reference is unique in the scope of the owner study.
+        */
+       public String getReference() {
+               // -----------------------------
+               return String.valueOf(sid);
+       }
+
+       public User getUser() {
+               return cuser; // Null if the scenario has not been checked-out
+       }
+
+       public void setUser(User aUser) {
+               cuser = aUser; // Null if the scenario has not been checked-out
+       }
+
+       public boolean isCheckedout() {
+               // ------------------------------
+               return (cuser != null);
+       }
+
+       // ==============================================================================================================================
+       // Private services
+       // ==============================================================================================================================
        /**
         * Get the persistent set of knowledge elements.
+        * 
         * @return the persistent set of scenario knowledge elements
         */
        public Set<KnowledgeElement> getKnowledgeElements() {
                return kelms;
        }
-       /** 
+
+       /**
         * Get the transient list of knowledge elements.
+        * 
         * @return the transient list of knowledge elements
         */
        public List<KnowledgeElement> getKnowledgeElementsList() {
                return knowl;
        }
+
        /**
         * Set the scenario transient "use case" knowledge element.
-        * @param kelm the scenario transient "use case" knowledge element
+        * 
+        * @param kelm
+        *            the scenario transient "use case" knowledge element
         */
        public void setUcase(KnowledgeElement kelm) {
                ucase = kelm;
        }
+
        /**
         * Get the scenario transient "use case" knowledge element.
+        * 
         * @return the scenario transient "use case" knowledge element
         */
        public KnowledgeElement getUcase() {
                return ucase;
        }
+
+       /**
+        * Get the known.
+        * 
+        * @return the known
+        */
+       public HashMap<Long, List<KnowledgeElement>> getKnowledgeByType() {
+               return known;
+       }
 }
\ No newline at end of file
index 828033b883a0dcf893b8dcdbeafc43719a74900f..ab900bd0660bf2b122c4f95e7fc4d5bdeb682fc6 100644 (file)
@@ -6,12 +6,8 @@ package org.splat.dal.bo.som;
  */
 
 import java.io.Serializable;
-import java.util.List;
-
-import org.hibernate.Session;
 
 import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.som.Database;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
@@ -24,7 +20,7 @@ public class SimulationContext extends Persistent implements Serializable {
        private SimulationContextType  type;     // User extendable types
     private int                    step;
     private ProgressState          state;
-    private String                 value;
+       private String                 value;
     private int                    counter;
 
     private static final long serialVersionUID = 422889133378471949L;
@@ -114,14 +110,6 @@ public class SimulationContext extends Persistent implements Serializable {
 //  Public member functions
 //  ==============================================================================================================================
 
-    public boolean approve () {
-//  -------------------------
-      if  (state != ProgressState.inCHECK) return false;      
-      this.state =  ProgressState.APPROVED;     // The type name is supposed being localized
-      Database.getSession().update(this);
-         return true;
-    }
-
     public boolean equals (SimulationContext given) {
 //  -----------------------------------------------
       if (isSaved()) return (this.getIndex() == given.getIndex());
@@ -140,6 +128,14 @@ public class SimulationContext extends Persistent implements Serializable {
       return state;
     }
 
+    /**
+        * Set the state.
+        * @param state the state to set
+        */
+       public void setProgressState(ProgressState state) {
+               this.state = state;
+       }
+       
     public SimulationContextType getType () {
 //  ---------------------------------------
       return type;
index c275cb87988b462e6cd41b36e4cdd0226340e911..607582aba8d21ff42ed0a060036ccec8dceac942 100644 (file)
@@ -8,11 +8,8 @@ package org.splat.dal.bo.som;
 import java.io.Serializable;
 
 import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.som.Database;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.technical.ProjectSettingsService.Step;
-import org.splat.service.technical.ProjectSettingsServiceImpl;
 
 
 public class SimulationContextType extends Persistent implements Serializable {
@@ -20,7 +17,7 @@ public class SimulationContextType extends Persistent implements Serializable {
 //  Persistent fields
     private String         name;
     private ProgressState  state;
-    private int            step;
+       private int            step;
 
 //  Required by the serialization
        private static final long serialVersionUID = 4819425038576161242L;
@@ -41,7 +38,7 @@ public class SimulationContextType extends Persistent implements Serializable {
       public ProjectSettingsService.Step getStep () {
        return step;
       }
-      public Properties setState (ProgressState state) {
+      public Properties setProgressState (ProgressState state) {
        this.state = state;
        return this;
       }
@@ -66,14 +63,6 @@ public class SimulationContextType extends Persistent implements Serializable {
 //  Public member functions
 //  ==============================================================================================================================
 
-    public boolean approve () {
-//  -------------------------
-      if  (state != ProgressState.inCHECK) return false;      
-      this.state =  ProgressState.APPROVED;     // The type name is supposed being localized
-      Database.getSession().update(this);
-         return true;
-    }
-
     public boolean equals(Object entity) {
 //  ------------------------------------
       if (entity == null) return false;
@@ -91,11 +80,6 @@ public class SimulationContextType extends Persistent implements Serializable {
       }
     }
 
-    public ProjectSettingsService.Step getAttachedStep () {
-//  ----------------------------------------------
-      return ProjectSettingsServiceImpl.getStep(step);
-    }
-
     public String getName () {
 //  ------------------------
       return name;
@@ -111,4 +95,33 @@ public class SimulationContextType extends Persistent implements Serializable {
 //  ----------------------------
       return (state == ProgressState.APPROVED);
     }
+    /**
+        * Get the state.
+        * @return the state
+        */
+       public ProgressState getState() {
+               return state;
+       }
+       /**
+        * Set the state.
+        * @param state the state to set
+        */
+       public void setState(ProgressState state) {
+               this.state = state;
+       }
+       /**
+        * Get the step.
+        * @return the step
+        */
+       public int getStep() {
+               return step;
+       }
+       /**
+        * Set the step.
+        * @param step the step to set
+        */
+       public void setStep(int step) {
+               this.step = step;
+       }
+
 }
\ No newline at end of file
index 989cd25befc67f1f08cbc9749647dbbf16e91d05..9b7579b89c7e771c240fd437b8e548002881761a 100644 (file)
@@ -26,16 +26,13 @@ package org.splat.dal.bo.som;
  * @copyright OPEN CASCADE 2012
  */
 
-import java.util.List;
 import java.util.Vector;
 
 import org.splat.dal.bo.kernel.Persistent;
 import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
-import org.splat.kernel.UserDirectory;
 import org.splat.service.technical.ProjectSettingsServiceImpl;
 
 public class ValidationCycle extends Persistent {
index 08642029c5841b005420e2179093d61bd052806c..9f13ef351bb3cdbae9193b92283c248b670a1a08 100644 (file)
@@ -1,4 +1,5 @@
 package org.splat.dal.dao.kernel;
+
 /**
  * 
  * @author    Daniel Brunier-Coulin
@@ -6,14 +7,16 @@ package org.splat.dal.dao.kernel;
  */
 
 import org.hibernate.Session;
-import org.hibernate.SessionFactory;
+import org.splat.service.technical.IndexService;
+import org.splat.service.technical.RepositoryService;
 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;
 
-
-public abstract class Database implements ApplicationContextAware {
+public abstract class Database extends HibernateDaoSupport implements
+               ApplicationContextAware {
 
        /**
         * The ApplicationContext.
@@ -22,67 +25,51 @@ public abstract class Database implements ApplicationContextAware {
 
        /**
         * Spring will call this method for initialize the applicationContext.
-        * @param ctx the application context
-        * @throws BeansException the BeanException
+        * 
+        * @param ctx
+        *            the application context
+        * @throws BeansException
+        *             the BeanException
         */
-       public void setApplicationContext(final ApplicationContext ctx) throws BeansException {
+       public void setApplicationContext(final ApplicationContext ctx)
+                       throws BeansException {
                _context = ctx;
        }
 
        /**
         * Static for getting the context.
+        * 
         * @return ApplicationContext the application context
         */
        public static ApplicationContext getContext() {
                return _context;
        }
-       
-//     private   static  String          CONFIG_FILE      = "/hibernate.cfg.xml";
-    private   static  SessionFactory  mySessionFactory = null;
 
-    protected final static Logger   logger = Logger.getLogger(Database.class);
-    
-//  ==============================================================================================================================
-//  Public services
-//  ==============================================================================================================================
+       // private static String CONFIG_FILE = "/hibernate.cfg.xml";
+       protected final static Logger logger = Logger.getLogger(Database.class);
 
-    public static Session getSession () {
-//  -----------------------------------        
-      return getInstance().getCurrentSession();
-       }
-       
-//  ==============================================================================================================================
-//  Protected services
-//  ==============================================================================================================================
+       // ==============================================================================================================================
+       // Protected services
+       // ==============================================================================================================================
 
-    protected String getSchemaVersion () {
-//  ------------------------------------
-      return null;//TODO: Get schema version into specific object/table: getIDPool().getSchemaVersion();
-    }
+       protected String getSchemaVersion() {
+               // ------------------------------------
+               return null;// TODO: Get schema version into specific object/table: getIDPool().getSchemaVersion();
+       }
 
-    protected void setSchemaVersion (String version) {
-//  ------------------------------------------------
-//TODO: Set schema version into specific object/table:      myIDpool = new IDPool(version);
-//      getSession().save(myIDpool);
-    }
+       protected void setSchemaVersion(String version) {
+               // ------------------------------------------------
+               // TODO: Set schema version into specific object/table: myIDpool = new IDPool(version);
+               // getSession().save(myIDpool);
+       }
 
-//  ==============================================================================================================================
-//  Private services
-//  ==============================================================================================================================
-       
-    private static SessionFactory getInstance () {
-//  --------------------------------------------
-      if (mySessionFactory == null) {
-//     org.hibernate.cfg.Configuration cfg = new org.hibernate.cfg.Configuration();
-        try {
-               mySessionFactory = getContext().getBean(SessionFactory.class);
-//          cfg.configure();   // The configuration file (hibernate.cfg.xml)) is supposed to be on the classpath
-//          mySessionFactory = cfg.buildSessionFactory();
-        }
-        catch (Exception error) {
-          logger.fatal("Could not initialize the Hibernate configuration, reason:", error);
-        }
-      }
-      return mySessionFactory;
-    }
+       // ==============================================================================================================================
+       // Private services
+       // ==============================================================================================================================
+//{
+//             if (myDB == null) {
+//                     myDB = new Database();
+//             }
+//             return myDB;
+//     }
 }
\ No newline at end of file
index 68f67d29912040d0f2b1fc039113a2d859dc5793..bfed9c5ecc74fb9a13e2bf4e60924b5c17d82303 100644 (file)
@@ -11,6 +11,7 @@ package org.splat.dal.dao.kernel;
 
 import java.io.Serializable;
 import java.util.List;
+import java.util.Properties;
 
 import org.hibernate.criterion.Criterion;
 import org.hibernate.criterion.Order;
@@ -70,12 +71,20 @@ public interface GenericDAO<T, PK extends Serializable> {
         */
        public T findByCriteria(Criterion aCondition);
 
+       /**
+        * Retrieve an object that was previously persisted to the database using the given criteria.
+        * 
+        * @param andParams
+        *            a properties values to filter with AND condition
+        * @return an object found according to the given criteria
+        */
+       public T findByCriteria(Properties andParams);
+
        /**
         * Retrieve a list of all objects of the considered type T which were previously persisted to the database.
         * 
         * @return a list of all objects of the considered type T
         */
-       @SuppressWarnings("unchecked")
        public List<T> getAll();
 
        /**
@@ -85,9 +94,8 @@ public interface GenericDAO<T, PK extends Serializable> {
         *            a result list order. Null is ignored and in such case the result list is unordered.
         * @return an ordered list of all objects of the considered type T
         */
-       @SuppressWarnings("unchecked")
-       public List<T> getAll(Order anOrder);
-       
+       public List<T> getAll(Order... anOrder);
+
        /**
         * Retrieve a list of objects which were previously persisted to the database using the given criteria.
         * 
@@ -96,6 +104,7 @@ public interface GenericDAO<T, PK extends Serializable> {
         * @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.
         * 
@@ -105,11 +114,31 @@ public interface GenericDAO<T, PK extends Serializable> {
         *            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);
+       public List<T> getFilteredList(Criterion aCondition, Order... anOrder);
+
+       /**
+        * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+        * 
+        * @param andParams
+        *            a properties values to filter with AND condition
+        * @return a list of objects filtered according to the given criteria
+        */
+       public List<T> getFilteredList(Properties andParams);
+
+       /**
+        * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+        * 
+        * @param andParams
+        *            a properties values to filter with AND 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
+        */
+       public List<T> getFilteredList(Properties andParams, Order... anOrder);
 
        /**
         * Makes detached object persistent.
+        * 
         * @param transientObject
         *            transient instance of the object to be made persistent
         */
index 64d3a6a4c598820d23f601a26fc7a9f491aa780c..88420adb4de1923016879dc1b3f9fe4be87de114 100644 (file)
@@ -11,10 +11,12 @@ package org.splat.dal.dao.kernel;
 
 import java.io.Serializable;
 import java.util.List;
+import java.util.Properties;
 
 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;
 
 /**
@@ -66,6 +68,21 @@ public abstract class GenericDAOImpl<T, PK extends Serializable> extends
                                .uniqueResult();
        }
 
+       /**
+        * Retrieve an object that was previously persisted to the database using the given criteria.
+        * 
+        * @param andParams
+        *            a properties values to filter with AND condition
+        * @return an object found according to the given criteria
+        */
+       public T findByCriteria(Properties andParams) {
+               Criterion aCondition = null;
+               for (String aName: andParams.stringPropertyNames()) {
+                       aCondition = Restrictions.and(aCondition, Restrictions.eq(aName, andParams.get(aName)));
+               }
+               return findByCriteria(aCondition);
+       }
+
        /**
         * Retrieve a list of all objects of the considered type T which were previously persisted to the database.
         * 
@@ -84,10 +101,12 @@ public abstract class GenericDAOImpl<T, PK extends Serializable> extends
         * @return an ordered list of all objects of the considered type T
         */
        @SuppressWarnings("unchecked")
-       public List<T> getAll(Order anOrder) {
+       public List<T> getAll(Order ... anOrder) {
                Criteria aCriteria = getSession().createCriteria(getType());
-               if (anOrder != null) {
-                       aCriteria.addOrder(anOrder);
+               for (Order order : anOrder) {
+                       if (anOrder != null) {
+                               aCriteria.addOrder(order);
+                       }
                }
                return aCriteria.list();
        }
@@ -114,15 +133,45 @@ public abstract class GenericDAOImpl<T, PK extends Serializable> extends
         * @return a list of objects filtered according to the given criteria
         */
        @SuppressWarnings("unchecked")
-       public List<T> getFilteredList(Criterion aCondition, Order anOrder) {
+       public List<T> getFilteredList(Criterion aCondition, Order ... anOrder) {
                Criteria aCriteria = getSession().createCriteria(getType()).add(
                                aCondition);
-               if (anOrder != null) {
-                       aCriteria.addOrder(anOrder);
+               for (Order order : anOrder) {
+                       if (anOrder != null) {
+                               aCriteria.addOrder(order);
+                       }
                }
                return aCriteria.list();
        }
 
+       /**
+        * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+        * 
+        * @param andParams
+        *            a properties values to filter with AND condition
+        * @return a list of objects filtered according to the given criteria
+        */
+       public List<T> getFilteredList(Properties andParams) {
+               return getFilteredList(andParams);
+       }
+
+       /**
+        * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+        * 
+        * @param andParams
+        *            a properties values to filter with AND 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
+        */
+       public List<T> getFilteredList(Properties andParams, Order ... anOrder) {
+               Criterion aCondition = null;
+               for (String aName: andParams.stringPropertyNames()) {
+                       aCondition = Restrictions.and(aCondition, Restrictions.eq(aName, andParams.get(aName)));
+               }
+               return getFilteredList(aCondition, anOrder);
+       }
+
        /**
         * Save changes made to a persistent object.
         * 
index 3d5790a3a0f763457e83ee749a87208a83b085fd..649b2f50f1c9f313da68bc817c98264d6d6d8c68 100644 (file)
@@ -6,39 +6,30 @@ package org.splat.dal.dao.som;
  * @copyright OPEN CASCADE 2012
  */
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
 import java.util.Properties;
-import java.io.File;
 import java.io.IOException;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
-import org.hibernate.Query;
 import org.hibernate.Session;
-import org.hibernate.SessionFactory;
 import org.hibernate.jdbc.Work;
 import org.apache.log4j.Logger;
 
 import org.splat.dal.bo.kernel.User;
-import org.splat.dal.bo.som.IDBuilder;
-import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.bo.som.SimulationContext;
-import org.splat.dal.bo.som.SimulationContextType;
-import org.splat.kernel.UserDirectory;
-import org.splat.kernel.InvalidPropertyException;
+import org.splat.service.UserService;
 import org.splat.service.technical.IndexService;
 import org.splat.service.technical.RepositoryService;
+import org.springframework.transaction.annotation.Transactional;
 
 public class Database extends org.splat.dal.dao.kernel.Database {
 
        private int uplevel = 0; // Level of database upgrade
        private RepositoryService _repositoryService;
        private IndexService _indexService;
-       private SessionFactory _sessionFactory;
+       private UserService _userService;
+       
 
        private static Database my = null; // Singleton instance
 
@@ -70,7 +61,21 @@ public class Database extends org.splat.dal.dao.kernel.Database {
        // Construction
        // ==============================================================================================================================
 
-       public Database getMe() {
+       private static Database myDB;
+
+       public static Database getInstance() {
+               if (myDB == null) {
+                       myDB = new Database();
+               }
+               return myDB; 
+       }
+       
+       public static Session getCurSession() {
+               // -----------------------------------
+               return getInstance().getSession();
+       }
+
+       public Database getCheckedDB() {
                // -------------------------------
                if (my == null)
                        try {
@@ -88,8 +93,9 @@ public class Database extends org.splat.dal.dao.kernel.Database {
        /**
         * Check version of the database schema.
         */
+       @Transactional(readOnly=true)
        private void checkVersion() {
-               getSessionFactory().getCurrentSession().doWork(new CheckVersion());
+               getSession().doWork(new CheckVersion());
        }
 
        // ==============================================================================================================================
@@ -109,12 +115,10 @@ public class Database extends org.splat.dal.dao.kernel.Database {
                getIndexService().create(); // May throw IOException if the index repository is improperly configured
 
                // Creation of the SIMER SQL tables
-               Session session = Database.getSession();
 
                // Population of the database with customized data
                this.populate();
 
-               session.flush();
                uplevel = 0; // The database is now up-to-date
        }
 
@@ -143,7 +147,7 @@ public class Database extends org.splat.dal.dao.kernel.Database {
                                        "label.sysadmin").addRole("sysadmin").setMailAddress(
                                        "noreply@salome-platform.org");
                        uprop.disableCheck();
-                       UserDirectory.createUser(uprop);
+                       getUserService().createUser(uprop);
                } catch (Exception e) {
                        // Let's continue, hoping the best...
                }
@@ -180,21 +184,18 @@ public class Database extends org.splat.dal.dao.kernel.Database {
        }
 
        /**
-        * Get the sessionFactory.
-        * 
-        * @return the sessionFactory
+        * Get the userService.
+        * @return the userService
         */
-       public SessionFactory getSessionFactory() {
-               return _sessionFactory;
+       public UserService getUserService() {
+               return _userService;
        }
 
        /**
-        * Set the sessionFactory.
-        * 
-        * @param sessionFactory
-        *            the sessionFactory to set
+        * Set the userService.
+        * @param userService the userService to set
         */
-       public void setSessionFactory(SessionFactory sessionFactory) {
-               _sessionFactory = sessionFactory;
+       public void setUserService(UserService userService) {
+               _userService = userService;
        }
 }
\ No newline at end of file
index a0234f4973e15850e7b7338a88dbf401f79b5d63..6269ae31167a8f79923eca8828d6787ba925deb3 100644 (file)
@@ -16,7 +16,7 @@ import javax.security.auth.spi.*;
 
 import org.apache.log4j.Logger;
 import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.kernel.Database;
+import org.splat.service.ServiceLocatorImpl;
 
 
 public class RealmLoginModule implements LoginModule {
@@ -47,7 +47,7 @@ public class RealmLoginModule implements LoginModule {
 //       sharedState     = state;
 //       options         = opts;
 //    debug           = "true".equalsIgnoreCase((String)options.get("debug"));
-         logger          = Logger.getLogger(Database.class);
+         logger          = Logger.getLogger(RealmLoginModule.class);
     }
 
 //  ==============================================================================================================================
@@ -73,18 +73,18 @@ public class RealmLoginModule implements LoginModule {
            }
            
 //    Authentication       
-           User found = UserDirectory.selectUser(username, password);
+           User found = ServiceLocatorImpl.getInstance().getUserService().selectUser(username, password);
            if (found != null) {
              identity  = found;
              succeeded = true;       
              Calendar today  = java.util.Calendar.getInstance();
              Date     datime = today.getTime();
-             logger.info("RKV:Connection of " + identity.toString() + " " + datime.toString() + ".");
+             logger.info("Connection of " + identity.toString() + " " + datime.toString() + ".");
              return true;
            } else {
              identity  = null;
                  succeeded = false;              
-                 found     = UserDirectory.selectUser(username);
+                 found     = ServiceLocatorImpl.getInstance().getUserService().selectUser(username);
           String             reason = "password";
                  if (found == null) reason = "username";
              logger.info("Connection attempt as " + username + ".");
diff --git a/Workspace/Siman-Common/src/org/splat/kernel/UserDirectory.java b/Workspace/Siman-Common/src/org/splat/kernel/UserDirectory.java
deleted file mode 100644 (file)
index e0fa88e..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-package org.splat.kernel;
-/**
- * Very minimal implementation of the user directory of a company department.<br/>
- * This directory can include members of the department, the two level hierarchy of these members (their n+1 and n+2 managers),
- * and all customers of the department.<br/>
- * The department hierarchy is defined through a hard-coded combination of user role and organization names (see the getManagerOf
- * function of this class). It is useful for implementing an application workflow requiring such informmation (the n+1 and n+2
- * managers are usually involved in the validation process).<br/>
- * <br/>
- * When needed, a full implementation of the company organization can be adjoin to this class by using user organization names
- * as reference to departments into this organization. In this context, the function getManagerOf(user) of this class will be
- * ineffective (it will return null).
- * 
- * @author    Daniel Brunier-Coulin
- * @copyright OPEN CASCADE 2012
- */
-
-import java.io.IOException;
-import java.io.File;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.hibernate.Session;
-import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
-import org.splat.manox.XDOM;
-import org.splat.manox.XMLException;
-import org.w3c.dom.Node;
-import org.apache.log4j.Logger;
-
-
-public class UserDirectory {
-       
-    final static Logger logger = Logger.getLogger(UserDirectory.class);
-
-//  ==============================================================================================================================
-//  Public services    
-//  ==============================================================================================================================
-
-       public static User createUser (User.Properties uprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException, RuntimeException {
-//  -----------------------------------------------------
-         User    nuser   = new User(uprop);
-      Session session = Database.getSession();
-      session.save(nuser);
-        
-      return nuser;
-       }
-
-    @SuppressWarnings("unchecked")                            // For the casting List<String>
-       public static Set<User> importUsers (File xfile) throws XMLException, MismatchException, RuntimeException {
-//  ------------------------------------------------
-         String[] name    = xfile.getName().split("\\x2E");   // Split by '.' (period) character
-         String   fext    = name[name.length-1];
-      Session  session = Database.getSession();
-      
-         if (!fext.equals("xml")) throw new MismatchException("filetype");
-         try {
-               DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
-               DocumentBuilder        dBuilder = dfactory.newDocumentBuilder();                                        
-               org.w3c.dom.Document   inDoc    = dBuilder.parse(xfile);
-               String                 xtag     = inDoc.getDocumentElement().getNodeName();
-       if (!xtag.equals("users")) throw new MismatchException("filetype");
-               org.w3c.dom.NodeList   ulist    = inDoc.getElementsByTagName("user");
-       
-        List<String>    result   = (List<String>)session.createSQLQuery("SELECT * FROM users").addScalar("username").list();
-       HashSet<String> members  = new HashSet<String>();
-       HashSet<User>   imported = new HashSet<User>();
-       for (Iterator<String> i=result.iterator(); i.hasNext();) members.add(i.next());
-       
-               for (int i=0; i<ulist.getLength(); i++) {
-                 HashMap<String, Node> row   = XDOM.getNamedChildNodes(ulist.item(i));
-                 User.Properties       uprop = new User.Properties();
-
-//        Mandatory properties
-                 String uname  = row.get("username").getTextContent();
-                 if (members.contains(uname)) continue;            // This user already exists
-                 uprop.setUsername(uname)
-                      .setFirstName(row.get("first").getTextContent())
-                      .setName(row.get("last").getTextContent())
-                      .setMailAddress(row.get("mail").getTextContent())
-                      .addRole(row.get("role").getTextContent());  // Add all roles at a time
-
-//        Optional properties
-                 org.w3c.dom.Node node = row.get("password");
-                 if (node != null) {
-                       uprop.setPassword(node.getTextContent());
-                 }
-                 node = row.get("display");
-                 if (node != null) {
-                       uprop.setDisplayName(node.getTextContent());
-                 }
-                 node = row.get("organization");
-                 if (node != null) {
-                       uprop.setOrganizationName(node.getTextContent());
-                 }
-//        Addition of the user
-                 uprop.disableCheck();                             // Existent user already checked above
-          User         newser = new User(uprop);
-                 session.save(newser);
-                 imported.add(newser);
-               }
-               return  imported;
-         }
-      catch (IOException error) {
-        throw new XMLException("XML users file not found");
-      }
-         catch (ParserConfigurationException e) {
-               throw new XMLException("XML Organization parser not accessible");
-         }
-         catch (Exception e) {
-               throw new XMLException("XML users file not valid");
-         }
-    }
-
-/**
- * Returns the manager of the given user.
- * This function is effective providing that users are defined according to the following conventions:
- * <ul>
- * <li>One user is assigned in the organization as Nx1 (n+1 manager of members of the organization)</li>
- * <li>Another user is assigned in the organization as Nx2 (n+2 manager of members of the organization)</li>
- * </ul>
- * If such users do not exit, null is returned.
- * 
- * @param user the user whose manager is get
- * @return the manager of the given user, if defined
- */
-    public static User getManagerOf (User user) {
-//  -------------------------------------------
-      User   result  = null;
-      String orgname = user.getOrganizationName();
-
-      if (orgname.equals("Nx2"))                    return result;
-      if (orgname.equals("Nx1")) orgname = "Nx2";
-      else {
-        if (user.getRoleNames().equals("customer")) return result;
-        orgname = "Nx1";
-      }
-      try {
-        User.Properties uprop = new User.Properties();
-        List<User>      ulist = UserDirectory.selectUsersWhere(uprop.setOrganizationName(orgname));
-        return ulist.get(0);     // n+1 and n+2 managers are unique
-      }
-      catch (Exception e) {
-        return null;
-      }
-    }
-
-       @SuppressWarnings("unchecked")                            // For the casting List<User>
-       public static List<User> selectAllUsers () {
-//  ------------------------------------------
-         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 User where username='").append(username).append("'");
-         return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
-       }
-
-       public static User selectUser (String username, String password) {
-//  ----------------------------------------------------------------
-//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 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("'");
-         
-         return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
-       }
-
-    public static User selectUser (int index) {
-//  -----------------------------------------
-      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 User");
-      String       separator = " where (";
-      String       value;
-
-      for (int i=0; i<uprop.length; i++) {
-
-        value = uprop[i].getOrganizationName();
-        if (value != null) {
-          query     = query.append(separator).append(" organid='").append(value).append("'");
-//        separator = " and";
-        }
-        separator = ") or (";
-      }
-      query.append(")");
-      return (List<User>)Database.getSession().createQuery(query.toString()).list();
-    }
-}
\ No newline at end of file
index 84078b42f9ef03218e825e4ac655388fcbcb7959..c4b2c3cd6cff2090c42029a006d07e3388a9acd0 100644 (file)
@@ -26,6 +26,7 @@ import org.splat.kernel.NotApplicableException;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.som.Revision;
 import org.splat.som.Step;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Document service interface.
@@ -35,6 +36,15 @@ import org.splat.som.Step;
  */
 public interface DocumentService {
 
+       /**
+        * Get document by its path.
+        * 
+        * @param path
+        *            the document path
+        * @return the document if found or null
+        */
+       public Document getDocumentByPath(String path);
+
        /**
         * Defines this document.
         * 
@@ -203,7 +213,7 @@ public interface DocumentService {
         */
        public void rename(Document aDoc, String title)
                        throws InvalidPropertyException;
-       
+
        /**
         * Update a version of the given document.
         * 
@@ -213,7 +223,7 @@ public interface DocumentService {
         *            the new version
         */
        public void updateAs(Document aDoc, Revision newvers);
-       
+
        /**
         * Update a state of the given document.
         * 
index df410aa36a93ec9ad76d9e850cf3c87d00402e6d..508ebfc23dcae0edde0e8c0827e8b4de0b31dcf6 100644 (file)
@@ -15,7 +15,6 @@ import java.util.Calendar;
 import java.util.Iterator;
 import java.util.List;
 
-import org.hibernate.Hibernate;
 import org.hibernate.criterion.Criterion;
 import org.hibernate.criterion.Restrictions;
 import org.splat.dal.bo.kernel.Relation;
@@ -37,7 +36,6 @@ import org.splat.dal.dao.som.DocumentTypeDAO;
 import org.splat.dal.dao.som.FileDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
-import org.splat.kernel.MultiplyDefinedException;
 import org.splat.kernel.NotApplicableException;
 import org.splat.manox.Reader;
 import org.splat.manox.Toolbox;
@@ -121,8 +119,8 @@ public class DocumentServiceImpl implements DocumentService {
                String path = owner.getReference();
                ProjectSettingsService.Step step = ProjectSettingsServiceImpl
                                .getStep(aDoc.getStep());
-               aDoc.setDid(new StringBuffer(path).append(".%").append(
-                               Document.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
@@ -149,11 +147,11 @@ public class DocumentServiceImpl implements DocumentService {
                int number = getStudyService().generateLocalIndex(scope);
 
                if (scheme == FileNaming.encoded) {
-                       encoding.append(scope.getReference()).append(".").append(
-                                       tostring.format(number));
+                       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();
        }
@@ -199,8 +197,12 @@ public class DocumentServiceImpl implements DocumentService {
                // }
                aDoc.setTitle(dprop.getName());
                aDoc.getFile().changePath(
-                               aDoc.getFile().getRelativePath().replace("%n",
-                                               getEncodedRootName(aDoc, (Study) dprop.getOwner())));
+                               aDoc.getFile()
+                                               .getRelativePath()
+                                               .replace(
+                                                               "%n",
+                                                               getEncodedRootName(aDoc,
+                                                                               (Study) dprop.getOwner())));
                if (aDoc.getHistory() == -1)
                        aDoc.setHistory(0);
                if (dprop.getDate() == null) {
@@ -568,6 +570,23 @@ public class DocumentServiceImpl implements DocumentService {
                return (aType.isResultOf(lastep));
        }
 
+       /**
+        * Get document by its path.
+        * @param path the document path
+        * @return the document if found or null
+        */
+       @Transactional(readOnly=true)
+       public Document getDocumentByPath(String path) {
+               String[] parse = path.split("'");
+
+               path = parse[0];
+               for (int i = 1; i < parse.length; i++) {
+                       path = path + "''" + parse[i];
+               }
+               Criterion aCondition = Restrictions.eq("path", path);
+               return getDocumentDAO().findByCriteria(aCondition);
+       }
+
        /**
         * Get the studyService.
         * 
index 3875736ea141de8c1a9b0d5855e7e8f7b5be0339..1033ece911fb483cccb8f723ab4f6d8653b6575d 100644 (file)
@@ -19,7 +19,7 @@ import org.splat.service.technical.ProjectSettingsService;
 
 /**
  * Document type service interface.
- *
+ * 
  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 public interface DocumentTypeService {
@@ -81,4 +81,13 @@ public interface DocumentTypeService {
         * @return the list of found document types
         */
        public List<DocumentType> selectTypesOf(ProjectSettingsService.Step step);
+
+       /**
+        * Approve the document type.
+        * 
+        * @param aType
+        *            the document type to approve
+        * @return true if approval succeeded
+        */
+       public boolean approve(DocumentType aType);
 }
index 63fecb5b6236687d0585a6eabae003b7b2fa6dc0..874bcb3e8af2b1d7c216915b186715b71e52dea4 100644 (file)
@@ -16,6 +16,8 @@ import org.hibernate.Hibernate;
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Restrictions;
 import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.dao.som.Database;
 import org.splat.dal.dao.som.DocumentTypeDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
@@ -40,7 +42,8 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * 
         * @return the list of all document types
         */
-       @Transactional(readOnly = true)
+//     @Transactional(readOnly = true)
+       @Transactional
        public List<DocumentType> selectAllTypes() {
                List<DocumentType> types = getDocumentTypeDAO().getAll();
                for (Iterator<DocumentType> i = types.iterator(); i.hasNext();) {
@@ -128,6 +131,19 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
                return types;
        }
 
+       /**
+        * Approve the document type.
+        * @param aType the document type to approve
+        * @return true if approval succeeded
+        */
+       @Transactional
+    public boolean approve (DocumentType aType) {
+      if  (aType.getState() != ProgressState.inCHECK) return false;      
+      aType.setState(ProgressState.APPROVED);        // The type name is supposed being localized
+      getDocumentTypeDAO().update(aType);
+         return true;
+    }
+
        /**
         * Get the documentTypeDAO.
         * 
index e17cb9751b2a7962ad1dccd0ff7b74a3dc0a5161..3bc8ca7940188585fa8b9815dfc210ee8522eff6 100644 (file)
@@ -64,4 +64,23 @@ public interface KnowledgeElementTypeService {
         * @return the found knowledge type
         */
        public KnowledgeElementType selectType(long index);
+
+       /**
+        * Approve the knowledge type.
+        * 
+        * @param kelt
+        *            the knowledge type to approve
+        * @return true if approval succeeded
+        */
+       public boolean approve(KnowledgeElementType kelt);
+
+       /**
+        * Reserves this type for the management of simulation contexts. For being able to get the studies in which simulation contexts are
+        * used, all study scenarios are indexed through this knowledge element type, whether they include knowledge elements or not.
+        * 
+        * @param kelt
+        *            the knowledge type to approve
+        * @return true if approval succeeded
+        */
+       public boolean reserve(KnowledgeElementType kelt);
 }
index a5dd084e996c5ec73a0876d389cd1b97eede91d5..f644d141dc7720a49a5c83230ab3ae2bbd5c2f66 100644 (file)
@@ -8,7 +8,7 @@
  * @copyright      OPEN CASCADE 2012
  *****************************************************************************/
 
-package org.splat.service; 
+package org.splat.service;
 
 import java.util.List;
 
@@ -17,10 +17,11 @@ import org.hibernate.criterion.Restrictions;
 import org.splat.dal.bo.som.KnowledgeElementType;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.dao.som.KnowledgeElementTypeDAO;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * KnowledgeElementTypeService implementation for working with knowledge types.
- *
+ * 
  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 public class KnowledgeElementTypeServiceImpl implements
@@ -89,6 +90,43 @@ public class KnowledgeElementTypeServiceImpl implements
                return getKnowledgeElementTypeDAO().get(index);
        }
 
+       /**
+        * Approve the knowledge type.
+        * 
+        * @param kelt
+        *            the knowledge type to approve
+        * @return true if approval succeeded
+        */
+       @Transactional
+       public boolean approve(KnowledgeElementType kelt) {
+               if (kelt.getState() != ProgressState.inCHECK)
+                       return false;
+               kelt.setState(ProgressState.APPROVED); // The type name is supposed being localized
+               if (kelt.isSaved()) {
+                       getKnowledgeElementTypeDAO().update(kelt);
+               }
+               return true;
+       }
+
+       /**
+        * Reserves this type for the management of simulation contexts. For being able to get the studies in which simulation contexts are
+        * used, all study scenarios are indexed through this knowledge element type, whether they include knowledge elements or not.
+        * 
+        * @param kelt
+        *            the knowledge type to approve
+        * @return true if approval succeeded
+        */
+       @Transactional
+       public boolean reserve(KnowledgeElementType kelt) {
+               if (kelt.getState() != ProgressState.inCHECK)
+                       return false;
+               kelt.setState(ProgressState.inWORK);
+               if (kelt.isSaved()) {
+                       getKnowledgeElementTypeDAO().update(kelt);
+               }
+               return true;
+       }
+
        /**
         * Get the knowledgeElementTypeDAO.
         * 
index 186a04847f6e5a73ecc6892bbd600a25d83d92bd..b686dec13cf64de4c4d2204e2bb4f32888f9d2e7 100644 (file)
@@ -11,9 +11,11 @@ package org.splat.service;
 
 import org.splat.dal.bo.som.ProjectElement;
 import org.splat.som.Step;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Project element service interface.
+ * 
  * @author RKV
  * 
  */
@@ -21,15 +23,29 @@ public interface ProjectElementService {
 
        /**
         * Get the first activity of the project element.
-        * @param elem a study or a scenario 
+        * 
+        * @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
+        * 
+        * @param elem
+        *            a study or a scenario
         * @return array of activities (steps).
         */
        public Step[] getSteps(ProjectElement elem);
+
+       /**
+        * Refreshes the internal data potentially out-of-date. This function needs to be called when Publication objects are added to this
+        * Project Element before being saved. The reason is, as saving a persistent object changes its hashcode, hashed data need to be rebuilt
+        * after saving for making functions based on this hashcode such as remove(), working.
+        * 
+        * @param elem
+        *            the project element to refresh
+        */
+       public void refresh(ProjectElement elem);
 }
index 84fc9df07753b7b7734a2f350cb868401403ccdb..7e7537617365fe1214b3ee0239384dba073269fc 100644 (file)
@@ -13,11 +13,16 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.splat.dal.bo.som.ProjectElement;
+import org.splat.dal.bo.som.Publication;
+import org.splat.dal.dao.som.Database;
+import org.splat.dal.dao.som.ProjectElementDAO;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.som.Step;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Project element service implementation.
+ * 
  * @author RKV
  * 
  */
@@ -27,9 +32,14 @@ public class ProjectElementServiceImpl implements ProjectElementService {
         * Injected project settings service.
         */
        private ProjectSettingsService _projectSettingsService;
+       /**
+        * Injected project element DAO.
+        */
+       private ProjectElementDAO _projectElementDAO;
 
-       /** 
+       /**
         * {@inheritDoc}
+        * 
         * @see org.splat.service.ProjectElementService#getFirstStep(org.splat.dal.bo.som.ProjectElement)
         */
        public Step getFirstStep(ProjectElement elem) {
@@ -41,8 +51,9 @@ public class ProjectElementServiceImpl implements ProjectElementService {
                return mystep[mystep.length - 1];
        }
 
-       /** 
+       /**
         * {@inheritDoc}
+        * 
         * @see org.splat.service.ProjectElementService#getSteps(org.splat.dal.bo.som.ProjectElement)
         */
        public Step[] getSteps(ProjectElement elem) {
@@ -59,6 +70,26 @@ public class ProjectElementServiceImpl implements ProjectElementService {
                return elem.getFolders(); // No protection against this object corruption as it would not corrupt the database
        }
 
+       /**
+        * Refreshes the internal data potentially out-of-date. This function needs to be called when Publication objects are added to this
+        * Project Element before being saved. The reason is, as saving a persistent object changes its hashcode, hashed data need to be rebuilt
+        * after saving for making functions based on this hashcode such as remove(), working.
+        * @param elem the project element to refresh
+        */
+       @Transactional
+       public void refresh(ProjectElement elem) {
+               // -------------------------
+               Publication[] curdoc = elem.getDocums().toArray(
+                               new Publication[elem.getDocums().size()]);
+
+               elem.setFolders(null); // Just in case
+               elem.getDocums().clear();
+               for (int i = 0; i < curdoc.length; i++)
+                       elem.getDocums().add(curdoc[i]);
+               // No need to rebuild the list of SimulationContext as it does not use hashcodes
+               getProjectElementDAO().update(elem);
+       }
+
        /**
         * Get project settings.
         * 
@@ -77,4 +108,20 @@ public class ProjectElementServiceImpl implements ProjectElementService {
        public void setProjectSettings(ProjectSettingsService projectSettingsService) {
                _projectSettingsService = projectSettingsService;
        }
+
+       /**
+        * Get the projectElementDAO.
+        * @return the projectElementDAO
+        */
+       public ProjectElementDAO getProjectElementDAO() {
+               return _projectElementDAO;
+       }
+
+       /**
+        * Set the projectElementDAO.
+        * @param projectElementDAO the projectElementDAO to set
+        */
+       public void setProjectElementDAO(ProjectElementDAO projectElementDAO) {
+               _projectElementDAO = projectElementDAO;
+       }
 }
index 39d8b8eebd74aa227e5737ae7bd4d05f1c87f158..192dc66a66e9f558f5f6c751184865fd51539e04 100644 (file)
@@ -54,9 +54,10 @@ public interface 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.
+        * 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
@@ -71,10 +72,11 @@ 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
-        * way this demotion is propagated to the study supposes that the study has only ONE final result document.
+        * 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
@@ -87,7 +89,9 @@ 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
@@ -102,10 +106,13 @@ 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
-        * propagated to the study supposes that the study has only ONE final result document.
+        * 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
@@ -121,9 +128,11 @@ 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
@@ -156,11 +165,11 @@ 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
@@ -212,4 +221,27 @@ public interface PublicationService {
         */
        public ConvertsRelation attach(Publication aPublication, String format,
                        String description);
+
+       /**
+        * Undo the out-date operation.
+        * 
+        * @param aPublication
+        *            the publication
+        * @return true if the acceptance succeeds
+        * @see #outdate()
+        * @see DocumentRights#canAccept()
+        */
+       public boolean actualize(Publication aPublication);
+
+       /**
+        * Out-dates this publication and recursively all publications using this one. Typically, a publication is out-dated when modifying a
+        * document to which it depends.
+        * 
+        * @param aPublication
+        *            the publication
+        * @see #isOutdated()
+        * @see #getProgressState()
+        * @see #actualize()
+        */
+       public void outdate(Publication aPublication);
 }
index 1516ba4305010b555607115c84c8c5c4006cf76c..e5a6634855878a2646d3aa8bf72b22320dab9763 100644 (file)
@@ -26,14 +26,17 @@ 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.Timestamp;
+import org.splat.dal.bo.som.UsedByRelation;
 import org.splat.dal.bo.som.ValidationCycle;
 import org.splat.dal.bo.som.ValidationStep;
+import org.splat.dal.dao.som.Database;
 import org.splat.dal.dao.som.ProjectElementDAO;
 import org.splat.dal.dao.som.PublicationDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.NotApplicableException;
 import org.splat.manox.Reader;
 import org.splat.manox.Toolbox;
+import org.splat.som.DocumentRights;
 import org.splat.som.Revision;
 import org.splat.som.Step;
 import org.springframework.transaction.annotation.Transactional;
@@ -107,8 +110,8 @@ public class PublicationServiceImpl implements PublicationService {
                ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
                                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 (!getDocumentService().promote(aPublication.value(), stamp))
                        return null;
                if (getDocumentService().isStudyResult(type)
@@ -218,8 +221,8 @@ public class PublicationServiceImpl implements PublicationService {
                ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
                                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 (!getDocumentService().promote(aPublication.value(), stamp))
                        return null;
                if (getDocumentService().isStudyResult(type)
@@ -332,7 +335,7 @@ public class PublicationServiceImpl implements PublicationService {
                        return; // No properties extractor available for this type of document
 
                SimulationContextType.Properties sprop = new SimulationContextType.Properties()
-                               .setStep(to.getStep()).setState(ProgressState.APPROVED);
+                               .setStep(to.getStep()).setProgressState(ProgressState.APPROVED);
                List<SimulationContextType> contype = getSimulationContextService()
                                .selectTypesWhere(sprop);
                if (contype.isEmpty())
@@ -393,6 +396,46 @@ public class PublicationServiceImpl implements PublicationService {
                return aPublication.getStep();
        }
 
+       /**
+        * Undo the out-date operation.
+        * 
+        * @param aPublication
+        *            the publication
+        * @return true if the acceptance succeeds
+        * @see #outdate()
+        * @see DocumentRights#canAccept()
+        */
+       public boolean actualize(Publication aPublication) {
+               if (!aPublication.isOutdated())
+                       return false;
+               aPublication.setIsnew('Y');
+               getPublicationDAO().update(aPublication);
+               return true;
+       }
+
+       /**
+        * Out-dates this publication and recursively all publications using this one. Typically, a publication is out-dated when modifying a
+        * document to which it depends.
+        * 
+        * @param aPublication
+        *            the publication
+        * @see #isOutdated()
+        * @see #getProgressState()
+        * @see #actualize()
+        */
+       public void outdate(Publication aPublication) {
+               if (aPublication.isOutdated())
+                       return;
+
+               List<Publication> relist = aPublication
+                               .getRelations(UsedByRelation.class);
+               for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
+                       outdate(i.next());
+               }
+               aPublication.setIsnew('O');
+               getPublicationDAO().update(aPublication);
+       }
+
        /**
         * Create "Converts" relation for the given document publication and format.
         * 
index 8c55cfbfcb0eecba95963dc7af2674c22eed69da..b5903e2b392da404ed07fe0ef13fd9fe3815b09d 100644 (file)
@@ -100,4 +100,16 @@ public interface ScenarioService {
         * @return true if the scenario is empty
         */
        public boolean isEmpty(Scenario scenario);
+
+       /**
+        * Remove a knowledge element from a scenario.
+        * 
+        * @param scenario
+        *            the scenario
+        * @param kelm
+        *            the knowledge element to remove
+        * @return true if removal succeeded
+        */
+       public boolean removeKnowledgeElement(Scenario scenario,
+                       KnowledgeElement kelm);
 }
index 10b5ba93b72c8982120a6cb7570b46b7990e1840..fb6629528bb9a5639f8ce93a36286d3e6133e5ef 100644 (file)
@@ -28,7 +28,6 @@ import org.splat.dal.dao.som.StudyDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
-import org.splat.kernel.UserDirectory;
 import org.splat.service.technical.IndexService;
 import org.splat.som.Step;
 import org.springframework.transaction.annotation.Transactional;
@@ -85,6 +84,11 @@ public class ScenarioServiceImpl implements ScenarioService {
         */
        private KnowledgeElementTypeService _knowledgeElementTypeService;
 
+       /**
+        * Injected user service.
+        */
+       private UserService _userService;
+
        /**
         * Get the projectElementService.
         * 
@@ -178,8 +182,9 @@ public class ScenarioServiceImpl implements ScenarioService {
                        update(aScenario);
 
                } catch (IOException error) {
-                       logger.error("Unable to index the knowedge element '"
-                                       + kelm.getIndex() + "', reason:", error);
+                       logger.error(
+                                       "Unable to index the knowedge element '" + kelm.getIndex()
+                                                       + "', reason:", error);
                        kelm = null;
                }
 
@@ -321,19 +326,50 @@ public class ScenarioServiceImpl implements ScenarioService {
                getScenarioDAO().create(scenario); // Must be done after updating this study because of the back reference to the study
                if (sprop.getBaseStep() != null) {
                        // No need to update the Knowledge Element index as Knowledge Elements are not copied
-                       scenario.refresh(); // Because saving the scenario changes the hashcode of copied Publications
+                       getProjectElementService().refresh(scenario); // Because saving the scenario changes the hashcode of copied Publications
                }
-               KnowledgeElementType ucase = getKnowledgeElementTypeService().selectType(
-                               "usecase");
+               KnowledgeElementType ucase = getKnowledgeElementTypeService()
+                               .selectType("usecase");
                KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
-               User admin = UserDirectory.selectUser(1); // First user created when creating the database
-               kprop.setType(ucase).setTitle(aStudy.getTitle()).setValue(
-                               scenario.getTitle()).setAuthor(admin); // Internal Knowledge Element required by the validation process of
+               User admin = getUserService().selectUser(1); // First user created when creating the database
+               kprop.setType(ucase).setTitle(aStudy.getTitle())
+                               .setValue(scenario.getTitle()).setAuthor(admin); // Internal Knowledge Element required by the validation process of
                // knowledges
                addKnowledgeElement(scenario, kprop);
                return scenario;
        }
 
+       /**
+        * Remove a knowledge element from a scenario.
+        * 
+        * @param scenario
+        *            the scenario
+        * @param kelm
+        *            the knowledge element to remove
+        * @return true if removal succeeded
+        */
+       public boolean removeKnowledgeElement(Scenario scenario,
+                       KnowledgeElement kelm) {
+               // -------------------------------------------------------------
+               KnowledgeElement torem = scenario.getKnowledgeElement(kelm.getIndex());
+               if (torem == null)
+                       return false;
+               boolean done = scenario.getKnowledgeElements().remove(torem);
+               if (done) {
+                       // Update of my transient data
+                       List<KnowledgeElement> kelms = scenario.getKnowledgeByType().get(
+                                       kelm.getType().getIndex());
+                       kelms.remove(torem);
+                       if (scenario.getKnowledgeElementsList() != null)
+                               scenario.getKnowledgeElementsList().remove(torem);
+                       getScenarioDAO().update(scenario);
+                       // TODO: If the owner study is not private, remove the knowledge from the Lucene index
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
        /**
         * Get the knowledgeElementDAO.
         * 
@@ -432,6 +468,7 @@ public class ScenarioServiceImpl implements ScenarioService {
 
        /**
         * Get the studyService.
+        * 
         * @return the studyService
         */
        public StudyService getStudyService() {
@@ -440,10 +477,28 @@ public class ScenarioServiceImpl implements ScenarioService {
 
        /**
         * Set the studyService.
-        * @param studyService the studyService to set
+        * 
+        * @param studyService
+        *            the studyService to set
         */
        public void setStudyService(StudyService studyService) {
                _studyService = studyService;
        }
 
+       /**
+        * Get the userService.
+        * @return the userService
+        */
+       public UserService getUserService() {
+               return _userService;
+       }
+
+       /**
+        * Set the userService.
+        * @param userService the userService to set
+        */
+       public void setUserService(UserService userService) {
+               _userService = userService;
+       }
+
 }
index 51c62147d8721d517ce17f7a5364c8d2496a5d69..e1b91331a8ca3080d8f2966fc0ce83afd38012b5 100644 (file)
@@ -8,18 +8,42 @@
  * @copyright      OPEN CASCADE 2012
  *****************************************************************************/
 
-package org.splat.service; 
+package org.splat.service;
 
 /**
  * The service locator interface.
- *
+ * 
  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 @Deprecated
 public interface ServiceLocator {
        /**
         * Get study service.
+        * 
         * @return study service
         */
        StudyService getStudyService();
+
+       /**
+        * Set the studyService.
+        * 
+        * @param studyService
+        *            the studyService to set
+        */
+       public void setStudyService(StudyService studyService);
+
+       /**
+        * Get the userService.
+        * 
+        * @return the userService
+        */
+       public UserService getUserService();
+
+       /**
+        * Set the userService.
+        * 
+        * @param userService
+        *            the userService to set
+        */
+       public void setUserService(UserService userService);
 }
index 6f99f6af4fb59ed36a50d138c044e3ea1e84e166..5810b0ac0cdbc0ccb8af50f8acdaa2dd5499db63 100644 (file)
@@ -44,6 +44,10 @@ public class ServiceLocatorImpl implements ServiceLocator {
         * Injected study service.
         */
        private StudyService _studyService;
+       /**
+        * Injected user service.
+        */
+       private UserService _userService;
 
        /**
         * Get the studyService.
@@ -60,4 +64,20 @@ public class ServiceLocatorImpl implements ServiceLocator {
        public void setStudyService(StudyService studyService) {
                _studyService = studyService;
        }
+
+       /**
+        * Get the userService.
+        * @return the userService
+        */
+       public UserService getUserService() {
+               return _userService;
+       }
+
+       /**
+        * Set the userService.
+        * @param userService the userService to set
+        */
+       public void setUserService(UserService userService) {
+               _userService = userService;
+       }
 }
index dc9cc3425405eaa73b44d991ede287e0c8af0508..a15cc17eb8dba7f8d5867ad40d5dfd866a1dfd6e 100644 (file)
@@ -88,7 +88,9 @@ public interface SimulationContextService {
 
        /**
         * Get simulation context types by example.
-        * @param sprop the example
+        * 
+        * @param sprop
+        *            the example
         * @return list of found context types
         */
        public List<SimulationContextType> selectTypesWhere(
@@ -96,7 +98,9 @@ public interface SimulationContextService {
 
        /**
         * Get a simulation context type by its name.
-        * @param name name of the context type
+        * 
+        * @param name
+        *            name of the context type
         * @return found context type
         */
        public SimulationContextType selectType(String name);
@@ -133,4 +137,19 @@ public interface SimulationContextService {
         */
        List<SimulationContext> getSimulationContextList();
 
+       /**
+        * Approve the simulation context type.
+        * 
+        * @param simCtxType
+        *            the type to approve
+        * @return true if approval succeeded
+        */
+       public boolean approve(SimulationContextType simCtxType);
+
+       /**
+        * @param simCtxType
+        * @return
+        */
+       public ProjectSettingsService.Step getAttachedStep(
+                       SimulationContextType simCtxType);
 }
index 81abc66eb2f1cfac6554bd8954bba5b5ef32aad0..0b31930a084eb1a5c105a15f5a75057336e5352a 100644 (file)
@@ -17,12 +17,12 @@ 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.splat.service.technical.ProjectSettingsServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -108,8 +108,8 @@ public class SimulationContextServiceImpl implements SimulationContextService {
                        // .append("'");
                        // separator = " and";
 
-                       aCondition = Restrictions.and(aCondition, Restrictions.eq("value",
-                                       value));
+                       aCondition = Restrictions.and(aCondition,
+                                       Restrictions.eq("value", value));
                }
                if (state != null) {
                        // query = query.append(separator).append(" state='").append(state)
@@ -118,8 +118,8 @@ public class SimulationContextServiceImpl implements SimulationContextService {
                                // order = " order by type asc";
                                anOrder = Order.asc("type");
                        }
-                       aCondition = Restrictions.and(aCondition, Restrictions.eq("state",
-                                       state));
+                       aCondition = Restrictions.and(aCondition,
+                                       Restrictions.eq("state", state));
                }
                // query.append(order);
                // return (List<SimulationContext>) Database.getSession().createQuery(
@@ -161,12 +161,10 @@ public class SimulationContextServiceImpl implements SimulationContextService {
         * 
         * @see org.splat.service.SimulationContextService#selectAllTypes()
         */
-       @SuppressWarnings("unchecked")
        public List<SimulationContextType> selectAllTypes() {
                // Useless to order by names as the result mixes localized
                // and non localized types
-               return getSimulationContextTypeDAO().getFilteredList(null,
-                               Order.asc("step"));
+               return getSimulationContextTypeDAO().getAll(Order.asc("step"));
        }
 
        /**
@@ -174,19 +172,23 @@ public class SimulationContextServiceImpl implements SimulationContextService {
         * 
         * @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("'");
+               // 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");
+               Criterion aCondition = Restrictions.eq("step", step[0].getNumber());
                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("'");
+                       aCondition = Restrictions.or(aCondition,
+                                       Restrictions.eq("step", step[i].getNumber()));
                }
-               query = query.append(" order by step asc");
-               return Database.getSession().createQuery(query.toString()).list();
+               return getSimulationContextTypeDAO().getFilteredList(aCondition,
+                               Order.asc("step"));
        }
 
        /**
@@ -194,34 +196,51 @@ public class SimulationContextServiceImpl implements SimulationContextService {
         * 
         * @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";
+               // StringBuffer query = new StringBuffer("from SimulationContextType");
+               // String separator = " where";
                ProjectSettingsService.Step step = sprop.getStep();
                ProgressState state = sprop.getProgressState();
-               String order = " order by step asc";
-
+               // 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);
+               Criterion aCondition = null;
+               Order anOrder = Order.asc("step");
                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)
+                       aCondition = Restrictions.eq("step", step.getNumber());
+                       anOrder = Order.desc("state"); // 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";
+                       aCondition = Restrictions.and(aCondition,
+                                       Restrictions.eq("state", state));
                        if (step != null) {
-                               if (state != ProgressState.APPROVED)
-                                       order = " order by name asc";
-                               else
-                                       order = ""; // Approved types are localized
+                               if (state != ProgressState.APPROVED) {
+                                       anOrder = Order.asc("name");
+                               } else {
+                                       anOrder = null; // Approved types are localized
+                               }
                        }
                }
-               query = query.append(order);
-               return Database.getSession().createQuery(query.toString()).list();
+               return getSimulationContextTypeDAO().getFilteredList(aCondition,
+                               anOrder);
        }
 
        /**
@@ -268,6 +287,47 @@ public class SimulationContextServiceImpl implements SimulationContextService {
                }
        }
 
+       /**
+        * Approve the simulation context.
+        * 
+        * @param simCtx
+        *            the context to approve
+        * @return true if approval succeeded
+        */
+       public boolean approve(SimulationContext simCtx) {
+               if (simCtx.getProgressState() != ProgressState.inCHECK)
+                       return false;
+               simCtx.setProgressState(ProgressState.APPROVED); // The type name is supposed being localized
+               if (simCtx.isSaved()) {
+                       getSimulationContextDAO().update(simCtx);
+               }
+               return true;
+       }
+
+       /**
+        * Approve the simulation context type.
+        * 
+        * @param simCtxType
+        *            the type to approve
+        * @return true if approval succeeded
+        */
+       public boolean approve(SimulationContextType simCtxType) {
+               if (simCtxType.getState() != ProgressState.inCHECK)
+                       return false;
+               simCtxType.setState(ProgressState.APPROVED); // The type name is supposed being localized
+               getSimulationContextTypeDAO().update(simCtxType);
+               return true;
+       }
+
+       /**
+        * @param simCtxType
+        * @return
+        */
+       public ProjectSettingsService.Step getAttachedStep(
+                       SimulationContextType simCtxType) {
+               return ProjectSettingsServiceImpl.getStep(simCtxType.getStep());
+       }
+
        /**
         * Get the simulationContextDAO.
         * 
index 5a0cbce2e6ae1031eab58576bd18e8347d8043dd..b9cd50e7269971c9be4d47152530775acdcccec9 100644 (file)
@@ -10,6 +10,8 @@
 package org.splat.service;
 
 import java.io.IOException;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Date;
@@ -46,7 +48,6 @@ import org.splat.dal.dao.som.ValidationCycleDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
-import org.splat.kernel.UserDirectory;
 import org.splat.log.AppLogger;
 import org.splat.service.technical.IndexService;
 import org.splat.service.technical.ProjectSettingsService;
@@ -113,6 +114,11 @@ public class StudyServiceImpl implements StudyService {
         */
        private DocumentTypeService _documentTypeService;
 
+       /**
+        * Injected user service.
+        */
+       private UserService _userService;
+
        /**
         * {@inheritDoc}
         * 
@@ -436,7 +442,7 @@ public class StudyServiceImpl implements StudyService {
                boolean isOk = false;
                try {
                        getStudyDAO().update(aStudy); // Update of relational base
-                       setShortCuts(aStudy); //RKV: initialize transient actors set
+                       setShortCuts(aStudy); // RKV: initialize transient actors set
                        getIndex().update(aStudy); // Update of Lucene index
                        isOk = true;
                } catch (Exception error) {
@@ -461,10 +467,77 @@ public class StudyServiceImpl implements StudyService {
                        tool = new IDBuilder(aStudy.getDate());
                        getIDBuilderDAO().create(tool);
                }
-               aStudy.setReference(tool.buildReference(pattern, aStudy));
+               aStudy.setReference(buildReference(tool, pattern, aStudy));
                return true;
        }
 
+       /**
+        * Build reference for the study. The reference of the study is stored as a new reference pattern (IDBuilder).
+        * 
+        * @param aBuilder
+        *            the id builder
+        * @param study
+        *            the study
+        * @param pattern
+        *            the reference pattern
+        * @return true if reference building is succeded
+        */
+       @Transactional
+       public String buildReference(IDBuilder aBuilder, String pattern, Study study) {
+               char[] format = pattern.toCharArray();
+               char[] ref = new char[80]; // Better evaluate the length of the generated string
+               int next = aBuilder.getBase() + 1;
+
+               int count = 0;
+               for (int i = 0; i < format.length; i++) {
+
+                       // Insertion of attribute values
+                       if (format[i] == '%') {
+                               i += 1;
+
+                               if (format[i] == 'y') { // Insertion of year in format 2 (e.g. 09) or 4 (e.g. 2009) digits
+                                       int n = i;
+                                       while (format[i] == 'y') {
+                                               i += 1;
+                                               if (i == format.length)
+                                                       break;
+                                       }
+                                       SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
+                                       String year = tostring.format(study.getDate());
+                                       year = year.substring(4 - (i - n), 4); // 4-(i-n) must be equal to either 0 or 2
+                                       for (int j = 0; j < year.length(); j++) {
+                                               ref[count] = year.charAt(j);
+                                               count += 1;
+                                       }
+                                       i -= 1; // Back to the last 'y' character
+                               } else if (format[i] == '0') { // Insertion of the index
+                                       int n = i;
+                                       while (format[i] == '0') {
+                                               i += 1;
+                                               if (i == format.length)
+                                                       break;
+                                       }
+                                       DecimalFormat tostring = new DecimalFormat(
+                                                       pattern.substring(n, i));
+                                       String number = tostring.format(next);
+                                       for (int j = 0; j < number.length(); j++) {
+                                               ref[count] = number.charAt(j);
+                                               count += 1;
+                                       }
+                                       i -= 1; // Back to the last '0' character
+                               }
+                               // Keep the character
+                       } else {
+                               ref[count] = format[i];
+                               count += 1;
+                       }
+               }
+               // Incrementation of the number of study
+               aBuilder.setBase(next);
+               getIDBuilderDAO().update(aBuilder);
+               return String.copyValueOf(ref, 0, count);
+       }
+
        /**
         * Find an id builder by date.
         * 
@@ -576,13 +649,13 @@ public class StudyServiceImpl implements StudyService {
                                        if (actype[i] == Actor.manager) {
                                                actor = from.getAuthor();
                                        } else if (actype[i] == Actor.Nx1) {
-                                               List<User> manager = UserDirectory
+                                               List<User> manager = getUserService()
                                                                .selectUsersWhere(uprop
                                                                                .setOrganizationName("Nx1"));
                                                if (manager.size() == 1)
                                                        actor = manager.get(0);
                                        } else if (actype[i] == Actor.Nx2) {
-                                               List<User> manager = UserDirectory
+                                               List<User> manager = getUserService()
                                                                .selectUsersWhere(uprop
                                                                                .setOrganizationName("Nx2"));
                                                if (manager.size() == 1)
@@ -1030,4 +1103,20 @@ public class StudyServiceImpl implements StudyService {
        public void setDocumentTypeService(DocumentTypeService documentTypeService) {
                _documentTypeService = documentTypeService;
        }
+
+       /**
+        * Get the userService.
+        * @return the userService
+        */
+       public UserService getUserService() {
+               return _userService;
+       }
+
+       /**
+        * Set the userService.
+        * @param userService the userService to set
+        */
+       public void setUserService(UserService userService) {
+               _userService = userService;
+       }
 }
diff --git a/Workspace/Siman-Common/src/org/splat/service/UserService.java b/Workspace/Siman-Common/src/org/splat/service/UserService.java
new file mode 100644 (file)
index 0000000..b170020
--- /dev/null
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   21.10.2012
+ * @author         $Author$
+ * @version        $Revision$
+ * @copyright      OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service;
+
+import java.io.File;
+import java.util.List;
+import java.util.Set;
+
+import org.splat.dal.bo.kernel.User;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MismatchException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
+import org.splat.manox.XMLException;
+
+/**
+ * User service interface.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public interface UserService {
+
+       public User createUser(User.Properties uprop)
+                       throws MissedPropertyException, InvalidPropertyException,
+                       MultiplyDefinedException;
+
+       public Set<User> importUsers(File xfile) throws XMLException,
+                       MismatchException;
+
+       /**
+        * Returns the manager of the given user. This function is effective providing that users are defined according to the following
+        * conventions:
+        * <ul>
+        * <li>One user is assigned in the organization as Nx1 (n+1 manager of members of the organization)</li>
+        * <li>Another user is assigned in the organization as Nx2 (n+2 manager of members of the organization)</li>
+        * </ul>
+        * If such users do not exit, null is returned.
+        * 
+        * @param user
+        *            the user whose manager is get
+        * @return the manager of the given user, if defined
+        */
+       public User getManagerOf(User user);
+
+       public List<User> selectAllUsers();
+
+       public User selectUser(String username);
+
+       public User selectUser(String username, String password);
+
+       public User selectUser(long index);
+
+       public List<User> selectUsersWhere(User.Properties... uprop);
+}
diff --git a/Workspace/Siman-Common/src/org/splat/service/UserServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/UserServiceImpl.java
new file mode 100644 (file)
index 0000000..f19dea8
--- /dev/null
@@ -0,0 +1,266 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   21.10.2012
+ * @author         $Author$
+ * @version        $Revision$
+ * @copyright      OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.dao.kernel.UserDAO;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MismatchException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
+import org.splat.manox.XDOM;
+import org.splat.manox.XMLException;
+import org.springframework.transaction.annotation.Transactional;
+import org.w3c.dom.Node;
+
+/**
+ * User service implementation.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class UserServiceImpl implements UserService {
+
+       /**
+        * The service logger.
+        */
+       final static Logger logger = Logger.getLogger(UserServiceImpl.class);
+
+       /**
+        * Injected user DAO.
+        */
+       private UserDAO _userDAO;
+
+       // ==============================================================================================================================
+       // Public services
+       // ==============================================================================================================================
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.UserService#createUser(org.splat.dal.bo.kernel.User.Properties)
+        */
+       @Transactional
+       public User createUser(User.Properties uprop)
+                       throws MissedPropertyException, InvalidPropertyException,
+                       MultiplyDefinedException, RuntimeException {
+               User nuser = new User(uprop);
+               getUserDAO().create(nuser);
+               return nuser;
+       }
+
+       // For the casting List<String>
+       @Transactional
+       public Set<User> importUsers(File xfile) throws XMLException,
+                       MismatchException {
+               String[] name = xfile.getName().split("\\x2E"); // Split by '.' (period) character
+               String fext = name[name.length - 1];
+
+               if (!fext.equals("xml"))
+                       throw new MismatchException("filetype");
+               try {
+                       DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory
+                                       .newInstance();
+                       DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
+                       org.w3c.dom.Document inDoc = dBuilder.parse(xfile);
+                       String xtag = inDoc.getDocumentElement().getNodeName();
+                       if (!xtag.equals("users"))
+                               throw new MismatchException("filetype");
+                       org.w3c.dom.NodeList ulist = inDoc.getElementsByTagName("user");
+
+                       // List<String> result = (List<String>) session
+                       // .createSQLQuery("SELECT * FROM users")
+                       // .addScalar("username").list();
+                       List<User> users = getUserDAO().getAll();
+                       HashSet<String> members = new HashSet<String>();
+                       HashSet<User> imported = new HashSet<User>();
+                       for (Iterator<User> i = users.iterator(); i.hasNext();)
+                               members.add(i.next().getUsername());
+
+                       for (int i = 0; i < ulist.getLength(); i++) {
+                               HashMap<String, Node> row = XDOM.getNamedChildNodes(ulist
+                                               .item(i));
+                               User.Properties uprop = new User.Properties();
+
+                               // Mandatory properties
+                               String uname = row.get("username").getTextContent();
+                               if (members.contains(uname))
+                                       continue; // This user already exists
+                               uprop.setUsername(uname)
+                                               .setFirstName(row.get("first").getTextContent())
+                                               .setName(row.get("last").getTextContent())
+                                               .setMailAddress(row.get("mail").getTextContent())
+                                               .addRole(row.get("role").getTextContent()); // Add all roles at a time
+
+                               // Optional properties
+                               org.w3c.dom.Node node = row.get("password");
+                               if (node != null) {
+                                       uprop.setPassword(node.getTextContent());
+                               }
+                               node = row.get("display");
+                               if (node != null) {
+                                       uprop.setDisplayName(node.getTextContent());
+                               }
+                               node = row.get("organization");
+                               if (node != null) {
+                                       uprop.setOrganizationName(node.getTextContent());
+                               }
+                               // Addition of the user
+                               uprop.disableCheck(); // Existent user already checked above
+                               User newser = new User(uprop);
+                               getUserDAO().create(newser);
+                               imported.add(newser);
+                       }
+                       return imported;
+               } catch (IOException error) {
+                       throw new XMLException("XML users file not found");
+               } catch (ParserConfigurationException e) {
+                       throw new XMLException("XML Organization parser not accessible");
+               } catch (Exception e) {
+                       throw new XMLException("XML users file not valid");
+               }
+       }
+
+       /**
+        * Returns the manager of the given user. This function is effective providing that users are defined according to the following
+        * conventions:
+        * <ul>
+        * <li>One user is assigned in the organization as Nx1 (n+1 manager of members of the organization)</li>
+        * <li>Another user is assigned in the organization as Nx2 (n+2 manager of members of the organization)</li>
+        * </ul>
+        * If such users do not exit, null is returned.
+        * 
+        * @param user
+        *            the user whose manager is get
+        * @return the manager of the given user, if defined
+        */
+       public User getManagerOf(User user) {
+               User result = null;
+               String orgname = user.getOrganizationName();
+
+               if (orgname.equals("Nx2"))
+                       return result;
+               if (orgname.equals("Nx1"))
+                       orgname = "Nx2";
+               else {
+                       if (user.getRoleNames().equals("customer"))
+                               return result;
+                       orgname = "Nx1";
+               }
+               try {
+                       User.Properties uprop = new User.Properties();
+                       List<User> ulist = selectUsersWhere(uprop
+                                       .setOrganizationName(orgname));
+                       return ulist.get(0); // n+1 and n+2 managers are unique
+               } catch (Exception e) {
+                       return null;
+               }
+       }
+
+       @Transactional(readOnly = true)
+       public List<User> selectAllUsers() {
+               // String query = "FROM User order by last asc, first asc";
+               return getUserDAO().getAll(Order.asc("last"), Order.asc("first"));
+       }
+
+       @Transactional(readOnly = true)
+       public User selectUser(String username) {
+               return getUserDAO().findByCriteria(
+                               Restrictions.eq("username", username));
+       }
+
+       public User selectUser(String username, String password) {
+               // WARNING: For not encoding the password here, we better call a selectUsersWhere(User.Properties),
+               // but this requires a getPassword in User.Properties nested class.
+               Criterion aCondition = Restrictions.eq("username", username);
+               if (password == null) {
+                       aCondition = Restrictions.and(aCondition,
+                                       Restrictions.isNull("password"));
+               } else {
+                       aCondition = Restrictions.and(
+                                       aCondition,
+                                       Restrictions.eq("password",
+                                                       String.valueOf(password.hashCode())));
+               }
+               return getUserDAO().findByCriteria(aCondition);
+       }
+
+       @Transactional(readOnly = true)
+       public User selectUser(long index) {
+               return getUserDAO().get(index);
+       }
+
+       @SuppressWarnings("unchecked")
+       public List<User> selectUsersWhere(User.Properties... uprop) {
+//             StringBuffer query = new StringBuffer("FROM User");
+//             String separator = " where (";
+//             String value;
+//
+//             for (int i = 0; i < uprop.length; i++) {
+//
+//                     value = uprop[i].getOrganizationName();
+//                     if (value != null) {
+//                             query = query.append(separator).append(" organid='")
+//                                             .append(value).append("'");
+//                             // separator = " and";
+//                     }
+//                     separator = ") or (";
+//             }
+//             query.append(")");
+               Criterion aCondition = null;
+               String value;
+               for (int i = 0; i < uprop.length; i++) {
+                       value = uprop[i].getOrganizationName();
+                       if (value != null) {
+                               if (aCondition == null) {
+                                       aCondition = Restrictions.eq("organid", value);
+                               } else {
+                                       aCondition = Restrictions.or(aCondition, Restrictions.eq("organid", value));
+                               }
+                       }
+               }
+               return getUserDAO().getFilteredList(aCondition);
+       }
+
+       /**
+        * Get the userDAO.
+        * 
+        * @return the userDAO
+        */
+       public UserDAO getUserDAO() {
+               return _userDAO;
+       }
+
+       /**
+        * Set the userDAO.
+        * 
+        * @param userDAO
+        *            the userDAO to set
+        */
+       public void setUserDAO(UserDAO userDAO) {
+               _userDAO = userDAO;
+       }
+}
index 687b8f5f48a7de456f3f66c5ff2ae2748498c8a9..b11341b33c0af8bad60f834e99c78ab9d1c23365 100644 (file)
@@ -127,7 +127,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                if (!steps.isEmpty())
                        return; // Project already configured
 
-               Database base = getDatabase().getMe();
+               Database base = getDatabase().getCheckedDB();
                File config = new File(filename);
                if (config.exists()) {
                        loadCustomization(config);
@@ -356,7 +356,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                        }
                        concycles.add(new ProjectSettingsValidationCycle()); // Adds the built-in validation cycle
 
-                       if (getDatabase().getMe().isInitialized())
+                       if (getDatabase().getCheckedDB().isInitialized())
                                return; // No need to load object type definitions as they are already stored
 
                        // Documents tag
@@ -470,7 +470,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
 
                                tprop.disableCheck();
                                tdoc = getDocumentTypeService().createType(tprop); // Creation of Document Types
-                               tdoc.approve();
+                               getDocumentTypeService().approve(tdoc);
                                maptype.put(type, tdoc);
                        }
                } catch (Exception error) {
@@ -483,12 +483,12 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                try {
                        KnowledgeElementType ktype = getKnowledgeElementTypeService()
                                        .createType("usecase"); // Internal reserved knowledge element type
-                       ktype.reserve();
+                       getKnowledgeElementTypeService().reserve(ktype);
                        for (Iterator<String> i = kname.iterator(); i.hasNext();) {
                                String type = i.next();
 
                                ktype = getKnowledgeElementTypeService().createType(type); // Knowledge Elements Types defined in the configuration
-                               ktype.approve();
+                               getKnowledgeElementTypeService().approve(ktype);
                        }
                } catch (Exception error) {
                        logger.warn("Error creating knowledge types, reason:", error); // Should not happen
@@ -523,7 +523,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                                }
                                tctex = getSimulationContextService().createType(type,
                                                mapstep.get(type)); // Creation of Simulation Context Types
-                               tctex.approve();
+                               getSimulationContextService().approve(tctex);
                        }
                } catch (Exception error) {
                        logger.warn("Error creating context types, reason:", error); // Should not happen
index 53680253214486f970ef9bd59f53d91761e6d23a..6ad603fda2585f1c32c5f9faed5a4e20f4227651 100644 (file)
@@ -15,11 +15,16 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                class="org.splat.service.ServiceLocatorImpl"
                factory-method="getInstance">
                <property name="studyService" ref="studyService" />
+        <property name="userService" ref="userService" />
        </bean>
 
+    <bean id="userService" class="org.splat.service.UserServiceImpl">
+        <property name="userDAO" ref="userDAO"/>
+    </bean>
        <bean id="projectElementService"
                class="org.splat.service.ProjectElementServiceImpl">
                <property name="projectSettings" ref="projectSettings" />
+        <property name="projectElementDAO" ref="projectElementDAO" />
        </bean>
 
        <bean id="documentTypeService"
@@ -70,9 +75,11 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                <property name="stepService" ref="stepService" />
                <property name="studyService" ref="studyService" />
                <property name="knowledgeElementDAO" ref="knowledgeElementDAO" />
-               <property name="scenarioDAO" ref="scenarioDAO" />
+        <property name="scenarioDAO" ref="scenarioDAO" />
+        <property name="studyDAO" ref="studyDAO" />
                <property name="knowledgeElementTypeService"
                        ref="knowledgeElementTypeService" />
+        <property name="userService" ref="userService" />
        </bean>
 
        <bean id="searchService"
@@ -114,6 +121,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                <property name="IDBuilderDAO" ref="iDBuilderDAO" />
                <property name="validationCycleDAO" ref="validationCycleDAO" />
                <property name="documentTypeService" ref="documentTypeService" />
+        <property name="userService" ref="userService" />
        </bean>
 
        <bean id="userRights" abstract="true" scope="session">
index d51867821dfb7438480f6099c5e01527f374554f..596379da675c229bc07f21f111d1417435e15e13 100644 (file)
@@ -21,9 +21,10 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        </bean>
        
        <!-- TODO: Replace database by services and DAOs -->
-       <bean id="database" class="org.splat.dal.dao.som.Database">
+       <bean id="database" class="org.splat.dal.dao.som.Database" factory-method="getInstance">
                <property name="sessionFactory" ref="simanSessionFactory" />
-               <property name="indexService" ref="indexService" />
+        <property name="indexService" ref="indexService" />
+        <property name="userService" ref="userService" />
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
index 10d81dff022a9ca3167005edc0a4b9d701e5d3f4..1806e0f721af1965050b8715e36dcd0adf388c61 100644 (file)
@@ -27,7 +27,6 @@ import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.ValidationCycle;
 import org.splat.dal.dao.som.Database;
 import org.splat.kernel.Do;
-import org.splat.kernel.UserDirectory;
 import org.splat.manox.Reader;
 import org.splat.manox.Toolbox;
 import org.splat.manox.Writer;
index 2f08300b84c99c424c524b1a975cb4b7885f8d2c..229da1aa0d62a9d4345eff90a4b0f6921cbeb0c3 100644 (file)
 <!-- Initialization
      =============================================================================================================================
   -->
-<%  String            path   = request.getParameter("open");
+<%
+       String            path   = request.getParameter("open");
     OpenStudy         simer  = (OpenStudy)session.getAttribute("study.open");
     ApplicationRights rights = (ApplicationRights)session.getAttribute("user.rights");
     String            name;
     boolean           ishared;
 
-    Session      connex  = Database.getSession();
+    Session      connex  = Database.getCurSession();
     Transaction  transax = connex.beginTransaction();
 
     if (path == null) {
@@ -36,7 +37,7 @@
            int  j = Integer.valueOf(item[0]);
       int  i;
                  for (i=0; i<scene.length; i++) {
-                         if (scene[i].getIndex() == j) break;
+         if (scene[i].getIndex() == j) break;
                  }
                 //TODO: RKV: scene[i].checkout(rights.getUser());
 
index 1ec4d31c56076ae7ee8b501757880570613578a2..c0f4c3f708bf59c49f31af7fac1e5b0b361aade4 100644 (file)
 <!-- Initialization
      =============================================================================================================================
   -->
-<%  String            path   = request.getParameter("open");
+<%
+       String            path   = request.getParameter("open");
     OpenStudy         simer  = (OpenStudy)session.getAttribute("study.open");
     ApplicationRights rights = (ApplicationRights)session.getAttribute("user.rights");
     String            name;
     boolean           ishared;
 
-    Session      connex  = Database.getSession();
+    Session      connex  = Database.getCurSession();
     Transaction  transax = connex.beginTransaction();
 
     if (path == null) {
diff --git a/Workspace/Siman/conf/debug_pg.properties b/Workspace/Siman/conf/debug_pg.properties
new file mode 100644 (file)
index 0000000..87e1a87
--- /dev/null
@@ -0,0 +1,32 @@
+# Connection properties
+connection.url=jdbc:postgresql://localhost:5432/simer
+connection.username=simer
+connection.password=admin
+connection.driver_class=org.postgresql.Driver
+#connection.driver_class=com.p6spy.engine.spy.P6SpyDriver
+
+# Hibernate config
+hibernate.hbm2ddl.auto=update
+hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
+hibernate.current_session_context_class=thread
+
+# Log properties
+hibernate.show_sql=true
+root.logger.appender=<appender-ref ref="console"/>
+root.logger.level=DEBUG
+com.opensymphony.logger.level=DEBUG
+org.apache.struts2.logger.level=DEBUG
+org.springframework.logger.level=DEBUG
+org.hibernate.logger.level=DEBUG
+org.splat.siman.logger.level=DEBUG
+log4j.logger.org.hibernate.logger.level=DEBUG
+com.opensymphony.xwork2.validator.logger.level=DEBUG
+org.apache.struts2.interceptor.validation.logger.level=DEBUG
+
+# Generated file header
+file.header=Don't edit manually. See the source in @config.src.dir@.
+
+wapp.root=c:/work/SIMAN/SIMAN_SRC/Workspace/Siman/WebContent/
+
+
+
index f0920aa666620d6ba1fa6280b560feea8060832a..611e58444be6c5a915ecf72b9881ed782a7932b9 100644 (file)
@@ -78,7 +78,7 @@ public class SaveDocumentAction extends Action {
 
        public String doSave() {
                // -----------------------
-               Session connex = Database.getSession();
+               Session connex = Database.getCurSession();
                Transaction transax = connex.beginTransaction();
                try {
                        // Getting user inputs
@@ -249,7 +249,7 @@ public class SaveDocumentAction extends Action {
 
        public String doVersion() {
                // --------------------------
-               Session connex = Database.getSession();
+               Session connex = Database.getCurSession();
                Transaction transax = connex.beginTransaction();
                try {
                        // Getting user inputs
index 0707ca507f6d00cf31b3ac49e3a68780bb90195f..ed1df7ae9690ee92c19b607b2a6ec925d6e5ba21 100644 (file)
@@ -537,6 +537,9 @@ public class ApplicationSettings {
 
        public static ApplicationSettings getMe() {
                // ------------------------------------------
+               if (my == null) {
+                       my = new ApplicationSettings();
+               }
                return my; // The application is supposed being previously created below
        }
 
@@ -560,8 +563,12 @@ public class ApplicationSettings {
 
                logger.info("Application root set to "
                                + wapprops.getProperty("wapp.root"));
-               my = this;
-               return this;
+               if (my == null) {
+                       my = this;
+               }
+//RKV          my = this;
+//RKV          return this;
+               return my;
        }
 
        // ==============================================================================================================================
@@ -655,8 +662,12 @@ public class ApplicationSettings {
                                module.add(command);
                                String[] parsed = command.split("/");
                                String[] name = parsed[parsed.length - 1].split("\\x2E");
-                               String docname = my.defdoctype.get(
-                                               step.getNumber() + "." + format).getName();
+                               DocumentType dtype = my.defdoctype.get(
+                                               step.getNumber() + "." + format);
+                               String docname = "";
+                               if (dtype != null) {
+                                       docname = dtype.getName();
+                               }
                                if (tempfile.get(docname) == null) { // No available template
                                        String tool = parsed[parsed.length - 1];
                                        String icon = name[0];
index dae99b3b4a741364c22a51af5bd4931bde82e186..e3114f734bc862bcd15283c5f3141e6a6adc0475 100644 (file)
@@ -7,146 +7,147 @@ import javax.security.auth.login.LoginContext;
 import javax.security.auth.Subject;
 import javax.security.auth.callback.*;
 
-import org.hibernate.Session;
-import org.hibernate.Transaction;
 import org.splat.dal.bo.kernel.User;
 import org.splat.som.ApplicationRights;
-import org.splat.dal.dao.som.Database;
 
 import java.io.IOException;
 import javax.security.auth.login.FailedLoginException;
 
-
 public class ConnectionAction extends Action {
 
-    private String             username = null;
-    private String             password = null;
-    private String             backmenu = null;
+       private String username = null;
+       private String password = null;
+       private String backmenu = null;
 
        /**
         * Serial version ID.
         */
-       private static final long  serialVersionUID = 6095471616361606231L;
-       
+       private static final long serialVersionUID = 6095471616361606231L;
+
        private class Handler implements CallbackHandler {
-//  ------------------------------------------------           
-      public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
-      {
-        for (int i = 0; i < callbacks.length; i++) {
-          if (callbacks[i] instanceof TextOutputCallback) {
-//        Display a message according to a specified type
-
-          } else if (callbacks[i] instanceof NameCallback) {
-//          Get the username            
-            NameCallback call = (NameCallback)callbacks[i];         
-            call.setName(username);
-                
-          } else if (callbacks[i] instanceof PasswordCallback) {    
-//          Get the password
-               if (password != null) {
-              PasswordCallback call = (PasswordCallback)callbacks[i];
-              call.setPassword(password.toCharArray());
-               }
-          } else {
-            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
-          }
-        }
-         }
+               // ------------------------------------------------
+               public void handle(Callback[] callbacks) throws IOException,
+                               UnsupportedCallbackException {
+                       for (int i = 0; i < callbacks.length; i++) {
+                               if (callbacks[i] instanceof TextOutputCallback) {
+                                       // Display a message according to a specified type
+
+                               } else if (callbacks[i] instanceof NameCallback) {
+                                       // Get the username
+                                       NameCallback call = (NameCallback) callbacks[i];
+                                       call.setName(username);
+
+                               } else if (callbacks[i] instanceof PasswordCallback) {
+                                       // Get the password
+                                       if (password != null) {
+                                               PasswordCallback call = (PasswordCallback) callbacks[i];
+                                               call.setPassword(password.toCharArray());
+                                       }
+                               } else {
+                                       throw new UnsupportedCallbackException(callbacks[i],
+                                                       "Unrecognized Callback");
+                               }
+                       }
+               }
        }
 
-//  ==============================================================================================================================
-//  Action execution
-//  ==============================================================================================================================
+       // ==============================================================================================================================
+       // Action execution
+       // ==============================================================================================================================
+
+       @SuppressWarnings("unchecked")
+       public String doLogin() throws Exception {
+               // ------------------------
+               if (username == null || username.length() == 0)
+                       return INPUT;
+               if (password != null && password.length() == 0)
+                       password = null; // User having no password
+               try {
+                       LoginContext context = new LoginContext("Simer", new Handler());
+                       context.login();
+
+                       Subject identity = context.getSubject();
+                       Set<User> table = identity.getPrincipals(User.class);
+                       if (table.isEmpty())
+                               throw new Exception();
+
+                       User user = table.iterator().next(); // The user is (apparently...) the 1st principal
+                       ApplicationRights logged = new ApplicationRights(user);
+                       if (logged.canContributeToStudy() || logged.canValidate()) {
+                               // TODO: Set the search filter according to user preferences
+                               Map<String, Object> session = getSession();
+                               // Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
+                               Map<String, Object> sfilter = (Map<String, Object>) session
+                                               .get("study.filter");
+
+                               sfilter.put("state", "ANY");
+                               sfilter.put("visibility", "PRIVATE");
+                               if (logged.canCreateStudy())
+                                       sfilter.put("author", String.valueOf(user.getIndex()));
+                       }
+                       this.connect(context, user); // Updates the session context
+                       return backmenu;
+               } catch (FailedLoginException error) {
+                       setErrorCode("message.error.login." + error.getMessage());
+                       return INPUT;
+               } catch (Exception error) {
+                       logger.error("Reason:", error);
+                       return ERROR;
+               }
+       }
 
        @SuppressWarnings("unchecked")
-       public String doLogin () throws Exception {
-//  ------------------------
-      if (username == null || username.length() == 0) return INPUT;
-      if (password != null && password.length() == 0) password = null;  // User having no password
-      try {
-        Session      connex  = Database.getSession();
-        Transaction  transax = connex.beginTransaction();
-        LoginContext context = new LoginContext("Simer", new Handler());
-        context.login();
-        transax.commit();
-         
-        Subject   identity = context.getSubject();
-        Set<User> table    = identity.getPrincipals(User.class);
-        if (table.isEmpty()) throw new Exception();
-
-        User              user   = table.iterator().next();             // The user is (apparently...) the 1st principal
-        ApplicationRights logged = new ApplicationRights(user);
-        if (logged.canContributeToStudy() || logged.canValidate()) {
-//TODO: Set the search filter according to user preferences
-          Map<String,Object> session = getSession();
-//        Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
-          Map<String,Object> sfilter = (Map<String, Object>)session.get("study.filter");
-          
-          sfilter.put("state", "ANY");
-          sfilter.put("visibility", "PRIVATE");
-          if (logged.canCreateStudy()) sfilter.put("author", String.valueOf(user.getIndex()));
-        }
-        this.connect(context, user);                                    // Updates the session context
-           return backmenu;
-     }
-      catch (FailedLoginException error) {
-       setErrorCode("message.error.login." + error.getMessage());
-        return INPUT;
-      }
-      catch (Exception error) {
-        logger.error("Reason:", error);
-        return ERROR;
-      }
+       public String doLogout() {
+               // -------------------------
+               try {
+                       Map<String, Object> session = getSession();
+                       // Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
+                       Map<String, Object> sfilter = (Map<String, Object>) session
+                                       .get("study.filter");
+                       LoginContext context = (LoginContext) session.get("login.context");
+
+                       logger.info("Deconnection of " + getConnectedUser().toString()
+                                       + ".");
+                       context.logout();
+
+                       // TODO: ProjectSettings.deleteDownloadDirectory(user);
+                       sfilter.put("state", "ANY");
+                       sfilter.put("author", "0");
+
+                       this.disconnect(); // Updates the session context
+                       return backmenu;
+               } catch (Exception error) {
+                       logger.error("Reason:", error);
+                       return ERROR;
+               }
+       }
+
+       // ==============================================================================================================================
+       // Getters and setters
+       // ==============================================================================================================================
+
+       public String getUsername() {
+               // ----------------------------
+               return username;
        }
 
-    @SuppressWarnings("unchecked")
-       public String doLogout () {
-//  -------------------------
-      try {
-        Map<String,Object>  session = getSession();
-//      Map<String,Object>  kfilter = (Map<String, Object>)session.get("knowledge.filter");
-        Map<String,Object>  sfilter = (Map<String, Object>)session.get("study.filter");
-        LoginContext        context = (LoginContext)session.get("login.context");     
-        
-        logger.info("Deconnection of " + getConnectedUser().toString() + ".");
-        context.logout();
-
-//TODO: ProjectSettings.deleteDownloadDirectory(user);
-        sfilter.put("state", "ANY");
-        sfilter.put("author", "0");
-
-        this.disconnect();                                              // Updates the session context
-        return backmenu;
-      }
-      catch (Exception error) {
-        logger.error("Reason:", error);
-        return ERROR;
-      }
-    }
-
-//  ==============================================================================================================================
-//  Getters and setters
-//  ==============================================================================================================================
-       
-    public String getUsername () {
-//  ----------------------------       
-      return username;
-    }
-    public String getPassword () {
-//  ----------------------------
-      return password;
-    }
-
-    public void setUsername (String value) {
-//  --------------------------------------
-      this.username = value;
-    }
-    public void setPassword (String value) {
-//  --------------------------------------
-      this.password = value;
-    }
-    public void setBackMenu (String menu) {
-//  -------------------------------------
-      this.backmenu = menu;
-    }
+       public String getPassword() {
+               // ----------------------------
+               return password;
+       }
+
+       public void setUsername(String value) {
+               // --------------------------------------
+               this.username = value;
+       }
+
+       public void setPassword(String value) {
+               // --------------------------------------
+               this.password = value;
+       }
+
+       public void setBackMenu(String menu) {
+               // -------------------------------------
+               this.backmenu = menu;
+       }
 }
\ No newline at end of file
index a5fec95a8cfd28e174f9a060564a5d436bf73800..a300c3d0142b43fb43bf95ab76d08eb58ef9bcca 100644 (file)
@@ -24,7 +24,7 @@ public class DisplayKnowledgeAction extends DisplayBaseAction {
 
     public String doOpen () {
 //  -----------------------
-      Session      connex  = Database.getSession();
+      Session      connex  = Database.getCurSession();
       Transaction  transax = connex.beginTransaction();
 
       myknelm = getOpenKnowledge();
@@ -55,7 +55,7 @@ public class DisplayKnowledgeAction extends DisplayBaseAction {
 
     public String doSelectStep () {
 //  -----------------------------
-      Session      connex  = Database.getSession();
+      Session      connex  = Database.getCurSession();
       Transaction  transax = connex.beginTransaction();
 
       myknelm = getOpenKnowledge();
index c94b23631c75945fb53f3885abea6f681970ea32..ab478c7eaa38d8c4a3deb686c6a58f52750cc51e 100644 (file)
@@ -28,7 +28,7 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
 
     public String doOpen () {
 //  -----------------------
-      Session      connex  = Database.getSession();
+      Session      connex  = Database.getCurSession();
       Transaction  transax = connex.beginTransaction();
       Study        study;
 
@@ -80,7 +80,7 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
     
     public String doSelectStep () {
 //  -----------------------------
-      Session      connex  = Database.getSession();
+      Session      connex  = Database.getCurSession();
       Transaction  transax = connex.beginTransaction();
 
       mystudy = getOpenStudy();
index 69edf20eb76effd0ec37d21ef2e534a47685a1fe..ca7baa1c7a7c3d531ee20255a0a266e29f2ca7a4 100644 (file)
@@ -3,12 +3,8 @@ package org.splat.simer;
 import java.io.File;
 import java.util.Calendar;
 
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.dal.bo.kernel.User;
-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;
@@ -64,9 +60,6 @@ public class EditDocumentAction extends DisplayStudyStepAction {
        }
 
        public String doSetDocument() {
-               // ------------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
                try {
                        mystudy = getOpenStudy();
 
@@ -78,7 +71,7 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                                getPublicationService().rename(doc, title);
                                // Useless to update the document presentation
                        } else if (todo == Execute.accept) {
-                               doc.actualize();
+                               getPublicationService().actualize(doc);
                                mystudy.update(doc);
                        } else if (todo == Execute.promote) {
                                getPublicationService().promote(doc,
@@ -100,29 +93,19 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                                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();
+//             Session connex = Database.getCurSession();
+//             Transaction transax = connex.beginTransaction();
                try {
                        // Getting user inputs
                        mystudy = getOpenStudy();
@@ -141,7 +124,7 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                        upfile.renameTo(export.getTo().asFile());
 
                        mystudy.update(edited);
-                       transax.commit();
+//                     transax.commit();
                        return SUCCESS;
                } catch (Exception error) {
                        logger.error("Reason:", error);
@@ -150,9 +133,6 @@ public class EditDocumentAction extends DisplayStudyStepAction {
        }
 
        public String doDeleteDocument() {
-               // ---------------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
                try {
                        mystudy = getOpenStudy();
 
@@ -160,20 +140,11 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                        Publication doctag = step.getDocument(Integer.valueOf(index));
 
                        getStepService().removeDocument(step, 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;
                }
        }
index 99ae151c2050a0f3b83d8c074f622ca322614218..ce3ac95d0d5583efa82e9aacb9042cb96fc2c916 100644 (file)
@@ -112,7 +112,7 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
 
                KnowledgeElement kelm = scene.getKnowledgeElement(Integer
                                .valueOf(myindex));
-               scene.removeKnowledgeElement(kelm); // The knowledge element necessarily exists
+               getScenarioService().removeKnowledgeElement(scene, kelm); // The knowledge element necessarily exists
 
                mystudy.remove(kelm);
                getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of last removed document
index cb27c9aa8a0a7399650104c9cfd4ae811504bd76..59ea206b944bdc27a6402aa3bc9d693294f8f8d1 100644 (file)
@@ -3,10 +3,7 @@ package org.splat.simer;
 import java.text.SimpleDateFormat;
 import java.util.ResourceBundle;
 
-import org.hibernate.Session;
-import org.hibernate.Transaction;
 import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.Scenario;
 import org.splat.service.ProjectElementService;
 import org.splat.service.ScenarioService;
@@ -50,9 +47,6 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
        }
 
        public String doCheckin() {
-               // --------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
                Step step;
 
                mystudy = getOpenStudy();
@@ -61,7 +55,6 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
                myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
 
                getScenarioService().checkin(myscenario);
-               transax.commit();
 
                mystudy.getMenu().refreshGivenStepItem(
                                getProjectElementService().getFirstStep(myscenario)); // For updating the scenario icon
index d133314ec4b1719456cdc4cce7ecc81751d521ac..20ea3c69c6e2f0639ae774f040cf967f5d900411 100644 (file)
@@ -3,10 +3,6 @@ package org.splat.simer;
 import java.util.Arrays;
 import java.util.List;
 
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-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;
@@ -63,14 +59,10 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        // ==============================================================================================================================
 
        public String doInitialize() {
-               // -----------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
 
                mystudy = getOpenStudy();
                contype = getInvolvedContexts();
 
-               transax.commit();
                if (contype.isEmpty())
                        return "create";
                else
@@ -78,32 +70,23 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        }
 
        public String doSelectContext() {
-               // --------------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
-               try {
-                       mystudy = getOpenStudy();
-                       int typid = Integer.valueOf(selectype);
-                       if (typid == 0)
-                               return "create";
+               mystudy = getOpenStudy();
+               int typid = Integer.valueOf(selectype);
+               if (typid == 0)
+                       return "create";
 
-                       SimulationContext.Properties cprop = new SimulationContext.Properties();
-                       type = getSimulationContextService().selectType(typid);
-                       newtype = type.getName();
-                       contype = getInvolvedContexts();
-                       contelm = getSimulationContextService()
-                                       .selectSimulationContextsWhere(cprop.setType(type));
+               SimulationContext.Properties cprop = new SimulationContext.Properties();
+               type = getSimulationContextService().selectType(typid);
+               newtype = type.getName();
+               contype = getInvolvedContexts();
+               contelm = getSimulationContextService()
+                               .selectSimulationContextsWhere(cprop.setType(type));
 
-                       return "set";
-               } finally {
-                       transax.commit();
-               }
+               return "set";
        }
 
        public String doCreateContext() {
                // --------------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
                try {
                        mystudy = getOpenStudy();
                        if (newtype.length() == 0 || value.length() == 0)
@@ -124,29 +107,16 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                                contex = getStepService().addSimulationContext(step, cprop); // Re-indexes knowledges only
 
                        mystudy.add(contex);
-                       transax.commit();
                        return SUCCESS;
                } catch (RuntimeException saverror) {
                        logger.error("Reason:", saverror);
-                       if (transax != null && transax.isActive()) {
-                               // Second try-catch as the rollback could fail as well
-                               try {
-                                       transax.rollback();
-                               } catch (HibernateException backerror) {
-                                       logger.debug("Error rolling back transaction", backerror);
-                               }
-                       }
                        return ERROR;
                } catch (Exception error) {
-                       transax.commit();
                        return INPUT;
                }
        }
 
        public String doDeleteContext() {
-               // --------------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
                try {
                        mystudy = getOpenStudy();
 
@@ -161,18 +131,9 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                                getStepService().removeSimulationContext(step, context); // Re-indexes knowledges only
 
                        mystudy.remove(context);
-                       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;
                }
        }
@@ -180,8 +141,8 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        public String doSetContext() {
                // -----------------------------
                String[] input = value.split(",");
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
+//             Session connex = Database.getCurSession();
+//             Transaction transax = connex.beginTransaction();
                try {
                        mystudy = getOpenStudy();
 
@@ -215,22 +176,13 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                        mystudy.add(contex);
                        contype = getInvolvedContexts();
 
-                       transax.commit();
+//                     transax.commit();
                        return SUCCESS;
                } catch (RuntimeException saverror) {
                        logger.error("Reason:", saverror);
-                       if (transax != null && transax.isActive()) {
-                               // Second try-catch as the rollback could fail as well
-                               try {
-                                       transax.rollback();
-                               } catch (HibernateException backerror) {
-                                       logger.debug("Error rolling back transaction", backerror);
-                               }
-                       }
                        return ERROR;
                } catch (Exception error) {
                        value = input[0];
-                       transax.commit();
                        return INPUT;
                }
        }
index a494f1afb21078a5573d193ae3238d7fc57504fd..76c546c425a8ed75378fdba0093fec65516ed63c 100644 (file)
@@ -1,9 +1,5 @@
 package org.splat.simer;
 
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.Study;
 import org.splat.service.StudyService;
 
@@ -24,9 +20,6 @@ public class EditStudyAction extends DisplayStudyStepAction {
 //  ==============================================================================================================================
 
     public String doEdition () {
-//  --------------------------
-      Session      connex  = Database.getSession();
-         Transaction  transax = connex.beginTransaction();
          try {
         mystudy = getOpenStudy();
 
@@ -37,20 +30,10 @@ public class EditStudyAction extends DisplayStudyStepAction {
         else if (todo == Execute.promote) getStudyService().moveToReference(study);
         mystudy.getPopup().setContext("study", mystudy.getStudyRights());   // The context has changed
 
-//      Useless to update the open study
-        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;
       }
     }
index 02d9070f37596f0b3e42b6d1e9de294fe97a2b1d..e35e72d9e44fd80fb7ea1071d08bae0fb57acb07 100644 (file)
@@ -77,7 +77,7 @@ public class ImportDocumentAction extends UploadBaseNextAction {
         */
        public String doInitialize() {
                // -----------------------------
-               Session connex = Database.getSession();
+               Session connex = Database.getCurSession();
                Transaction transax = connex.beginTransaction();
                User user = getConnectedUser();
                File updir = getRepositoryService().getDownloadDirectory(user);
@@ -182,7 +182,7 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                        setErrorCode("import.type");
                        return ERROR;
                }
-               Session connex = Database.getSession();
+               Session connex = Database.getCurSession();
                Transaction transax = connex.beginTransaction();
                try {
                        // Getting user inputs
index 68f98e200b3e156f60dc588e11517c499a388a58..cc1b63406873401cc1facdfda6887d3db3ece397 100644 (file)
@@ -88,8 +88,8 @@ public class NewScenarioAction extends Action {
 //  -------------------------
       if (action == ToDo.cancel) return "cancel";
 
-      Session      session   = Database.getSession();
-         Transaction  transax   = session.beginTransaction();  
+//      Session      session   = Database.getCurSession();
+//       Transaction  transax   = session.beginTransaction();  
          try {        mystudy   = getOpenStudy();
                    selection = getMenu("scenario").getSelection();
         Study      study     = mystudy.getStudyObject();
@@ -112,7 +112,7 @@ public class NewScenarioAction extends Action {
           sprop.setBaseStep(step[number-bastep]);
         }
         bascene = getScenarioService().addScenario(study, sprop);
-        transax.commit();
+//        transax.commit();
 
 //      Update of the display
         if (step != null) for (int i=0; i<number-bastep+1; i++) {
@@ -125,14 +125,6 @@ public class NewScenarioAction extends Action {
          }
       catch (RuntimeException saverror) {
         logger.error("Reason:", saverror);
-        if (transax != null && transax.isActive()) {
-//        Second try-catch as the rollback could fail as well
-          try {
-               transax.rollback();
-          } catch (HibernateException backerror) {
-            logger.debug("Error rolling back transaction", backerror);
-          }
-        }
         return ERROR;
       }
          catch (Exception error) {
index 82755c5d540a0f444b075835030f7165750c337c..1a89f79a373e070b86bb9d533ba737dfad607887 100644 (file)
@@ -3,10 +3,6 @@ package org.splat.simer;
 import java.util.List;
 import java.util.ResourceBundle;
 
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
@@ -57,13 +53,10 @@ public class NewStudyAction extends Action {
        }
 
        public String doCreate() throws Exception {
-               // -------------------------
                String[] input = context.split(",");
                int valid = Integer.valueOf(input[0]);
                String value = ""; // input[1] if exists
 
-               Session session = Database.getSession();
-               Transaction transax = session.beginTransaction();
                Study.Properties sprop = new Study.Properties();
 
                // Check arguments and creation of the study
@@ -84,7 +77,6 @@ public class NewStudyAction extends Action {
                                        .selectType("product");
                        contelm = getSimulationContextService()
                                        .selectSimulationContextsWhere(cprop.setType(product));
-                       transax.commit();
                        return INPUT; // Title empty, simply wait for input without error message
                }
                try {
@@ -112,18 +104,9 @@ public class NewStudyAction extends Action {
                        // Update of the session
                        number += 1;
                        open(study); // Opens the study,
-                       transax.commit();
                        return SUCCESS;
                } catch (Exception error) {
                        logger.error("Unable to save the study, reason:", error);
-                       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;
                }
        }
index dd9937e34ec299c5d64a047d9e67e8cc1c27632b..d572a408ee47b067239ad5eb8adb559a32269ec0 100644 (file)
@@ -15,18 +15,15 @@ import java.util.List;
 import java.util.ResourceBundle;
 
 import org.apache.log4j.Logger;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
 import org.splat.kernel.Do;
 import org.splat.dal.bo.kernel.User;
 import org.splat.manox.Toolbox;
 import org.splat.manox.Writer;
-import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.Document;
 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.DocumentService;
 import org.splat.service.DocumentTypeService;
 import org.splat.service.StepService;
 import org.splat.service.StudyService;
@@ -67,7 +64,10 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
         * Injected document type service.
         */
        private DocumentTypeService _documentTypeService;
-
+       /**
+        * Injected document service.
+        */
+       private DocumentService _documentService;
        /**
         * The injected Study service.
         */
@@ -235,8 +235,8 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                if (!template.exists())
                        return null;
 
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
+//             Session connex = Database.getCurSession();
+//             Transaction transax = connex.beginTransaction();
                try {
                        File udir = getRepositoryService().getDownloadDirectory(author);
                        File credoc = new File(udir.getPath() + "/" + filename);
@@ -248,7 +248,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                        Document medoc = getStepService().createDocument(step,
                                        dprop.setType(type).setFormat("xml").setAuthor(author))
                                        .value();
-                       transax.commit();
+//                     transax.commit();
 
                        // Instantiation of the template into the user download directory
                        if (!udir.exists())
@@ -288,14 +288,6 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                                        + filename);
                } catch (Exception 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 null;
                }
        }
@@ -306,21 +298,10 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
 
                if (docurl.startsWith(prefix))
                        try {
-                               Session connex = Database.getSession();
-                               Transaction transax = connex.beginTransaction();
                                String path = docurl.substring(prefix.length());
-                               String[] parse = path.split("'");
-
-                               path = parse[0];
-                               for (int i = 1; i < parse.length; i++)
-                                       path = path + "''" + parse[i];
-                               // Better call Database.selectDocument(path), but this service does not exist (overloading issue)
-                               String query = "from Document where path='" + path + "'";
-                               Document value = (Document) Database.getSession().createQuery(
-                                               query).uniqueResult();
+                               Document value = getDocumentService().getDocumentByPath(path);
 
                                selecdoc = ustep.getDocument(value.getIndex());
-                               transax.commit();
                        } catch (Exception error) {
                                logger.error("Reason:", error);
                        }
@@ -576,4 +557,20 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        public void setStudyService(StudyService studyService) {
                _studyService = studyService;
        }
+
+       /**
+        * 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;
+       }
 }
\ No newline at end of file
index 2c321176fc3a7b51ea54aaa5ff84e6e6b11f7228..86a35c0bddac9227309ca6f8953f468bf7677413 100644 (file)
@@ -10,10 +10,10 @@ import org.hibernate.Transaction;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.Name;
 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.UserService;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.service.dto.Proxy;
 import org.splat.dal.bo.som.SimulationContext;
@@ -41,6 +41,11 @@ public abstract class SearchBaseAction extends Action {
         */
        private SimulationContextService _simulationContextService;
 
+       /**
+        * Injected user service.
+        */
+       private UserService _userService;
+
        enum UserAction {
                refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext
        }
@@ -65,7 +70,7 @@ public abstract class SearchBaseAction extends Action {
                                action = UserAction.cancelSelect;
                }
                // Execution of the user action
-               Session connex = Database.getSession();
+               Session connex = Database.getCurSession();
                Transaction transax = connex.beginTransaction();
                String done;
                try {
@@ -98,7 +103,8 @@ public abstract class SearchBaseAction extends Action {
                // ---------------------------------------
                SimulationContext.Properties sprop = new SimulationContext.Properties();
 
-               newtype = getSimulationContextService().selectType(Integer.valueOf(ctype));
+               newtype = getSimulationContextService().selectType(
+                               Integer.valueOf(ctype));
                newvalue = getSimulationContextService().selectSimulationContextsWhere(
                                sprop.setType(newtype));
                if (cindex.length() > 0 && Integer.valueOf(cindex) == 0)
@@ -208,7 +214,7 @@ public abstract class SearchBaseAction extends Action {
        protected void setCandidates() {
                // -------------------------------
                manager = new Vector<Name>();
-               List<User> users = UserDirectory.selectAllUsers();
+               List<User> users = getUserService().selectAllUsers();
                User me = getConnectedUser(); // May be null
                for (Iterator<User> i = users.iterator(); i.hasNext();) {
                        User next = i.next();
@@ -231,7 +237,8 @@ public abstract class SearchBaseAction extends Action {
                SimulationContextType[] types = critext
                                .toArray(new SimulationContextType[critext.size()]);
                ContextTypeComparator compare = new ContextTypeComparator();
-               ProjectSettingsService.Step step = types[0].getAttachedStep();
+               ProjectSettingsService.Step step = getSimulationContextService()
+                               .getAttachedStep(types[0]);
                int from = 0;
                int to = 0;
                while (to < types.length - 1) {
@@ -242,7 +249,7 @@ public abstract class SearchBaseAction extends Action {
                        if (to > from + 1)
                                Arrays.sort(types, from, to, compare);
                        from = to;
-                       step = types[to].getAttachedStep();
+                       step = getSimulationContextService().getAttachedStep(types[to]);
                }
                if (to > from)
                        Arrays.sort(types, from, to + 1, compare);
@@ -280,4 +287,20 @@ public abstract class SearchBaseAction extends Action {
                        SimulationContextService simulationContextService) {
                _simulationContextService = simulationContextService;
        }
+
+       /**
+        * Get the userService.
+        * @return the userService
+        */
+       public UserService getUserService() {
+               return _userService;
+       }
+
+       /**
+        * Set the userService.
+        * @param userService the userService to set
+        */
+       public void setUserService(UserService userService) {
+               _userService = userService;
+       }
 }
\ No newline at end of file
index 33f39b2391484eb7bd01234bb9998add5316c56f..60bf70fdb2727ac0e7bc30052ee880a43a0f7387 100644 (file)
@@ -5,10 +5,10 @@ import java.util.Map;
 
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.dal.bo.kernel.User;
-import org.splat.kernel.UserDirectory;
 import org.splat.service.KnowledgeElementTypeService;
 import org.splat.service.SearchService;
 import org.splat.service.SimulationContextService;
+import org.splat.service.UserService;
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.KnowledgeElementType;
 import org.splat.dal.bo.som.ProgressState;
@@ -43,6 +43,11 @@ public class SearchKnowledgeAction extends SearchBaseAction {
         */
        private KnowledgeElementTypeService _knowledgeElementTypeService;
 
+       /**
+        * Injected user service.
+        */
+       private UserService _userService;
+
        // ==============================================================================================================================
        // Action methods
        // ==============================================================================================================================
@@ -89,7 +94,7 @@ public class SearchKnowledgeAction extends SearchBaseAction {
                        sprop.setSimulationContexts(context);
                int index = Integer.valueOf(author);
                if (index > 0) {
-                       User him = UserDirectory.selectUser(index);
+                       User him = getUserService().selectUser(index);
                        sprop.setAuthor(him);
                }
                // Set of the visibility
@@ -301,4 +306,20 @@ public class SearchKnowledgeAction extends SearchBaseAction {
                        KnowledgeElementTypeService knowledgeElementTypeService) {
                _knowledgeElementTypeService = knowledgeElementTypeService;
        }
+
+       /**
+        * Get the userService.
+        * @return the userService
+        */
+       public UserService getUserService() {
+               return _userService;
+       }
+
+       /**
+        * Set the userService.
+        * @param userService the userService to set
+        */
+       public void setUserService(UserService userService) {
+               _userService = userService;
+       }
 }
\ No newline at end of file
index 58a7718e5effa9d5f9737339b6572cf281e1bc9b..188e5f07f6e3d79eef7de7228222477d720af81b 100644 (file)
@@ -7,11 +7,11 @@ import org.hibernate.Session;
 import org.hibernate.Transaction;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.dal.bo.kernel.User;
-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.UserService;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
@@ -33,6 +33,10 @@ public class SearchStudyAction extends SearchBaseAction {
         * Injected simulation context service.
         */
        private SimulationContextService _simulationContextService;
+       /**
+        * Injected user service.
+        */
+       private UserService _userService;
 
        /**
         * Serial version ID.
@@ -47,7 +51,7 @@ public class SearchStudyAction extends SearchBaseAction {
 
     public String doInitialize () {
 //  -----------------------------
-      Session      connex  = Database.getSession();
+      Session      connex  = Database.getCurSession();
       Transaction  transax = connex.beginTransaction();
       try {
         loadFilter();
@@ -81,7 +85,7 @@ public class SearchStudyAction extends SearchBaseAction {
         if (context.size() > 0)            sprop.setSimulationContexts(context);
         int index = Integer.valueOf(author);
         if (index > 0) {
-          User him = UserDirectory.selectUser(index);
+          User him = getUserService().selectUser(index);
           sprop.setManager(him);
         }
 //    Set of the visibility
@@ -266,4 +270,20 @@ public class SearchStudyAction extends SearchBaseAction {
                        SimulationContextService simulationContextService) {
                _simulationContextService = simulationContextService;
        }
+
+       /**
+        * Get the userService.
+        * @return the userService
+        */
+       public UserService getUserService() {
+               return _userService;
+       }
+
+       /**
+        * Set the userService.
+        * @param userService the userService to set
+        */
+       public void setUserService(UserService userService) {
+               _userService = userService;
+       }
 }
\ No newline at end of file
index e38e02d52cc60a46c735d1cd1349488df433d300..ae892fb3b517ff941cd37ea121fd76c0c6609eec 100644 (file)
@@ -31,8 +31,8 @@ public class StartAction extends Action implements ServletRequestAware {
 
        public String doInitialize () throws Exception {
 //  -----------------------------
-      Session      connex  = Database.getSession();
-      Transaction  transax = connex.beginTransaction();                  
+//      Session      connex  = Database.getSession();
+//      Transaction  transax = connex.beginTransaction();                
          StringBuffer wappurl = request.getRequestURL();     // "http://{server}:{port}/{webapp}/", including the leading '/'
 
       logger.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
@@ -55,19 +55,11 @@ public class StartAction extends Action implements ServletRequestAware {
                session.put("study.filter",     wapp.getFilter("study"));
                session.put("knowledge.filter", wapp.getFilter("knowledge"));
 
-           transax.commit();
+//         transax.commit();
            return SUCCESS;
       }
       catch (Exception error) {
         logger.fatal("Reason:", error);
-        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;
       }
        }
index 5cb967c80f654e86d2c5409bc3a7227b666839c1..07e84c455952d61b484f4c01ce3896ba2decd1f9 100644 (file)
@@ -4,16 +4,13 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
 
-import org.hibernate.Session;
-import org.hibernate.Transaction;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.Name;
 import org.splat.dal.bo.kernel.User;
-import org.splat.kernel.UserDirectory;
 import org.splat.service.DocumentTypeService;
 import org.splat.service.StudyService;
+import org.splat.service.UserService;
 import org.splat.som.ApplicationRights;
-import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.Study;
 import org.splat.som.StudyRights;
@@ -58,6 +55,11 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
         */
        private DocumentTypeService _documentTypeService;
 
+       /**
+        * Injected user service.
+        */
+       private UserService _userService;
+
        /**
         * Save operation type enumeration pointing which section of properties has been edited.
         */
@@ -117,9 +119,8 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
        }
 
        public String doEditTitle() {
-               // ----------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
+//             Session connex = Database.getCurSession();
+//             Transaction transax = connex.beginTransaction();
 
                mystudy = getOpenStudy();
                validation = new Vector<ValidationFacade>();
@@ -143,14 +144,13 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
                validor = null;
                other = null;
 
-               transax.commit();
+//             transax.commit();
                return SUCCESS;
        }
 
        public String doEditContributors() {
-               // -----------------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
+//             Session connex = Database.getCurSession();
+//             Transaction transax = connex.beginTransaction();
 
                mystudy = getOpenStudy();
                validation = new Vector<ValidationFacade>();
@@ -170,7 +170,7 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
                if (validefault != null)
                        validation.add(validefault); // In order to be at the end
                member = getStudyService().getContributors(study);
-               staff = UserDirectory.selectAllUsers();
+               staff = getUserService().selectAllUsers();
                validor = null;
                other = null;
                User me = this.getConnectedUser();
@@ -181,14 +181,13 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
                                        || !he.canContributeToStudy())
                                i.remove();
                }
-               transax.commit();
+//             transax.commit();
                return SUCCESS;
        }
 
        public String doEditCycle() {
-               // ----------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
+//             Session connex = Database.getCurSession();
+//             Transaction transax = connex.beginTransaction();
 
                mystudy = getOpenStudy();
                validation = new Vector<ValidationFacade>();
@@ -214,7 +213,7 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
                member = getStudyService().getContributors(study);
                validor = new Vector<Name>();
                staff = null;
-               List<User> user = UserDirectory.selectAllUsers();
+               List<User> user = getUserService().selectAllUsers();
                for (Iterator<User> i = user.iterator(); i.hasNext();) {
                        User next = i.next();
                        ApplicationRights he = new ApplicationRights(next);
@@ -225,14 +224,14 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
                                        validor.add(next);
                        }
                }
-               transax.commit();
+//             transax.commit();
                return SUCCESS;
        }
 
        public String doEdition() {
                // --------------------------
-               Session connex = Database.getSession();
-               Transaction transax = connex.beginTransaction();
+//             Session connex = Database.getCurSession();
+//             Transaction transax = connex.beginTransaction();
                Study study = getOpenStudy().getStudyObject();
 
                if (tosave == Save.title) {
@@ -277,7 +276,7 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
                                if (parsenew[i].length() == 0)
                                        continue; // No any new contributor
                                int index = Integer.valueOf(parsenew[i].trim());
-                               User newser = UserDirectory.selectUser(index);
+                               User newser = getUserService().selectUser(index);
 
                                getStudyService().addContributor(study, newser);
                        }
@@ -287,20 +286,20 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
                        DocumentType apply = getDocumentTypeService().selectType(type);
                        ValidationCycle.Properties vprop = new ValidationCycle.Properties();
                        if (publisher > 0) {
-                               User actor = UserDirectory.selectUser(publisher);
+                               User actor = getUserService().selectUser(publisher);
                                vprop.setActor(ValidationStep.PROMOTION, actor);
                        }
                        if (reviewer > 0) {
-                               User actor = UserDirectory.selectUser(reviewer);
+                               User actor = getUserService().selectUser(reviewer);
                                vprop.setActor(ValidationStep.REVIEW, actor);
                        }
                        if (approver > 0) {
-                               User actor = UserDirectory.selectUser(approver);
+                               User actor = getUserService().selectUser(approver);
                                vprop.setActor(ValidationStep.APPROVAL, actor);
                        }
                        getStudyService().setValidationCycle(study, apply, vprop);
                }
-               transax.commit();
+//             transax.commit();
 
                doInitialize(); // Re-initialization following the above edition
                return SUCCESS;
@@ -456,4 +455,20 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
        public void setDocumentTypeService(DocumentTypeService documentTypeService) {
                _documentTypeService = documentTypeService;
        }
+
+       /**
+        * Get the userService.
+        * @return the userService
+        */
+       public UserService getUserService() {
+               return _userService;
+       }
+
+       /**
+        * Set the userService.
+        * @param userService the userService to set
+        */
+       public void setUserService(UserService userService) {
+               _userService = userService;
+       }
 }
\ No newline at end of file
index e56c4dbace4b39d469875e859538d0f19a545f18..1b02a876e626e75fb7267f229a15f2a054b82046 100644 (file)
@@ -58,7 +58,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
 
        public String doInitialize() {
                // -----------------------------
-               Session connex = Database.getSession();
+               Session connex = Database.getCurSession();
                Transaction transax = connex.beginTransaction();
                User user = getConnectedUser();
                File updir = getRepositoryService().getDownloadDirectory(user);
@@ -137,7 +137,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                if (action == ToDo.cancel)
                        return "cancel";
 
-               Session connex = Database.getSession();
+               Session connex = Database.getCurSession();
                Transaction transax = connex.beginTransaction();
                try {
                        // Getting user inputs
@@ -215,7 +215,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                        for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
                                Publication using = i.next();
                                if (!compatible.contains(using.getIndex()))
-                                       using.outdate();
+                                       getPublicationService().outdate(using);
                        }
                        // Update of the open study
                        mystudy.setSelection(mystudy.getSelection()); // Rebuilds the presentation
index 931e0b8f5887782deab6739b262767b1c68da760..e0cb6c917dd90156c7b106edf7db4360f1146523 100644 (file)
@@ -32,7 +32,7 @@ public class DatabaseIndexingAction extends Action {
 
     public String doInitialize () {
 //  -----------------------------
-      Session      connex  = Database.getSession();
+      Session      connex  = Database.getCurSession();
       Transaction  transax = connex.beginTransaction();
 
       newstudies = getImportedStudy().selectAll();
@@ -44,7 +44,7 @@ public class DatabaseIndexingAction extends Action {
 
     public String doIndexing () {
 //  ---------------------------
-      Session             connex  = Database.getSession();
+      Session             connex  = Database.getCurSession();
       Transaction         transax = connex.beginTransaction();
       String[]            ridlist = indices.split(",");
       @SuppressWarnings("unchecked")
index 444cff8faaad22bab963be447a2c3cca87f25739..ee82a22e2be03ceaf92063336630ae8c2c987c86 100644 (file)
@@ -8,7 +8,7 @@ import java.util.Set;
 import org.hibernate.Session;
 import org.hibernate.Transaction;
 import org.splat.dal.bo.kernel.User;
-import org.splat.kernel.UserDirectory;
+import org.splat.service.UserService;
 import org.splat.service.technical.RepositoryService;
 import org.splat.simer.UploadBaseNextAction;
 import org.splat.dal.dao.som.Database;
@@ -28,21 +28,26 @@ public class ImportUserAction extends UploadBaseNextAction {
         */
        private RepositoryService _repositoryService;
 
+       /**
+        * Injected user service.
+        */
+       private UserService _userService;
+
 //  ==============================================================================================================================
 //  Action methods
 //  ==============================================================================================================================
 
     public String doImport () {
 //  -------------------------
-      Session      connex  = Database.getSession();
+      Session      connex  = Database.getCurSession();
       Transaction  transax = connex.beginTransaction();
       try {
         User       user    = getConnectedUser();     // The database administrator
        File       updir   = getRepositoryService().getDownloadDirectory(user);
        File       upfile  = new File(updir.getPath() + "/" + filename);
 
-        newsers = UserDirectory.importUsers(upfile);
-        users   = UserDirectory.selectAllUsers();
+        newsers = getUserService().importUsers(upfile);
+        users   = getUserService().selectAllUsers();
         for (Iterator<User> i=users.iterator(); i.hasNext(); ) {
           User next = i.next();
           if (!next.equals(user)) continue;
@@ -86,4 +91,20 @@ public class ImportUserAction extends UploadBaseNextAction {
        public void setRepositoryService(RepositoryService repositoryService) {
                _repositoryService = repositoryService;
        }
+
+       /**
+        * Get the userService.
+        * @return the userService
+        */
+       public UserService getUserService() {
+               return _userService;
+       }
+
+       /**
+        * Set the userService.
+        * @param userService the userService to set
+        */
+       public void setUserService(UserService userService) {
+               _userService = userService;
+       }
 }
\ No newline at end of file
index 66afc6318df3b5906ee73490330368155a6a4852..837a9c5d777a1eb32c7767312ea11bef2c78c3e8 100644 (file)
@@ -93,7 +93,7 @@ public class ImportedStudy {
 
     public List<ImportedStudy> selectAll () {
 //  ----------------------------------------------
-      Session        session = Database.getSession();
+      Session        session = Database.getCurSession();
       SelectStudies  query   = new SelectStudies(getSearchService());
       session.doWork(query);
 
index 232e52c9dc9b78b5908a53d4e37e6bcfcf85fc0b..92b36c9b6aeeb3909797bc043c1d91ae57475d93 100644 (file)
@@ -120,7 +120,7 @@ public class SimulationContextAction extends Action {
 
        public String doInitialize() {
                // -----------------------------
-               Session connex = Database.getSession();
+               Session connex = Database.getCurSession();
                Transaction transax = connex.beginTransaction();
                try {
                        SimulationContext.Properties cprop = new SimulationContext.Properties();
@@ -148,7 +148,7 @@ public class SimulationContextAction extends Action {
 
        public String doSelect() {
                // -------------------------
-               Session connex = Database.getSession();
+               Session connex = Database.getCurSession();
                Transaction transax = connex.beginTransaction();
                try {
                        SimulationContext.Properties cprop = new SimulationContext.Properties();
@@ -174,7 +174,7 @@ public class SimulationContextAction extends Action {
                                        kprop.setSimulationContexts(selected).setState(
                                                        ProgressState.inWORK));
 
-                       step = edition.getType().getAttachedStep();
+                       step = getSimulationContextService().getAttachedStep(edition.getType());
                        owner = new HashSet<ProjectElementFacade>();
                        for (Iterator<Proxy> i = kelm.iterator(); i.hasNext();) {
                                KnowledgeElement next = getKnowledgeElementService()
@@ -190,7 +190,7 @@ public class SimulationContextAction extends Action {
                        }
                        SimulationContextType.Properties sprop = new SimulationContextType.Properties();
                        List<SimulationContextType> types = getSimulationContextService()
-                                       .selectTypesWhere(sprop.setState(ProgressState.APPROVED));
+                                       .selectTypesWhere(sprop.setProgressState(ProgressState.APPROVED));
                        Locale[] support = ApplicationSettings.getSupportedLocales();
 
                        // Sort localized type names
index 62240ae9b2b0d7c6650e626dd66408fd269c8c83..71782db2122dde67ee387b715c0ac43e9fcf154b 100644 (file)
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
        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
@@ -17,8 +16,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
        <!-- configuration i18n -->
        <bean id="i18nUtils" class="org.splat.i18n.I18nUtils">
-               <property name="resourceBundleMessageSource"
-                       ref="messageSource" />
+               <property name="resourceBundleMessageSource" ref="messageSource" />
        </bean>
 
        <bean id="messageSource"
@@ -31,10 +29,10 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                </property>
        </bean>
        <!-- ref 'baseMessageSource' into Siman-common\src\spring\globalContext.xml -->
-       <!-- property name="parentMessageSource" ref="baseMessageSource"/-->
+       <!-- property name="parentMessageSource" ref="baseMessageSource"/ -->
 
-       <bean id="applicationSettings"
-               class="org.splat.simer.ApplicationSettings">
+       <bean id="applicationSettings" class="org.splat.simer.ApplicationSettings"
+               factory-method="getMe">
                <property name="projectSettings" ref="projectSettings" />
                <property name="documentTypeService" ref="documentTypeService" />
        </bean>
@@ -43,69 +41,63 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                scope="prototype" />
 
        <bean id="slidMenu" scope="session" abstract="true">
-               <property name="projectElementService"
-                       ref="projectElementService" />
+               <property name="projectElementService" ref="projectElementService" />
                <property name="scenarioService" ref="scenarioService" />
        </bean>
 
-       <bean id="studyMenu" class="org.splat.simer.StudyMenu"
-               scope="session" parent="slidMenu" />
+       <bean id="studyMenu" class="org.splat.simer.StudyMenu" scope="session"
+               parent="slidMenu" />
 
        <bean id="newScenarioMenu" class="org.splat.simer.NewScenarioMenu"
                scope="session" parent="slidMenu" />
 
-       <bean id="openObject" abstract="true"
-               class="org.splat.simer.OpenObject" scope="session">
-               <property name="projectElementService"
-                       ref="projectElementService" />
+       <bean id="openObject" abstract="true" class="org.splat.simer.OpenObject"
+               scope="session">
+               <property name="projectElementService" ref="projectElementService" />
                <property name="projectSettings" ref="projectSettings" />
-               <property name="knowledgeElementTypeService"
-                       ref="knowledgeElementTypeService" />
+               <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
        </bean>
 
-       <bean id="openStudy" class="org.splat.simer.OpenStudy"
-               parent="openObject" scope="session">
-               <property name="projectElementService"
-                       ref="projectElementService" />
+       <bean id="openStudy" class="org.splat.simer.OpenStudy" parent="openObject"
+               scope="session">
+               <property name="projectElementService" ref="projectElementService" />
                <property name="publicationService" ref="publicationService" />
                <property name="studyService" ref="studyService" />
                <property name="stepService" ref="stepService" />
                <property name="repositoryService" ref="repositoryService" />
                <property name="menu" ref="studyMenu" />
                <property name="documentTypeService" ref="documentTypeService" />
+        <property name="documentService" ref="documentService" />
        </bean>
 
        <bean id="openKnowledge" class="org.splat.simer.OpenKnowledge"
                parent="openObject" scope="session">
        </bean>
 
-       <bean id="baseAction" class="org.splat.simer.Action"
-               scope="prototype" abstract="true">
+       <bean id="baseAction" class="org.splat.simer.Action" scope="prototype"
+               abstract="true">
                <property name="openStudy" ref="openStudy" />
                <property name="openKnowledge" ref="openKnowledge" />
        </bean>
 
-       <!--========= Inherited from baseAction =========-->
+       <!--========= Inherited from baseAction ========= -->
 
        <bean id="newStudyAction" class="org.splat.simer.NewStudyAction"
                parent="baseAction" scope="prototype">
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
+               <property name="simulationContextService" ref="simulationContextService" />
+               <property name="scenarioService" ref="scenarioService" />
                <property name="studyService" ref="studyService" />
        </bean>
 
-       <bean id="newScenarioAction"
-               class="org.splat.simer.NewScenarioAction" parent="baseAction"
-               scope="prototype">
-               <property name="projectElementService"
-                       ref="projectElementService" />
+       <bean id="newScenarioAction" class="org.splat.simer.NewScenarioAction"
+               parent="baseAction" scope="prototype">
+               <property name="projectElementService" ref="projectElementService" />
                <property name="scenarioService" ref="scenarioService" />
                <property name="menu" ref="newScenarioMenu" />
        </bean>
 
-       <bean id="importDocumentAction"
-               class="org.splat.simer.ImportDocumentAction" scope="prototype"
-               parent="baseAction">
+       <bean id="importDocumentAction" class="org.splat.simer.ImportDocumentAction"
+               scope="prototype" parent="baseAction">
                <property name="stepService" ref="stepService" />
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
@@ -113,62 +105,52 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="documentTypeService" ref="documentTypeService" />
        </bean>
 
-       <bean id="displayStudyStepAction"
-               class="org.splat.simer.DisplayStudyStepAction" parent="baseAction"
-               scope="prototype">
+       <bean id="displayStudyStepAction" class="org.splat.simer.DisplayStudyStepAction"
+               parent="baseAction" scope="prototype">
                <property name="studyService" ref="studyService" />
        </bean>
 
-       <!--========= Inherited from displayStudyStepAction =========-->
+       <!--========= Inherited from displayStudyStepAction ========= -->
 
-       <bean id="studyPropertiesAction"
-               class="org.splat.simer.StudyPropertiesAction" scope="prototype"
-               parent="displayStudyStepAction">
+       <bean id="studyPropertiesAction" class="org.splat.simer.StudyPropertiesAction"
+               scope="prototype" parent="displayStudyStepAction">
                <property name="documentTypeService" ref="documentTypeService" />
+        <property name="userService" ref="userService" />
        </bean>
 
        <bean id="editStudyAction" class="org.splat.simer.EditStudyAction"
                scope="prototype" parent="displayStudyStepAction">
        </bean>
 
-       <bean id="editScenarioPropertiesAction"
-               class="org.splat.simer.EditScenarioPropertiesAction" scope="prototype"
-               parent="displayStudyStepAction">
-               <property name="projectElementService"
-                       ref="projectElementService" />
+       <bean id="editScenarioPropertiesAction" class="org.splat.simer.EditScenarioPropertiesAction"
+               scope="prototype" parent="displayStudyStepAction">
+               <property name="projectElementService" ref="projectElementService" />
                <property name="scenarioService" ref="scenarioService" />
        </bean>
 
-       <bean id="editSimulationContextAction"
-               class="org.splat.simer.EditSimulationContextAction" scope="prototype"
-               parent="displayStudyStepAction">
+       <bean id="editSimulationContextAction" class="org.splat.simer.EditSimulationContextAction"
+               scope="prototype" parent="displayStudyStepAction">
                <property name="stepService" ref="stepService" />
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
+               <property name="simulationContextService" ref="simulationContextService" />
        </bean>
 
-       <bean id="editDocumentAction"
-               class="org.splat.simer.EditDocumentAction" scope="prototype"
-               parent="displayStudyStepAction">
+       <bean id="editDocumentAction" class="org.splat.simer.EditDocumentAction"
+               scope="prototype" parent="displayStudyStepAction">
                <property name="stepService" ref="stepService" />
                <property name="publicationService" ref="publicationService" />
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
-       <bean id="editKnowledgeElementAction"
-               class="org.splat.simer.EditKnowledgeElementAction" scope="prototype"
-               parent="displayStudyStepAction">
-               <property name="knowledgeElementService"
-                       ref="knowledgeElementService" />
-               <property name="knowledgeElementTypeService"
-                       ref="knowledgeElementTypeService" />
+       <bean id="editKnowledgeElementAction" class="org.splat.simer.EditKnowledgeElementAction"
+               scope="prototype" parent="displayStudyStepAction">
+               <property name="knowledgeElementService" ref="knowledgeElementService" />
+               <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
                <property name="scenarioService" ref="scenarioService" />
        </bean>
 
        <!-- End of Inherited from displayStudyStepAction -->
 
-       <bean id="startAction" class="org.splat.simer.StartAction"
-               scope="prototype">
+       <bean id="startAction" class="org.splat.simer.StartAction" scope="prototype">
                <property name="applicationSettings" ref="applicationSettings" />
                <property name="projectSettings" ref="projectSettings" />
        </bean>
@@ -176,39 +158,36 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                scope="prototype">
        </bean>
 
-       <bean id="menuAction" class="org.splat.simer.MenuAction"
-               scope="prototype">
+       <bean id="menuAction" class="org.splat.simer.MenuAction" scope="prototype">
        </bean>
 
-       <bean id="notYetImplementedAction"
-               class="org.splat.simer.NotYetImplementedAction" scope="prototype">
+       <bean id="notYetImplementedAction" class="org.splat.simer.NotYetImplementedAction"
+               scope="prototype">
        </bean>
 
-       <bean id="searchStudyAction"
-               class="org.splat.simer.SearchStudyAction" scope="prototype">
+       <bean id="searchStudyAction" class="org.splat.simer.SearchStudyAction"
+               scope="prototype">
                <property name="projectSettings" ref="projectSettings" />
                <property name="searchService" ref="searchService" />
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
+               <property name="simulationContextService" ref="simulationContextService" />
+        <property name="userService" ref="userService" />
        </bean>
 
-       <bean id="searchKnowledgeAction"
-               class="org.splat.simer.SearchKnowledgeAction" scope="prototype">
+       <bean id="searchKnowledgeAction" class="org.splat.simer.SearchKnowledgeAction"
+               scope="prototype">
                <property name="searchService" ref="searchService" />
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
-               <property name="knowledgeElementTypeService"
-                       ref="knowledgeElementTypeService" />
+               <property name="simulationContextService" ref="simulationContextService" />
+               <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
+        <property name="userService" ref="userService" />
        </bean>
 
-       <bean id="searchDocumentAction"
-               class="org.splat.simer.SearchDocumentAction" scope="prototype">
+       <bean id="searchDocumentAction" class="org.splat.simer.SearchDocumentAction"
+               scope="prototype">
        </bean>
 
-       <bean id="displayKnowledgeAction"
-               class="org.splat.simer.DisplayKnowledgeAction" scope="prototype">
-               <property name="knowledgeElementService"
-                       ref="knowledgeElementService" />
+       <bean id="displayKnowledgeAction" class="org.splat.simer.DisplayKnowledgeAction"
+               scope="prototype">
+               <property name="knowledgeElementService" ref="knowledgeElementService" />
        </bean>
 
        <bean id="uploadAction" class="org.splat.simer.UploadAction"
@@ -216,52 +195,47 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
-       <bean id="versionDocumentAction"
-               class="org.splat.simer.VersionDocumentAction" scope="prototype">
+       <bean id="versionDocumentAction" class="org.splat.simer.VersionDocumentAction"
+               scope="prototype">
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
                <property name="stepService" ref="stepService" />
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
-       <bean id="databaseIndexingAction"
-               class="org.splat.simer.admin.DatabaseIndexingAction"
+       <bean id="databaseIndexingAction" class="org.splat.simer.admin.DatabaseIndexingAction"
                scope="prototype">
                <property name="studyService" ref="studyService" />
                <property name="importedStudy" ref="importedStudy" />
                <property name="searchService" ref="searchService" />
        </bean>
 
-       <bean id="importUserAction"
-               class="org.splat.simer.admin.ImportUserAction" scope="prototype">
+       <bean id="importUserAction" class="org.splat.simer.admin.ImportUserAction"
+               scope="prototype">
                <property name="repositoryService" ref="repositoryService" />
+        <property name="userService" ref="userService" />
        </bean>
 
-       <bean id="simulationContextAction"
-               class="org.splat.simer.admin.SimulationContextAction"
+       <bean id="simulationContextAction" class="org.splat.simer.admin.SimulationContextAction"
                scope="prototype">
-               <property name="knowledgeElementService"
-                       ref="knowledgeElementService" />
+               <property name="knowledgeElementService" ref="knowledgeElementService" />
                <property name="searchService" ref="searchService" />
                <property name="projectSettings" ref="projectSettings" />
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
+               <property name="simulationContextService" ref="simulationContextService" />
        </bean>
 
-       <bean id="knowledgeElementAction"
-               class="org.splat.simer.admin.KnowledgeElementAction"
+       <bean id="knowledgeElementAction" class="org.splat.simer.admin.KnowledgeElementAction"
                scope="prototype">
        </bean>
 
-       <bean id="saveDocumentAction"
-               class="org.splat.module.SaveDocumentAction" scope="prototype">
+       <bean id="saveDocumentAction" class="org.splat.module.SaveDocumentAction"
+               scope="prototype">
                <property name="documentTypeService" ref="documentTypeService" />
                <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" />
+               <property name="simulationContextService" ref="simulationContextService" />
        </bean>
 
 </beans>