]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Modifications done to respect PMD rules. Versioning a document is fixed. Validation...
authorrkv <rkv@opencascade.com>
Wed, 7 Nov 2012 08:01:13 +0000 (08:01 +0000)
committerrkv <rkv@opencascade.com>
Wed, 7 Nov 2012 08:01:13 +0000 (08:01 +0000)
117 files changed:
Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AbstractDatabase.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AbstractGenericDAOImpl.java [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AnyDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AnyDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AttributeDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AttributeDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/EntityDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/EntityDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAOImpl.java [deleted file]
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/PersistentDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/PersistentDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/RoleDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/TextAttributeDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/UserDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/CommentAttributeDAO.java [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/dal/dao/som/CommentAttributeDAOImpl.java [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ContributorRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ConvertsRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/Database.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/DescriptionAttributeDAO.java [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/dal/dao/som/DescriptionAttributeDAOImpl.java [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/DocumentTypeDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/FileDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/IDBuilderDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementTypeDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ProjectElementDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ProjectElementDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/PublicationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ScenarioDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/SimulationContextTypeDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/StampRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/StudyDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/TimestampDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/UsedByRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/UsesRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/ValidationCycleRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/VersionsRelationDAOImpl.java
Workspace/Siman-Common/src/org/splat/kernel/Do.java
Workspace/Siman-Common/src/org/splat/kernel/MismatchException.java
Workspace/Siman-Common/src/org/splat/kernel/MultiplyDefinedException.java
Workspace/Siman-Common/src/org/splat/kernel/RealmLoginModule.java
Workspace/Siman-Common/src/org/splat/service/DocumentService.java
Workspace/Siman-Common/src/org/splat/service/DocumentServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/DocumentTypeService.java
Workspace/Siman-Common/src/org/splat/service/DocumentTypeServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/KnowledgeElementService.java
Workspace/Siman-Common/src/org/splat/service/KnowledgeElementServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/KnowledgeElementTypeService.java
Workspace/Siman-Common/src/org/splat/service/LockServiceImpl.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/SearchService.java
Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.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/SimulationContextTypeService.java
Workspace/Siman-Common/src/org/splat/service/StepService.java
Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/StudyService.java
Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/UserService.java
Workspace/Siman-Common/src/org/splat/service/UserServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/UtilServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/dto/KnowledgeElementTypeDTO.java
Workspace/Siman-Common/src/org/splat/service/dto/Proxy.java
Workspace/Siman-Common/src/org/splat/service/dto/RoleDTO.java
Workspace/Siman-Common/src/org/splat/service/dto/SimulationContextFacade.java
Workspace/Siman-Common/src/org/splat/service/dto/UserDTO.java
Workspace/Siman-Common/src/org/splat/service/technical/IndexServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsService.java
Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsServiceImpl.java
Workspace/Siman-Common/src/org/splat/som/ApplicationRights.java
Workspace/Siman-Common/src/org/splat/som/Revision.java
Workspace/Siman-Common/src/org/splat/som/Step.java
Workspace/Siman-Common/src/org/splat/som/StepRights.java
Workspace/Siman-Common/src/org/splat/som/StudyRights.java
Workspace/Siman-Common/src/org/splat/util/DTOTransformer.java
Workspace/Siman-Common/src/spring/daoContext.xml
Workspace/Siman-Common/src/spring/globalContext.xml
Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Workspace/Siman/src/org/splat/simer/OpenObject.java

index d312469cc8cdc90710ad309045b79ec575ac0c1e..bb5d140241fc3b18fbfd838159b63c6fdb3fc772 100644 (file)
@@ -289,8 +289,8 @@ public class Document extends Entity {
                }
        }
 
-       // Database fetch constructor
        protected Document() {
+               // Database fetch constructor
        }
 
        // Internal constructor
@@ -363,10 +363,10 @@ public class Document extends Entity {
        public Document getPreviousVersion() {
                // -------------------------------------
                Relation previous = getFirstRelation(VersionsRelation.class);
-               if (previous != null) {
-                       return (Document) previous.getTo();
-               } else {
+               if (previous == null) {
                        return null;
+               } else {
+                       return (Document) previous.getTo();
                }
        }
 
index 0bfef74287bea3caa553a0c816a0b2d8debdbf7a..2f2487769e8c64306b003efe33af9bb78ad96a25 100644 (file)
@@ -21,8 +21,8 @@ public abstract class AbstractDatabase extends HibernateDaoSupport {
                return res;// TODO: Get schema version from the specific object/table
        }
 
-       protected void setSchemaVersion(final String version) {
-               // TODO: Set schema version into specific object/table: myIDpool = new IDPool(version);
+       protected void setSchemaVersion(final String version) { // RKV: NOPMD: TODO: Set schema version into specific object/table
+               // RKV: NOPMD: TODO: Set schema version into specific object/table: myIDpool = new IDPool(version);
                // getSession().save(myIDpool);
        }
 }
\ No newline at end of file
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AbstractGenericDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/AbstractGenericDAOImpl.java
new file mode 100644 (file)
index 0000000..b1276d2
--- /dev/null
@@ -0,0 +1,234 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   08.10.2012
+ * @author         $Author$
+ * @version        $Revision$
+ *****************************************************************************/
+
+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;
+
+/**
+ * Generic DAO implementation.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ * 
+ * @param <T>
+ *            Persistent object class
+ * @param <PK>
+ *            Primary key class
+ */
+public abstract class AbstractGenericDAOImpl<T, PK extends Serializable> extends
+               HibernateDaoSupport implements GenericDAO<T, PK> {
+       /**
+        * Unchecked warning specification.
+        */
+       private static final String UNCHECKED = "unchecked";
+       /**
+        * Persist the newInstance object into database.
+        * 
+        * @param newInstance
+        *            new object as a transient instance
+        * @return new primary key for the created persistent object
+        */
+       @SuppressWarnings(UNCHECKED)
+       public PK create(final T newInstance) {
+               return (PK) getSession().save(newInstance);
+       }
+
+       /**
+        * Retrieve an object that was previously persisted to the database using the indicated id as primary key.
+        * 
+        * @param id
+        *            primary key of an object to read
+        * @return an object found by the given key
+        */
+       @SuppressWarnings(UNCHECKED)
+       public T get(final PK id) {
+               return (T) getSession().get(getType(), id);
+       }
+
+       /**
+        * Retrieve an object that was previously persisted to the database using the given criteria.
+        * 
+        * @param aCondition
+        *            a search condition
+        * @return an object found according to the given criteria
+        */
+       @SuppressWarnings(UNCHECKED)
+       public T findByCriteria(final Criterion aCondition) {
+               return (T) getSession().createCriteria(getType()).add(aCondition)
+                               .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(final 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.
+        * 
+        * @return a list of all objects of the considered type T
+        */
+       @SuppressWarnings(UNCHECKED)
+       public List<T> getAll() {
+               return getSession().createCriteria(getType()).list();
+       }
+
+       /**
+        * Retrieve an ordered list of all objects of the considered type T which were previously persisted to the database.
+        * 
+        * @param anOrder
+        *            a result list order. Null is ignored and in such case the result list is unordered.
+        * @return an ordered list of all objects of the considered type T
+        */
+       @SuppressWarnings(UNCHECKED)
+       public List<T> getAll(final Order ... anOrder) {
+               Criteria aCriteria = getSession().createCriteria(getType());
+               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 aCondition
+        *            a search condition
+        * @return a list of objects filtered according to the given criteria
+        */
+       @SuppressWarnings(UNCHECKED)
+       public List<T> getFilteredList(final Criterion aCondition) {
+               return getSession().createCriteria(getType()).add(aCondition).list();
+       }
+
+       /**
+        * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+        * 
+        * @param aCondition
+        *            a search condition
+        * @param anOrder
+        *            a result list order. Null is ignored and in such case the result list is unordered.
+        * @return a list of objects filtered according to the given criteria
+        */
+       @SuppressWarnings(UNCHECKED)
+       public List<T> getFilteredList(final Criterion aCondition, final Order ... anOrder) {
+               Criteria aCriteria = getSession().createCriteria(getType()).add(
+                               aCondition);
+               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(final 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(final Properties andParams, final 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.
+        * 
+        * @param transientObject
+        *            transient instance of the object to update
+        */
+       public void update(final T transientObject) {
+               getSession().update(transientObject);
+       }
+
+       /**
+        * Remove an object from persistent storage in the database.
+        * 
+        * @param persistentObject
+        *            a persistent object to delete from the database
+        */
+       public void delete(final T persistentObject) {
+               getSession().delete(persistentObject);
+       }
+
+       /**
+        * Makes detached object persistent.
+        * 
+        * @param transientObject
+        *            transient instance of the object to be made persistent
+        */
+       public void persist(final T transientObject) {
+               getSession().persist(transientObject);
+       }
+
+       /**
+        * Merge detached object with persistent data.
+        * 
+        * @param transientObject
+        *            transient instance of the object to be merged with persistent data
+        * @return merged persistent object
+        */
+       @SuppressWarnings(UNCHECKED)
+       public T merge(final T transientObject) {
+               return (T) getSession().merge(transientObject);
+       }
+
+       /**
+        * Synchronize the session data with the database.
+        */
+       public void flush() {
+               getSession().flush();
+       }
+
+       /**
+        * Get persistent object type.
+        * 
+        * @return Persistent object class to be processed by this DAO
+        */
+       abstract protected Class<T> getType();
+}
\ No newline at end of file
index 1afa838471eb3cf6e9a7d08494e26212d11f33f8..ed354a2f6b5845f80965e2658e3d2543bb79c911 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel; 
 
 import org.splat.dal.bo.kernel.Any;
-import org.splat.dal.dao.kernel.GenericDAO;
 
 /**
  * Any DAO class implementation.
index 2a8d6461af891e4f832f299a686023186b266696..ecdc7b50770904847fe9b4231eae9eeef16e4f7f 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel;
 
 import org.splat.dal.bo.kernel.Any;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
 
 /**
  * Any DAO.
@@ -19,11 +18,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class AnyDAOImpl extends
-               GenericDAOImpl<Any, Long> implements AnyDAO {
+               AbstractGenericDAOImpl<Any, Long> implements AnyDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<Any> getType() {
index 22e7036b65d1ca048112c9347780d95e49ea334e..533f9c9ded543481bcdc44e02740d8dc4eeac34c 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel; 
 
 import org.splat.dal.bo.kernel.Attribute;
-import org.splat.dal.dao.kernel.GenericDAO;
 
 /**
  * Attribute DAO class implementation.
index fc639d1efdcddf72b96fb3847025d3fc4ebbc00d..41576bf8d715fb9e52613460ea50f977dc7c7443 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel;
 
 import org.splat.dal.bo.kernel.Attribute;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
 
 /**
  * Attribute DAO.
@@ -19,11 +18,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class AttributeDAOImpl extends
-               GenericDAOImpl<Attribute, Long> implements AttributeDAO {
+               AbstractGenericDAOImpl<Attribute, Long> implements AttributeDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<Attribute> getType() {
index 9b219dc4393cece7857096fc085c92308a2ab1bd..aa8d3a1b62d820e794ae665b67102150425b19d3 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel; 
 
 import org.splat.dal.bo.kernel.Entity;
-import org.splat.dal.dao.kernel.GenericDAO;
 
 /**
  * Entity DAO class implementation.
index 62e383b12142d8d8817b8867d001aa581b12ef1c..1f2e911112935f1484e52ca730d17d554fab9abd 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel;
 
 import org.splat.dal.bo.kernel.Entity;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
 
 /**
  * Entity DAO.
@@ -19,11 +18,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class EntityDAOImpl extends
-               GenericDAOImpl<Entity, Long> implements EntityDAO {
+               AbstractGenericDAOImpl<Entity, Long> implements EntityDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<Entity> getType() {
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAOImpl.java
deleted file mode 100644 (file)
index 55ed8bb..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/*****************************************************************************
- * Company         OPEN CASCADE
- * Application     SIMAN
- * File            $Id$ 
- * Creation date   08.10.2012
- * @author         $Author$
- * @version        $Revision$
- *****************************************************************************/
-
-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;
-
-/**
- * Generic DAO implementation.
- * 
- * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
- * 
- * @param <T>
- *            Persistent object class
- * @param <PK>
- *            Primary key class
- */
-public abstract class GenericDAOImpl<T, PK extends Serializable> extends
-               HibernateDaoSupport implements GenericDAO<T, PK> {
-       /**
-        * Persist the newInstance object into database.
-        * 
-        * @param newInstance
-        *            new object as a transient instance
-        * @return new primary key for the created persistent object
-        */
-       @SuppressWarnings("unchecked")
-       public PK create(T newInstance) {
-               return (PK) getSession().save(newInstance);
-       }
-
-       /**
-        * Retrieve an object that was previously persisted to the database using the indicated id as primary key.
-        * 
-        * @param id
-        *            primary key of an object to read
-        * @return an object found by the given key
-        */
-       @SuppressWarnings("unchecked")
-       public T get(PK id) {
-               return (T) getSession().get(getType(), id);
-       }
-
-       /**
-        * Retrieve an object that was previously persisted to the database using the given criteria.
-        * 
-        * @param aCondition
-        *            a search condition
-        * @return an object found according to the given criteria
-        */
-       @SuppressWarnings("unchecked")
-       public T findByCriteria(Criterion aCondition) {
-               return (T) getSession().createCriteria(getType()).add(aCondition)
-                               .uniqueResult();
-       }
-
-       /**
-        * Retrieve 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.
-        * 
-        * @return a list of all objects of the considered type T
-        */
-       @SuppressWarnings("unchecked")
-       public List<T> getAll() {
-               return getSession().createCriteria(getType()).list();
-       }
-
-       /**
-        * Retrieve an ordered list of all objects of the considered type T which were previously persisted to the database.
-        * 
-        * @param anOrder
-        *            a result list order. Null is ignored and in such case the result list is unordered.
-        * @return an ordered list of all objects of the considered type T
-        */
-       @SuppressWarnings("unchecked")
-       public List<T> getAll(Order ... anOrder) {
-               Criteria aCriteria = getSession().createCriteria(getType());
-               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 aCondition
-        *            a search condition
-        * @return a list of objects filtered according to the given criteria
-        */
-       @SuppressWarnings("unchecked")
-       public List<T> getFilteredList(Criterion aCondition) {
-               return getSession().createCriteria(getType()).add(aCondition).list();
-       }
-
-       /**
-        * Retrieve a list of objects which were previously persisted to the database using the given criteria.
-        * 
-        * @param aCondition
-        *            a search condition
-        * @param anOrder
-        *            a result list order. Null is ignored and in such case the result list is unordered.
-        * @return a list of objects filtered according to the given criteria
-        */
-       @SuppressWarnings("unchecked")
-       public List<T> getFilteredList(Criterion aCondition, Order ... anOrder) {
-               Criteria aCriteria = getSession().createCriteria(getType()).add(
-                               aCondition);
-               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.
-        * 
-        * @param transientObject
-        *            transient instance of the object to update
-        */
-       public void update(T transientObject) {
-               getSession().update(transientObject);
-       }
-
-       /**
-        * Remove an object from persistent storage in the database.
-        * 
-        * @param persistentObject
-        *            a persistent object to delete from the database
-        */
-       public void delete(T persistentObject) {
-               getSession().delete(persistentObject);
-       }
-
-       /**
-        * Makes detached object persistent.
-        * 
-        * @param transientObject
-        *            transient instance of the object to be made persistent
-        */
-       public void persist(T transientObject) {
-               getSession().persist(transientObject);
-       }
-
-       /**
-        * Merge detached object with persistent data.
-        * 
-        * @param transientObject
-        *            transient instance of the object to be merged with persistent data
-        * @return merged persistent object
-        */
-       @SuppressWarnings("unchecked")
-       public T merge(T transientObject) {
-               return (T) getSession().merge(transientObject);
-       }
-
-       /**
-        * Synchronize the session data with the database.
-        */
-       public void flush() {
-               getSession().flush();
-       }
-
-       /**
-        * Get persistent object type.
-        * 
-        * @return Persistent object class to be processed by this DAO
-        */
-       abstract protected Class<T> getType();
-}
\ No newline at end of file
index a7ad02f6bcfe1297e5b11bc78466d04b7dd1799e..31d22ec126eaae9ab66e76747f5a1c4e37e4f9cc 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel; 
 
 import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.kernel.GenericDAO;
 
 /**
  * Persistent DAO class implementation.
index a95ea661658459435e969aaba90a4e8e7f4bab96..97b3df4f78b59f956af632a736df3099df4076d2 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel;
 
 import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
 
 /**
  * Persistent DAO.
@@ -19,11 +18,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class PersistentDAOImpl extends
-               GenericDAOImpl<Persistent, Long> implements PersistentDAO {
+               AbstractGenericDAOImpl<Persistent, Long> implements PersistentDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<Persistent> getType() {
index 10820f10b6afdd346050b337756994dd9e1da93f..7670ff099b19d01fa42e6086287fb28472cee40f 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel; 
 
 import org.splat.dal.bo.kernel.Relation;
-import org.splat.dal.dao.kernel.GenericDAO;
 
 /**
  * Relation DAO class implementation.
index 2e785228302243e031b844be86a539ecfb62d73f..5843cfd14dc7251583f011d44150330b6772f9e4 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel;
 
 import org.splat.dal.bo.kernel.Relation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
 
 /**
  * Relation DAO.
@@ -19,11 +18,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class RelationDAOImpl extends
-               GenericDAOImpl<Relation, Long> implements RelationDAO {
+               AbstractGenericDAOImpl<Relation, Long> implements RelationDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<Relation> getType() {
index 900f464aa12e46e35a75e6bb6ef3e441bca6ffb5..826504bfc0b738428e6d63ac9401d4a19baae61b 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel; 
 
 import org.splat.dal.bo.kernel.Role;
-import org.splat.dal.dao.kernel.GenericDAO;
 
 /**
  * Role DAO class implementation.
index 732abb28ea0fd3d10d4ad56b6bbf46c79458c8dd..bb4659ee9d7c9d800990e3df2bc6ac9f4107b734 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel;
 
 import org.splat.dal.bo.kernel.Role;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
 
 /**
  * Role DAO.
@@ -19,11 +18,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class RoleDAOImpl extends
-               GenericDAOImpl<Role, Long> implements RoleDAO {
+               AbstractGenericDAOImpl<Role, Long> implements RoleDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<Role> getType() {
index 6e463900ada28eb4b183cbdfa10f8f7782e44ecd..304d2f2b7d5f9b728c635aeff28e80c7c29179ff 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel; 
 
 import org.splat.dal.bo.kernel.TextAttribute;
-import org.splat.dal.dao.kernel.GenericDAO;
 
 /**
  * TextAttribute DAO class implementation.
index eef3992fa163fbc8f9ad51832628bf96ed666f49..af30aa2c506d9239a1cc7e14158727217f73f108 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel;
 
 import org.splat.dal.bo.kernel.TextAttribute;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
 
 /**
  * TextAttribute DAO.
@@ -19,11 +18,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class TextAttributeDAOImpl extends
-               GenericDAOImpl<TextAttribute, Long> implements TextAttributeDAO {
+               AbstractGenericDAOImpl<TextAttribute, Long> implements TextAttributeDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<TextAttribute> getType() {
index 3bb4f41d6e02f74bcaf05121fa0c517862c70d9f..a560c946330cd3278de907b3d769572a8c00b44f 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel; 
 
 import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.kernel.GenericDAO;
 
 /**
  * User DAO class implementation.
index be184408e235df5e8d63b1817885561da0ed6958..04c4bbc8050080a5547d1a933b1defde8937f7b8 100644 (file)
@@ -5,13 +5,12 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.kernel;
 
 import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
 
 /**
  * User DAO.
@@ -19,11 +18,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class UserDAOImpl extends
-               GenericDAOImpl<User, Long> implements UserDAO {
+               AbstractGenericDAOImpl<User, Long> implements UserDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<User> getType() {
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/CommentAttributeDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/CommentAttributeDAO.java
new file mode 100644 (file)
index 0000000..a96aa45
--- /dev/null
@@ -0,0 +1,22 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   06.10.2012
+ * @author         $Author$
+ * @version        $Revision$
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
+ *****************************************************************************/
+
+package org.splat.dal.dao.som; 
+
+import org.splat.dal.bo.som.CommentAttribute;
+import org.splat.dal.dao.kernel.GenericDAO;
+
+/**
+ * CommentAttribute DAO class implementation.
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ *
+ */
+public interface CommentAttributeDAO extends GenericDAO<CommentAttribute, Long> {
+}
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/CommentAttributeDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/CommentAttributeDAOImpl.java
new file mode 100644 (file)
index 0000000..00e68b6
--- /dev/null
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   06.10.2012
+ * @author         $Author$
+ * @version        $Revision$
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
+ *****************************************************************************/
+
+package org.splat.dal.dao.som;
+
+import org.splat.dal.bo.som.CommentAttribute;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
+
+/**
+ * CommentAttribute DAO.
+ * @author RKV
+ * 
+ */
+public class CommentAttributeDAOImpl extends
+               AbstractGenericDAOImpl<CommentAttribute, Long> implements CommentAttributeDAO {
+
+       /** 
+        * {@inheritDoc}
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
+        */
+       @Override
+       protected Class<CommentAttribute> getType() {
+               return CommentAttribute.class;
+       }
+
+}
\ No newline at end of file
index 4ca3260a6240443a294dcc3a5187b1ad818beddf..b083ab63a70cd755f1f108ca88265866a8b82687 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index e908dfb90cecf7c2c0b52ae680cd2bc0be049ee5..6245113882d972aef17c70eefeb9983fcfc12ef0 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.ContributorRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * ContributorRelation DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class ContributorRelationDAOImpl extends
-               GenericDAOImpl<ContributorRelation, Long> implements ContributorRelationDAO {
+               AbstractGenericDAOImpl<ContributorRelation, Long> implements ContributorRelationDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<ContributorRelation> getType() {
index 4cd4c873363c46caf51d75ea0d641b6808103772..d71c4394a9820bdccdfdae1dfe4f8fb950ef20c9 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 43c5e54d9ba6f6caf329c2adf5fbaa841df0f307..919cdd0f8b4c4c3a9e1df6683fcb937aa57a7387 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.ConvertsRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * ConvertsRelation DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class ConvertsRelationDAOImpl extends
-               GenericDAOImpl<ConvertsRelation, Long> implements ConvertsRelationDAO {
+               AbstractGenericDAOImpl<ConvertsRelation, Long> implements ConvertsRelationDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<ConvertsRelation> getType() {
index c87860648ea6377318c57020d3eb65b8f246574d..ec6639d8e652b548b14158617b287864727d73cd 100644 (file)
@@ -24,7 +24,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 public class Database extends org.splat.dal.dao.kernel.AbstractDatabase {
 
-       private int uplevel = 0; // Level of database upgrade
+       public final static Logger LOG = org.splat.dal.dao.som.Database.LOG;
+
+       private transient int _uplevel = 0; // Level of database upgrade
        private RepositoryService _repositoryService;
        private IndexService _indexService;
        private UserService _userService;
@@ -40,33 +42,38 @@ public class Database extends org.splat.dal.dao.kernel.AbstractDatabase {
        protected class CheckVersion implements Work {
                /** 
                 * {@inheritDoc}
+                * @throws SQLException 
                 * @see org.hibernate.jdbc.Work#execute(java.sql.Connection)
                 */
                public void execute(final Connection connex) throws SQLException {
                        DatabaseMetaData dbmdata = connex.getMetaData();
                        String dbname = connex.getCatalog();
-                       ResultSet table;
+                       ResultSet table = null;
 
-                       table = dbmdata.getTables(dbname, null, "study", null);
-                       if (table.next()) {
-                               return;
+                       try {
+                               table = dbmdata.getTables(dbname, null, "study", null);
+                               if (table.next()) {
+                                       return;
+                               }
+                       } catch (SQLException e) {
+                               LOG.debug("Can't check the database version: ", e);
+                               throw e;
+                       } finally {
+                               if (table != null) {
+                                       table.close();
+                               }
                        }
-                       uplevel = -1; // Database not initialized
+                       _uplevel = -1; // Database not initialized
                }
        }
 
-       public final static Logger logger = org.splat.dal.dao.som.Database.logger;
-
        // ==============================================================================================================================
        // Construction
        // ==============================================================================================================================
 
-       private static Database myDB;
+       private static Database myDB = new Database();
 
        public static Database getInstance() {
-               if (myDB == null) {
-                       myDB = new Database();
-               }
                return myDB; 
        }
        
@@ -80,7 +87,7 @@ public class Database extends org.splat.dal.dao.kernel.AbstractDatabase {
                                my = this;
                                my.checkVersion();
                        } catch (Exception error) {
-                               logger.fatal("Could not access the database, reason:", error);
+                               LOG.fatal("Could not access the database, reason:", error);
                        }
                }
                return my;
@@ -102,11 +109,11 @@ public class Database extends org.splat.dal.dao.kernel.AbstractDatabase {
        // ==============================================================================================================================
 
        public boolean isInitialized() {
-               return (uplevel >= 0);
+               return (_uplevel >= 0);
        }
 
        public void initialize() throws IOException, SQLException {
-               logger.info("Creation of the database.");
+               LOG.info("Creation of the database.");
 
                // Creation of the Lucene index
                getIndexService().create(); // May throw IOException if the index repository is improperly configured
@@ -116,7 +123,7 @@ public class Database extends org.splat.dal.dao.kernel.AbstractDatabase {
                // Population of the database with customized data
                this.populate();
 
-               uplevel = 0; // The database is now up-to-date
+               _uplevel = 0; // The database is now up-to-date
        }
 
        // ==============================================================================================================================
@@ -145,6 +152,7 @@ public class Database extends org.splat.dal.dao.kernel.AbstractDatabase {
                        getUserService().createUser(uprop);
                } catch (Exception e) {
                        // Let's continue, hoping the best...
+                       LOG.debug(e.getMessage(), e);
                }
        }
 
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/DescriptionAttributeDAO.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/DescriptionAttributeDAO.java
new file mode 100644 (file)
index 0000000..c064f0b
--- /dev/null
@@ -0,0 +1,22 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   06.10.2012
+ * @author         $Author$
+ * @version        $Revision$
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
+ *****************************************************************************/
+
+package org.splat.dal.dao.som; 
+
+import org.splat.dal.bo.som.DescriptionAttribute;
+import org.splat.dal.dao.kernel.GenericDAO;
+
+/**
+ * DescriptionAttribute DAO class implementation.
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ *
+ */
+public interface DescriptionAttributeDAO extends GenericDAO<DescriptionAttribute, Long> {
+}
diff --git a/Workspace/Siman-Common/src/org/splat/dal/dao/som/DescriptionAttributeDAOImpl.java b/Workspace/Siman-Common/src/org/splat/dal/dao/som/DescriptionAttributeDAOImpl.java
new file mode 100644 (file)
index 0000000..fa2e3f8
--- /dev/null
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   06.10.2012
+ * @author         $Author$
+ * @version        $Revision$
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
+ *****************************************************************************/
+
+package org.splat.dal.dao.som;
+
+import org.splat.dal.bo.som.DescriptionAttribute;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
+
+/**
+ * DescriptionAttribute DAO.
+ * @author RKV
+ * 
+ */
+public class DescriptionAttributeDAOImpl extends
+               AbstractGenericDAOImpl<DescriptionAttribute, Long> implements DescriptionAttributeDAO {
+
+       /** 
+        * {@inheritDoc}
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
+        */
+       @Override
+       protected Class<DescriptionAttribute> getType() {
+               return DescriptionAttribute.class;
+       }
+
+}
\ No newline at end of file
index c56c7301e6783f9f4a64f26c1a9f3b6e64b3e18e..c43c21ad7a9be99f21e31e634bbb6619d2d49721 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 74a3b1680dda4e606a2bb06dc5a01d516a2733a2..34409147fa1befeda9ea136f33aea8b972a3d2a8 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.Document;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * Document DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class DocumentDAOImpl extends
-               GenericDAOImpl<Document, Long> implements DocumentDAO {
+               AbstractGenericDAOImpl<Document, Long> implements DocumentDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<Document> getType() {
index 2f47380eead0320387d96b6cd76b890032a56442..14e4110a9ff89ad9bb38d78d6ad8992ea78f7975 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 5004061ffc70e011f09996fc331ce3e712f496e7..0f35e8fed456f9886d4e50e0c5ab5089da810ea1 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.DocumentType;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * DocumentType DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class DocumentTypeDAOImpl extends
-               GenericDAOImpl<DocumentType, Long> implements DocumentTypeDAO {
+               AbstractGenericDAOImpl<DocumentType, Long> implements DocumentTypeDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<DocumentType> getType() {
index 9677aaaa50c8bcffecb10b32202153b9d15d4c86..d953284f1b14477667e2f39cb1643ebe0c96153d 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 3a0ed00c7aa089658ed2ab8ec74574f7e9c70436..e557d4bb51cdfa47433032b5a5f348ee22881e1c 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.File;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * File DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class FileDAOImpl extends
-               GenericDAOImpl<File, Long> implements FileDAO {
+               AbstractGenericDAOImpl<File, Long> implements FileDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<File> getType() {
index 96163ef975c80a4519ffab3d6bea68bde2c14e72..7f0b75424a685f4e96d9ebbb89414c532b1c7594 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index ca139e372f567afe5d157f0fa185cd5a6b40110d..1d178bb039500049e3dd3e1be7ffecd558142175 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.IDBuilder;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * IDBuilder DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class IDBuilderDAOImpl extends
-               GenericDAOImpl<IDBuilder, Long> implements IDBuilderDAO {
+               AbstractGenericDAOImpl<IDBuilder, Long> implements IDBuilderDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<IDBuilder> getType() {
index dcdc8ba90dc4d0fa6234037b429ae66aa8a429b6..571f2621f4d9cb7ba8eedc2ab5cf03677e7ea2db 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index d559ebc6e92ac48ecbe71c8bf0eaa012d3099144..925ff5fd45ab2a1d014b8a6053e5c035cbc55bd5 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.KnowledgeElement;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * KnowledgeElement DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class KnowledgeElementDAOImpl extends
-               GenericDAOImpl<KnowledgeElement, Long> implements KnowledgeElementDAO {
+               AbstractGenericDAOImpl<KnowledgeElement, Long> implements KnowledgeElementDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<KnowledgeElement> getType() {
index 1541a105faf0acf906c7fd23536058362f9fd75f..e99aafa2326df14adcd8a8b86af1adc53dd8c963 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 00590cc29b963f54810644d4c5ae8a83e197ec67..54f4f27677c9fd78d9b197a2bc9ceb17954abc07 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.KnowledgeElementType;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * KnowledgeElementType DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class KnowledgeElementTypeDAOImpl extends
-               GenericDAOImpl<KnowledgeElementType, Long> implements KnowledgeElementTypeDAO {
+               AbstractGenericDAOImpl<KnowledgeElementType, Long> implements KnowledgeElementTypeDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<KnowledgeElementType> getType() {
index 99218cd151cf97344f697f25f9ea948cb7286fe6..7c33c5ed457ded89f5376acf7b3a658daa3dcc22 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 7d660eac503bf0bc13af4c446ae2079ccc204d31..246bfa3e7c7d4d90e3e67163cb1642bcff4a6b4d 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.ProjectElement;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * ProjectElement DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class ProjectElementDAOImpl extends
-               GenericDAOImpl<ProjectElement, Long> implements ProjectElementDAO {
+               AbstractGenericDAOImpl<ProjectElement, Long> implements ProjectElementDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<ProjectElement> getType() {
index e25072a63efaf1a4155a1a424ea49083fe441fe7..49bc702f9cc83ec6e21488c3d551fef5201b687c 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index a5a70ec301d8c60806f128bb4a97e7c454f6166a..c013d72997c8c6e53ad0b5e7cef4873a5668eb90 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.Publication;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * Publication DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class PublicationDAOImpl extends
-               GenericDAOImpl<Publication, Long> implements PublicationDAO {
+               AbstractGenericDAOImpl<Publication, Long> implements PublicationDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<Publication> getType() {
index 8391883297afdca805a6a55b1ed8abbe2e518d11..b4f94c57d4d6b7daea6d82fceeb08ef9514ee1b7 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 920e530863c140328a81adb4673983c372a7b412..3697307b39a94d1893629648380f5410ad2eb4b3 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.Scenario;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * Scenario DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class ScenarioDAOImpl extends
-               GenericDAOImpl<Scenario, Long> implements ScenarioDAO {
+               AbstractGenericDAOImpl<Scenario, Long> implements ScenarioDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<Scenario> getType() {
index baef74ca7d1fc3ab8ea19aa6594481f81488a648..0484882a3c0fa660911af14a48e439b4a96356c6 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 4c1a7ecc7183d5b9d85c4ccd53b174ab1f85d053..2131193ab67b5937fe55049ac0e5df33d25c8c87 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.SimulationContext;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * SimulationContext DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class SimulationContextDAOImpl extends
-               GenericDAOImpl<SimulationContext, Long> implements SimulationContextDAO {
+               AbstractGenericDAOImpl<SimulationContext, Long> implements SimulationContextDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<SimulationContext> getType() {
index bd1ad8cd5379e89305b817e8d212fc17b8585a97..3c8aa68eddcb7af23502e764b5d8fd063cbd8eaf 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 3066bc43812d145bbf2234802055bfee1f908d1d..524269a384e5e391a588f7a0cc61a1ab53ccb8b6 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.SimulationContextType;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * SimulationContextType DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class SimulationContextTypeDAOImpl extends
-               GenericDAOImpl<SimulationContextType, Long> implements SimulationContextTypeDAO {
+               AbstractGenericDAOImpl<SimulationContextType, Long> implements SimulationContextTypeDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<SimulationContextType> getType() {
index 78c50a750bf4eedd7426e35e4d3fe2a44bacc059..07677aba4f345308c625cb9bd08f70936e79460d 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 9f66a7dae420b2459fc85b3dc9f864106b2e02ef..3ff680b8cdffb931abe59bd75f1c133f980572c3 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.StampRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * StampRelation DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class StampRelationDAOImpl extends
-               GenericDAOImpl<StampRelation, Long> implements StampRelationDAO {
+               AbstractGenericDAOImpl<StampRelation, Long> implements StampRelationDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<StampRelation> getType() {
index 5b3c5139b7cd72fd963ab09b1af801f2f5dfaac4..e7c70f1fcc9ebb2d4266e9d4879150c1acfa3405 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index e6e3aa6871208f923adf736fd24dbf0c918d29cd..9b8847edda4c99497bcb2518686fca2636c8ad17 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.Study;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * Study DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class StudyDAOImpl extends
-               GenericDAOImpl<Study, Long> implements StudyDAO {
+               AbstractGenericDAOImpl<Study, Long> implements StudyDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<Study> getType() {
index 2639da2ba676908d5c0188e019ae7ccd93a808f4..636eea25e80a25e150ccc1499d0ed25e6e61dcd4 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index dca4c40c977c94b5204b546aaea74b75fcc89f4b..4bc7f7586abe516c44e5e8e10f8fe7ca119d7939 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.Timestamp;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * Timestamp DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class TimestampDAOImpl extends
-               GenericDAOImpl<Timestamp, Long> implements TimestampDAO {
+               AbstractGenericDAOImpl<Timestamp, Long> implements TimestampDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<Timestamp> getType() {
index dfb24870e7c651a0f2827078f5bb4ddb36657359..dfae5603ee1ff496bb01acf402eed82749af5091 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 1b4078ca727aa79dbb3fab81d5274892d2de4f35..e8da8b111409245d477e7925c9b29abab9e13887 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.UsedByRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * UsedByRelation DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class UsedByRelationDAOImpl extends
-               GenericDAOImpl<UsedByRelation, Long> implements UsedByRelationDAO {
+               AbstractGenericDAOImpl<UsedByRelation, Long> implements UsedByRelationDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<UsedByRelation> getType() {
index 0c5254b393b7ed15f247eb67a4c1b632fc3cf4ae..646fccdae3f2b9cfe66ac522388b09a20ba5b9f0 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 2d6a3a4e3deb4826256f8eaa241738b946a0d591..fb1cddb0c74fed059f60d60784c63df544daafeb 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.UsesRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * UsesRelation DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class UsesRelationDAOImpl extends
-               GenericDAOImpl<UsesRelation, Long> implements UsesRelationDAO {
+               AbstractGenericDAOImpl<UsesRelation, Long> implements UsesRelationDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<UsesRelation> getType() {
index a89ce0939b1663f54c57cefc2d58fdfae933be65..2a9c9c0702f969ccb21a4eb6bae13940ebd3fb04 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index da0ad869859760180ff348457316cb3ce527970a..fcc20748facaf59a6fbb959876b21049ee4c6171 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.ValidationCycle;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * ValidationCycle DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class ValidationCycleDAOImpl extends
-               GenericDAOImpl<ValidationCycle, Long> implements ValidationCycleDAO {
+               AbstractGenericDAOImpl<ValidationCycle, Long> implements ValidationCycleDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<ValidationCycle> getType() {
index fbae333c10ca9d7b4f4edc08c5f62a73c70fcf9b..cd4f74dbe55827563b51395a44b6f23ba44e7972 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index fae40cee36e587e07b04e1b65704966e6603727d..e787dad28d572c06dc7c1e6bbb7b07b4d51d5f0d 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.ValidationCycleRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * ValidationCycleRelation DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class ValidationCycleRelationDAOImpl extends
-               GenericDAOImpl<ValidationCycleRelation, Long> implements ValidationCycleRelationDAO {
+               AbstractGenericDAOImpl<ValidationCycleRelation, Long> implements ValidationCycleRelationDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<ValidationCycleRelation> getType() {
index 468549a565be9a03e555e71682c7d0dd3dbea1d7..e5f360f44168de51d6237c266af8325d00eea5fb 100644 (file)
@@ -5,7 +5,7 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som; 
index 247e0beb18593cca6a6a1da836617b9f845bea33..67b07b7d8425a95292f1d082546cb980e5453e2b 100644 (file)
@@ -5,13 +5,13 @@
  * Creation date   06.10.2012
  * @author         $Author$
  * @version        $Revision$
- * Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012
+ * Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012
  *****************************************************************************/
 
 package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.VersionsRelation;
-import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.splat.dal.dao.kernel.AbstractGenericDAOImpl;
 
 /**
  * VersionsRelation DAO.
@@ -19,11 +19,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl;
  * 
  */
 public class VersionsRelationDAOImpl extends
-               GenericDAOImpl<VersionsRelation, Long> implements VersionsRelationDAO {
+               AbstractGenericDAOImpl<VersionsRelation, Long> implements VersionsRelationDAO {
 
        /** 
         * {@inheritDoc}
-        * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType()
+        * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType()
         */
        @Override
        protected Class<VersionsRelation> getType() {
index c7702900d5dc5c5cdc00eb5c71f6a7ef61390c95..7c6d4f2bd7b6a0b489a3521ff529cc7f6a155490 100644 (file)
@@ -31,39 +31,70 @@ import org.splat.dal.bo.kernel.User;
 
 public class Do {
 
-    public static boolean containsIllicitCharacter (String name) {
+    public static boolean containsIllicitCharacter (final String name) {
 //  ------------------------------------------------------------               
       char parse[] = name.toCharArray();
          
       for (int i=0; i<parse.length; i++) {
         int k =  java.lang.Character.getType(parse[i]);
-        if (k == java.lang.Character.DECIMAL_DIGIT_NUMBER) continue;
-        if (k == java.lang.Character.LOWERCASE_LETTER)     continue;
-        if (k == java.lang.Character.UPPERCASE_LETTER)     continue;
-        if (k == java.lang.Character.SPACE_SEPARATOR)      continue;
-        if (k == java.lang.Character.END_PUNCTUATION)      continue;
-        if (k == java.lang.Character.DASH_PUNCTUATION)     continue;
-        if (parse[i] == '\'')                              continue;
-        if (parse[i] == '_')                               continue;
-        if (parse[i] == '&')                               continue;
-        if (parse[i] == '.')                               continue;
+        if (k == java.lang.Character.DECIMAL_DIGIT_NUMBER) {
+                       continue;
+               }
+        if (k == java.lang.Character.LOWERCASE_LETTER) {
+                       continue;
+               }
+        if (k == java.lang.Character.UPPERCASE_LETTER) {
+                       continue;
+               }
+        if (k == java.lang.Character.SPACE_SEPARATOR) {
+                       continue;
+               }
+        if (k == java.lang.Character.END_PUNCTUATION) {
+                       continue;
+               }
+        if (k == java.lang.Character.DASH_PUNCTUATION) {
+                       continue;
+               }
+        if (parse[i] == '\'') {
+                       continue;
+               }
+        if (parse[i] == '_') {
+                       continue;
+               }
+        if (parse[i] == '&') {
+                       continue;
+               }
+        if (parse[i] == '.') {
+                       continue;
+               }
         return true;
       }
       return false;
        }
 
-    public static void copy (File fromFile, File toFile) throws IOException {
+    public static void copy (final File fromFile, File toFile) throws IOException {
 //  ----------------------------------------------------
-      if (!fromFile.exists()) throw new IOException("ERROR File copy: no such '" + fromFile.getName() + "' source file.");
-      if (!fromFile.isFile()) throw new IOException("Error File copy: can't copy directory '" + fromFile.getName() + "'.");
+      if (!fromFile.exists()) {
+               throw new IOException("ERROR File copy: no such '" + fromFile.getName() + "' source file.");
+       }
+      if (!fromFile.isFile()) {
+               throw new IOException("Error File copy: can't copy directory '" + fromFile.getName() + "'.");
+       }
 
-      if (toFile.isDirectory()) toFile = new File(toFile, fromFile.getName());
-      if (toFile.exists())  throw new IOException("ERROR File copy: file " + toFile.getName() + " already exist.");
-      else {
+      if (toFile.isDirectory()) {
+               toFile = new File(toFile, fromFile.getName());
+       }
+      if (toFile.exists()) {
+               throw new IOException("ERROR File copy: file " + toFile.getName() + " already exist.");
+       } else {
         String parent = toFile.getParent();
-        if (parent == null) throw new IOException("ERROR File copy: destination directory not defined.");
+        if (parent == null) {
+                       throw new IOException("ERROR File copy: destination directory not defined.");
+               }
         File dir = new File(parent);
-        if (!dir.exists())  throw new IOException("ERROR File copy: destination directory " + parent + " doesn't exist.");
+        if (!dir.exists()) {
+                       throw new IOException("ERROR File copy: destination directory " + parent + " doesn't exist.");
+               }
       }
       FileInputStream from = null;
       FileOutputStream  to = null;
@@ -71,23 +102,40 @@ public class Do {
         from = new FileInputStream(fromFile);
         to = new FileOutputStream(toFile);
         byte[] buffer = new byte[4096];
-        int bytesRead;
+        int bytesRead = from.read(buffer);
 
-        while ((bytesRead = from.read(buffer)) != -1) to.write(buffer, 0, bytesRead);   // write
+        while (bytesRead != -1) {
+               to.write(buffer, 0, bytesRead);   // write
+               bytesRead = from.read(buffer);
+        }
         
         from.close();
         to.close();
       }
       catch (IOException e) {
-       throw new IOException();
+       throw e;
+      }
+      finally {
+         if (from != null) {
+                 from.close();
+         }
+         if (to != null) {
+                 to.close();
+         }
       }
     }
 
-       public static boolean sendMail (User to, String subject, String message, File attachement, Properties mprop) {
+       public static boolean sendMail (final User to, final String subject, final String message, final File attachement, final Properties mprop) {
 //  ------------------------------------------------------------------------------------------------------------
-         if (mprop.getProperty("mail.smtp.host") == null) return false;
-         if (mprop.getProperty("mail.pop3.host") == null) return false;
-         if (mprop.getProperty("mail.from")      == null) return false;
+         if (mprop.getProperty("mail.smtp.host") == null) {
+               return false;
+       }
+         if (mprop.getProperty("mail.pop3.host") == null) {
+               return false;
+       }
+         if (mprop.getProperty("mail.from")      == null) {
+               return false;
+       }
          
       Session mail = Session.getInstance(mprop, null);
       Logger  log  = Logger.getLogger(Do.class);
index c066532ae9a14cab3d000f91434c48c3596cbe4f..f0a103cfde5fab06191ac689bc1fe7bed3330ef8 100644 (file)
@@ -1,17 +1,20 @@
 package org.splat.kernel;
+
 /**
  * 
- * @author    Daniel Brunier-Coulin
+ * @author Daniel Brunier-Coulin
  * @copyright OPEN CASCADE 2012
  */
 
 public class MismatchException extends Exception {
 
-    private static final long serialVersionUID = 366699682058153984L;
+       private static final long serialVersionUID = 366699682058153984L;
+
+       public MismatchException() {
+               super();
+       }
 
-    public MismatchException () {
-    }
-    public MismatchException (String message) {
-      super(message);
-    }
+       public MismatchException(final String message) {
+               super(message);
+       }
 }
\ No newline at end of file
index d7aa75adff8d685bb68448d89ad924ad0cde52f2..708cf45bf0fb7338c45f775d8e73cbb911274f1c 100644 (file)
@@ -1,7 +1,8 @@
 package org.splat.kernel;
+
 /**
  * 
- * @author    Daniel Brunier-Coulin
+ * @author Daniel Brunier-Coulin
  * @copyright OPEN CASCADE 2012
  */
 
@@ -9,9 +10,11 @@ public class MultiplyDefinedException extends Exception {
 
        private static final long serialVersionUID = 3551033092059904168L;
 
-    public MultiplyDefinedException () {
-    }
-    public MultiplyDefinedException (String message) {
-      super(message);
-    }
+       public MultiplyDefinedException() {
+               super();
+       }
+
+       public MultiplyDefinedException(final String message) {
+               super(message);
+       }
 }
\ No newline at end of file
index 6269ae31167a8f79923eca8828d6787ba925deb3..0a8eeb7f1b97787303577eab4e541fa3c5ee8df7 100644 (file)
@@ -1,4 +1,5 @@
 package org.splat.kernel;
+
 /**
  * 
  * @author    Daniel Brunier-Coulin
@@ -9,128 +10,135 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.Map;
 
-import javax.security.auth.*;
-import javax.security.auth.callback.*;
-import javax.security.auth.login.*;
-import javax.security.auth.spi.*;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.FailedLoginException;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
 
 import org.apache.log4j.Logger;
 import org.splat.dal.bo.kernel.User;
 import org.splat.service.ServiceLocatorImpl;
 
-
 public class RealmLoginModule implements LoginModule {
-       
-//  Initial state
-    private Subject         subject;
-    private CallbackHandler callbackHandler;
-//  private Map             sharedState;
-//  private Map             options;
-
-//  Authentication status
-    private boolean succeeded = false;
-    private boolean commit    = false;
-
-//  Principal
-    private User    identity  = null;
-    
-    private Logger  logger    = null;
-
-//  ==============================================================================================================================
-//  Constructor        
-//  ==============================================================================================================================
-
-    public void initialize(Subject user, CallbackHandler handler, Map<String, ?> state, Map<String, ?> opts) {
-//  --------------------------------------------------------------------------------------------------------
-      subject         = user;
-         callbackHandler = handler;
-//       sharedState     = state;
-//       options         = opts;
-//    debug           = "true".equalsIgnoreCase((String)options.get("debug"));
-         logger          = Logger.getLogger(RealmLoginModule.class);
-    }
-
-//  ==============================================================================================================================
-//  Public services
-//  ==============================================================================================================================
+
+       // Initial state
+       private transient Subject _subject;
+       private transient CallbackHandler _callbackHandler;
+       // private Map sharedState;
+       // private Map options;
+
+       // Authentication status
+       private transient boolean _succeeded = false;
+       private transient boolean _commit = false;
+
+       // Principal
+       private transient User _identity = null;
+
+       private static final Logger LOG = Logger.getLogger(RealmLoginModule.class);
+
+       // ==============================================================================================================================
+       // Constructor
+       // ==============================================================================================================================
+
+       public void initialize(final Subject user, final CallbackHandler handler,
+                       final Map<String, ?> state, final Map<String, ?> opts) {
+               // --------------------------------------------------------------------------------------------------------
+               _subject = user;
+               _callbackHandler = handler;
+               // sharedState = state;
+               // options = opts;
+               // debug = "true".equalsIgnoreCase((String)options.get("debug"));
+               //_logger = Logger.getLogger(RealmLoginModule.class);
+       }
+
+       // ==============================================================================================================================
+       // Public services
+       // ==============================================================================================================================
 
        public boolean login() throws LoginException {
-//  ----------------------
-         try {           
-//    Ask for username password          
-               Callback[] callbacks = new Callback[2];
-               callbacks[0] = new NameCallback("username");
-               callbacks[1] = new PasswordCallback("password", false);
-
-           callbackHandler.handle(callbacks);
-
-           String username = ((NameCallback)callbacks[0]).getName();
-           String password = null;
-           char[] entered  = ((PasswordCallback)callbacks[1]).getPassword();
-           if (entered != null) {
-             password = new String(entered);
-             ((PasswordCallback)callbacks[1]).clearPassword();
-           }
-           
-//    Authentication       
-           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("Connection of " + identity.toString() + " " + datime.toString() + ".");
-             return true;
-           } else {
-             identity  = null;
-                 succeeded = false;              
-                 found     = ServiceLocatorImpl.getInstance().getUserService().selectUser(username);
-          String             reason = "password";
-                 if (found == null) reason = "username";
-             logger.info("Connection attempt as " + username + ".");
-                 throw new FailedLoginException(reason);
-           }
-         }
-         catch (java.io.IOException ioe) {
-               throw new LoginException(ioe.toString());
-         }
-         catch (UnsupportedCallbackException uce) {
-               throw new LoginException("Error: " + uce.getCallback().toString() +
-                       " not available to garner authentication information" +
-                       " from the user");
-         }
+               boolean res = false;
+               try {
+                       // Ask for username password
+                       Callback[] callbacks = new Callback[2];
+                       callbacks[0] = new NameCallback("username");
+                       callbacks[1] = new PasswordCallback("password", false);
+
+                       _callbackHandler.handle(callbacks);
+
+                       String username = ((NameCallback) callbacks[0]).getName();
+                       String password = null;
+                       char[] entered = ((PasswordCallback) callbacks[1]).getPassword();
+                       if (entered != null) {
+                               password = new String(entered);
+                               ((PasswordCallback) callbacks[1]).clearPassword();
+                       }
+
+                       // Authentication
+                       User found = ServiceLocatorImpl.getInstance().getUserService()
+                                       .selectUser(username, password);
+                       _identity = found;
+                       _succeeded = (found != null);
+                       if (_succeeded) {
+                               Calendar today = java.util.Calendar.getInstance();
+                               Date datime = today.getTime();
+                               LOG.info("Connection of " + _identity.toString() + " "
+                                               + datime.toString() + ".");
+                               res = true;
+                       } else {
+                               found = ServiceLocatorImpl.getInstance().getUserService()
+                                               .selectUser(username);
+                               String reason = "password";
+                               if (found == null) {
+                                       reason = "username";
+                               }
+                               LOG.info("Connection attempt as " + username + ".");
+                               throw new FailedLoginException(reason);
+                       }
+               } catch (java.io.IOException ioe) {
+                       throw new LoginException(ioe.getMessage()); // RKV: NOPMD: The message is sent into the constructor
+               } catch (UnsupportedCallbackException uce) {
+                       throw new LoginException("Error: " + uce.getCallback().toString() // RKV: NOPMD: Stacktrace is printed
+                                       + " not available to garner authentication information"
+                                       + " from the user");
+               }
+               return res;
        }
 
        public boolean commit() throws LoginException {
-//  -----------------------
-         if (!succeeded) return false;
-         
-         if (!subject.getPrincipals().contains(identity)) subject.getPrincipals().add(identity);
-         identity = null;
-         commit   = true;
-         return true;
+               boolean res = _succeeded;
+               if (res) {
+                       if (!_subject.getPrincipals().contains(_identity)) {
+                               _subject.getPrincipals().add(_identity);
+                       }
+                       _identity = null;
+                       _commit = true;
+               }
+               return res;
        }
 
        public boolean abort() throws LoginException {
-//  ----------------------
-         if (!succeeded) {
-               return false;
-         } else
-         if (succeeded && !commit) {
-               identity  = null;
-               succeeded = false;
-         } else {
-               logout();
-         }
-         return true;
+               boolean res = _succeeded;
+               if (res) {
+                       if (_succeeded && !_commit) {
+                               _identity = null;
+                               _succeeded = false;
+                       } else {
+                               logout();
+                       }
+               }
+               return res;
        }
 
        public boolean logout() throws LoginException {
-//  -----------------------
-         subject.getPrincipals().remove(identity);
-         identity  = null;
-         succeeded = false;
-         commit    = false;     // To be validated
-         return true;
+               _subject.getPrincipals().remove(_identity);
+               _identity = null;
+               _succeeded = false;
+               _commit = false; // To be validated
+               return true;
        }
 }
\ No newline at end of file
index c4b2c3cd6cff2090c42029a006d07e3388a9acd0..1c65b18edfbeb93d4a427961c8cfb00c58178fc4 100644 (file)
@@ -9,8 +9,6 @@
 
 package org.splat.service;
 
-import java.util.List;
-
 import org.splat.dal.bo.som.ConvertsRelation;
 import org.splat.dal.bo.som.Document;
 import org.splat.dal.bo.som.DocumentType;
@@ -21,12 +19,9 @@ import org.splat.dal.bo.som.Timestamp;
 import org.splat.dal.bo.som.Document.Properties;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
-import org.splat.kernel.MultiplyDefinedException;
 import org.splat.kernel.NotApplicableException;
-import org.splat.service.technical.ProjectSettingsService;
 import org.splat.som.Revision;
 import org.splat.som.Step;
-import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Document service interface.
@@ -43,7 +38,7 @@ public interface DocumentService {
         *            the document path
         * @return the document if found or null
         */
-       public Document getDocumentByPath(String path);
+       Document getDocumentByPath(String path);
 
        /**
         * Defines this document.
@@ -61,7 +56,7 @@ public interface DocumentService {
         * @see Step#createDocument(Properties)
         * @see #isUndefined()
         */
-       public void initialize(Document aDoc, Properties dprop)
+       void initialize(Document aDoc, Properties dprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        NotApplicableException;
 
@@ -72,7 +67,7 @@ public interface DocumentService {
         *            document id
         * @return found document
         */
-       public Document selectDocument(long index);
+       Document selectDocument(long index);
 
        /**
         * Find a document by its reference and version.
@@ -83,7 +78,7 @@ public interface DocumentService {
         *            document version
         * @return found document
         */
-       public Document selectDocument(String refid, String version);
+       Document selectDocument(String refid, String version);
 
        /**
         * Generate document reference.
@@ -93,7 +88,7 @@ public interface DocumentService {
         * @param dprop
         *            document properties (owner project element is used)
         */
-       public void generateDocumentId(Document aDoc, Properties dprop);
+       void generateDocumentId(Document aDoc, Properties dprop);
 
        /**
         * Get a directory where the document file is saved.
@@ -102,7 +97,7 @@ public interface DocumentService {
         *            the document
         * @return a directory
         */
-       public java.io.File getSaveDirectory(Document aDoc);
+       java.io.File getSaveDirectory(Document aDoc);
 
        /**
         * Extract title and reference properties from the given file.
@@ -111,7 +106,7 @@ public interface DocumentService {
         *            the file to parse
         * @return the extracted properties
         */
-       public Properties extractProperties(java.io.File file);
+       Properties extractProperties(java.io.File file);
 
        /**
         * Create "Converts" relation for the given document and the given format.
@@ -122,7 +117,7 @@ public interface DocumentService {
         *            the format
         * @return the created "Converts" relation
         */
-       public ConvertsRelation attach(Document aDoc, String format);
+       ConvertsRelation attach(Document aDoc, String format);
 
        /**
         * Create "Converts" relation for the given document, format and description.
@@ -135,7 +130,7 @@ public interface DocumentService {
         *            the description of the relation
         * @return the created "Converts" relation
         */
-       public ConvertsRelation attach(Document aDoc, String format,
+       ConvertsRelation attach(Document aDoc, String format,
                        String description);
 
        /**
@@ -149,7 +144,7 @@ public interface DocumentService {
         *            the original document
         * @return true if the new reference is set
         */
-       public boolean buildReferenceFrom(Document aDoc, ProjectElement scope,
+       boolean buildReferenceFrom(Document aDoc, ProjectElement scope,
                        Document lineage);
 
        /**
@@ -161,7 +156,7 @@ public interface DocumentService {
         *            the study
         * @return true if the new reference is set
         */
-       public boolean buildReferenceFrom(Document aDoc, Study scope);
+       boolean buildReferenceFrom(Document aDoc, Study scope);
 
        /**
         * Demote a document.
@@ -170,7 +165,7 @@ public interface DocumentService {
         *            the document to demote
         * @return true if demoting succeeded
         */
-       public boolean demote(Document aDoc);
+       boolean demote(Document aDoc);
 
        /**
         * Promote a document.
@@ -181,7 +176,7 @@ public interface DocumentService {
         *            the timestamp of the promotion
         * @return true if promotion succeeded
         */
-       public boolean promote(Document aDoc, Timestamp stamp);
+       boolean promote(Document aDoc, Timestamp stamp);
 
        /**
         * Increments the reference count of this document following its publication in a Study step.
@@ -190,7 +185,7 @@ public interface DocumentService {
         *            the document to hold
         * @see #release()
         */
-       public void hold(Document aDoc);
+       void hold(Document aDoc);
 
        /**
         * Decrements the reference count of this document following the removal of a Publication from a Study step.
@@ -199,7 +194,7 @@ public interface DocumentService {
         *            the document to release
         * @see #hold()
         */
-       public void release(Document aDoc);
+       void release(Document aDoc);
 
        /**
         * Rename a document.
@@ -211,7 +206,7 @@ public interface DocumentService {
         * @throws InvalidPropertyException
         *             if the new title is empty
         */
-       public void rename(Document aDoc, String title)
+       void rename(Document aDoc, String title)
                        throws InvalidPropertyException;
 
        /**
@@ -222,7 +217,7 @@ public interface DocumentService {
         * @param newvers
         *            the new version
         */
-       public void updateAs(Document aDoc, Revision newvers);
+       void updateAs(Document aDoc, Revision newvers);
 
        /**
         * Update a state of the given document.
@@ -232,7 +227,7 @@ public interface DocumentService {
         * @param state
         *            the new state
         */
-       public void updateAs(Document aDoc, ProgressState state);
+       void updateAs(Document aDoc, ProgressState state);
 
        /**
         * Checks if documents of this type are result of a study. A document is the result of a study when it is the result of the last step of
@@ -244,5 +239,5 @@ public interface DocumentService {
         * @see #isStepResult()
         * @see #isResultOf(org.splat.service.technical.ProjectSettingsServiceImpl.Step)
         */
-       public boolean isStudyResult(DocumentType aType);
+       boolean isStudyResult(DocumentType aType);
 }
index 5c87bae00b947266f80bae6f720ed88e8dc6ad24..4391e4e05d0aec6de63fa020be328e96fc62d8f2 100644 (file)
@@ -38,6 +38,7 @@ import org.splat.dal.dao.som.StudyDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.NotApplicableException;
+import org.splat.log.AppLogger;
 import org.splat.manox.Reader;
 import org.splat.manox.Toolbox;
 import org.splat.service.technical.ProjectSettingsService;
@@ -54,6 +55,12 @@ import org.springframework.transaction.annotation.Transactional;
  */
 public class DocumentServiceImpl implements DocumentService {
 
+       /**
+        * The logger for the service.
+        */
+       public final static AppLogger LOG = AppLogger
+                       .getLogger(DocumentServiceImpl.class);
+
        /**
         * Injected study service.
         */
@@ -61,7 +68,7 @@ public class DocumentServiceImpl implements DocumentService {
        /**
         * Injected project settings service.
         */
-       private ProjectSettingsService _projectSettingsService;
+       private ProjectSettingsService _projectSettings;
        /**
         * Injected repository service.
         */
@@ -122,7 +129,7 @@ public class DocumentServiceImpl implements DocumentService {
                // Synchronize the object with the current Hibernate session.
                owner = getStudyDAO().get(owner.getIndex());
 
-               SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
+               SimpleDateFormat tostring = new SimpleDateFormat("yyyy"); //RKV: NOPMD: TODO: Use locale here?
                String year = tostring.format(owner.getDate());
                String filename = generateEncodedName(aDoc, owner);
                String path = owner.getReference();
@@ -266,6 +273,7 @@ public class DocumentServiceImpl implements DocumentService {
                                        fprop.setReference(value);
                                }
                        } catch (Exception e) {
+                               LOG.debug(e.getMessage(), e);
                        }
                }
                return fprop;
@@ -325,8 +333,8 @@ public class DocumentServiceImpl implements DocumentService {
         *            the original document
         * @return true if the new reference is set
         */
-       public boolean buildReferenceFrom(final Document aDoc, final ProjectElement scope,
-                       final Document lineage) {
+       public boolean buildReferenceFrom(final Document aDoc,
+                       final ProjectElement scope, final Document lineage) {
                if (aDoc.getProgressState() != ProgressState.inWORK) {
                        return false;
                }
@@ -637,7 +645,7 @@ public class DocumentServiceImpl implements DocumentService {
         * @return Project settings service
         */
        private ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
+               return _projectSettings;
        }
 
        /**
@@ -646,8 +654,9 @@ public class DocumentServiceImpl implements DocumentService {
         * @param projectSettingsService
         *            project settings service
         */
-       public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
+       public void setProjectSettings(
+                       final ProjectSettingsService projectSettingsService) {
+               _projectSettings = projectSettingsService;
        }
 
        /**
index 1033ece911fb483cccb8f723ab4f6d8653b6575d..349218a73a0ecb4fa03d48d8399890c9fc28d4c9 100644 (file)
@@ -29,14 +29,14 @@ public interface DocumentTypeService {
         * 
         * @return the list of all document types
         */
-       public List<DocumentType> selectAllTypes();
+       List<DocumentType> selectAllTypes();
 
        /**
         * Find all result document types.
         * 
         * @return the list of found types
         */
-       public List<DocumentType> selectResultTypes();
+       List<DocumentType> selectResultTypes();
 
        /**
         * Get document type by the given type name.
@@ -45,7 +45,7 @@ public interface DocumentTypeService {
         *            the type name
         * @return the found document type
         */
-       public DocumentType selectType(String name);
+       DocumentType selectType(String name);
 
        /**
         * Get document type by the given id.
@@ -54,7 +54,7 @@ public interface DocumentTypeService {
         *            the id
         * @return the found document type
         */
-       public DocumentType selectType(long index);
+       DocumentType selectType(long index);
 
        /**
         * Create a new document type.
@@ -69,7 +69,7 @@ public interface DocumentTypeService {
         * @throws MultiplyDefinedException
         *             if some property is defined several times
         */
-       public DocumentType createType(DocumentType.Properties tprop)
+       DocumentType createType(DocumentType.Properties tprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        MultiplyDefinedException;
 
@@ -80,7 +80,7 @@ public interface DocumentTypeService {
         *            the step (study activity)
         * @return the list of found document types
         */
-       public List<DocumentType> selectTypesOf(ProjectSettingsService.Step step);
+       List<DocumentType> selectTypesOf(ProjectSettingsService.Step step);
 
        /**
         * Approve the document type.
@@ -89,5 +89,5 @@ public interface DocumentTypeService {
         *            the document type to approve
         * @return true if approval succeeded
         */
-       public boolean approve(DocumentType aType);
+       boolean approve(DocumentType aType);
 }
index 874bcb3e8af2b1d7c216915b186715b71e52dea4..5fa287eb675225d1aa52edb17d34e25d77136346 100644 (file)
@@ -17,7 +17,6 @@ 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;
@@ -71,7 +70,7 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * @return the found document type
         */
        @Transactional(readOnly = true)
-       public DocumentType selectType(String name) {
+       public DocumentType selectType(final String name) {
                return getDocumentTypeDAO().findByCriteria(
                                Restrictions.eq("name", name));
        }
@@ -84,7 +83,7 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * @return the found document type
         */
        @Transactional(readOnly = true)
-       public DocumentType selectType(long index) {
+       public DocumentType selectType(final long index) {
                return getDocumentTypeDAO().get(index);
        }
 
@@ -102,7 +101,7 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         *             if some property is defined several times
         */
        @Transactional
-       public DocumentType createType(DocumentType.Properties tprop)
+       public DocumentType createType(final DocumentType.Properties tprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        MultiplyDefinedException {
                // TODO: Check for duplicate definition
@@ -119,7 +118,7 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * @return the list of found document types
         */
        @Transactional(readOnly = true)
-       public List<DocumentType> selectTypesOf(ProjectSettingsService.Step step) {
+       public List<DocumentType> selectTypesOf(final ProjectSettingsService.Step step) {
                Integer number = step.getNumber();
                String sampleStr = new StringBuffer("%-").append(number).append("-%")
                                .toString();
@@ -137,12 +136,14 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * @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;
-    }
+    public boolean approve(final DocumentType aType) {
+               boolean res = (aType.getState() == ProgressState.inCHECK);
+               if (res) {
+                       aType.setState(ProgressState.APPROVED); // The type name is supposed being localized
+                       getDocumentTypeDAO().update(aType);
+               }
+               return res;
+       }
 
        /**
         * Get the documentTypeDAO.
@@ -159,7 +160,7 @@ public class DocumentTypeServiceImpl implements DocumentTypeService {
         * @param documentTypeDAO
         *            the documentTypeDAO to set
         */
-       public void setDocumentTypeDAO(DocumentTypeDAO documentTypeDAO) {
+       public void setDocumentTypeDAO(final DocumentTypeDAO documentTypeDAO) {
                _documentTypeDAO = documentTypeDAO;
        }
 }
index 5ad86c633759a0539e33588b7644a1f6464cf898..f5835bf9278b109ea8edc96c706408c8971010a7 100644 (file)
@@ -27,7 +27,7 @@ public interface KnowledgeElementService {
         *            the knowledge element to approve
         * @return true if approving succeeded
         */
-       public boolean approve(KnowledgeElement knowledgeElement);
+       boolean approve(KnowledgeElement knowledgeElement);
 
        /**
         * Demote the knowledge element.
@@ -36,7 +36,7 @@ public interface KnowledgeElementService {
         *            the knowledge element to demote
         * @return true if demoting succeeded
         */
-       public boolean demote(KnowledgeElement knowledgeElement);
+       boolean demote(KnowledgeElement knowledgeElement);
 
        /**
         * Promote the knowledge element.
@@ -45,7 +45,7 @@ public interface KnowledgeElementService {
         *            the knowledge element to promote
         * @return true if promotion succeeded
         */
-       public boolean promote(KnowledgeElement knowledgeElement);
+       boolean promote(KnowledgeElement knowledgeElement);
 
        /**
         * Rename the knowledge element.
@@ -57,7 +57,7 @@ public interface KnowledgeElementService {
         * @throws InvalidPropertyException
         *             if renaming is failed
         */
-       public void rename(KnowledgeElementDTO knowledgeElement, String title)
+       void rename(KnowledgeElementDTO knowledgeElement, String title)
                        throws InvalidPropertyException;
 
        /**
@@ -67,7 +67,7 @@ public interface KnowledgeElementService {
         *            the knowledge element id
         * @return the found knowledge element
         */
-       public KnowledgeElement selectKnowledgeElement(long index);
+       KnowledgeElement selectKnowledgeElement(long index);
 
        /**
         * Get a knowledge element DTO by id.
@@ -76,7 +76,7 @@ public interface KnowledgeElementService {
         *            the knowledge element id
         * @return the found knowledge element as DTO
         */
-       public KnowledgeElementDTO getKnowledgeElement(long index);
+       KnowledgeElementDTO getKnowledgeElement(long index);
 
        /**
         * Update the description of the knowledge element.
@@ -86,5 +86,5 @@ public interface KnowledgeElementService {
         * @param description
         *            the new description
         */
-       public void update(KnowledgeElementDTO kelm, String description);
+       void update(KnowledgeElementDTO kelm, String description);
 }
index 3c929457e9db4699e8e22b35d92f3c9c60ff4516..2171ff9f4d05d14f4acf1419ddb5e97204dd6de8 100644 (file)
@@ -34,7 +34,7 @@ public class KnowledgeElementServiceImpl implements KnowledgeElementService {
        /**
         * The logger for the service.
         */
-       public final static AppLogger LOGGER = AppLogger
+       public final static AppLogger LOG = AppLogger
                        .getLogger(KnowledgeElementServiceImpl.class);
 
        /**
@@ -96,7 +96,7 @@ public class KnowledgeElementServiceImpl implements KnowledgeElementService {
                        getIndexService().update(knowledgeElement);
                        return true;
                } catch (Exception error) {
-                       LOGGER.error("Unable to re-index the knowledge '"
+                       LOG.error("Unable to re-index the knowledge '"
                                        + knowledgeElement.getIndex() + "', reason:", error);
                        return false;
                }
index 3bc8ca7940188585fa8b9815dfc210ee8522eff6..d7391d6af14f18855f54bd86148f894cffbd3e1b 100644 (file)
@@ -29,7 +29,7 @@ public interface KnowledgeElementTypeService {
         *            the knowledge type name
         * @return the found knowledge type
         */
-       public KnowledgeElementType selectType(String name);
+       KnowledgeElementType selectType(String name);
 
        /**
         * Create a knowledge element type with the given name.
@@ -38,14 +38,14 @@ public interface KnowledgeElementTypeService {
         *            the new type name
         * @return the created knowledge type
         */
-       public KnowledgeElementType createType(String name);
+       KnowledgeElementType createType(String name);
 
        /**
         * Get all knowledge types from the database.
         * 
         * @return the list of all knowledge types
         */
-       public List<KnowledgeElementType> selectAllTypes();
+       List<KnowledgeElementType> selectAllTypes();
 
        /**
         * Get knowledge types which have the given progress state.
@@ -54,7 +54,7 @@ public interface KnowledgeElementTypeService {
         *            the progress state
         * @return the list of found knowledge types
         */
-       public List<KnowledgeElementType> selectTypesWhere(ProgressState state);
+       List<KnowledgeElementType> selectTypesWhere(ProgressState state);
 
        /**
         * Get a knowledge type by its id.
@@ -63,7 +63,7 @@ public interface KnowledgeElementTypeService {
         *            the id of a knowledge type
         * @return the found knowledge type
         */
-       public KnowledgeElementType selectType(long index);
+       KnowledgeElementType selectType(long index);
 
        /**
         * Approve the knowledge type.
@@ -72,7 +72,7 @@ public interface KnowledgeElementTypeService {
         *            the knowledge type to approve
         * @return true if approval succeeded
         */
-       public boolean approve(KnowledgeElementType kelt);
+       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
@@ -82,5 +82,5 @@ public interface KnowledgeElementTypeService {
         *            the knowledge type to approve
         * @return true if approval succeeded
         */
-       public boolean reserve(KnowledgeElementType kelt);
+       boolean reserve(KnowledgeElementType kelt);
 }
index 9df0f087f961d2df9278b3436196b07e1f80033d..b2f7f0d87c5f8c3867eb0bf31e6c5a9a49687154 100644 (file)
@@ -7,7 +7,7 @@
  * @version        $Revision$
  *****************************************************************************/
 
-package org.splat.service; 
+package org.splat.service;
 
 import org.splat.exception.LockAlreadyExistsException;
 import org.splat.exception.LockNotExistsException;
@@ -16,67 +16,91 @@ import org.splat.exception.LockProtectedException;
 import org.splat.log.AppLogger;
 
 /**
+ * The service to lock objects in the database.
+ * 
  * @author Maria KRUCHININA
- *
  */
 public class LockServiceImpl implements LockService {
-       
+
        /**
         * logger.
         */
-       private final static AppLogger LOG = AppLogger.getLogger(LockService.class);
+       private final static AppLogger LOG = AppLogger.getLogger(LockService.class); // RKV: NOPMD: TODO: Complete the service.
 
        /**
         * Lock timeout period in milliseconds. A 24 hours by default.
         */
-       private long _timeoutPeriod = 86400000L;
+       private final long _timeoutPeriod = 86400000L; // RKV: NOPMD: TODO: Complete the service.
 
        /**
         * Lock a data row or update lock on a data row for one user.
-        * @param rowUid Row uid
-        * @param tableUid Table uid
-        * @param userUid User uid
-        * @throws LockAlreadyExistsException when a lock already exists for row uid and another user id
+        * 
+        * @param rowUid
+        *            Row uid
+        * @param tableUid
+        *            Table uid
+        * @param userUid
+        *            User uid
+        * @throws LockAlreadyExistsException
+        *             when a lock already exists for row uid and another user id
         */
-       public void lock(final String rowUid, final String tableUid, final String userUid) throws LockAlreadyExistsException {
-               //TODO:
+       public void lock(final String rowUid, final String tableUid,
+                       final String userUid) throws LockAlreadyExistsException {
+               // TODO:
        }
-       
+
        /**
         * Unlock a data row for one user.
-        * @param rowUid Row uid
-        * @param tableUid Table uid
-        * @param userUid User uid
-        * @throws LockNotExistsException when lock does not exist
-        * @throws LockProtectedException lock exists for another user
+        * 
+        * @param rowUid
+        *            Row uid
+        * @param tableUid
+        *            Table uid
+        * @param userUid
+        *            User uid
+        * @throws LockNotExistsException
+        *             when lock does not exist
+        * @throws LockProtectedException
+        *             lock exists for another user
         */
-       public void unlock(final String rowUid, final String tableUid, final String userUid) throws LockNotExistsException, LockProtectedException {
-               //TODO:
+       public void unlock(final String rowUid, final String tableUid,
+                       final String userUid) throws LockNotExistsException,
+                       LockProtectedException {
+               // TODO:
        }
 
-       /** 
+       /**
         * Unlock all datas rox for one user.
-        * @param userUid User uid
+        * 
+        * @param userUid
+        *            User uid
         */
        @Override
-       public void unlockAll(String userUid) {
+       public void unlockAll(final String userUid) {
                // TODO Auto-generated method stub
 
        }
-       
+
        /**
         * Check lock on a data row in a table for a user.
-        * @param rowUid Row uid
-        * @param tableUid Table uid
-        * @param userUid User uid
-        * @throws LockNotExistsException when lock does not exist
-        * @throws LockProtectedException lock exists for another user
-        * @throws LockOutdatedException when lock on object is in timeout but the
-        * owner of lock is another user
+        * 
+        * @param rowUid
+        *            Row uid
+        * @param tableUid
+        *            Table uid
+        * @param userUid
+        *            User uid
+        * @throws LockNotExistsException
+        *             when lock does not exist
+        * @throws LockProtectedException
+        *             lock exists for another user
+        * @throws LockOutdatedException
+        *             when lock on object is in timeout but the owner of lock is another user
         */
-       public void check(final String rowUid, final String tableUid, final String userUid) throws LockNotExistsException, LockProtectedException, LockOutdatedException {
-               //TODO:
+       public void check(final String rowUid, final String tableUid,
+                       final String userUid) throws LockNotExistsException,
+                       LockProtectedException, LockOutdatedException {
+               // TODO:
        }
-       
 
 }
index b686dec13cf64de4c4d2204e2bb4f32888f9d2e7..81792bbc6c231a197e6e163897a7fb842681f71f 100644 (file)
@@ -11,7 +11,6 @@ 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.
@@ -28,7 +27,7 @@ public interface ProjectElementService {
         *            a study or a scenario
         * @return the first activity (step) of the project element
         */
-       public Step getFirstStep(ProjectElement elem);
+       Step getFirstStep(ProjectElement elem);
 
        /**
         * Get activities of the project element.
@@ -37,7 +36,7 @@ public interface ProjectElementService {
         *            a study or a scenario
         * @return array of activities (steps).
         */
-       public Step[] getSteps(ProjectElement elem);
+       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
@@ -47,5 +46,5 @@ public interface ProjectElementService {
         * @param elem
         *            the project element to refresh
         */
-       public void refresh(ProjectElement elem);
+       void refresh(ProjectElement elem);
 }
index b8a35358a7c28cae24ea90f6fbbed4003ab7bd09..f5ec91e9abdbd1d0891ef60e416a38f512abde61 100644 (file)
@@ -30,7 +30,7 @@ public class ProjectElementServiceImpl implements ProjectElementService {
        /**
         * Injected project settings service.
         */
-       private ProjectSettingsService _projectSettingsService;
+       private ProjectSettingsService _projectSettings;
        /**
         * Injected project element DAO.
         */
@@ -41,11 +41,11 @@ public class ProjectElementServiceImpl implements ProjectElementService {
         * 
         * @see org.splat.service.ProjectElementService#getFirstStep(org.splat.dal.bo.som.ProjectElement)
         */
-       public Step getFirstStep(ProjectElement elem) {
+       public Step getFirstStep(final ProjectElement elem) {
                return getSteps(elem)[0];
        }
 
-       public Step getLastStep(ProjectElement elem) {
+       public Step getLastStep(final ProjectElement elem) {
                Step[] mystep = getSteps(elem); // For getting the folders length, if null
                return mystep[mystep.length - 1];
        }
@@ -55,7 +55,7 @@ public class ProjectElementServiceImpl implements ProjectElementService {
         * 
         * @see org.splat.service.ProjectElementService#getSteps(org.splat.dal.bo.som.ProjectElement)
         */
-       public Step[] getSteps(ProjectElement elem) {
+       public Step[] getSteps(final ProjectElement elem) {
                if (elem.getFolders() == null) {
                        List<ProjectSettingsService.Step> steps = getProjectSettings()
                                        .getStepsOf(elem.getClass());
@@ -76,15 +76,16 @@ public class ProjectElementServiceImpl implements ProjectElementService {
         * @param elem the project element to refresh
         */
        @Transactional
-       public void refresh(ProjectElement elem) {
+       public void refresh(final 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++)
+               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);
        }
@@ -95,7 +96,7 @@ public class ProjectElementServiceImpl implements ProjectElementService {
         * @return Project settings service
         */
        private ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
+               return _projectSettings;
        }
 
        /**
@@ -104,8 +105,8 @@ public class ProjectElementServiceImpl implements ProjectElementService {
         * @param projectSettingsService
         *            project settings service
         */
-       public void setProjectSettings(ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
+       public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
+               _projectSettings = projectSettingsService;
        }
 
        /**
@@ -120,7 +121,7 @@ public class ProjectElementServiceImpl implements ProjectElementService {
         * Set the projectElementDAO.
         * @param projectElementDAO the projectElementDAO to set
         */
-       public void setProjectElementDAO(ProjectElementDAO projectElementDAO) {
+       public void setProjectElementDAO(final ProjectElementDAO projectElementDAO) {
                _projectElementDAO = projectElementDAO;
        }
 }
index 85a16042b06c2c106693caaf54f58b20779faa02..9abcf754aa078c50a6faaf70b5d0383e409d9fb4 100644 (file)
@@ -46,7 +46,7 @@ public interface PublicationService {
         *            the target project element
         * @return the created copy of the publication
         */
-       public Publication copy(Publication aPublication, ProjectElement publisher);
+       Publication copy(Publication aPublication, ProjectElement publisher);
 
        /**
         * Create a new version of the document.
@@ -68,7 +68,7 @@ public interface PublicationService {
         * @throws NotApplicableException if publication's document is undefined
         * @throws InterruptedException by Thread.sleep if interrupted
         */
-       public void versionDocument(Step step, User user, String filename,
+       void versionDocument(Step step, User user, String filename,
                        long docIndex, String docver, String summary, ProgressState state,
                        Date date, String[] docuses, long[] docusedby)
                        throws MissedPropertyException, InvalidPropertyException,
@@ -82,7 +82,7 @@ public interface PublicationService {
         *            the document publication
         * @return study step
         */
-       public Step getInvolvedStep(Publication aPublication);
+       Step getInvolvedStep(Publication aPublication);
 
        /**
         * Promotes the document referenced by this publication from In-Check to Approved state, if not out-dated, and attaches the
@@ -100,7 +100,7 @@ public interface PublicationService {
         * @see DocumentType#isStudyResult()
         * @see Study#getApproverOf(Publication)
         */
-       public Timestamp approve(Publication aPublication, Date adate);
+       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
@@ -115,7 +115,7 @@ public interface PublicationService {
         * @see DocumentRights#canDemote()
         * @see DocumentType#isStudyResult()
         */
-       public boolean demote(Publication aPublication);
+       boolean demote(Publication aPublication);
 
        /**
         * Undo the review operation by demoting the document referenced by this publication from In-Check to In-Draft state and removing the
@@ -130,7 +130,7 @@ public interface PublicationService {
         * @see DocumentRights#canInvalidate()
         * @see DocumentType#isStudyResult()
         */
-       public boolean invalidate(Publication aPublication);
+       boolean invalidate(Publication aPublication);
 
        /**
         * Promotes the document referenced by this publication from In-Work to In-Draft or In-Check state, if not out-dated, and attaches the
@@ -149,7 +149,7 @@ public interface PublicationService {
         * @see DocumentRights#canPromote()
         * @see DocumentType#isStudyResult()
         */
-       public Timestamp promote(Publication aPublication, Date pdate);
+       Timestamp promote(Publication aPublication, Date pdate);
 
        /**
         * Promotes the document referenced by this publication from In-Draft to In-Check state, if not out-dated, and attaches the
@@ -168,7 +168,7 @@ public interface PublicationService {
         * @see DocumentType#isStudyResult()
         * @see Study#getReviewerOf(Publication)
         */
-       public Timestamp review(Publication aPublication, Date rdate);
+       Timestamp review(Publication aPublication, Date rdate);
 
        /**
         * Publishes the document referenced by this publication into the owner Project Element under the given state, the revision number of
@@ -184,7 +184,7 @@ public interface PublicationService {
         * @throws NotApplicableException
         *             If the referenced document is undefined
         */
-       public void saveAs(Publication aPublication, ProgressState state)
+       void saveAs(Publication aPublication, ProgressState state)
                        throws FileNotFoundException, NotApplicableException;
 
        /**
@@ -204,7 +204,8 @@ public interface PublicationService {
         *             If the referenced document is undefined
         * @deprecated
         */
-       public void saveAs(Publication aPublication, Revision newvers)
+       @Deprecated
+       void saveAs(Publication aPublication, Revision newvers)
                        throws FileNotFoundException, NotApplicableException;
 
        /**
@@ -217,7 +218,7 @@ public interface PublicationService {
         * @throws InvalidPropertyException
         *             if the new title is empty
         */
-       public void rename(Publication aPublication, String title)
+       void rename(Publication aPublication, String title)
                        throws InvalidPropertyException;
 
        /**
@@ -229,7 +230,7 @@ public interface PublicationService {
         *            the format
         * @return the created "Converts" relation
         */
-       public ConvertsRelation attach(Publication aPublication, String format);
+       ConvertsRelation attach(Publication aPublication, String format);
 
        /**
         * Create "Converts" relation for the given document publication, format and description.
@@ -242,7 +243,7 @@ public interface PublicationService {
         *            the description of the relation
         * @return the created "Converts" relation
         */
-       public ConvertsRelation attach(Publication aPublication, String format,
+       ConvertsRelation attach(Publication aPublication, String format,
                        String description);
 
        /**
@@ -254,7 +255,7 @@ public interface PublicationService {
         * @see #outdate()
         * @see DocumentRights#canAccept()
         */
-       public boolean actualize(Publication aPublication);
+       boolean actualize(Publication aPublication);
 
        /**
         * Out-dates this publication and recursively all publications using this one. Typically, a publication is out-dated when modifying a
@@ -266,5 +267,5 @@ public interface PublicationService {
         * @see #getProgressState()
         * @see #actualize()
         */
-       public void outdate(Publication aPublication);
+       void outdate(Publication aPublication);
 }
index 08fd40d9640e88fc63d53a0484f16438b3bd8352..9e3a570afcbc01de09d022814d8408df5e009a1d 100644 (file)
@@ -59,7 +59,7 @@ public class PublicationServiceImpl implements PublicationService {
        /**
         * Logger for this class.
         */
-       protected final static Logger logger = Logger
+       protected final static Logger LOG = Logger
                        .getLogger(PublicationServiceImpl.class);
 
        /**
@@ -104,7 +104,7 @@ public class PublicationServiceImpl implements PublicationService {
         * 
         * @see org.splat.service.PublicationService#copy(org.splat.dal.bo.som.Publication, org.splat.dal.bo.som.ProjectElement)
         */
-       public Publication copy(Publication aPublication, ProjectElement publisher) {
+       public Publication copy(final Publication aPublication, final ProjectElement publisher) {
                Publication copy = new Publication();
                copy.setValue(aPublication.value());
                copy.setStep(aPublication.getStep()); // May not be initialized yet
@@ -121,9 +121,10 @@ public class PublicationServiceImpl implements PublicationService {
         * @see org.splat.service.PublicationService#versionDocument(org.splat.som.Step, org.splat.dal.bo.kernel.User, java.lang.String, long, java.lang.String, java.lang.String, org.splat.dal.bo.som.ProgressState, java.util.Date, java.lang.String[], long[])
         */
        @Transactional
-       public void versionDocument(Step step, User user, String filename,
-                       long docIndex, String docver, String summary, ProgressState state,
-                       Date date, String[] docuses, long[] docusedby)
+       public void versionDocument(final Step step, final User user,
+                       final String filename, final long docIndex, final String docver,
+                       final String summary, final ProgressState state, final Date date,
+                       final String[] docuses, final long[] docusedby)
                        throws MissedPropertyException, InvalidPropertyException,
                        MultiplyDefinedException, IOException, MismatchException,
                        NotApplicableException, InterruptedException {
@@ -135,49 +136,56 @@ public class PublicationServiceImpl implements PublicationService {
                Publication current = step.getDocument(docIndex);
                Publication next;
 
-               if (docver.length() == 0) { // Importation of a foreign document
-                       next = getStepService().versionDocument(step, current,
-                                       dprop.setAuthor(user).setDescription(summary));
-                       updir = next.getSourceFile().asFile();
-                       if (logger.isInfoEnabled())
-                               logger.info("Moving \"" + upfile.getName() + "\" to \""
-                                               + updir.getPath() + "\".");
-                       upfile.renameTo(updir);
-                       try {
+               if ((docver.length() != 0) && // Importation of a not foreign document
+                               (date != null)) {
+                       dprop.setDate(date);
+               }
+               next = getStepService().versionDocument(step, current,
+                               dprop.setAuthor(user).setDescription(summary));
+               updir = next.getSourceFile().asFile();
+               if (LOG.isInfoEnabled()) {
+                       LOG.info("Moving \"" + upfile.getName() + "\" to \""
+                                       + updir.getPath() + "\".");
+               }
+               upfile.renameTo(updir);
+
+               try {
+                       if (docver.length() == 0) { // Importation of a foreign document
                                saveAs(next, state); // May throw FileNotFound if rename was not done
-                       } catch (FileNotFoundException saverror) {
-                               Thread.sleep(1000);
-                               logger.info("Waiting for the file.");
-                               upfile.renameTo(updir);
-                               saveAs(next, state); // Forget it if throw again FileNotFound
-                       }
-               } else {
-                       if (date != null) {
-                               dprop.setDate(date);
-                       }
-                       next = getStepService().versionDocument(step, current,
-                                       dprop.setAuthor(user).setDescription(summary));
-                       updir = next.getSourceFile().asFile();
-                       if (logger.isInfoEnabled())
-                               logger.info("Moving \"" + upfile.getName() + "\" to \""
-                                               + updir.getPath() + "\".");
-                       upfile.renameTo(updir);
-                       try {
+                       } else {
                                saveAs(next, new Revision(docver));
-                       } catch (FileNotFoundException saverror) {
-                               Thread.sleep(1000);
-                               logger.info("Waiting for the file.");
-                               upfile.renameTo(updir);
-                               saveAs(next, state);
                        }
+               } catch (FileNotFoundException saverror) {
+                       Thread.sleep(1000);
+                       LOG.info("Waiting for the file.");
+                       upfile.renameTo(updir);
+                       saveAs(next, state);
                }
                // TODO: Remove current document details from the contents of open study
 
                // Creation of uses relations
+               updateRelations(current, next, docuses, docusedby);
+       }
+
+       /**
+        * Update relations after creation of a new document version.
+        * 
+        * @param current
+        *            the current version
+        * @param next
+        *            the new version
+        * @param docuses
+        *            ids of used documents
+        * @param docusedby
+        *            ids of documents used by the versioned one.
+        */
+       private void updateRelations(final Publication current,
+                       final Publication next, final String[] docuses,
+                       final long[] docusedby) {
                if (docuses != null) {
                        for (int i = 0; i < docuses.length; i++) {
                                Long index = Long.valueOf(docuses[i].trim());
-                               Publication used = getPublicationDAO().get(index);//RKV: getPublication(index, steps);
+                               Publication used = getPublicationDAO().get(index);// RKV: getPublication(index, steps);
                                next.addDependency(used);
                        }
                }
@@ -191,10 +199,10 @@ public class PublicationServiceImpl implements PublicationService {
                List<Publication> relist = current.getRelations(UsedByRelation.class);
                for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
                        Publication using = i.next();
-                       if (!compatible.contains(using.getIndex()))
+                       if (!compatible.contains(using.getIndex())) {
                                outdate(using);
+                       }
                }
-
        }
 
 /*     protected Publication getPublication(int index, List<Step> steps) {
@@ -215,27 +223,27 @@ public class PublicationServiceImpl implements PublicationService {
         * @see org.splat.service.PublicationService#approve(org.splat.dal.bo.som.Publication, java.util.Date)
         */
        @Transactional
-       public Timestamp approve(Publication aPublication, Date adate) {
-               if (aPublication.isOutdated())
-                       return null;
-               else if (aPublication.value().getProgressState() != ProgressState.inCHECK)
-                       return null; // This statement must conform to the corresponding right
-
-               DocumentType type = aPublication.value().getType();
-               Study owner = aPublication.getOwnerStudy();
-               ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
-                               type);
-               User approver = cycle.getActor(ValidationStep.APPROVAL);
-               Timestamp stamp = new Timestamp(ValidationStep.APPROVAL, aPublication
-                               .value(), approver, adate);
-               getTimestampDAO().create(stamp);
-               
-               if (!getDocumentService().promote(aPublication.value(), stamp))
-                       return null;
-               if (getDocumentService().isStudyResult(type)
-                               && owner.getProgressState() == ProgressState.inCHECK)
-                       getStudyService().promote(owner);
-               return stamp; // Hoping that promotion of the study succeeded
+       public Timestamp approve(final Publication aPublication, final Date adate) {
+               Timestamp res = null;
+               if (!(aPublication.isOutdated() || (aPublication.value().getProgressState() != ProgressState.inCHECK))) {
+                       DocumentType type = aPublication.value().getType();
+                       Study owner = aPublication.getOwnerStudy();
+                       ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
+                                       type);
+                       User approver = cycle.getActor(ValidationStep.APPROVAL);
+                       Timestamp stamp = new Timestamp(ValidationStep.APPROVAL, aPublication
+                                       .value(), approver, adate);
+                       getTimestampDAO().create(stamp);
+                       
+                       if (getDocumentService().promote(aPublication.value(), stamp)) {
+                               res = stamp;
+                               if (getDocumentService().isStudyResult(type)
+                                               && owner.getProgressState() == ProgressState.inCHECK) {
+                                       getStudyService().promote(owner);
+                               }
+                       }
+               }
+               return res; // Hoping that promotion of the study succeeded
        }
 
        /**
@@ -244,7 +252,8 @@ public class PublicationServiceImpl implements PublicationService {
         * @see org.splat.service.PublicationService#demote(org.splat.dal.bo.som.Publication)
         */
        @Transactional
-       public boolean demote(Publication aPublication) {
+       public boolean demote(final Publication aPublication) {
+               boolean res = false;
                DocumentType type = aPublication.value().getType();
                Study owner = aPublication.getOwnerStudy();
 
@@ -252,23 +261,21 @@ public class PublicationServiceImpl implements PublicationService {
                        ValidationCycle cycle = getStudyService().getValidationCycleOf(
                                        owner, type);
                        if (cycle.enables(ValidationStep.REVIEW)) {
-                               if (!getDocumentService().demote(aPublication.value()))
-                                       return false;
+                               res = getDocumentService().demote(aPublication.value());
                        } else {
-                               if (!getDocumentService().demote(aPublication.value()))
-                                       return false;
-                               getDocumentService().demote(aPublication.value());
+                               res = getDocumentService().demote(aPublication.value());
+                               if (res) {
+                                       getDocumentService().demote(aPublication.value());
+                               }
                        }
                } else if (aPublication.value().getProgressState() == ProgressState.inDRAFT) {
-                       if (!getDocumentService().demote(aPublication.value()))
-                               return false;
-               } else {
-                       return false;
+                       res = getDocumentService().demote(aPublication.value());
                }
-               if (getDocumentService().isStudyResult(type)
-                               && owner.getProgressState() != ProgressState.inWORK)
+               if (res && getDocumentService().isStudyResult(type)
+                               && owner.getProgressState() != ProgressState.inWORK) {
                        getStudyService().demote(owner);
-               return true;
+               }
+               return res;
        }
 
        /**
@@ -277,17 +284,19 @@ public class PublicationServiceImpl implements PublicationService {
         * @see org.splat.service.PublicationService#invalidate(org.splat.dal.bo.som.Publication)
         */
        @Transactional
-       public boolean invalidate(Publication aPublication) {
-               if (aPublication.value().getProgressState() != ProgressState.inCHECK)
-                       return false;
-               if (!getDocumentService().demote(aPublication.value())) // Removes the reviewer if this document is In-Check
-                       return false;
-               DocumentType type = aPublication.value().getType();
-               Study owner = aPublication.getOwnerStudy();
-               if (getDocumentService().isStudyResult(type)
-                               && owner.getProgressState() == ProgressState.inCHECK)
-                       getStudyService().demote(owner);
-               return true;
+       public boolean invalidate(final Publication aPublication) {
+               boolean res = false;
+               if ((aPublication.value().getProgressState() == ProgressState.inCHECK)
+                               && getDocumentService().demote(aPublication.value())) {
+                       DocumentType type = aPublication.value().getType();
+                       Study owner = aPublication.getOwnerStudy();
+                       if (getDocumentService().isStudyResult(type)
+                                       && owner.getProgressState() == ProgressState.inCHECK) {
+                               getStudyService().demote(owner);
+                       }
+                       res = true;
+               }
+               return res;
        }
 
        /**
@@ -296,35 +305,37 @@ public class PublicationServiceImpl implements PublicationService {
         * @see org.splat.service.PublicationService#promote(org.splat.dal.bo.som.Publication, java.util.Date)
         */
        @Transactional
-       public Timestamp promote(Publication aPublication, Date pdate) {
-               if (aPublication.isOutdated())
-                       return null;
-               else if (aPublication.value().getProgressState() != ProgressState.inWORK)
-                       return null; // This statement must conform to the corresponding right
-               else {
+       public Timestamp promote(final Publication aPublication, final Date pdate) {
+               Timestamp res = null;
+               if ((!aPublication.isOutdated())
+                               && (aPublication.value().getProgressState() == ProgressState.inWORK)) {
                        DocumentType type = aPublication.value().getType();
                        Study owner = aPublication.getOwnerStudy();
                        ValidationCycle cycle = getStudyService().getValidationCycleOf(
                                        owner, type);
                        User promoter = cycle.getActor(ValidationStep.PROMOTION);
-                       if (promoter == null)
+                       if (promoter == null) {
                                promoter = getInvolvedStep(aPublication).getActor();
-                       if (promoter == null)
+                       }
+                       if (promoter == null) {
                                promoter = owner.getAuthor();
+                       }
                        Timestamp stamp = new Timestamp(ValidationStep.PROMOTION,
                                        aPublication.value(), promoter, pdate);
                        getTimestampDAO().create(stamp);
 
-                       if (!getDocumentService().promote(aPublication.value(), stamp)) // Promotion to being reviewed
-                               return null;
-                       if (!cycle.enables(ValidationStep.REVIEW)) {
-                               getDocumentService().promote(aPublication.value(), null);
+                       if (getDocumentService().promote(aPublication.value(), stamp)) {
+                               res = stamp;
+                               if (!cycle.enables(ValidationStep.REVIEW)) {
+                                       getDocumentService().promote(aPublication.value(), null);
+                               }
+                               if (getDocumentService().isStudyResult(type)
+                                               && owner.getProgressState() == ProgressState.inWORK) {
+                                       getStudyService().promote(owner);
+                               }
                        }
-                       if (getDocumentService().isStudyResult(type)
-                                       && owner.getProgressState() == ProgressState.inWORK)
-                               getStudyService().promote(owner);
-                       return stamp; // Hoping that promotion of the study succeeded
                }
+               return res; // Hoping that promotion of the study succeeded
        }
 
        /**
@@ -333,27 +344,29 @@ public class PublicationServiceImpl implements PublicationService {
         * @see org.splat.service.PublicationService#review(org.splat.dal.bo.som.Publication, java.util.Date)
         */
        @Transactional
-       public Timestamp review(Publication aPublication, Date rdate) {
-               if (aPublication.isOutdated())
-                       return null;
-               else if (aPublication.value().getProgressState() != ProgressState.inDRAFT)
-                       return null; // This statement must conform to the corresponding right
+       public Timestamp review(final Publication aPublication, final Date rdate) {
+               Timestamp res = null;
+               if (!aPublication.isOutdated()
+                               && !(aPublication.value().getProgressState() != ProgressState.inDRAFT)) {
 
-               DocumentType type = aPublication.value().getType();
-               Study owner = aPublication.getOwnerStudy();
-               ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
-                               type);
-               User reviewer = cycle.getActor(ValidationStep.REVIEW);
-               Timestamp stamp = new Timestamp(ValidationStep.REVIEW, aPublication
-                               .value(), reviewer, rdate);
-               getTimestampDAO().create(stamp);
-               
-               if (!getDocumentService().promote(aPublication.value(), stamp))
-                       return null;
-               if (getDocumentService().isStudyResult(type)
-                               && owner.getProgressState() == ProgressState.inDRAFT)
-                       getStudyService().promote(owner);
-               return stamp; // Hoping that promotion of the study succeeded
+                       DocumentType type = aPublication.value().getType();
+                       Study owner = aPublication.getOwnerStudy();
+                       ValidationCycle cycle = getStudyService().getValidationCycleOf(
+                                       owner, type);
+                       User reviewer = cycle.getActor(ValidationStep.REVIEW);
+                       Timestamp stamp = new Timestamp(ValidationStep.REVIEW, aPublication
+                                       .value(), reviewer, rdate);
+                       getTimestampDAO().create(stamp);
+
+                       if (getDocumentService().promote(aPublication.value(), stamp)) {
+                               res = stamp;
+                               if (getDocumentService().isStudyResult(type)
+                                               && owner.getProgressState() == ProgressState.inDRAFT) {
+                                       getStudyService().promote(owner);
+                               }
+                       }
+               }
+               return res; // Hoping that promotion of the study succeeded
        }
 
        /**
@@ -362,14 +375,17 @@ public class PublicationServiceImpl implements PublicationService {
         * @see org.splat.service.PublicationService#saveAs(org.splat.dal.bo.som.Publication, org.splat.som.Revision)
         * @deprecated
         */
+       @Deprecated
        @Transactional
-       public void saveAs(Publication aPublication, Revision newvers)
+       public void saveAs(final Publication aPublication, final Revision newvers)
                        throws FileNotFoundException, NotApplicableException {
-               if (aPublication.value().isUndefined())
+               if (aPublication.value().isUndefined()) {
                        throw new NotApplicableException(
                                        "Cannot save a Publication object refering an undefined Document");
-               if (!aPublication.value().getSourceFile().exists())
+               }
+               if (!aPublication.value().getSourceFile().exists()) {
                        throw new FileNotFoundException();
+               }
 
                getPublicationDAO().create(aPublication); // Must be done before updating the study in order to fix this final (rid-based) hascode
                getDocumentService().updateAs(aPublication.value(), newvers); // May change the branch name of given revision
@@ -382,13 +398,15 @@ public class PublicationServiceImpl implements PublicationService {
         * @see org.splat.service.PublicationService#saveAs(org.splat.dal.bo.som.Publication, org.splat.dal.bo.som.ProgressState)
         */
        @Transactional
-       public void saveAs(Publication aPublication, ProgressState state)
+       public void saveAs(final Publication aPublication, final ProgressState state)
                        throws FileNotFoundException, NotApplicableException {
-               if (aPublication.value().isUndefined())
+               if (aPublication.value().isUndefined()) {
                        throw new NotApplicableException(
                                        "Cannot save a Publication object refering an undefined Document");
-               if (!aPublication.value().getSourceFile().exists())
+               }
+               if (!aPublication.value().getSourceFile().exists()) {
                        throw new FileNotFoundException();
+               }
 
                if (state == ProgressState.inWORK || state == ProgressState.EXTERN) {
                        getPublicationDAO().create(aPublication); // Must be done before updating the study in order to fix this final (rid-based)
@@ -424,7 +442,7 @@ public class PublicationServiceImpl implements PublicationService {
         *            the document publication
         */
        @Transactional
-       private void updateOwner(Publication aPublication) {
+       private void updateOwner(final Publication aPublication) {
                Step step = getInvolvedStep(aPublication);
 
                // Update of involved step
@@ -455,51 +473,58 @@ public class PublicationServiceImpl implements PublicationService {
         * @param to
         *            the study step
         */
-       private void forwardProperties(Publication aPublication, java.io.File from,
-                       Step to) {
+       private void forwardProperties(final Publication aPublication,
+                       final java.io.File from, final Step to) {
                Reader tool = Toolbox.getReader(from);
-               if (tool == null)
-                       return; // No properties extractor available for this type of document
-
-               SimulationContextType.Properties sprop = new SimulationContextType.Properties()
-                               .setStep(to.getStep()).setProgressState(ProgressState.APPROVED);
-               List<SimulationContextType> contype = getSimulationContextService()
-                               .selectTypesWhere(sprop);
-               if (contype.isEmpty())
-                       return; // No approved property type configured at this step
-
-               SimulationContext.Properties cprop = new SimulationContext.Properties();
-               List<SimulationContext> context = to.getAllSimulationContexts();
-
-               context = new ArrayList<SimulationContext>(context.size());
-               context.addAll(to.getAllSimulationContexts());
-               cprop.disableCheck();
-               for (Iterator<SimulationContextType> i = contype.iterator(); i
-                               .hasNext();) {
-                       SimulationContextType property = i.next();
-                       for (Iterator<SimulationContext> j = context.iterator(); j
-                                       .hasNext();) {
-                               SimulationContext existing = j.next();
-                               if (!existing.getType().equals(property))
-                                       continue;
-                               property = null; // Forget this property as it is already set
-                               break;
-                       }
-                       if (property != null)
-                               try {
-                                       String value = tool.extractProperty(property.getName());
-                                       if (value == null)
-                                               continue; // Property not defined into the document
-
-                                       cprop.setType(property).setValue(value);
-                                       if (aPublication.getOwner() instanceof Study)
-                                               getStudyService().addProjectContext(
-                                                               (Study) aPublication.getOwner(), cprop); // Re-indexes knowledges and the study
-                                       else
-                                               getStepService().addSimulationContext(to, cprop); // Re-indexes knowledges only
-                               } catch (Exception e) {
-                                       break;
+               if (tool != null) { // Properties extractor available for this type of document
+                       SimulationContextType.Properties sprop = new SimulationContextType.Properties()
+                                       .setStep(to.getStep()).setProgressState(
+                                                       ProgressState.APPROVED);
+                       List<SimulationContextType> contype = getSimulationContextService()
+                                       .selectTypesWhere(sprop);
+                       if (!contype.isEmpty()) { // There is an approved property type configured at this step
+
+                               SimulationContext.Properties cprop = new SimulationContext.Properties();
+                               List<SimulationContext> context = to.getAllSimulationContexts();
+
+                               context = new ArrayList<SimulationContext>(context.size());
+                               context.addAll(to.getAllSimulationContexts());
+                               cprop.disableCheck();
+                               for (Iterator<SimulationContextType> i = contype.iterator(); i
+                                               .hasNext();) {
+                                       SimulationContextType property = i.next();
+                                       boolean isFound = false;
+                                       for (Iterator<SimulationContext> j = context.iterator(); j
+                                                       .hasNext();) {
+                                               SimulationContext existing = j.next();
+                                               isFound = existing.getType().equals(property);
+                                               if (isFound) {
+                                                       // Forget this property as it is already set
+                                                       break;
+                                               }
+                                       }
+                                       if (!isFound) {
+                                               try {
+                                                       String value = tool.extractProperty(property
+                                                                       .getName());
+                                                       if (value == null) {
+                                                               continue; // Property not defined into the document
+                                                       }
+
+                                                       cprop.setType(property).setValue(value);
+                                                       if (aPublication.getOwner() instanceof Study) {
+                                                               getStudyService().addProjectContext(
+                                                                               (Study) aPublication.getOwner(), cprop); // Re-indexes knowledges and the study
+                                                       } else {
+                                                               getStepService()
+                                                                               .addSimulationContext(to, cprop); // Re-indexes knowledges only
+                                                       }
+                                               } catch (Exception e) {
+                                                       break;
+                                               }
+                                       }
                                }
+                       }
                }
        }
 
@@ -510,14 +535,15 @@ public class PublicationServiceImpl implements PublicationService {
         *            the document publication
         * @return the study step where the document is published
         */
-       public Step getInvolvedStep(Publication aPublication) {
+       public Step getInvolvedStep(final Publication aPublication) {
                if (aPublication.getStep() == null) {
                        Step[] step = getProjectElementService().getSteps(
                                        aPublication.getOwner());
                        for (int i = 0; i < step.length; i++) {
                                aPublication.setStep(step[i]); // The involved step necessarily exists
-                               if (aPublication.value().isInto(aPublication.getStep()))
+                               if (aPublication.value().isInto(aPublication.getStep())) {
                                        break;
+                               }
                        }
                }
                return aPublication.getStep();
@@ -533,12 +559,13 @@ public class PublicationServiceImpl implements PublicationService {
         * @see DocumentRights#canAccept()
         */
        @Transactional
-       public boolean actualize(Publication aPublication) {
-               if (!aPublication.isOutdated())
-                       return false;
-               aPublication.setIsnew('Y');
-               getPublicationDAO().update(aPublication);
-               return true;
+       public boolean actualize(final Publication aPublication) {
+               boolean res = aPublication.isOutdated();
+               if (res) {
+                       aPublication.setIsnew('Y');
+                       getPublicationDAO().update(aPublication);
+               }
+               return res;
        }
 
        /**
@@ -551,9 +578,10 @@ public class PublicationServiceImpl implements PublicationService {
         * @see #getProgressState()
         * @see #actualize()
         */
-       public void outdate(Publication aPublication) {
-               if (aPublication.isOutdated())
+       public void outdate(final Publication aPublication) {
+               if (aPublication.isOutdated()) {
                        return;
+               }
 
                List<Publication> relist = aPublication
                                .getRelations(UsedByRelation.class);
@@ -573,7 +601,7 @@ public class PublicationServiceImpl implements PublicationService {
         *            the format
         * @return the created "Converts" relation
         */
-       public ConvertsRelation attach(Publication aPublication, String format) {
+       public ConvertsRelation attach(final Publication aPublication, final String format) {
                return getDocumentService().attach(aPublication.value(), format);
        }
 
@@ -588,8 +616,8 @@ public class PublicationServiceImpl implements PublicationService {
         *            the description of the relation
         * @return the created "Converts" relation
         */
-       public ConvertsRelation attach(Publication aPublication, String format,
-                       String description) {
+       public ConvertsRelation attach(final Publication aPublication, final String format,
+                       final String description) {
                return getDocumentService().attach(aPublication.value(), format,
                                description);
        }
@@ -604,7 +632,7 @@ public class PublicationServiceImpl implements PublicationService {
         * @throws InvalidPropertyException
         *             if the new title is empty
         */
-       public void rename(Publication aPublication, String title)
+       public void rename(final Publication aPublication, final String title)
                        throws InvalidPropertyException {
                getDocumentService().rename(aPublication.value(), title);
        }
@@ -625,7 +653,7 @@ public class PublicationServiceImpl implements PublicationService {
         *            the projectElementService to set
         */
        public void setProjectElementService(
-                       ProjectElementService projectElementService) {
+                       final ProjectElementService projectElementService) {
                _projectElementService = projectElementService;
        }
 
@@ -645,7 +673,7 @@ public class PublicationServiceImpl implements PublicationService {
         *            the simulationContextService to set
         */
        public void setSimulationContextService(
-                       SimulationContextService simulationContextService) {
+                       final SimulationContextService simulationContextService) {
                _simulationContextService = simulationContextService;
        }
 
@@ -664,7 +692,7 @@ public class PublicationServiceImpl implements PublicationService {
         * @param studyService
         *            the studyService to set
         */
-       public void setStudyService(StudyService studyService) {
+       public void setStudyService(final StudyService studyService) {
                _studyService = studyService;
        }
 
@@ -683,7 +711,7 @@ public class PublicationServiceImpl implements PublicationService {
         * @param stepService
         *            the stepService to set
         */
-       public void setStepService(StepService stepService) {
+       public void setStepService(final StepService stepService) {
                _stepService = stepService;
        }
 
@@ -702,7 +730,7 @@ public class PublicationServiceImpl implements PublicationService {
         * @param documentService
         *            the documentService to set
         */
-       public void setDocumentService(DocumentService documentService) {
+       public void setDocumentService(final DocumentService documentService) {
                _documentService = documentService;
        }
 
@@ -721,7 +749,7 @@ public class PublicationServiceImpl implements PublicationService {
         * @param publicationDAO
         *            the publicationDAO to set
         */
-       public void setPublicationDAO(PublicationDAO publicationDAO) {
+       public void setPublicationDAO(final PublicationDAO publicationDAO) {
                _publicationDAO = publicationDAO;
        }
 
@@ -740,7 +768,7 @@ public class PublicationServiceImpl implements PublicationService {
         * @param projectElementDAO
         *            the projectElementDAO to set
         */
-       public void setProjectElementDAO(ProjectElementDAO projectElementDAO) {
+       public void setProjectElementDAO(final ProjectElementDAO projectElementDAO) {
                _projectElementDAO = projectElementDAO;
        }
 
@@ -759,7 +787,7 @@ public class PublicationServiceImpl implements PublicationService {
         * @param repositoryService
         *            the repositoryService to set
         */
-       public void setRepositoryService(RepositoryService repositoryService) {
+       public void setRepositoryService(final RepositoryService repositoryService) {
                _repositoryService = repositoryService;
        }
 
@@ -775,7 +803,7 @@ public class PublicationServiceImpl implements PublicationService {
         * Set the timestampDAO.
         * @param timestampDAO the timestampDAO to set
         */
-       public void setTimestampDAO(TimestampDAO timestampDAO) {
+       public void setTimestampDAO(final TimestampDAO timestampDAO) {
                _timestampDAO = timestampDAO;
        }
 }
index 025a6cb5e3e64e00f1089ee9b349e60d6b8363c7..84bf9c78c97fd4294ed24ba9c2a5c89f13933440 100644 (file)
@@ -43,7 +43,7 @@ public interface ScenarioService {
         * @throws MultiplyDefinedException
         *             if some property occurs several times
         */
-       public Study createStudy(Study.Properties sprop, Scenario.Properties oprop,
+       Study createStudy(Study.Properties sprop, Scenario.Properties oprop,
                        SimulationContext.Properties cprop) throws MissedPropertyException,
                        InvalidPropertyException, MultiplyDefinedException;
 
@@ -62,7 +62,7 @@ public interface ScenarioService {
         * @throws MultiplyDefinedException
         *             if some property occurs several times
         */
-       public Scenario addScenario(Study aStudy, Scenario.Properties sprop)
+       Scenario addScenario(Study aStudy, Scenario.Properties sprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        MultiplyDefinedException;
 
@@ -81,7 +81,7 @@ public interface ScenarioService {
         * @throws MultiplyDefinedException
         *             if some property is defined several times
         */
-       public KnowledgeElement addKnowledgeElement(Scenario aScenario,
+       KnowledgeElement addKnowledgeElement(Scenario aScenario,
                        KnowledgeElement.Properties kprop) throws MissedPropertyException,
                        InvalidPropertyException, MultiplyDefinedException;
 
@@ -91,7 +91,7 @@ public interface ScenarioService {
         * @param aScenario
         *            the scenario to check in
         */
-       public void checkin(Scenario aScenario);
+       void checkin(Scenario aScenario);
 
        /**
         * Check out the scenario.
@@ -102,7 +102,7 @@ public interface ScenarioService {
         *            the current user
         * @return true if check out operation succeeded
         */
-       public boolean checkout(Scenario aScenario, User user);
+       boolean checkout(Scenario aScenario, User user);
 
        /**
         * Copy contents from other scenario up to its given step into the given scenario.
@@ -112,7 +112,7 @@ public interface ScenarioService {
         * @param lastep
         *            the last processed step of the source scenario
         */
-       public void copyContentsUpTo(Scenario scenario, Step lastep);
+       void copyContentsUpTo(Scenario scenario, Step lastep);
 
        /**
         * Check if the scenario is empty, i.d. no one of its steps doesn't contain any knowledge elements or documents.
@@ -121,7 +121,7 @@ public interface ScenarioService {
         *            the scenario to check
         * @return true if the scenario is empty
         */
-       public boolean isEmpty(Scenario scenario);
+       boolean isEmpty(Scenario scenario);
 
        /**
         * Remove a knowledge element from a scenario.
@@ -132,6 +132,6 @@ public interface ScenarioService {
         *            the knowledge element to remove
         * @return true if removal succeeded
         */
-       public boolean removeKnowledgeElement(Scenario scenario,
+       boolean removeKnowledgeElement(Scenario scenario,
                        KnowledgeElement kelm);
 }
index 6adbabaa6b6307520b204ad802b9ec9f483b221d..79c424db78803e1266126b9fb32039c30f3c476f 100644 (file)
@@ -44,7 +44,7 @@ public class ScenarioServiceImpl implements ScenarioService {
        /**
         * Logger for this class.
         */
-       protected final static Logger logger = Logger
+       protected final static Logger LOG = Logger
                        .getLogger(ScenarioServiceImpl.class);
 
        /**
@@ -212,8 +212,8 @@ public class ScenarioServiceImpl implements ScenarioService {
                KnowledgeElement kelm = null;
                try {
                        long aScenarioId = aScenarioDTO.getIndex();
-                       if (logger.isDebugEnabled()) {
-                               logger.debug("Add a knowledge element to the scenario #"
+                       if (LOG.isDebugEnabled()) {
+                               LOG.debug("Add a knowledge element to the scenario #"
                                                + aScenarioId);
                        }
                        // Get the persistent scenario.
@@ -239,12 +239,12 @@ public class ScenarioServiceImpl implements ScenarioService {
                        
                        // Update the lucene index of knowledge elements.
                        getIndexService().add(kelm);
-                       if (logger.isDebugEnabled()) {
-                               logger.debug("A knowledge element #" + kelm.getIndex()
+                       if (LOG.isDebugEnabled()) {
+                               LOG.debug("A knowledge element #" + kelm.getIndex()
                                                + " is added to the scenario #" + aScenario.getIndex());
                        }
                } catch (IOException error) {
-                       logger.error("Unable to index the knowedge element '"
+                       LOG.error("Unable to index the knowedge element '"
                                        + kelm.getIndex() + "', reason:", error);
                        kelm = null;
                }
@@ -266,7 +266,7 @@ public class ScenarioServiceImpl implements ScenarioService {
                        getScenarioDAO().update(aScenario); // Update of relational base
                        isOk = true;
                } catch (Exception error) {
-                       logger.error("Unable to re-index the knowledge element '"
+                       LOG.error("Unable to re-index the knowledge element '"
                                        + aScenario.getIndex() + "', reason:", error);
                }
                return isOk;
index cda12a1a07ab28edb54beeeba977477b8f88fc21..18a024d4b7101832881c6d0bd49d011f57e21973 100644 (file)
@@ -10,6 +10,7 @@
 package org.splat.service;
 
 import java.util.List;
+
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.Study;
 import org.splat.service.dto.ImportedStudyDTO;
@@ -27,7 +28,7 @@ public interface SearchService {
         * 
         * @return list of ImportedStudy DTO
         */
-       public List<ImportedStudyDTO> selectStudies();
+       List<ImportedStudyDTO> selectStudies();
 
        /**
         * Refresh lucene index for studies.
@@ -35,7 +36,7 @@ public interface SearchService {
         * @param ridlist
         *            list of studies id's
         */
-       public void reindexStudies(String[] ridlist);
+       void reindexStudies(String[] ridlist);
 
        /**
         * Find knowledge elements with given properties.
@@ -44,7 +45,7 @@ public interface SearchService {
         *            search filter parameters
         * @return the list of found knowledge elements as proxiy results of lucene search
         */
-       public List<Proxy> selectKnowledgeElementsWhere(
+       List<Proxy> selectKnowledgeElementsWhere(
                        KnowledgeElement.Properties... kprop);
 
        /**
@@ -54,7 +55,7 @@ public interface SearchService {
         *            search filter parameters
         * @return the list of found studies as proxiy results of lucene search
         */
-       public List<Proxy> selectStudiesWhere(Study.Properties... sprop);
+       List<Proxy> selectStudiesWhere(Study.Properties... sprop);
 
        /**
         * Refresh lucene index for a study.
@@ -62,5 +63,5 @@ public interface SearchService {
         * @param study
         *            the study to reindex
         */
-       public void indexStudy(Study study);
+       void indexStudy(Study study);
 }
index d58620a5368b5545a0375c534a8fd14fc84150f7..8fcb6693955ab7ea990f701b3157477ef43386cd 100644 (file)
@@ -39,11 +39,11 @@ import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.Visibility;
 import org.splat.dal.dao.som.StudyDAO;
+import org.splat.service.dto.ImportedStudyDTO;
 import org.splat.service.dto.Proxy;
 import org.splat.service.technical.IndexService;
 import org.splat.service.technical.IndexServiceImpl;
 import org.splat.service.technical.RepositoryService;
-import org.splat.service.dto.ImportedStudyDTO;
 import org.splat.util.BeanHelper;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -57,7 +57,7 @@ public class SearchServiceImpl implements SearchService {
        /**
         * The service logger.
         */
-       public final static Logger logger = Logger
+       public final static Logger LOG = Logger
                        .getLogger(org.splat.service.SearchServiceImpl.class);
 
        /**
@@ -113,7 +113,7 @@ public class SearchServiceImpl implements SearchService {
         *            list of studies id's
         */
        @Transactional(readOnly = true)
-       public void reindexStudies(String[] ridlist) {
+       public void reindexStudies(final String[] ridlist) {
                for (int i = 0; i < ridlist.length; i++) {
                        long index = Long.valueOf(ridlist[i].trim());
                        Study study = getStudyService().selectStudy(index);
@@ -127,7 +127,7 @@ public class SearchServiceImpl implements SearchService {
         * @see org.splat.service.SearchService#selectKnowledgeElementsWhere(org.splat.dal.bo.som.KnowledgeElement.Properties[])
         */
        public List<Proxy> selectKnowledgeElementsWhere(
-                       KnowledgeElement.Properties... kprop) {
+                       final KnowledgeElement.Properties... kprop) {
                List<Proxy> result = new ArrayList<Proxy>();
                int hitsize = 20;
                try {
@@ -187,8 +187,9 @@ public class SearchServiceImpl implements SearchService {
                                        BooleanQuery critext = new BooleanQuery();
                                        String operator = "AND"; // Future user input
                                        BooleanClause.Occur clause = BooleanClause.Occur.MUST;
-                                       if (operator.equals("OR"))
+                                       if (operator.equals("OR")) {
                                                clause = BooleanClause.Occur.SHOULD;
+                                       }
                                        String[] word = title.split(" ");
                                        for (int j = 0; j < word.length; j++) {
                                                critext.add(new TermQuery(input.createTerm(word[j])),
@@ -212,8 +213,8 @@ public class SearchServiceImpl implements SearchService {
                                }
                                fulquery.add(query, BooleanClause.Occur.SHOULD);
                        }
-                       if (logger.isInfoEnabled()) {
-                               logger.info("Searching knowledges by Lucene query \""
+                       if (LOG.isInfoEnabled()) {
+                               LOG.info("Searching knowledges by Lucene query \""
                                                + fulquery.toString() + "\".");
                        }
                        // Creation of the knowledge filter
@@ -230,8 +231,9 @@ public class SearchServiceImpl implements SearchService {
                        TopFieldDocs found = searcher.search(fulquery, filter, hitsize,
                                        sort);
 
-                       if (found.totalHits < 1)
+                       if (found.totalHits < 1) {
                                return result; // No study found
+                       }
 
                        // Construction of the result list
                        ScoreDoc[] hits = found.scoreDocs;
@@ -241,7 +243,7 @@ public class SearchServiceImpl implements SearchService {
                        }
                        searcher.close();
                } catch (Exception error) {
-                       logger.error("Error during Lucene search, reason:", error);
+                       LOG.error("Error during Lucene search, reason:", error);
                }
                return result;
        }
@@ -251,7 +253,7 @@ public class SearchServiceImpl implements SearchService {
         * 
         * @see org.splat.service.SearchService#selectStudiesWhere(org.splat.dal.bo.som.Study.Properties[])
         */
-       public List<Proxy> selectStudiesWhere(Study.Properties... sprop) {
+       public List<Proxy> selectStudiesWhere(final Study.Properties... sprop) {
                List<Proxy> result = new ArrayList<Proxy>();
                int hitsize = 20;
                try {
@@ -317,8 +319,9 @@ public class SearchServiceImpl implements SearchService {
                                        BooleanQuery critext = new BooleanQuery();
                                        String operator = "AND"; // Future user input
                                        BooleanClause.Occur clause = BooleanClause.Occur.MUST;
-                                       if (operator.equals("OR"))
+                                       if (operator.equals("OR")) {
                                                clause = BooleanClause.Occur.SHOULD;
+                                       }
                                        String[] word = title.split(" ");
                                        for (int j = 0; j < word.length; j++) {
                                                critext.add(new TermQuery(input.createTerm(word[j])),
@@ -342,8 +345,8 @@ public class SearchServiceImpl implements SearchService {
                                }
                                fulquery.add(query, BooleanClause.Occur.SHOULD);
                        }
-                       if (logger.isInfoEnabled()) {
-                               logger.info("Searching studies by Lucene query \""
+                       if (LOG.isInfoEnabled()) {
+                               LOG.info("Searching studies by Lucene query \""
                                                + fulquery.toString() + "\".");
                        }
                        // Creation of the studies filter
@@ -360,8 +363,9 @@ public class SearchServiceImpl implements SearchService {
                        TopFieldDocs found = searcher.search(fulquery, filter, hitsize,
                                        sort);
 
-                       if (found.totalHits < 1)
+                       if (found.totalHits < 1) {
                                return result; // No study found
+                       }
 
                        // Construction of the result list
                        ScoreDoc[] hits = found.scoreDocs;
@@ -371,7 +375,7 @@ public class SearchServiceImpl implements SearchService {
                        }
                        searcher.close();
                } catch (Exception error) {
-                       logger.error("Error during Lucene search, reason:", error);
+                       LOG.error("Error during Lucene search, reason:", error);
                }
                return result;
        }
@@ -381,8 +385,8 @@ public class SearchServiceImpl implements SearchService {
         * 
         * @see org.splat.service.SearchService#indexStudy(org.splat.dal.bo.som.Study)
         */
-       public void indexStudy(Study study) {
-               logger.debug("Index study: id=" + study.getRid() + "; reference="
+       public void indexStudy(final Study study) {
+               LOG.debug("Index study: id=" + study.getRid() + "; reference="
                                + study.getReference());
                try {
                        Study.Properties sprop = new Study.Properties();
@@ -390,29 +394,30 @@ public class SearchServiceImpl implements SearchService {
                                        .getReference()));
 
                        if (index.size() != 0) {
-                               logger.debug("The given study is already indexed.");
+                               LOG.debug("The given study is already indexed.");
                                return; // The given study is already indexed
                        }
 
                        IndexService lucin = getIndex();
                        Scenario[] scenes = study.getScenarii();
 
-                       logger.debug("Number of study " + study.getReference()
+                       LOG.debug("Number of study " + study.getReference()
                                        + " actors: " + study.getActor().size());
                        lucin.add(study);
-                       if (study.getProgressState() != ProgressState.inWORK)
+                       if (study.getProgressState() != ProgressState.inWORK) {
                                for (int i = 0; i < scenes.length; i++) {
                                        List<KnowledgeElement> list = scenes[i]
                                                        .getAllKnowledgeElements();
                                        for (Iterator<KnowledgeElement> j = list.iterator(); j
                                                        .hasNext();) {
                                                lucin.add(j.next());
-                                               logger.debug("Knowlegge added: id="
+                                               LOG.debug("Knowlegge added: id="
                                                                + j.next().getIndex());
                                        }
                                }
+                       }
                } catch (Exception error) {
-                       logger.error("Unable to index the study '" + study.getIndex()
+                       LOG.error("Unable to index the study '" + study.getIndex()
                                        + "', reason:", error);
                }
        }
@@ -426,8 +431,9 @@ public class SearchServiceImpl implements SearchService {
         */
        private IndexService getIndex() throws IOException {
                IndexService lucin = getIndexService();
-               if (!lucin.exists())
+               if (!lucin.exists()) {
                        lucin.create(); // Happens when re-indexing all studies
+               }
                return lucin;
        }
 
@@ -446,7 +452,7 @@ public class SearchServiceImpl implements SearchService {
         * @param repositoryService
         *            the repositoryService to set
         */
-       public void setRepositoryService(RepositoryService repositoryService) {
+       public void setRepositoryService(final RepositoryService repositoryService) {
                _repositoryService = repositoryService;
        }
 
@@ -465,7 +471,7 @@ public class SearchServiceImpl implements SearchService {
         * @param indexService
         *            the indexService to set
         */
-       public void setIndexService(IndexService indexService) {
+       public void setIndexService(final IndexService indexService) {
                _indexService = indexService;
        }
 
@@ -484,7 +490,7 @@ public class SearchServiceImpl implements SearchService {
         * @param studyService
         *            the studyService to set
         */
-       public void setStudyService(StudyService studyService) {
+       public void setStudyService(final StudyService studyService) {
                _studyService = studyService;
        }
 
@@ -503,7 +509,7 @@ public class SearchServiceImpl implements SearchService {
         * @param studyDAO
         *            the studyDAO to set
         */
-       public void setStudyDAO(StudyDAO studyDAO) {
+       public void setStudyDAO(final StudyDAO studyDAO) {
                _studyDAO = studyDAO;
        }
 }
index e1b91331a8ca3080d8f2966fc0ce83afd38012b5..b4f0ae150d65e7feaf85d4a65d2722514d96e869 100644 (file)
@@ -30,14 +30,14 @@ public interface ServiceLocator {
         * @param studyService
         *            the studyService to set
         */
-       public void setStudyService(StudyService studyService);
+       void setStudyService(StudyService studyService);
 
        /**
         * Get the userService.
         * 
         * @return the userService
         */
-       public UserService getUserService();
+       UserService getUserService();
 
        /**
         * Set the userService.
@@ -45,5 +45,5 @@ public interface ServiceLocator {
         * @param userService
         *            the userService to set
         */
-       public void setUserService(UserService userService);
+       void setUserService(UserService userService);
 }
index 5810b0ac0cdbc0ccb8af50f8acdaa2dd5499db63..966d8824fde831166831bdd5278848010453b053 100644 (file)
@@ -16,21 +16,18 @@ package org.splat.service;
  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 @Deprecated
-public class ServiceLocatorImpl implements ServiceLocator {
+public final class ServiceLocatorImpl implements ServiceLocator {
 
        /**
         * The Locator instance.
         */
-       static ServiceLocator theInstance;
+       static private ServiceLocator theInstance = new ServiceLocatorImpl();
 
        /**
         * Get the locator instance.
         * @return the locator instance
         */
        public static ServiceLocator getInstance() {
-               if (theInstance == null) {
-                       theInstance = new ServiceLocatorImpl();
-               }
                return theInstance;
        }
        
@@ -61,7 +58,7 @@ public class ServiceLocatorImpl implements ServiceLocator {
         * Set the studyService.
         * @param studyService the studyService to set
         */
-       public void setStudyService(StudyService studyService) {
+       public void setStudyService(final StudyService studyService) {
                _studyService = studyService;
        }
 
@@ -77,7 +74,7 @@ public class ServiceLocatorImpl implements ServiceLocator {
         * Set the userService.
         * @param userService the userService to set
         */
-       public void setUserService(UserService userService) {
+       public void setUserService(final UserService userService) {
                _userService = userService;
        }
 }
index e82b810d43dc0e059f2ac5f5668fa7b0613f4d4e..866f29ffba3d26d09253585e20478875174cffe9 100644 (file)
@@ -36,7 +36,7 @@ public interface SimulationContextService {
         * @throws InvalidPropertyException
         *             if the given state is invalid
         */
-       public Vector<SimulationContextFacade> getSimulationContextsInState(
+       Vector<SimulationContextFacade> getSimulationContextsInState(
                        ProgressState aState) throws InvalidPropertyException;
 
        /**
@@ -46,7 +46,7 @@ public interface SimulationContextService {
         *            simulation context id.
         * @return found context
         */
-       public SimulationContext selectSimulationContext(long index);
+       SimulationContext selectSimulationContext(long index);
 
        /**
         * Find simulation context by its type and value.
@@ -57,7 +57,7 @@ public interface SimulationContextService {
         *            context value
         * @return found context
         */
-       public SimulationContext selectSimulationContext(
+       SimulationContext selectSimulationContext(
                        SimulationContextType celt, String value);
 
        /**
@@ -67,7 +67,7 @@ public interface SimulationContextService {
         *            example properties
         * @return list of contexts
         */
-       public List<SimulationContext> selectSimulationContextsWhere(
+       List<SimulationContext> selectSimulationContextsWhere(
                        SimulationContext.Properties cprop);
 
        /**
@@ -75,7 +75,7 @@ public interface SimulationContextService {
         * 
         * @return list of context types
         */
-       public List<SimulationContextType> selectAllTypes();
+       List<SimulationContextType> selectAllTypes();
 
        /**
         * Get simulation context types related to given activities.
@@ -84,7 +84,7 @@ public interface SimulationContextService {
         *            the activity
         * @return list of found context types
         */
-       public List<SimulationContextType> selectTypesOf(
+       List<SimulationContextType> selectTypesOf(
                        ProjectSettingsService.Step... step);
 
        /**
@@ -94,7 +94,7 @@ public interface SimulationContextService {
         *            the example
         * @return list of found context types
         */
-       public List<SimulationContextType> selectTypesWhere(
+       List<SimulationContextType> selectTypesWhere(
                        SimulationContextType.Properties sprop);
 
        /**
@@ -104,7 +104,7 @@ public interface SimulationContextService {
         *            name of the context type
         * @return found context type
         */
-       public SimulationContextType selectType(String name);
+       SimulationContextType selectType(String name);
 
        /**
         * Get simulation context type by its id.
@@ -113,7 +113,7 @@ public interface SimulationContextService {
         *            simulation context type id.
         * @return found context type
         */
-       public SimulationContextType selectType(long index);
+       SimulationContextType selectType(long index);
 
        /**
         * Hold the simulation context.
@@ -121,7 +121,7 @@ public interface SimulationContextService {
         * @param simCtx
         *            the context to hold.
         */
-       public void hold(SimulationContext simCtx);
+       void hold(SimulationContext simCtx);
 
        /**
         * Release the simulation context.
@@ -129,7 +129,7 @@ public interface SimulationContextService {
         * @param simCtx
         *            the context to release
         */
-       public void release(SimulationContext simCtx);
+       void release(SimulationContext simCtx);
 
        /**
         * Get the simulation context list for displaying drop-down list values populating on the "Create new study" screen.
@@ -142,6 +142,6 @@ public interface SimulationContextService {
         * @param simCtxType
         * @return
         */
-       public ProjectSettingsService.Step getAttachedStep(
+       ProjectSettingsService.Step getAttachedStep(
                        SimulationContextType simCtxType);
 }
index 209d9637d244dab2c105edab9432c3d7e4c4cf81..34a5cf3773431cdebcbe3fba9384af4c00bc0220 100644 (file)
@@ -38,8 +38,14 @@ public class SimulationContextServiceImpl implements SimulationContextService {
        /**
         * logger for the service.
         */
-       public final static AppLogger logger = AppLogger
+       public final static AppLogger LOG = AppLogger
                        .getLogger(SimulationContextServiceImpl.class);
+       
+       /**
+        * Step property name.
+        */
+       public final static String STEP_PROP = "step";
+       
        /**
         * Injected simulation context DAO.
         */
@@ -52,7 +58,7 @@ public class SimulationContextServiceImpl implements SimulationContextService {
        /**
         * Injected project settings service.
         */
-       private ProjectSettingsService _projectSettingsService;
+       private ProjectSettingsService _projectSettings;
 
        /**
         * Get simulation contexts which are currently in the given state.
@@ -104,7 +110,7 @@ public class SimulationContextServiceImpl implements SimulationContextService {
                                result = clist.get(0); // Supposed being the most used one if many exist
                        }
                } catch (InvalidPropertyException error) {
-                       logger.info("Attempt to select a simulation context \""
+                       LOG.info("Attempt to select a simulation context \""
                                        + celt.getName() + "\" with an invalid value.");
                }
                return result;
@@ -179,7 +185,7 @@ public class SimulationContextServiceImpl implements SimulationContextService {
        public List<SimulationContextType> selectAllTypes() {
                // Useless to order by names as the result mixes localized
                // and non localized types
-               return getSimulationContextTypeDAO().getAll(Order.asc("step"));
+               return getSimulationContextTypeDAO().getAll(Order.asc(STEP_PROP));
        }
 
        /**
@@ -197,13 +203,13 @@ public class SimulationContextServiceImpl implements SimulationContextService {
                // .append("'");
                // }
                // query = query.append(" order by step asc");
-               Criterion aCondition = Restrictions.eq("step", step[0].getNumber());
+               Criterion aCondition = Restrictions.eq(STEP_PROP, step[0].getNumber());
                for (int i = 1; i < step.length; i++) { // Useless to order as the result mixes localized and non localized types
-                       aCondition = Restrictions.or(aCondition, Restrictions.eq("step",
+                       aCondition = Restrictions.or(aCondition, Restrictions.eq(STEP_PROP,
                                        step[i].getNumber()));
                }
                return getSimulationContextTypeDAO().getFilteredList(aCondition,
-                               Order.asc("step"));
+                               Order.asc(STEP_PROP));
        }
 
        /**
@@ -238,19 +244,19 @@ public class SimulationContextServiceImpl implements SimulationContextService {
                // }
                // query = query.append(order);
                Criterion aCondition = null;
-               Order anOrder = Order.asc("step");
+               Order anOrder = Order.asc(STEP_PROP);
                if (step != null) {
-                       aCondition = Restrictions.eq("step", step.getNumber());
+                       aCondition = Restrictions.eq(STEP_PROP, step.getNumber());
                        anOrder = Order.desc("state"); // APPROVED (upper case A) is grater than inCHECK (lower case i)
                }
                if (state != null) {
                        aCondition = Restrictions.and(aCondition, Restrictions.eq("state",
                                        state));
                        if (step != null) {
-                               if (state != ProgressState.APPROVED) {
-                                       anOrder = Order.asc("name");
-                               } else {
+                               if (state == ProgressState.APPROVED) {
                                        anOrder = null; // Approved types are localized
+                               } else {
+                                       anOrder = Order.asc("name");
                                }
                        }
                }
@@ -310,14 +316,14 @@ public class SimulationContextServiceImpl implements SimulationContextService {
         * @return true if approval succeeded
         */
        public boolean approve(final 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);
+               boolean res = (simCtx.getProgressState() == ProgressState.inCHECK);
+               if (res) {
+                       simCtx.setProgressState(ProgressState.APPROVED); // The type name is supposed being localized
+                       if (simCtx.isSaved()) {
+                               getSimulationContextDAO().update(simCtx);
+                       }
                }
-               return true;
+               return res;
        }
 
        /**
@@ -375,7 +381,7 @@ public class SimulationContextServiceImpl implements SimulationContextService {
         * @return Project settings service
         */
        private ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
+               return _projectSettings;
        }
 
        /**
@@ -385,6 +391,6 @@ public class SimulationContextServiceImpl implements SimulationContextService {
         *            project settings service
         */
        public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
+               _projectSettings = projectSettingsService;
        }
 }
index 10d50f6152dc82dea25943407ded7393554ad743..0d73fd5665bfe8fbb0c43b7a06ba79f4d5c79ae9 100644 (file)
@@ -32,7 +32,7 @@ public interface SimulationContextTypeService {
         * @throws InvalidPropertyException
         *             if some property of the type to be created is invalid
         */
-       public SimulationContextType createType(String name,
+       SimulationContextType createType(String name,
                        ProjectSettingsService.Step step) throws InvalidPropertyException;
 
        /**
@@ -42,6 +42,6 @@ public interface SimulationContextTypeService {
         *            the type to approve
         * @return true if approval succeeded
         */
-       public boolean approve(SimulationContextType simCtxType);
+       boolean approve(SimulationContextType simCtxType);
 
 }
index 35a8ad057671d0da2f5cf1a04962e3c6f6cfd714..bc93b46bddadf6233b091aa6f211c640019c72ce 100644 (file)
@@ -47,7 +47,7 @@ public interface StepService {
         * @throws IOException
         *             if a file system error occurs
         */
-       public Publication createDocument(Step aStep, Document.Properties dprop)
+       Publication createDocument(Step aStep, Document.Properties dprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        MultiplyDefinedException, IOException;
 
@@ -66,7 +66,7 @@ public interface StepService {
         * @throws NotApplicableException
         *             if the document is undefined
         */
-       public Publication assignDocument(Step aStep, Document.Properties dprop)
+       Publication assignDocument(Step aStep, Document.Properties dprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        NotApplicableException;
 
@@ -91,7 +91,7 @@ public interface StepService {
         * @throws MismatchException
         *             if the document is not applicable to the given study step
         */
-       public Publication versionDocument(Step aStep, Publication base,
+       Publication versionDocument(Step aStep, Publication base,
                        Document.Properties dprop) throws MissedPropertyException,
                        InvalidPropertyException, MultiplyDefinedException, IOException,
                        MismatchException;
@@ -111,7 +111,7 @@ public interface StepService {
         * @throws MultiplyDefinedException
         *             if some property is defined several times
         */
-       public SimulationContext addSimulationContext(Step aStep,
+       SimulationContext addSimulationContext(Step aStep,
                        SimulationContext.Properties dprop) throws MissedPropertyException,
                        InvalidPropertyException, MultiplyDefinedException;
 
@@ -124,7 +124,7 @@ public interface StepService {
         *            the simulation context to add
         * @return the added simulation context
         */
-       public SimulationContext addSimulationContext(Step firstStep,
+       SimulationContext addSimulationContext(Step firstStep,
                        SimulationContext context);
 
        /**
@@ -136,7 +136,7 @@ public interface StepService {
         *            the simulation context to remove
         * @return true if removal succeeded
         */
-       public boolean removeSimulationContext(Step aStep, SimulationContext context);
+       boolean removeSimulationContext(Step aStep, SimulationContext context);
 
        /**
         * Add a document publication to the given step.
@@ -147,7 +147,7 @@ public interface StepService {
         *            the document publication to add
         * @return true if publication succeeded
         */
-       public boolean add(Step aStep, Publication newdoc);
+       boolean add(Step aStep, Publication newdoc);
 
        /**
         * Remove a document publication from the given step.
@@ -158,7 +158,7 @@ public interface StepService {
         *            the document publication to remove
         * @return true if removing of the publication succeeded
         */
-       public boolean remove(Step aStep, Publication oldoc);
+       boolean remove(Step aStep, Publication oldoc);
 
        /**
         * Remove a document from the given step.
@@ -169,7 +169,7 @@ public interface StepService {
         *            the document publication
         * @return true if removing of the document succeeded
         */
-       public boolean removeDocument(Step aStep, Publication doctag);
+       boolean removeDocument(Step aStep, Publication doctag);
 
        /**
         * Get document types which are applicable for the given study step (activity).
@@ -178,5 +178,5 @@ public interface StepService {
         *            the study step
         * @return the list of document types
         */
-       public List<DocumentType> getValidDocumentTypes(Step aStep);
+       List<DocumentType> getValidDocumentTypes(Step aStep);
 }
index ea57a734c421fad5e72bda09f79c839284d15fe8..fbbcb088fca0ec6e905b45abfa80cfbd0a7f97ff 100644 (file)
 package org.splat.service;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
-import java.util.Vector;
 
 import org.splat.dal.bo.kernel.Relation;
 import org.splat.dal.bo.som.ConvertsRelation;
@@ -55,7 +55,7 @@ public class StepServiceImpl implements StepService {
        /**
         * logger for the service.
         */
-       public final static AppLogger logger = AppLogger
+       public final static AppLogger LOG = AppLogger
                        .getLogger(StepServiceImpl.class);
        /**
         * Injected index service.
@@ -96,7 +96,7 @@ public class StepServiceImpl implements StepService {
        /**
         * Injected project service.
         */
-       private ProjectSettingsService _projectSettingsService;
+       private ProjectSettingsService _projectSettings;
 
        /**
         * {@inheritDoc}
@@ -119,6 +119,7 @@ public class StepServiceImpl implements StepService {
        @Transactional
        public SimulationContext addSimulationContext(final Step aStep,
                        final SimulationContext context) {
+               SimulationContext res = null;
                getSimulationContextService().hold(context); // Increments the reference count of simulation context
                if (aStep.getOwner().isSaved()) {
                        try {
@@ -129,15 +130,17 @@ public class StepServiceImpl implements StepService {
                                aStep.getContex().add(context); // The context is also referenced from this (transient) Step
                                getProjectElementDAO().update(aStep.getOwner());
                                updateKnowledgeElementsIndex(aStep);
+                               res = context;
                        } catch (Exception error) {
-                               return null;
+                               LOG.debug(error.getMessage(), error);
                        }
                } else { // Happens when copying a scenario
                        aStep.getOwner().add(context);
                        aStep.getContex().add(context); // The context is also referenced from this (transient) Step
                        // In case of owner scenario, the Knowledge Element index will be updated later, when saving the scenario
+                       res = context;
                }
-               return context;
+               return res;
        }
 
        /**
@@ -166,7 +169,7 @@ public class StepServiceImpl implements StepService {
                                updateScenarioIndex(scene);
                        }
                } catch (Exception error) {
-                       logger.error("Unable to re-index Knowledge Elements, reason:",
+                       LOG.error("Unable to re-index Knowledge Elements, reason:",
                                        error);
                }
        }
@@ -201,11 +204,11 @@ public class StepServiceImpl implements StepService {
         */
        @Transactional
        public boolean removeSimulationContext(final Step aStep, final SimulationContext context) {
-               boolean isOk = false;
                SimulationContext torem = aStep
                                .getSimulationContext(context.getIndex());
 
-               if ((torem != null) && (aStep.getOwner().remove(torem))) {
+               boolean isOk = (torem != null) && (aStep.getOwner().remove(torem));
+               if (isOk) {
 
                        aStep.getContex().remove(torem);
                        getProjectElementDAO().update(aStep.getOwner());
@@ -215,7 +218,6 @@ public class StepServiceImpl implements StepService {
                        } else {
                                getSimulationContextDAO().delete(torem);
                        }
-                       isOk = true;
                }
                return isOk;
        }
@@ -235,11 +237,9 @@ public class StepServiceImpl implements StepService {
 
                // Creation of the save directory
                java.io.File wdir = getDocumentService().getSaveDirectory(newdoc);
-               if (!wdir.exists()) {
-                       if (!wdir.mkdirs()) {
-                               throw new IOException(
-                                               "Cannot create the repository vault directory");
-                       }
+               if ((!wdir.exists()) && (!wdir.mkdirs())) {
+                       throw new IOException(
+                                       "Cannot create the repository vault directory");
                }
 
                // Identification and save
@@ -254,26 +254,21 @@ public class StepServiceImpl implements StepService {
         * 
         * @see org.splat.service.StepService#assignDocument(org.splat.som.Step, org.splat.dal.bo.som.Document.Properties)
         */
-       public Publication assignDocument(final Step aStep, final Document.Properties dprop)
-                       throws MissedPropertyException, InvalidPropertyException,
-                       NotApplicableException {
+       public Publication assignDocument(final Step aStep,
+                       final Document.Properties dprop) throws MissedPropertyException,
+                       InvalidPropertyException, NotApplicableException {
                String refid = dprop.getReference();
-               if (refid == null) {
-                       return null;
-               }
-
-               Document slot = getDocumentService().selectDocument(refid,
-                               new Revision().toString());
-               if (slot == null) {
-                       return null;
-               }
-               if (!slot.isUndefined()) {
-                       return null; // Should not happen
+               Publication res = null;
+               if (refid != null) {
+                       Document slot = getDocumentService().selectDocument(refid,
+                                       new Revision().toString());
+                       if ((slot != null) && (slot.isUndefined())) {
+                               getDocumentService().initialize(slot,
+                                               dprop.setOwner(aStep.getOwnerStudy()));
+                               res = new Publication(slot, aStep.getOwner());
+                       }
                }
-
-               getDocumentService().initialize(slot,
-                               dprop.setOwner(aStep.getOwnerStudy()));
-               return new Publication(slot, aStep.getOwner());
+               return res;
        }
 
        /**
@@ -418,14 +413,14 @@ public class StepServiceImpl implements StepService {
         * @return true if publication succeeded
         */
        public boolean add(final Step aStep, final Publication newdoc) {
-               if (!aStep.getOwner().add(newdoc)) {
-                       return false; // Updates the study in memory
+               boolean res = aStep.getOwner().add(newdoc); // Updates the study in memory
+               if (res) {
+                       aStep.getDocuments().add(0, newdoc); // Updates this step
+                       getDocumentService().hold(newdoc.value()); // Increments the configuration tag count of document
+                       // If not yet saved, the Publication MUST NOT be saved here, although this creates a temporary inconsistent state into the
+                       // database (it will be saved later by cascading the update of owner scenario).
                }
-               aStep.getDocuments().add(0, newdoc); // Updates this step
-               getDocumentService().hold(newdoc.value()); // Increments the configuration tag count of document
-               // If not yet saved, the Publication MUST NOT be saved here, although this creates a temporary inconsistent state into the
-               // database (it will be saved later by cascading the update of owner scenario).
-               return true;
+               return res;
        }
 
        /**
@@ -438,13 +433,13 @@ public class StepServiceImpl implements StepService {
         * @return true if removing of the publication succeeded
         */
        public boolean remove(final Step aStep, final Publication oldoc) {
-               if (!aStep.getOwner().remove(oldoc)) {
-                       return false; // Updates the study in memory
+               boolean res = aStep.getOwner().remove(oldoc); // Updates the study in memory
+               if (res) {
+                       aStep.getDocuments().remove(oldoc); // Updates this step
+                       getDocumentService().release(oldoc.value()); // Decrements the configuration tag count of document
+                       // The publication becoming orphan, it should automatically be removed from the database when updating of owner scenario.
                }
-               aStep.getDocuments().remove(oldoc); // Updates this step
-               getDocumentService().release(oldoc.value()); // Decrements the configuration tag count of document
-               // The publication becoming orphan, it should automatically be removed from the database when updating of owner scenario.
-               return true;
+               return res;
        }
 
        /**
@@ -462,29 +457,28 @@ public class StepServiceImpl implements StepService {
                getDocumentDAO().update(value);
                Publication torem = aStep.getDocument(value.getIndex());
 
-               if (torem == null) {
-                       return false;
-               }
-
-               remove(aStep, torem);
-               getProjectElementDAO().update(aStep.getOwner());
-               if (!value.isPublished() && !value.isVersioned()) { // The referenced document is no more used
-                       Set<Relation> links = value.getAllRelations(); // Get all relation of the document to remove them
-                       List<Document> using = new Vector<Document>();
-                       for (Iterator<Relation> i = links.iterator(); i.hasNext();) {
-                               Relation link = i.next();
-                               if (link.getClass().equals(ConvertsRelation.class)) { // File conversion
-                                       getFileDAO().delete((File) link.getTo()); // The corresponding physical file is not removed from the vault
-                               } else if (link.getClass().equals(UsesRelation.class)) { // Document dependency
-                                       using.add((Document) link.getTo());
+               boolean res = (torem != null);
+               if (res) {
+                       remove(aStep, torem);
+                       getProjectElementDAO().update(aStep.getOwner());
+                       if (!value.isPublished() && !value.isVersioned()) { // The referenced document is no more used
+                               Set<Relation> links = value.getAllRelations(); // Get all relation of the document to remove them
+                               List<Document> using = new ArrayList<Document>();
+                               for (Iterator<Relation> i = links.iterator(); i.hasNext();) {
+                                       Relation link = i.next();
+                                       if (link.getClass().equals(ConvertsRelation.class)) { // File conversion
+                                               getFileDAO().delete((File) link.getTo()); // The corresponding physical file is not removed from the vault
+                                       } else if (link.getClass().equals(UsesRelation.class)) { // Document dependency
+                                               using.add((Document) link.getTo());
+                                       }
                                }
+                               for (Iterator<Document> i = using.iterator(); i.hasNext();) {
+                                       i.next().removeRelation(UsedByRelation.class, value); // TODO: RKV: don't use Database.getSession in removeRelation
+                               }
+                               getDocumentDAO().delete(value); // The corresponding physical file is not removed from the vault
                        }
-                       for (Iterator<Document> i = using.iterator(); i.hasNext();) {
-                               i.next().removeRelation(UsedByRelation.class, value); // TODO: RKV: don't use Database.getSession in removeRelation
-                       }
-                       getDocumentDAO().delete(value); // The corresponding physical file is not removed from the vault
                }
-               return true;
+               return res;
        }
 
        /**
@@ -663,7 +657,7 @@ public class StepServiceImpl implements StepService {
         * @return Project settings service
         */
        private ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
+               return _projectSettings;
        }
 
        /**
@@ -674,6 +668,6 @@ public class StepServiceImpl implements StepService {
         */
        public void setProjectSettings(
                        final ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
+               _projectSettings = projectSettingsService;
        }
 }
index 50595523194a58b0341c0e1633b57632ccb131b2..9ba72257473e60635760ff54dcaf42b82dd78b96 100644 (file)
@@ -14,7 +14,6 @@ import java.util.List;
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.Publication;
-import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.ValidationCycle;
@@ -38,7 +37,7 @@ public interface StudyService {
         *            the study
         * @return incremented docount value
         */
-       public int generateLocalIndex(Study aStudy);
+       int generateLocalIndex(Study aStudy);
 
        /**
         * Get study by its id.
@@ -47,7 +46,7 @@ public interface StudyService {
         *            the study id
         * @return found study or null
         */
-       public Study selectStudy(long index);
+       Study selectStudy(long index);
 
        /**
         * Create a new study.
@@ -62,7 +61,7 @@ public interface StudyService {
         * @throws MultiplyDefinedException
         *             if some property is defined several times
         */
-       public Study createStudy(Study.Properties sprop)
+       Study createStudy(Study.Properties sprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        MultiplyDefinedException;
 
@@ -81,7 +80,7 @@ public interface StudyService {
         * @throws MultiplyDefinedException
         *             if some property occurs several times
         */
-       public SimulationContext addProjectContext(Study aStudy,
+       SimulationContext addProjectContext(Study aStudy,
                        SimulationContext.Properties cprop) throws MissedPropertyException,
                        InvalidPropertyException, MultiplyDefinedException;
 
@@ -94,7 +93,7 @@ public interface StudyService {
         *            the simulation context to add
         * @return the added simulation context
         */
-       public SimulationContext addProjectContext(Study aStudy,
+       SimulationContext addProjectContext(Study aStudy,
                        SimulationContext context);
 
        /**
@@ -106,7 +105,7 @@ public interface StudyService {
         *            the simulation context to remove
         * @return true if removing succeeded
         */
-       public boolean removeProjectContext(Study aStudy, SimulationContext context);
+       boolean removeProjectContext(Study aStudy, SimulationContext context);
 
        /**
         * Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
@@ -116,7 +115,7 @@ public interface StudyService {
         *            the study to demote
         * @return true if the demotion succeeded.
         */
-       public boolean demote(Study aStudy);
+       boolean demote(Study aStudy);
 
        /**
         * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
@@ -126,7 +125,7 @@ public interface StudyService {
         *            the study to promote
         * @return true if the promotion succeeded.
         */
-       public boolean promote(Study aStudy);
+       boolean promote(Study aStudy);
 
        /**
         * Add a contributor to the study.
@@ -137,7 +136,7 @@ public interface StudyService {
         *            the contributor
         * @return true if addition succeeded
         */
-       public boolean addContributor(Study aStudy, User user);
+       boolean addContributor(Study aStudy, User user);
 
        /**
         * Remove contributors from the study.
@@ -148,7 +147,7 @@ public interface StudyService {
         *            contributor(s)
         * @return true if removing succeeded
         */
-       public boolean removeContributor(Study aStudy, User... users);
+       boolean removeContributor(Study aStudy, User... users);
 
        /**
         * Set a validation cycle for documents of the given type in the given study.
@@ -160,7 +159,7 @@ public interface StudyService {
         * @param vprop
         *            validation cycle properties
         */
-       public void setValidationCycle(Study aStudy, DocumentType type,
+       void setValidationCycle(Study aStudy, DocumentType type,
                        ValidationCycle.Properties vprop);
 
        /**
@@ -171,7 +170,7 @@ public interface StudyService {
         * @return true if the move succeeded.
         * @see #isPublic()
         */
-       public boolean moveToPublic(Study aStudy);
+       boolean moveToPublic(Study aStudy);
 
        /**
         * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
@@ -184,7 +183,7 @@ public interface StudyService {
         * @see #isPublic()
         * @see Publication#approve(Date)
         */
-       public boolean moveToReference(Study aStudy);
+       boolean moveToReference(Study aStudy);
 
        /**
         * Update a study.
@@ -197,7 +196,7 @@ public interface StudyService {
         * @throws InvalidPropertyException
         *             if some property doesn't exist
         */
-       public boolean update(Study aStudy, Properties sprop)
+       boolean update(Study aStudy, Properties sprop)
                        throws InvalidPropertyException;
 
        /**
@@ -206,7 +205,7 @@ public interface StudyService {
         * @param aStudy
         *            the study
         */
-       public void loadWorkflow(Study aStudy);
+       void loadWorkflow(Study aStudy);
 
        /**
         * Returns the validation cycle of the given document type.
@@ -217,7 +216,7 @@ public interface StudyService {
         *            the document type being subject of validation
         * @return the validation cycle of the document, or null if not defined.
         */
-       public ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
+       ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
 
        /**
         * Checks if the given user participates to this study. The Study staff includes the author and contributors.
@@ -229,7 +228,7 @@ public interface StudyService {
         * @return true if the given user is actor of this study.
         * @see #getContributors()
         */
-       public boolean isStaffedBy(Study aStudy, User user);
+       boolean isStaffedBy(Study aStudy, User user);
 
        /**
         * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
@@ -241,7 +240,7 @@ public interface StudyService {
         * @return true if the given user is actor of this study.
         * @see #getActors()
         */
-       public boolean hasActor(Study aStudy, User user);
+       boolean hasActor(Study aStudy, User user);
 
        /**
         * Returns unmodifiable initialized transient list of contributors of this study.
@@ -250,5 +249,5 @@ public interface StudyService {
         *            the study
         * @return the unmodifiable not null transient list of contributors of this study
         */
-       public List<User> getContributors(Study aStudy);
+       List<User> getContributors(Study aStudy);
 }
index b0355625d65c89681b9d4471d2751d060ee40126..0d133d13705e5d41a4728ec67d398b3b64c9a006 100644 (file)
@@ -26,7 +26,6 @@ import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.ActorRelation;
 import org.splat.dal.bo.som.ContributorRelation;
 import org.splat.dal.bo.som.DescriptionAttribute;
-import org.splat.dal.bo.som.Document;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.IDBuilder;
 import org.splat.dal.bo.som.KnowledgeElement;
@@ -66,7 +65,7 @@ public class StudyServiceImpl implements StudyService {
        /**
         * logger for the service.
         */
-       public final static AppLogger logger = AppLogger
+       public final static AppLogger LOG = AppLogger
                        .getLogger(StudyServiceImpl.class);
 
        /**
@@ -164,7 +163,7 @@ public class StudyServiceImpl implements StudyService {
                        IndexService lucin = getIndex();
                        lucin.add(study);
                } catch (IOException error) {
-                       logger.error("Unable to index the study '" + study.getIndex()
+                       LOG.error("Unable to index the study '" + study.getIndex()
                                        + "', reason:", error);
                        // Continue and try to index later
                }
@@ -277,7 +276,7 @@ public class StudyServiceImpl implements StudyService {
         *            the document
         * @return true if the document is published in the study
         */
-       private boolean publishes(final Study aStudy, final Document doc) {
+/*     private boolean publishes(final Study aStudy, final Document doc) {
                if (!aStudy.publishes(doc)) {
                        Scenario[] scene = aStudy.getScenarii();
                        for (int i = 0; i < scene.length; i++) {
@@ -288,7 +287,7 @@ public class StudyServiceImpl implements StudyService {
                }
                return false;
        }
-
+*/
        /**
         * {@inheritDoc}
         * 
@@ -337,13 +336,15 @@ public class StudyServiceImpl implements StudyService {
         *      org.splat.dal.bo.som.ValidationCycle.Properties)
         */
        @Transactional
-       public void setValidationCycle(final Study aStudy, final DocumentType type,
+       public void setValidationCycle(final Study aStudyDTO, final DocumentType type,
                        final ValidationCycle.Properties vprop) {
-               Map<String, ValidationCycle> validactor = aStudy.getValidationCycles();
+               Map<String, ValidationCycle> validactor = aStudyDTO.getValidationCycles();
                if (validactor == null) {
-                       setShortCuts(aStudy); // Initializes validactor and actor
+                       setShortCuts(aStudyDTO); // Initializes validactor and actor
                }
 
+               Study aStudy = selectStudy(aStudyDTO.getIndex());
+               
                String cname = type.getName();
                ValidationCycle cycle = validactor.get(cname);
 
@@ -357,16 +358,16 @@ public class StudyServiceImpl implements StudyService {
 
                                ValidationCycleRelation link = cycle.getContext();
                                // RKV: aStudy.addRelation(link);
-                               aStudy.getAllRelations().add(link); // RKV
+                               aStudyDTO.getAllRelations().add(link); // RKV
 
                                validactor.put(cname, link.getTo()); // Replaces the cycle if exists as default,
                        } catch (Exception error) {
-                               logger.error("Unable to re-index Knowledge Elements, reason:",
+                               LOG.error("Unable to re-index Knowledge Elements, reason:",
                                                error);
                                return;
                        }
                }
-               resetActorsShortCut(aStudy);
+               resetActorsShortCut(aStudyDTO);
                update(aStudy); // Re-index the study, just in case
        }
 
@@ -463,7 +464,7 @@ public class StudyServiceImpl implements StudyService {
                        getIndex().update(aStudy); // Update of Lucene index
                        isOk = true;
                } catch (Exception e) {
-                       logger.error("STD-000001", e, aStudy.getIndex(), e.getMessage());
+                       LOG.error("STD-000001", e, aStudy.getIndex(), e.getMessage());
                }
                return isOk;
        }
@@ -520,7 +521,7 @@ public class StudyServiceImpl implements StudyService {
                                                        break;
                                                }
                                        }
-                                       SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
+                                       SimpleDateFormat tostring = new SimpleDateFormat("yyyy"); //RKV: NOPMD: TODO: Use locale here?
                                        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++) {
@@ -623,7 +624,7 @@ public class StudyServiceImpl implements StudyService {
                        }
                        isOk = true;
                } catch (Exception error) {
-                       logger.error("Unable to re-index Knowledge Elements, reason:",
+                       LOG.error("Unable to re-index Knowledge Elements, reason:",
                                        error);
                }
                return isOk;
index b170020041d3d56d68be8597a4a697f18f936b1a..168a6ce144f80d972bd67469567b2aa785088521 100644 (file)
@@ -28,11 +28,11 @@ import org.splat.manox.XMLException;
  */
 public interface UserService {
 
-       public User createUser(User.Properties uprop)
+       User createUser(User.Properties uprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        MultiplyDefinedException;
 
-       public Set<User> importUsers(File xfile) throws XMLException,
+       Set<User> importUsers(File xfile) throws XMLException,
                        MismatchException;
 
        /**
@@ -48,15 +48,15 @@ public interface UserService {
         *            the user whose manager is get
         * @return the manager of the given user, if defined
         */
-       public User getManagerOf(User user);
+       User getManagerOf(User user);
 
-       public List<User> selectAllUsers();
+       List<User> selectAllUsers();
 
-       public User selectUser(String username);
+       User selectUser(String username);
 
-       public User selectUser(String username, String password);
+       User selectUser(String username, String password);
 
-       public User selectUser(long index);
+       User selectUser(long index);
 
-       public List<User> selectUsersWhere(User.Properties... uprop);
+       List<User> selectUsersWhere(User.Properties... uprop);
 }
index f19dea8c366160e96c2fb2ff7ad9e4df16d9ad06..862f30e50709d00718ac42ebc01d4784fe9e7ead 100644 (file)
@@ -47,7 +47,7 @@ public class UserServiceImpl implements UserService {
        /**
         * The service logger.
         */
-       final static Logger logger = Logger.getLogger(UserServiceImpl.class);
+       protected final static Logger LOG = Logger.getLogger(UserServiceImpl.class);
 
        /**
         * Injected user DAO.
@@ -64,7 +64,7 @@ public class UserServiceImpl implements UserService {
         * @see org.splat.service.UserService#createUser(org.splat.dal.bo.kernel.User.Properties)
         */
        @Transactional
-       public User createUser(User.Properties uprop)
+       public User createUser(final User.Properties uprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        MultiplyDefinedException, RuntimeException {
                User nuser = new User(uprop);
@@ -74,21 +74,23 @@ public class UserServiceImpl implements UserService {
 
        // For the casting List<String>
        @Transactional
-       public Set<User> importUsers(File xfile) throws XMLException,
+       public Set<User> importUsers(final 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"))
+               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"))
+                       if (!xtag.equals("users")) {
                                throw new MismatchException("filetype");
+                       }
                        org.w3c.dom.NodeList ulist = inDoc.getElementsByTagName("user");
 
                        // List<String> result = (List<String>) session
@@ -97,8 +99,9 @@ public class UserServiceImpl implements UserService {
                        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();)
+                       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
@@ -107,8 +110,9 @@ public class UserServiceImpl implements UserService {
 
                                // Mandatory properties
                                String uname = row.get("username").getTextContent();
-                               if (members.contains(uname))
+                               if (members.contains(uname)) {
                                        continue; // This user already exists
+                               }
                                uprop.setUsername(uname)
                                                .setFirstName(row.get("first").getTextContent())
                                                .setName(row.get("last").getTextContent())
@@ -136,11 +140,14 @@ public class UserServiceImpl implements UserService {
                        }
                        return imported;
                } catch (IOException error) {
-                       throw new XMLException("XML users file not found");
+                       LOG.debug(error.getMessage(), error);
+                       throw new XMLException("XML users file not found"); //RKV: NOPMD: Original message is printed
                } catch (ParserConfigurationException e) {
-                       throw new XMLException("XML Organization parser not accessible");
+                       LOG.debug(e.getMessage(), e);
+                       throw new XMLException("XML Organization parser not accessible"); //RKV: NOPMD: Original message is printed
                } catch (Exception e) {
-                       throw new XMLException("XML users file not valid");
+                       LOG.debug(e.getMessage(), e);
+                       throw new XMLException("XML users file not valid"); //RKV: NOPMD: Original message is printed
                }
        }
 
@@ -157,17 +164,19 @@ public class UserServiceImpl implements UserService {
         *            the user whose manager is get
         * @return the manager of the given user, if defined
         */
-       public User getManagerOf(User user) {
+       public User getManagerOf(final User user) {
                User result = null;
                String orgname = user.getOrganizationName();
 
-               if (orgname.equals("Nx2"))
+               if (orgname.equals("Nx2")) {
                        return result;
-               if (orgname.equals("Nx1"))
+               }
+               if (orgname.equals("Nx1")) {
                        orgname = "Nx2";
-               else {
-                       if (user.getRoleNames().equals("customer"))
+               else {
+                       if (user.getRoleNames().equals("customer")) {
                                return result;
+                       }
                        orgname = "Nx1";
                }
                try {
@@ -187,12 +196,12 @@ public class UserServiceImpl implements UserService {
        }
 
        @Transactional(readOnly = true)
-       public User selectUser(String username) {
+       public User selectUser(final String username) {
                return getUserDAO().findByCriteria(
                                Restrictions.eq("username", username));
        }
 
-       public User selectUser(String username, String password) {
+       public User selectUser(final String username, final 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);
@@ -209,12 +218,12 @@ public class UserServiceImpl implements UserService {
        }
 
        @Transactional(readOnly = true)
-       public User selectUser(long index) {
+       public User selectUser(final long index) {
                return getUserDAO().get(index);
        }
 
        @SuppressWarnings("unchecked")
-       public List<User> selectUsersWhere(User.Properties... uprop) {
+       public List<User> selectUsersWhere(final User.Properties... uprop) {
 //             StringBuffer query = new StringBuffer("FROM User");
 //             String separator = " where (";
 //             String value;
@@ -260,7 +269,7 @@ public class UserServiceImpl implements UserService {
         * @param userDAO
         *            the userDAO to set
         */
-       public void setUserDAO(UserDAO userDAO) {
+       public void setUserDAO(final UserDAO userDAO) {
                _userDAO = userDAO;
        }
 }
index 4bd90ae99c654189515b65aca24926d07b29a07a..a7f410e3c6bd1b043d7e7a4ffe64a03f02fdee2e 100644 (file)
@@ -9,10 +9,7 @@
 
 package org.splat.service; 
 
-import java.util.Map;
-
 import org.splat.log.AppLogger;
-import org.splat.som.ApplicationRights;
 
 /**
  * @author Maria KRUCHININA
@@ -23,7 +20,7 @@ public class UtilServiceImpl implements UtilService {
        /**
         * logger for the service.
         */
-       private static final AppLogger LOG = AppLogger.getLogger(UtilServiceImpl.class);
+       private static final AppLogger LOG = AppLogger.getLogger(UtilServiceImpl.class); //RKV: NOPMD: TODO: Complete the service
 
        /**
         * Get the connected user.
index 48cec3b49746812f4616d029c9c819abef1f9a86..e6ea1b3eb5184b1fe91c9e18452801325203306e 100644 (file)
@@ -10,11 +10,11 @@ public class KnowledgeElementTypeDTO {
        /**
         * Type name.
         */
-       private String name;
+       private String _name;
        /**
         * Persistent id of the type.
         */
-       private long rid;
+       private long _index;
 
        // ==============================================================================================================================
        // Public member functions
@@ -25,32 +25,47 @@ public class KnowledgeElementTypeDTO {
         * 
         * @see java.lang.Object#equals(java.lang.Object)
         */
-       public boolean equals(Object entity) {
-               if (entity == null)
-                       return false;
-               if (entity instanceof String) {
-                       return this.name.equals((String) entity); // Names are unique
-               } else if (entity instanceof KnowledgeElementTypeDTO) {
-                       KnowledgeElementTypeDTO object = (KnowledgeElementTypeDTO) entity;
-                       long he = object.getIndex();
-                       long me = this.getIndex();
-                       if (me * he != 0) {
-                               return (he == me);
-                       } else {
-                               return this.getName().equals(object.getName());
+       @Override
+       public boolean equals(final Object entity) {
+               boolean res = (entity != null);
+               if (res) {
+                       if (entity instanceof String) {
+                               res = this._name.equals(entity); // Names are unique
+                       } else if (entity instanceof KnowledgeElementTypeDTO) {
+                               KnowledgeElementTypeDTO object = (KnowledgeElementTypeDTO) entity;
+                               long he = object.getIndex();
+                               long me = this.getIndex();
+                               if (me * he == 0) {
+                                       res = this.getName().equals(object.getName());
+                               } else {
+                                       res = (he == me);
+                               }
                        }
-               } else {
-                       return false;
                }
+               return res;
        }
 
+       /** 
+        * {@inheritDoc}
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               long oid = getIndex(); // getIndex() is supposed fetching the index if not yet done
+               if (oid == 0) {
+                       oid = super.hashCode(); // WARNING: Must not call super.toString() as it goes back here (this.toString())
+               }
+               return new StringBuffer("object ").append(getClass().getName()).append(
+                               "@").append(oid).toString().hashCode();
+       }
+       
        /**
         * Get the name of the knowledge type.
         * 
         * @return the type name
         */
        public String getName() {
-               return name;
+               return _name;
        }
 
        /**
@@ -59,7 +74,7 @@ public class KnowledgeElementTypeDTO {
         * @return the rid
         */
        public long getIndex() {
-               return rid;
+               return _index;
        }
 
        /**
@@ -68,15 +83,15 @@ public class KnowledgeElementTypeDTO {
         * @param rid
         *            the rid to set
         */
-       public void setIndex(long rid) {
-               this.rid = rid;
+       public void setIndex(final long rid) {
+               this._index = rid;
        }
 
        /**
         * Set the name.
         * @param name the name to set
         */
-       public void setName(String name) {
-               this.name = name;
+       public void setName(final String name) {
+               this._name = name;
        }
 }
\ No newline at end of file
index b17d99ea174175c96b874ab3795b7b36c29c0a31..de0d20ff69b446e2242d968b218e5ac0d16ce3a4 100644 (file)
@@ -1,14 +1,7 @@
 package org.splat.service.dto;
 
 import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.dao.som.Database;
-
-
 import org.splat.service.technical.IndexServiceImpl;
-import org.splat.dal.bo.som.KnowledgeElement;
-import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.bo.som.Study;
-import org.splat.dal.bo.som.Study.Properties;
 
 /**
  * Stand proxy for entities such as Study and Knowledge Element returned by Lucene-based searches.
@@ -18,10 +11,6 @@ import org.splat.dal.bo.som.Study.Properties;
  * One of these properties is the internal persistent identifier of the object represented by a proxy allowing the
  * user of this interface to load the object from the database.
  * 
- * @see Database#selectStudiesWhere(Study.Properties...)
- * @see Database#selectKnowledgeElementsWhere(KnowledgeElement.Properties)
- * @see Database#selectStudy(int)
- * @see Database#selectKnowledgeElement(int)
  * @see IndexServiceImpl
  * @see IndexServiceImpl.ObjectProxy
  * @author    Daniel Brunier-Coulin
@@ -30,30 +19,30 @@ import org.splat.dal.bo.som.Study.Properties;
 
 public interface Proxy {
 
-       public String        getAuthorName ();
+       String        getAuthorName ();
 
 /**
  * Returns the internal persistent identifier of the object represented by this proxy. The returned identifier can be used
  * for selecting the corresponding persistent object from the database.
  * @return the internal persistent identifier of the object represented by this proxy.
  */
-    public Long       getIndex ();
+    Long       getIndex ();
 
-       public ProgressState getProgressState ();
+       ProgressState getProgressState ();
 
 /**
  * Returns the external reference number of the object represented by this proxy. The returned reference is formated
  * according to the format defined in the configuration file of the application.
  * @return the external reference number of the object represented by this proxy.
  */
-    public String        getReference ();
+    String        getReference ();
 
-       public String        getTitle ();
+       String        getTitle ();
 
 /**
  * Returns the type of the object represented by this proxy. Depending on the implementation, the returned type may or
  * may not be localized in the current locale of final user.
  * @return the type of the object represented by this proxy.
  */
-    public String        getType ();
+    String        getType ();
 }
\ No newline at end of file
index 5f9966cb88f3e5a912c35758381f06668d397a49..7ac576c49dca355d62a18007218790055f61cb9d 100644 (file)
@@ -1,45 +1,68 @@
 package org.splat.service.dto;
 
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
- * Role DTO.
+ * DTO for keeping roles of a user.
  * 
  * @see UserDTO
  */
 public class RoleDTO {
 
-       private String username;
-       private String role;
+       /**
+        * User name.
+        */
+       private transient String _username;
+       /**
+        * Roles names.
+        */
+       private String _name;
 
        // ==============================================================================================================================
        // Constructors
        // ==============================================================================================================================
 
-       // Database fetch constructor
+       /**
+        * Bean replication constructor.
+        */
        protected RoleDTO() {
+               // Bean replication constructor
        }
 
-       // Initialization constructor
-       protected RoleDTO(String username, String role) {
-               this.username = username;
-               this.role = role;
+       /**
+        * Initialization constructor.
+        * @param username user name
+        * @param role role name
+        */
+       protected RoleDTO(final String username, final String role) {
+               this._username = username;
+               this._name = role;
        }
 
        // ==============================================================================================================================
        // Protected member functions
        // ==============================================================================================================================
 
-       protected void addRole(String role) {
-               this.role = this.role + "," + role;
+       /**
+        * Add a role.
+        * @param role the role to add
+        */
+       protected void addRole(final String role) {
+               this._name = this._name + "," + role;
        }
 
+       /**
+        * Get roles as an array of separate DTOs.
+        * @return array of roles
+        */
        protected RoleDTO[] toArray() {
-               String[] name = role.split(",");
-               Vector<RoleDTO> role = new Vector<RoleDTO>();
+               String[] name = _name.split(",");
+               List<RoleDTO> role = new ArrayList<RoleDTO>();
 
-               for (int i = 0; i < name.length; i++)
-                       role.add(new RoleDTO(username, name[i]));
+               for (int i = 0; i < name.length; i++) {
+                       role.add(new RoleDTO(_username, name[i]));
+               }
                return role.toArray(new RoleDTO[name.length]);
        }
 
@@ -49,18 +72,18 @@ public class RoleDTO {
        // In functions below, the role is supposed having previously been extracted as an array.
 
        public String getName() {
-               return role;
+               return _name;
        }
 
        public void setName(final String name) {
-               role = name;
+               _name = name;
        }
 
-       public boolean is(String name) {
-               return this.role.equals(name);
+       public boolean is(final String name) {
+               return this._name.equals(name);
        }
 
-       public boolean isSame(RoleDTO other) {
-               return this.role.equals(other.role);
+       public boolean isSame(final RoleDTO other) {
+               return this._name.equals(other._name);
        }
 }
\ No newline at end of file
index 77475ed2668a504c9992de767a9a626947d4d65d..07b5de1349eadc6e7083efb5230eb6738b713c79 100644 (file)
@@ -3,44 +3,45 @@ package org.splat.service.dto;
 import java.util.Iterator;
 import java.util.List;
 
-import org.splat.service.technical.ProjectSettingsService;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.service.technical.ProjectSettingsService;
 
 public class SimulationContextFacade {
 
-       private SimulationContext my;
-       private String name;
-       private int at;
-       private ProgressState state;
+       private transient final SimulationContext _my;
+       private transient final String _name;
+       private transient int _at;
+       private transient ProgressState _state;
 
        // ==============================================================================================================================
        // Constructor
        // ==============================================================================================================================
 
-       public SimulationContextFacade(SimulationContext represented,
-                       List<ProjectSettingsService.Step> steps) {
+       public SimulationContextFacade(final SimulationContext represented,
+                       final List<ProjectSettingsService.Step> steps) {
                // --------------------------------------------------------------
                SimulationContextType mytype;
 
-               my = represented;
-               mytype = my.getType();
+               _my = represented;
+               mytype = _my.getType();
                for (Iterator<ProjectSettingsService.Step> i = steps.iterator(); i
                                .hasNext();) {
                        ProjectSettingsService.Step step = i.next();
-                       if (!mytype.isAttachedTo(step))
+                       if (!mytype.isAttachedTo(step)) {
                                continue;
-                       at = step.getNumber(); // There is no direct service for getting the step number
+                       }
+                       _at = step.getNumber(); // There is no direct service for getting the step number
                        break;
                }
-               name = my.getType().getName();
+               _name = _my.getType().getName();
                if (mytype.isApproved()) {
-                       state = ProgressState.inCHECK;
+                       _state = ProgressState.inCHECK;
                        // RKV: TODO: Do translation in presentation layer by struts tools: name = ResourceBundle.getBundle("som",
                        // ApplicationSettings.getCurrentLocale()).getString("type.context." + name);
                } else {
-                       state = ProgressState.inDRAFT;
+                       _state = ProgressState.inDRAFT;
                }
        }
 
@@ -50,28 +51,28 @@ public class SimulationContextFacade {
 
        public String getEditIcon() {
                // ----------------------------
-               StringBuffer result = new StringBuffer("icon.ed").append(state).append(
+               StringBuffer result = new StringBuffer("icon.ed").append(_state).append(
                                ".png");
                return result.toString();
        }
 
        public String getIndex() {
                // -------------------------
-               return String.valueOf(my.getIndex());
+               return String.valueOf(_my.getIndex());
        }
 
        public int getStepNumber() {
                // ---------------------------
-               return at;
+               return _at;
        }
 
        public String getTypeName() {
                // ----------------------------
-               return name;
+               return _name;
        }
 
        public String getValue() {
                // -------------------------
-               return my.getValue();
+               return _my.getValue();
        }
 }
\ No newline at end of file
index 3d2b4c93cbc0bc00ff1e2dd8c8e230f31a4582c7..0109dac369d25ba0c1beef911387d0aab416435f 100644 (file)
@@ -1,6 +1,7 @@
 package org.splat.service.dto;
 
 import java.security.Principal;
+
 import org.splat.kernel.Name;
 
 /**
@@ -10,90 +11,93 @@ import org.splat.kernel.Name;
  */
 public class UserDTO implements Principal, Name {
 
-       private String password; // Property without getter function
-       private String username; // Unique in the user directory
-       private String first;
-       private String last;
-       private String display; // Optional
-       private RoleDTO role = new RoleDTO(); // Roles as list (as stored into the database)
-       private String email;
-       private String organid;
+       private String _password; // Property without getter function
+       private String _username; // Unique in the user directory
+       private String _firstName;
+       private String _name;
+       private String _displayName; // Optional
+       private RoleDTO _role = new RoleDTO(); // Roles as list (as stored into the database)
+       private String _mailAddress;
+       private String _organizationName;
 
        /**
         * Persistent id of the type.
         */
-       private long rid;
+       private long _index;
 
        // ==============================================================================================================================
        // Public member functions
        // ==============================================================================================================================
 
-       public boolean equals(Object item) {
-               if (item == null)
-                       return false;
-               if (item instanceof String) {
-                       return this.username.equals((String) item); // Usernames are unique
-               } else if (item instanceof UserDTO) {
-                       UserDTO given = (UserDTO) item;
-                       return (given.username.equals(this.username)); // Usernames are unique
-               } else {
-                       return false;
+       @Override
+       public boolean equals(final Object item) {
+               boolean res = (item != null);
+               if (res) {
+                       if (item instanceof String) {
+                               res = this._username.equals(item); // Usernames are unique
+                       } else if (item instanceof UserDTO) {
+                               UserDTO given = (UserDTO) item;
+                               res = given._username.equals(this._username); // Usernames are unique
+                       }
                }
+               return res;
        }
 
        public String getDisplayName() {
-               if (display == null)
-                       return last + " " + first;
-               else
-                       return display;
+               String res = _displayName;
+               if (res == null) {
+                       res = _name + " " + _firstName;
+               }
+               return res;
        }
 
        public String getFirstName() {
-               return first;
+               return _firstName;
        }
 
        public void setFirstName(final String name) {
-               first = name;
+               _firstName = name;
        }
 
        public String getMailAddress() {
-               return email;
+               return _mailAddress;
        }
 
        public void setMailAddress(final String addr) {
-               email = addr;
+               _mailAddress = addr;
        }
 
        public String getName() {
-               return last;
+               return _name;
        }
        
        public void setName(final String name) {
-               last = name;
+               _name = name;
        }
 
        public String getOrganizationName() {
-               return organid;
+               return _organizationName;
        }
 
-       public void setOrganizationName(String name) {
-               organid = name;
+       public void setOrganizationName(final String name) {
+               _organizationName = name;
        }
 
        public String getRoleNames() {
-               return role.getName();
+               return _role.getName();
        }
 
        public RoleDTO[] getRoles() {
-               return role.toArray();
+               return _role.toArray();
        }
 
        public String getUsername() {
-               return username;
+               return _username;
        }
 
+       @Override
        public String toString() {
-               return last + " " + first;
+               return _name + " " + _firstName;
        }
 
        /**
@@ -102,7 +106,7 @@ public class UserDTO implements Principal, Name {
         * @return the rid
         */
        public long getIndex() {
-               return rid;
+               return _index;
        }
 
        /**
@@ -111,8 +115,8 @@ public class UserDTO implements Principal, Name {
         * @param rid
         *            the rid to set
         */
-       public void setIndex(long rid) {
-               this.rid = rid;
+       public void setIndex(final long rid) {
+               this._index = rid;
        }
 
        /**
@@ -120,23 +124,23 @@ public class UserDTO implements Principal, Name {
         * @return the password
         */
        public String getPassword() {
-               return password;
+               return _password;
        }
 
        /**
         * Set the password.
         * @param password the password to set
         */
-       public void setPassword(String password) {
-               this.password = password;
+       public void setPassword(final String password) {
+               this._password = password;
        }
 
        /**
         * Set the username.
         * @param username the username to set
         */
-       public void setUsername(String username) {
-               this.username = username;
+       public void setUsername(final String username) {
+               this._username = username;
        }
 
        /**
@@ -144,14 +148,22 @@ public class UserDTO implements Principal, Name {
         * @return the role
         */
        public RoleDTO getRole() {
-               return role;
+               return _role;
        }
 
        /**
         * Set the role.
         * @param role the role to set
         */
-       public void setRole(RoleDTO role) {
-               this.role = role;
+       public void setRole(final RoleDTO role) {
+               this._role = role;
+       }
+
+       /**
+        * Set the displayName.
+        * @param displayName the displayName to set
+        */
+       public void setDisplayName(final String displayName) {
+               _displayName = displayName;
        }
 }
\ No newline at end of file
index 9ed81a75a46db8cffdab958ccba44d6457194b8a..7e7602086572b28f2c68b4d5adfd9a28f9bc692f 100644 (file)
@@ -14,7 +14,6 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.log4j.Logger;
-
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.CorruptIndexException;
@@ -40,93 +39,102 @@ import org.splat.som.Step;
  */
 public class IndexServiceImpl implements IndexService {
 
-       private Directory index;
-       private org.apache.lucene.document.Document body;
+       /**
+        * The logger for this service.
+        */
+       private static final Logger LOG = Logger
+       .getLogger(IndexServiceImpl.class);
+
+       private final static String PROP_INDEX  = "index";
+       private final static String PROP_REF    = "ref";
+       private final static String PROP_STATE  = "state";
+       private final static String PROP_AUTHOR = "author";
+       private final static String PROP_TITLE  = "title";
+       
+       private transient Directory _index;
+       private transient org.apache.lucene.document.Document _body;
        private ProjectElementService _projectElementService;
        private RepositoryService _repositoryService;
 
        protected static StandardAnalyzer analyzer = new StandardAnalyzer(
                        Version.LUCENE_29);
-       private static final Logger logger = Logger
-                       .getLogger(IndexServiceImpl.class);
-
        private class Entry extends IndexWriter {
-               private org.apache.lucene.document.Document entry;
+               private transient final org.apache.lucene.document.Document _entry;
 
-               private Entry(Study study) throws CorruptIndexException,
+               private Entry(final Study study) throws CorruptIndexException,
                                LockObtainFailedException, IOException {
-                       super(index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
+                       super(_index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
 
                        // Addition of mandatory fields
-                       entry = new org.apache.lucene.document.Document();
+                       _entry = new org.apache.lucene.document.Document();
                        Field field;
-                       field = body.getField("index");
+                       field = _body.getField(PROP_INDEX);
                        field.setValue(String.valueOf(study.getIndex()));
-                       entry.add(field);
-                       field = body.getField("class");
+                       _entry.add(field);
+                       field = _body.getField("class");
                        field.setValue("Study");
-                       entry.add(field);
-                       field = body.getField("type");
+                       _entry.add(field);
+                       field = _body.getField("type");
                        field.setValue(""); // Reserved for configurable Study type
-                       entry.add(field);
-                       field = body.getField("ref");
+                       _entry.add(field);
+                       field = _body.getField(PROP_REF);
                        field.setValue(study.getReference());
-                       entry.add(field);
-                       field = body.getField("area");
+                       _entry.add(field);
+                       field = _body.getField("area");
                        field.setValue(study.getVisibility().toString());
-                       entry.add(field);
-                       field = body.getField("state");
+                       _entry.add(field);
+                       field = _body.getField(PROP_STATE);
                        field.setValue(study.getProgressState().toString());
-                       entry.add(field);
-                       field = body.getField("author");
+                       _entry.add(field);
+                       field = _body.getField(PROP_AUTHOR);
                        field.setValue(study.getAuthor().toString());
-                       entry.add(field);
-                       field = body.getField("title");
+                       _entry.add(field);
+                       field = _body.getField(PROP_TITLE);
                        field.setValue(study.getTitle());
-                       entry.add(field);
-                       field = body.getField("contents");
+                       _entry.add(field);
+                       field = _body.getField("contents");
                        field.setValue(study.getTitle());
-                       entry.add(field);
+                       _entry.add(field);
 
                        // Addition of optional fields
                        setActorsOf(study);
                        setContextAt(getProjectElementService().getSteps(study));
                }
 
-               private Entry(KnowledgeElement kelm) throws CorruptIndexException,
+               private Entry(final KnowledgeElement kelm) throws CorruptIndexException,
                                LockObtainFailedException, IOException {
-                       super(index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
+                       super(_index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
 
                        // Addition of mandatory fields
-                       entry = new org.apache.lucene.document.Document();
+                       _entry = new org.apache.lucene.document.Document();
                        Field field;
-                       field = body.getField("index");
+                       field = _body.getField(PROP_INDEX);
                        field.setValue(String.valueOf(kelm.getIndex()));
-                       entry.add(field);
-                       field = body.getField("class");
+                       _entry.add(field);
+                       field = _body.getField("class");
                        field.setValue("KnowledgeElement");
-                       entry.add(field);
-                       field = body.getField("type");
+                       _entry.add(field);
+                       field = _body.getField("type");
                        field.setValue(kelm.getType().getName());
-                       entry.add(field);
-                       field = body.getField("ref");
+                       _entry.add(field);
+                       field = _body.getField(PROP_REF);
                        field.setValue(kelm.getReference());
-                       entry.add(field);
-                       field = body.getField("area");
+                       _entry.add(field);
+                       field = _body.getField("area");
                        field.setValue(kelm.getVisibility().toString());
-                       entry.add(field);
-                       field = body.getField("state");
+                       _entry.add(field);
+                       field = _body.getField(PROP_STATE);
                        field.setValue(kelm.getProgressState().toString());
-                       entry.add(field);
-                       field = body.getField("author");
+                       _entry.add(field);
+                       field = _body.getField(PROP_AUTHOR);
                        field.setValue(kelm.getAuthor().toString());
-                       entry.add(field);
-                       field = body.getField("title");
+                       _entry.add(field);
+                       field = _body.getField(PROP_TITLE);
                        field.setValue(kelm.getTitle());
-                       entry.add(field);
-                       field = body.getField("contents");
+                       _entry.add(field);
+                       field = _body.getField("contents");
                        field.setValue(kelm.getTitle());
-                       entry.add(field);
+                       _entry.add(field);
 
                        // TODO: Addition of optional fields
                        Scenario scene = kelm.getOwnerScenario();
@@ -137,22 +145,22 @@ public class IndexServiceImpl implements IndexService {
                }
 
                private void add() throws CorruptIndexException, IOException {
-                       addDocument(entry);
+                       addDocument(_entry);
                        // Save the new entry
                        optimize(); // Should be called before committing the index
                        close(); // Commits the index
                }
 
                private void update() throws CorruptIndexException, IOException {
-                       String value = entry.getField("ref").stringValue(); // Only field with unique value
-                       Term term = new Term("ref").createTerm(value);
-                       updateDocument(term, entry);
+                       String value = _entry.getField(PROP_REF).stringValue(); // Only field with unique value
+                       Term term = new Term(PROP_REF).createTerm(value);
+                       updateDocument(term, _entry);
                        // Save the updated entry
                        optimize(); // Should be called before committing the index
                        close(); // Commits the index
                }
 
-               private void setContextAt(Step[] step) {
+               private void setContextAt(final Step[] step) {
                        for (int i = 0; i < step.length; i++) {
                                List<SimulationContext> contexts = step[i]
                                                .getAllSimulationContexts();
@@ -161,72 +169,71 @@ public class IndexServiceImpl implements IndexService {
                                        SimulationContext context = j.next();
                                        String type = String.valueOf(context.getType().getIndex());
                                        String value = context.getValue();
-                                       entry.add(new Field(type, value, Field.Store.NO,
+                                       _entry.add(new Field(type, value, Field.Store.NO,
                                                        Field.Index.NOT_ANALYZED));
                                }
                        }
                }
 
-               private void setActorsOf(Study study) {
+               private void setActorsOf(final Study study) {
                        // RKV: This set is always not null. Let's assume that it must be initialized before reindexing: Set<User> actors =
                        // study.getActors();
                        Set<User> actors = study.getActor(); // RKV
-                       if (logger.isDebugEnabled()) {
-                               logger.debug("Study " + study.getReference()
+                       if (LOG.isDebugEnabled()) {
+                               LOG.debug("Study " + study.getReference()
                                                + " actors number to be added to the lucen index: "
                                                + actors.size());
                        }
                        for (Iterator<User> i = actors.iterator(); i.hasNext();) {
                                String value = i.next().toString();
-                               entry.add(new Field("actor", value, Field.Store.NO,
+                               _entry.add(new Field("actor", value, Field.Store.NO,
                                                Field.Index.NOT_ANALYZED));
-                               if (logger.isDebugEnabled()) {
-                                       logger.debug("    actor added to the lucen index: " + value);
+                               if (LOG.isDebugEnabled()) {
+                                       LOG.debug("    actor added to the lucen index: " + value);
                                }
                        }
                }
        }
 
        public static class ObjectProxy implements Proxy, Serializable {
-               // --------------------------------------------------------------
-               private Long rid;
-               private String sid;
-               private ProgressState state;
-               private String title;
-               private String type;
-               private String name;
+               private transient final Long _rid;
+               private transient final String _sid;
+               private transient final ProgressState _state;
+               private transient final String _title;
+               private transient String _type;
+               private transient final String _name;
                private static final long serialVersionUID = -4386494192709562221L;
 
-               public ObjectProxy(org.apache.lucene.document.Document ludoc) {
-                       rid = Long.valueOf(ludoc.get("index"));
-                       sid = ludoc.get("ref");
-                       state = ProgressState.valueOf(ludoc.get("state"));
-                       title = ludoc.get("title");
-                       name = ludoc.get("author");
+               public ObjectProxy(final org.apache.lucene.document.Document ludoc) {
+                       _rid = Long.valueOf(ludoc.get(PROP_INDEX));
+                       _sid = ludoc.get(PROP_REF);
+                       _state = ProgressState.valueOf(ludoc.get(PROP_STATE));
+                       _title = ludoc.get(PROP_TITLE);
+                       _name = ludoc.get(PROP_AUTHOR);
                }
 
                public String getAuthorName() {
-                       return name;
+                       return _name;
                }
 
                public Long getIndex() {
-                       return rid;
+                       return _rid;
                }
 
                public ProgressState getProgressState() {
-                       return state;
+                       return _state;
                }
 
                public String getReference() {
-                       return sid;
+                       return _sid;
                }
 
                public String getTitle() {
-                       return title;
+                       return _title;
                }
 
                public String getType() {
-                       return type;
+                       return _type;
                }
        }
 
@@ -236,35 +243,35 @@ public class IndexServiceImpl implements IndexService {
 
        public void configure() throws IOException {
                File indir = getRepositoryService().getRepositoryIndexDirectory();
-               index = FSDirectory.open(indir);
-               body = new org.apache.lucene.document.Document();
-               body.add(new Field("index", "", Field.Store.YES,
+               _index = FSDirectory.open(indir);
+               _body = new org.apache.lucene.document.Document();
+               _body.add(new Field(PROP_INDEX, "", Field.Store.YES,
                                Field.Index.NOT_ANALYZED));
-               body.add(new Field("class", "", Field.Store.NO,
+               _body.add(new Field("class", "", Field.Store.NO,
                                Field.Index.NOT_ANALYZED));
-               body.add(new Field("type", "", Field.Store.YES,
+               _body.add(new Field("type", "", Field.Store.YES,
                                Field.Index.NOT_ANALYZED));
-               body
-                               .add(new Field("ref", "", Field.Store.YES,
+               _body
+                               .add(new Field(PROP_REF, "", Field.Store.YES,
                                                Field.Index.NOT_ANALYZED));
-               body
+               _body
                                .add(new Field("area", "", Field.Store.NO,
                                                Field.Index.NOT_ANALYZED));
-               body.add(new Field("state", "", Field.Store.YES,
+               _body.add(new Field(PROP_STATE, "", Field.Store.YES,
                                Field.Index.NOT_ANALYZED));
-               body.add(new Field("author", "", Field.Store.YES,
+               _body.add(new Field(PROP_AUTHOR, "", Field.Store.YES,
                                Field.Index.NOT_ANALYZED));
-               body.add(new Field("title", "", Field.Store.YES,
+               _body.add(new Field(PROP_TITLE, "", Field.Store.YES,
                                Field.Index.NOT_ANALYZED));
-               body
+               _body
                                .add(new Field("contents", "", Field.Store.NO,
                                                Field.Index.ANALYZED));
-               if (!this.exists())
+               if (!this.exists()) {
                        this.create(); // Happens when re-indexing all studies
+               }
        }
 
        public void create() throws IOException {
-               // -------------------------------
                Directory index = FSDirectory.open(getRepositoryService()
                                .getRepositoryIndexDirectory());
                IndexWriter writer = new IndexWriter(index, analyzer, true,
@@ -276,49 +283,45 @@ public class IndexServiceImpl implements IndexService {
        // Member functions
        // ==============================================================================================================================
 
-       public void add(Study study) throws IOException {
-               // --------------------------------
+       public void add(final Study study) throws IOException {
                IndexServiceImpl.Entry entry = new Entry(study);
                entry.add();
-               if (logger.isInfoEnabled()) {
-                       logger.info("Study \"" + study.getIndex() + "\" indexed.");
+               if (LOG.isInfoEnabled()) {
+                       LOG.info("Study \"" + study.getIndex() + "\" indexed.");
                }
        }
 
-       public void add(KnowledgeElement kelm) throws IOException {
-               // ------------------------------------------
+       public void add(final KnowledgeElement kelm) throws IOException {
                IndexServiceImpl.Entry entry = new Entry(kelm);
                entry.add();
-               if (logger.isInfoEnabled()) {
-                       logger.info("Knowledge \"" + kelm.getIndex() + "\" indexed.");
+               if (LOG.isInfoEnabled()) {
+                       LOG.info("Knowledge \"" + kelm.getIndex() + "\" indexed.");
                }
        }
 
        public boolean exists() {
-               // ---------------------------
+               boolean res = false;
                try {
-                       return IndexReader.indexExists(index);
+                       res = IndexReader.indexExists(_index);
                } catch (IOException error) {
-                       error.printStackTrace();
-                       return false;
+                       LOG.error(error.getMessage(), error);
                }
+               return res;
        }
 
-       public void update(Study study) throws IOException {
-               // -----------------------------------
+       public void update(final Study study) throws IOException {
                IndexServiceImpl.Entry entry = new Entry(study);
                entry.update();
-               if (logger.isInfoEnabled()) {
-                       logger.info("Study \"" + study.getIndex() + "\" re-indexed.");
+               if (LOG.isInfoEnabled()) {
+                       LOG.info("Study \"" + study.getIndex() + "\" re-indexed.");
                }
        }
 
-       public void update(KnowledgeElement kelm) throws IOException {
-               // ---------------------------------------------
+       public void update(final KnowledgeElement kelm) throws IOException {
                IndexServiceImpl.Entry entry = new Entry(kelm);
                entry.update();
-               if (logger.isInfoEnabled()) {
-                       logger.info("Knowledge \"" + kelm.getIndex() + "\" re-indexed.");
+               if (LOG.isInfoEnabled()) {
+                       LOG.info("Knowledge \"" + kelm.getIndex() + "\" re-indexed.");
                }
        }
 
@@ -338,7 +341,7 @@ public class IndexServiceImpl implements IndexService {
         *            the projectElementService to set
         */
        public void setProjectElementService(
-                       ProjectElementService projectElementService) {
+                       final ProjectElementService projectElementService) {
                _projectElementService = projectElementService;
        }
 
@@ -357,7 +360,7 @@ public class IndexServiceImpl implements IndexService {
         * @param repositoryService
         *            the repositoryService to set
         */
-       public void setRepositoryService(RepositoryService repositoryService) {
+       public void setRepositoryService(final RepositoryService repositoryService) {
                _repositoryService = repositoryService;
        }
 }
\ No newline at end of file
index c6f4f9779905b2cf6ca34131457833b08d24563a..b3c32c73ff2f9dc0d6013dcc026a90ae1519d892 100644 (file)
@@ -27,24 +27,24 @@ public interface ProjectSettingsService {
        /**
         * Transient study step data.
         */
-       public static class Step {
+    class Step {
                /**
                 * The sequential number of the step.
                 */
-               int number;
+               private int _number;
 
                /**
                 * The owner of the step: study or scenario.
                 */
-               private Class<? extends ProjectElement> level;
+               private Class<? extends ProjectElement> _level;
                /**
                 * Set of Document and/or Knowledge applicable on this step.
                 */
-               Set<Class<?>> contents;
+               protected Set<Class<?>> _contents;
                /**
                 * Data path for this step.
                 */
-               private String path;
+               private String _path;
 
                /**
                 * Create a transient study step definition.
@@ -78,7 +78,7 @@ public interface ProjectSettingsService {
                                final Class<? extends ProjectElement> level,
                                final Class<?> contents, final String path) {
                        this.initialize(number, level, path);
-                       this.contents.add(contents);
+                       this._contents.add(contents);
                }
 
                /**
@@ -93,10 +93,10 @@ public interface ProjectSettingsService {
                 */
                private void initialize(final int number,
                                final Class<? extends ProjectElement> level, final String path) {
-                       this.number = number;
-                       this.level = level;
-                       this.path = path + "/";
-                       this.contents = new HashSet<Class<?>>();
+                       this._number = number;
+                       this._level = level;
+                       this._path = path + "/";
+                       this._contents = new HashSet<Class<?>>();
                }
 
                /**
@@ -107,7 +107,7 @@ public interface ProjectSettingsService {
                 * @return true if the step is applied to the given level
                 */
                public boolean appliesTo(final Class<? extends ProjectElement> level) {
-                       return (level == this.level);
+                       return (level == this._level);
                }
 
                /**
@@ -118,7 +118,7 @@ public interface ProjectSettingsService {
                 * @return true if the step can contain data of the given type
                 */
                public boolean mayContain(final Class<?> type) {
-                       return contents.contains(type);
+                       return _contents.contains(type);
                }
 
                /**
@@ -127,7 +127,7 @@ public interface ProjectSettingsService {
                 * @return the sequential number of the step
                 */
                public int getNumber() {
-                       return number;
+                       return _number;
                }
 
                /**
@@ -136,7 +136,7 @@ public interface ProjectSettingsService {
                 * @return data path for this step
                 */
                public String getPath() {
-                       return path;
+                       return _path;
                }
        }
 
@@ -146,7 +146,7 @@ public interface ProjectSettingsService {
         * 
         * @return the validation cycles of the workflow
         */
-       public List<ProjectSettingsValidationCycle> getAllValidationCycles();
+       List<ProjectSettingsValidationCycle> getAllValidationCycles();
 
        /**
         * Get a study step by its sequential number.
@@ -155,14 +155,14 @@ public interface ProjectSettingsService {
         *            the step number
         * @return the step
         */
-       public ProjectSettingsService.Step getStep(final int number);
+       ProjectSettingsService.Step getStep(final int number);
 
        /**
         * Get ordered list of (transient) study steps.
         * 
         * @return the list of steps from project settings
         */
-       public List<ProjectSettingsService.Step> getAllSteps();
+       List<ProjectSettingsService.Step> getAllSteps();
 
        /**
         * Get file naming scheme setting.
@@ -170,21 +170,21 @@ public interface ProjectSettingsService {
         * @return file naming scheme
         * @see org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming
         */
-       public FileNaming getFileNamingScheme();
+       FileNaming getFileNamingScheme();
 
        /**
         * Get a pattern of study references.
         * 
         * @return the reference pattern
         */
-       public String getReferencePattern();
+       String getReferencePattern();
 
        /**
         * Get a pattern of the presentation of version numbers.
         * 
         * @return the version numbers presentation pattern
         */
-       public String getRevisionPattern();
+       String getRevisionPattern();
 
        /**
         * Load workflow configuration from the given file. <br/> Create necessary default staff in the database if it is not initialized yet.
@@ -196,7 +196,7 @@ public interface ProjectSettingsService {
         * @throws SQLException
         *             if there is a database population problem
         */
-       public void configure(String filename) throws IOException, SQLException;
+       void configure(String filename) throws IOException, SQLException;
 
        /**
         * Get steps of the given project element (study or scenario).
@@ -205,6 +205,6 @@ public interface ProjectSettingsService {
         *            the project element (study or scenario)
         * @return the list of steps
         */
-       public List<ProjectSettingsService.Step> getStepsOf(
+       List<ProjectSettingsService.Step> getStepsOf(
                        Class<? extends ProjectElement> level);
 }
index b537b10f8db4e2c7de6b525265afbde1a2e0bf11..14e6e66d58e7a01d791636fe656a70450573b36e 100644 (file)
@@ -10,13 +10,14 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
-import java.util.Vector;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -48,56 +49,56 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
        /**
         * The logger for the service.
         */
-       protected final static Logger logger = Logger
+       protected final static Logger LOG = Logger
                        .getLogger(ProjectSettingsServiceImpl.class);
 
        // Non persistent configuration information
        /**
         * Repository settings.
         */
-       private final Properties reprop = new Properties();
+       private transient final Properties _reprop = new Properties();
        /**
         * Pattern of study references.
         */
-       private String pattern;
+       private transient String _pattern;
        /**
         * Scheme of file names stored into the repository.
         */
-       private FileNaming naming;
+       private transient FileNaming _naming;
        /**
         * Pattern of the presentation of version numbers.
         */
-       private String versioning;
+       private transient String _versioning;
        /**
         * Ordered list of (transient) study steps.
         */
-       private final Vector<ProjectSettingsService.Step> steps = new Vector<ProjectSettingsService.Step>();
+       private transient final List<ProjectSettingsService.Step> _steps = new ArrayList<ProjectSettingsService.Step>();
        /**
         * Configuration document validation cycles.
         */
-       private Vector<ProjectSettingsValidationCycle> concycles;
+       private transient List<ProjectSettingsValidationCycle> _concycles;
 
        // Temporary attributes initialized from the configuration file for populating the database with object types
        /**
         * Document type names and uses mapping.
         */
-       private LinkedHashMap<String, String> mapuse;
+       private transient Map<String, String> _mapuse;
        /**
         * Simulation Context type names.
         */
-       private Vector<String> context;
+       private transient List<String> _context;
        /**
         * Knowledge Element type names.
         */
-       private Vector<String> kname;
+       private transient List<String> _kname;
        /**
         * Document flows.
         */
-       private Vector<NamedNodeMap> flows;
+       private transient List<NamedNodeMap> _flows;
        /**
         * Study classifications.
         */
-       private Vector<NamedNodeMap> sclass;
+       private transient List<NamedNodeMap> _sclass;
 
        // Other resources
        /**
@@ -128,18 +129,18 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                /**
                 * Cycle (document) type name.
                 */
-               private final String name;
+               private final String _name;
                /**
                 * Array of cycle actors positions in the organization. TODO: Must be replaced by Roles.
                 */
-               private final Actor[] actor;
+               private final Actor[] _actor;
 
                /**
                 * Default constructor.
                 */
                private ProjectSettingsValidationCycle() {
-                       this.name = "built-in";
-                       this.actor = new Actor[] { null, null, null };
+                       this._name = "built-in";
+                       this._actor = new Actor[] { null, null, null };
                }
 
                /**
@@ -152,8 +153,8 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                 */
                private ProjectSettingsValidationCycle(final String name,
                                final Actor[] actor) {
-                       this.name = name;
-                       this.actor = actor;
+                       this._name = name;
+                       this._actor = actor;
                }
 
                /**
@@ -162,7 +163,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                 * @return the document type name
                 */
                public String getName() {
-                       return name;
+                       return _name;
                }
 
                /**
@@ -172,7 +173,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                 * @see org.splat.dal.bo.som.ValidationCycle.Actor
                 */
                public Actor[] getActorTypes() {
-                       return actor;
+                       return _actor;
                }
        }
 
@@ -192,7 +193,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
         */
        public void configure(final String filename) throws IOException,
                        SQLException {
-               if (!steps.isEmpty()) {
+               if (!_steps.isEmpty()) {
                        return; // Project already configured
                }
 
@@ -201,11 +202,11 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                if (config.exists()) {
                        loadCustomization(config);
                } else {
-                       logger.fatal("Could not find the database configuration file \""
+                       LOG.fatal("Could not find the database configuration file \""
                                        + config.getAbsolutePath() + "\"");
                        throw new FileNotFoundException();
                }
-               base.configure(reprop);
+               base.configure(_reprop);
                if (!base.isInitialized()) {
                        base.initialize();
                        initialize(); // Populates the database with all necessary stuff
@@ -218,7 +219,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
         * @return the list of steps from project settings
         */
        public List<ProjectSettingsService.Step> getAllSteps() {
-               return steps;
+               return _steps;
        }
 
        /**
@@ -228,7 +229,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
         * @return the validation cycles of the workflow
         */
        public List<ProjectSettingsValidationCycle> getAllValidationCycles() {
-               return concycles;
+               return _concycles;
        }
 
        /**
@@ -238,7 +239,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
         * @see org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming
         */
        public FileNaming getFileNamingScheme() {
-               return naming;
+               return _naming;
        }
 
        /**
@@ -247,7 +248,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
         * @return the reference pattern
         */
        public String getReferencePattern() {
-               return pattern;
+               return _pattern;
        }
 
        /**
@@ -256,7 +257,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
         * @return the version numbers presentation pattern
         */
        public String getRevisionPattern() {
-               return versioning;
+               return _versioning;
        }
 
        /**
@@ -267,13 +268,15 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
         * @return the step
         */
        public ProjectSettingsService.Step getStep(final int number) {
-               for (int i = 0; i < steps.size(); i++) {
-                       ProjectSettingsService.Step step = steps.get(i);
-                       if (step.number == number) {
-                               return step;
+               ProjectSettingsService.Step res = null;
+               for (int i = 0; i < _steps.size(); i++) {
+                       ProjectSettingsService.Step step = _steps.get(i);
+                       if (step.getNumber() == number) {
+                               res = step;
+                               break;
                        }
                }
-               return null;
+               return res;
        }
 
        /**
@@ -285,10 +288,10 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
         */
        public List<ProjectSettingsService.Step> getStepsOf(
                        final Class<? extends ProjectElement> level) {
-               Vector<ProjectSettingsService.Step> result = new Vector<ProjectSettingsService.Step>();
+               List<ProjectSettingsService.Step> result = new ArrayList<ProjectSettingsService.Step>();
 
-               for (int i = 0; i < steps.size(); i++) {
-                       ProjectSettingsService.Step step = steps.get(i);
+               for (int i = 0; i < _steps.size(); i++) {
+                       ProjectSettingsService.Step step = _steps.get(i);
                        if (step.appliesTo(level)) {
                                result.add(step);
                        }
@@ -334,29 +337,29 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                        if (!disk.endsWith("/")) {
                                disk = disk + "/";
                        }
-                       logger.info("Database root set to " + disk);
-                       reprop.setProperty("repository", disk);
+                       LOG.info("Database root set to " + disk);
+                       _reprop.setProperty("repository", disk);
 
                        // Formats tag initializing the reference pattern and date attributes
                        child = children.get("formats");
                        datag = XDOM.getNamedChildNodes(child);
 
                        NamedNodeMap natr = datag.get("references").getAttributes();
-                       pattern = natr.getNamedItem("study").getNodeValue();
+                       _pattern = natr.getNamedItem("study").getNodeValue();
 
                        natr = datag.get("files").getAttributes();
-                       naming = FileNaming.valueOf(natr.getNamedItem("name")
+                       _naming = FileNaming.valueOf(natr.getNamedItem("name")
                                        .getNodeValue());
 
                        natr = datag.get("versions").getAttributes();
-                       versioning = natr.getNamedItem("pattern").getNodeValue();
+                       _versioning = natr.getNamedItem("pattern").getNodeValue();
 
                        // Activities tag initializing the steps and rex attributes
                        child = children.get("activities");
                        NodeList nlist = child.getChildNodes();
-                       Vector<NamedNodeMap> flist = new Vector<NamedNodeMap>();
-                       Vector<String> resultype = new Vector<String>();
-                       Vector<NamedNodeMap> clist = new Vector<NamedNodeMap>();
+                       List<NamedNodeMap> flist = new ArrayList<NamedNodeMap>();
+                       List<String> resultype = new ArrayList<String>();
+                       List<NamedNodeMap> clist = new ArrayList<NamedNodeMap>();
 
                        int snum = 1; // Base number of steps
                        for (int i = 0; i < nlist.getLength(); i++) {
@@ -385,20 +388,20 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                                                }
 
                                                child = tags.get("classification");
-                                               if (child != null) {
-                                                       clist.add(child.getAttributes());
-                                               } else {
+                                               if (child == null) {
                                                        clist.add(null);
+                                               } else {
+                                                       clist.add(child.getAttributes());
                                                }
 
                                                if (natr.getNamedItem("contents").getNodeValue()
                                                                .equals("knowledge")) {
                                                        // TODO In a given scenario, only one step must contain knowledges
-                                                       step.contents.add(KnowledgeElement.class);
+                                                       step._contents.add(KnowledgeElement.class);
                                                } else {
-                                                       step.contents.add(Document.class);
+                                                       step._contents.add(Document.class);
                                                }
-                                               steps.add(step);
+                                               _steps.add(step);
                                                snum += 1;
                                        }
                                } else {
@@ -421,25 +424,26 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                                        }
 
                                        child = tags.get("classification"); // Optional information
-                                       if (child != null) {
-                                               clist.add(child.getAttributes());
-                                       } else {
+                                       if (child == null) {
                                                clist.add(null);
+                                       } else {
+                                               clist.add(child.getAttributes());
                                        }
 
                                        if (natr.getNamedItem("contents").getNodeValue().equals(
                                                        "knowledge")) {
                                                // TODO Error: knowledges must be attached to scenarios
+                                               LOG.error("Error: knowledges must be attached to scenarios.");
                                        } else {
-                                               step.contents.add(Document.class);
+                                               step._contents.add(Document.class);
                                        }
-                                       steps.add(step);
+                                       _steps.add(step);
                                        snum += 1;
                                }
                        }
                        // Validations tag
                        child = children.get("validations");
-                       concycles = new Vector<ProjectSettingsValidationCycle>();
+                       _concycles = new ArrayList<ProjectSettingsValidationCycle>();
                        datag = XDOM.getNamedChildNodes(child);
 
                        String[] step = { "review", "approval", "acceptance" };
@@ -459,9 +463,9 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                                        }
                                        actor[j] = Actor.valueOf(child.getNodeValue());
                                }
-                               concycles.add(new ProjectSettingsValidationCycle(name, actor));
+                               _concycles.add(new ProjectSettingsValidationCycle(name, actor));
                        }
-                       concycles.add(new ProjectSettingsValidationCycle()); // Adds the built-in validation cycle
+                       _concycles.add(new ProjectSettingsValidationCycle()); // Adds the built-in validation cycle
 
                        if (getDatabase().getCheckedDB().isInitialized()) {
                                return; // No need to load object type definitions as they are already stored
@@ -471,9 +475,9 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                        child = children.get("documents");
                        nlist = child.getChildNodes();
 
-                       flows = flist; // Kept for later use in document type definition
-                       sclass = clist; // Kept for later use in simulation context type definition
-                       mapuse = new LinkedHashMap<String, String>();
+                       _flows = flist; // Kept for later use in document type definition
+                       _sclass = clist; // Kept for later use in simulation context type definition
+                       _mapuse = new LinkedHashMap<String, String>();
                        for (int i = 0; i < nlist.getLength(); i++) {
                                child = nlist.item(i);
                                if (!child.getNodeName().equals("article")) {
@@ -487,38 +491,38 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                                if (child != null) {
                                        uses = child.getNodeValue();
                                }
-                               mapuse.put(type, uses); // Must be added to the map even if no (null) uses
+                               _mapuse.put(type, uses); // Must be added to the map even if no (null) uses
                        }
                        // Simulation Contexts tag
                        child = children.get("contexts");
                        nlist = child.getChildNodes();
 
-                       context = new Vector<String>();
+                       _context = new ArrayList<String>();
                        for (int i = 0; i < nlist.getLength(); i++) {
                                child = nlist.item(i);
                                if (!child.getNodeName().equals("article")) {
                                        continue;
                                }
 
-                               context.add(child.getAttributes().getNamedItem("type")
+                               _context.add(child.getAttributes().getNamedItem("type")
                                                .getNodeValue());
                        }
                        // Knowledge Elements tag
                        child = children.get("knowledges");
                        nlist = child.getChildNodes();
 
-                       kname = new Vector<String>();
+                       _kname = new ArrayList<String>();
                        for (int i = 0; i < nlist.getLength(); i++) {
                                child = nlist.item(i);
                                if (!child.getNodeName().equals("article")) {
                                        continue;
                                }
 
-                               kname.add(child.getAttributes().getNamedItem("type")
+                               _kname.add(child.getAttributes().getNamedItem("type")
                                                .getNodeValue());
                        }
                } catch (Exception error) {
-                       logger.info("Error in customization", error);
+                       LOG.info("Error in customization", error);
                }
        }
 
@@ -527,28 +531,28 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
         */
        private void createDocumentTypes() {
                DocumentType.Properties tprop = new DocumentType.Properties();
-               HashMap<String, Vector<ProjectSettingsService.Step>> mapsteps = new HashMap<String, Vector<ProjectSettingsService.Step>>();
-               HashMap<String, ProjectSettingsService.Step> mapresult = new HashMap<String, ProjectSettingsService.Step>();
-               HashMap<String, DocumentType> maptype = new HashMap<String, DocumentType>();
+               Map<String, List<ProjectSettingsService.Step>> mapsteps = new HashMap<String, List<ProjectSettingsService.Step>>();
+               Map<String, ProjectSettingsService.Step> mapresult = new HashMap<String, ProjectSettingsService.Step>();
+               Map<String, DocumentType> maptype = new HashMap<String, DocumentType>();
 
-               Vector<ProjectSettingsService.Step> slist = null; // List of Steps to which each document type is valid
+               List<ProjectSettingsService.Step> slist = null; // List of Steps to which each document type is valid
                int snum = 0; // Step number
                String type = null;
                String uses = null;
-               for (Iterator<NamedNodeMap> i = flows.iterator(); i.hasNext(); snum++) {
+               for (Iterator<NamedNodeMap> i = _flows.iterator(); i.hasNext(); snum++) {
                        NamedNodeMap flow = i.next();
-                       ProjectSettingsService.Step step = steps.get(snum);
+                       ProjectSettingsService.Step step = _steps.get(snum);
                        String[] contents = flow.getNamedItem("contents").getNodeValue()
                                        .split(",");
                        for (int j = 0; j < contents.length; j++) {
                                type = contents[j];
-                               if (!mapuse.containsKey(type)) {
-                                       logger.warn("Undefined \"" + type + "\" document type.");
+                               if (!_mapuse.containsKey(type)) {
+                                       LOG.warn("Undefined \"" + type + "\" document type.");
                                        continue;
                                }
                                slist = mapsteps.get(type);
                                if (slist == null) {
-                                       slist = new Vector<ProjectSettingsService.Step>();
+                                       slist = new ArrayList<ProjectSettingsService.Step>();
                                }
                                slist.add(step);
                                mapsteps.put(type, slist);
@@ -560,12 +564,12 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                }
                try {
                        DocumentType tdoc = null;
-                       Set<String> tset = mapuse.keySet();
+                       Set<String> tset = _mapuse.keySet();
                        ProjectSettingsService.Step step;
                        for (Iterator<String> i = tset.iterator(); i.hasNext();) {
                                type = i.next();
                                slist = mapsteps.get(type);
-                               uses = mapuse.get(type);
+                               uses = _mapuse.get(type);
                                step = mapresult.get(type);
 
                                tprop.clear();
@@ -575,7 +579,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                                if (uses != null) {
                                        tdoc = maptype.get(uses);
                                        if (tdoc == null) {
-                                               logger
+                                               LOG
                                                                .warn("Undefined \"" + uses
                                                                                + "\" document type.");
                                        } else {
@@ -592,7 +596,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                                maptype.put(type, tdoc);
                        }
                } catch (Exception error) {
-                       logger.warn("Error creating document types, reason:", error); // Should not happen
+                       LOG.warn("Error creating document types, reason:", error); // Should not happen
                }
        }
 
@@ -604,14 +608,14 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                        KnowledgeElementType ktype = getKnowledgeElementTypeService()
                                        .createType("usecase"); // Internal reserved knowledge element type
                        getKnowledgeElementTypeService().reserve(ktype);
-                       for (Iterator<String> i = kname.iterator(); i.hasNext();) {
+                       for (Iterator<String> i = _kname.iterator(); i.hasNext();) {
                                String type = i.next();
 
                                ktype = getKnowledgeElementTypeService().createType(type); // Knowledge Elements Types defined in the configuration
                                getKnowledgeElementTypeService().approve(ktype);
                        }
                } catch (Exception error) {
-                       logger.warn("Error creating knowledge types, reason:", error); // Should not happen
+                       LOG.warn("Error creating knowledge types, reason:", error); // Should not happen
                }
        }
 
@@ -619,9 +623,9 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
         * Create in the database simulation contexts types defined in the custom configuration.
         */
        private void createSimulationContextTypes() {
-               HashMap<String, ProjectSettingsService.Step> mapstep = new HashMap<String, ProjectSettingsService.Step>();
+               Map<String, ProjectSettingsService.Step> mapstep = new HashMap<String, ProjectSettingsService.Step>();
                int snum = 0;
-               for (Iterator<NamedNodeMap> i = sclass.iterator(); i.hasNext(); snum++) {
+               for (Iterator<NamedNodeMap> i = _sclass.iterator(); i.hasNext(); snum++) {
                        NamedNodeMap clatr = i.next();
                        if (clatr == null) {
                                continue;
@@ -630,15 +634,15 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                        String[] clist = clatr.getNamedItem("context").getNodeValue()
                                        .split(",");
                        for (int j = 0; j < clist.length; j++) {
-                               mapstep.put(clist[j], steps.get(snum));
+                               mapstep.put(clist[j], _steps.get(snum));
                        }
                }
                try {
                        SimulationContextType tctex = null;
-                       for (Iterator<String> i = context.iterator(); i.hasNext();) {
+                       for (Iterator<String> i = _context.iterator(); i.hasNext();) {
                                String type = i.next();
                                if (!mapstep.containsKey(type)) {
-                                       logger
+                                       LOG
                                                        .warn("Could not find \""
                                                                        + type
                                                                        + "\" classification. Simulation Context type ignored.");
@@ -649,7 +653,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService {
                                getSimulationContextTypeService().approve(tctex);
                        }
                } catch (Exception error) {
-                       logger.warn("Error creating context types, reason:", error); // Should not happen
+                       LOG.warn("Error creating context types, reason:", error); // Should not happen
                }
        }
 
index 4a4da8ac08ac8042435b7c6e368556af00ee060b..8c3fe9010d14e7e8f4476eebe63ce37153a09509 100644 (file)
@@ -1,4 +1,5 @@
 package org.splat.som;
+
 /**
  * 
  * @author    Daniel Brunier-Coulin
@@ -11,80 +12,88 @@ import java.util.Set;
 import org.splat.dal.bo.kernel.Role;
 import org.splat.dal.bo.kernel.User;
 
-
 public class ApplicationRights {
 
-    private User        user;
-    private Set<String> roles;
+       private static final String N_1 = "Nx1";
+       private static final String N_2 = "Nx2";
+       private transient final User _user;
+       private transient final Set<String> _roles;
 
-//  ==============================================================================================================================
-//  Construction
-//  ==============================================================================================================================
+       // ==============================================================================================================================
+       // Construction
+       // ==============================================================================================================================
 
-    public ApplicationRights (User user) {     // Warning: user may be null
-//  ------------------------------------
-      this.roles = new HashSet<String>();
-      this.user  = user;
-      if  (user != null) {
-       Role[] role = user.getRoles();
-       for (int i=0; i<role.length; i++) {
-          String    iam = role[i].getName();
-          roles.add(iam);
-       }
-      }
-    }
+       public ApplicationRights(final User user) { // Warning: user may be null
+               this._roles = new HashSet<String>();
+               this._user = user;
+               if (user != null) {
+                       Role[] role = user.getRoles();
+                       for (int i = 0; i < role.length; i++) {
+                               String iam = role[i].getName();
+                               _roles.add(iam);
+                       }
+               }
+       }
 
-//  ==============================================================================================================================
-//  Public member functions
-//  ==============================================================================================================================
+       // ==============================================================================================================================
+       // Public member functions
+       // ==============================================================================================================================
 
-    public boolean canCreateStudy () {
-//  --------------------------------
-      if (user != null) {
-        String position = user.getOrganizationName();
-        if (position != null && position.equals("Nx2")) return false;
-      }
-      return  roles.contains(Profile.manager.toString());
-    }
+       public boolean canCreateStudy() {
+               boolean res = (_user == null);
+               if (res) {
+                       res = _roles.contains(Profile.manager.toString());
+               } else {
+                       String position = _user.getOrganizationName();
+                       res = (position == null || !position.equals(N_2));
+               }
+               return res;
+       }
 
-    public boolean canContributeToStudy () {
-//  --------------------------------------
-      if (user != null) {
-        String position = user.getOrganizationName();
-        if (position != null && (position.equals("Nx1") || position.equals("Nx2"))) return false;
-      }
-      return (roles.contains(Profile.manager.toString()) || roles.contains(Profile.studengineer.toString()));
-    }
+       public boolean canContributeToStudy() {
+               boolean res = (_user == null);
+               if (res) {
+                       res = (_roles.contains(Profile.manager.toString()) || _roles
+                                       .contains(Profile.studengineer.toString()));
+               } else {
+                       String position = _user.getOrganizationName();
+                       res = (position == null || ((!position.equals(N_1)) && (!position
+                                       .equals(N_2))));
+               }
+               return res;
+       }
 
-    public boolean canValidate () {
-//  -----------------------------
-      return  roles.contains(Profile.manager.toString());
-    }
+       public boolean canValidate() {
+               return _roles.contains(Profile.manager.toString());
+       }
 
-    public boolean canManageKnowledges () {
-//  -------------------------------------
-      if (user != null) {
-        String position = user.getOrganizationName();
-        if (position != null && position.equals("Nx2")) return false;
-      }
-      return  roles.contains(Profile.knowledgineer.toString());
-    }
+       public boolean canManageKnowledges() {
+               boolean res = (_user == null); 
+               if (res) {
+                       res = _roles.contains(Profile.knowledgineer.toString());
+               } else {
+                       String position = _user.getOrganizationName();
+                       res = (position == null || (!position.equals(N_2)));
+               }
+               return res;
+       }
 
-    public boolean canManageDatabase () {
-//  -----------------------------------
-      if (user != null) {
-        String position = user.getOrganizationName();
-        if (position != null && position.equals("Nx2")) return false;
-      }
-      return  roles.contains(Profile.sysadmin.toString());
-    }
+       public boolean canManageDatabase() {
+               boolean res = (_user == null); 
+               if (res) {
+                       res = _roles.contains(Profile.sysadmin.toString());
+               } else {
+                       String position = _user.getOrganizationName();
+                       res = (position == null || (!position.equals(N_2)));
+               }
+               return res;
+       }
 
-//  ==============================================================================================================================
-//  Getters
-//  ==============================================================================================================================
+       // ==============================================================================================================================
+       // Getters
+       // ==============================================================================================================================
 
-    public User getUser () {
-//  ----------------------
-      return user;                             // May be null
-    }
+       public User getUser() {
+               return _user; // May be null
+       }
 }
\ No newline at end of file
index bc00b66b938d1ce942ebfbc0000d38c260285f6f..6e79a5890f5b7426d8f2ababed7c6d88d3154e4f 100644 (file)
@@ -18,21 +18,20 @@ import org.splat.dal.bo.som.ProgressState;
 
 public class Revision {
 
-    private  int major;
-    private  int minor;
-    private  int branch;
+    private transient int _major;
+    private transient int _minor;
+    private transient int _branch;
 
     public static class Format {
-//  --------------------------
-      private String pattern;
+      private transient final String _pattern;
 
-      public Format (String pattern) {
-        this.pattern = pattern;
+      public Format (final String pattern) {
+        this._pattern = pattern;
       }
 
-      public String format (String verstring) {
-       CharBuffer  version = CharBuffer.allocate(pattern.length() + 2*2);   // Maximum possible size
-        char[]      format  = pattern.toCharArray();
+      public String format (final String verstring) {
+       CharBuffer  version = CharBuffer.allocate(_pattern.length() + 2*2);   // Maximum possible size
+        char[]      format  = _pattern.toCharArray();
         String[]    vernum  = verstring.split("\\x2E");                      // version is suposed of the internal form (m.n.s)
         int         branch  = Integer.valueOf(vernum[2]);
 
@@ -49,7 +48,11 @@ public class Revision {
               version.put(vernum[2]);
             }
           } else if (token == '[') {
-               if (branch == 0) while (format[i] != ']') i += 1;
+               if (branch == 0) {
+                               while (format[i] != ']') {
+                                       i += 1;
+                               }
+                       }
           } else if (token == ']') {
                continue;
           } else {
@@ -59,8 +62,8 @@ public class Revision {
        return  new String(version.array(), 0, version.position());
       }
 
-      public Revision parse (String verstring) throws ParseException {
-        char[]      format  = pattern.toCharArray();
+      public Revision parse (final String verstring) throws ParseException {
+        char[]      format  = _pattern.toCharArray();
         char[]      version = verstring.toCharArray();
         CharBuffer  major   = CharBuffer.allocate(4);
         CharBuffer  minor   = CharBuffer.allocate(4);
@@ -74,19 +77,25 @@ public class Revision {
                token = format[i];
             if        (token == 'M') {
               while (cursor < version.length) {
-                if (!Character.isDigit(version[cursor])) break;
+                if (!Character.isDigit(version[cursor])) {
+                                       break;
+                               }
                 major.put(version[cursor]);
                 cursor += 1;
               }
             } else if (token == 'm') {
               while (cursor < version.length) {
-                if (!Character.isDigit(version[cursor])) break;
+                if (!Character.isDigit(version[cursor])) {
+                                       break;
+                               }
                 minor.put(version[cursor]);
                 cursor += 1;
               }
             } else if (token == 's') {
               while (cursor < version.length) {
-                if (!Character.isDigit(version[cursor])) break;
+                if (!Character.isDigit(version[cursor])) {
+                                       break;
+                               }
                 branch.put(version[cursor]);
                 cursor += 1;
               }
@@ -94,12 +103,18 @@ public class Revision {
           } else if (token == '[' || token == ']') {
                continue;
           } else {
-            if (version[cursor] != token) throw new ParseException(verstring, cursor);
+            if (version[cursor] != token) {
+                               throw new ParseException(verstring, cursor);
+                       }
             cursor += 1;
           }
-          if (cursor >= version.length) break;
+          if (cursor >= version.length) {
+                       break;
+               }
         }
-        if (major.position() == 0) throw  new ParseException(verstring, 0);
+        if (major.position() == 0) {
+                       throw  new ParseException(verstring, 0);
+               }
 
         String  majnum = new String(major.array(), 0, major.position());
         if (minor.position() == 0) {
@@ -116,7 +131,7 @@ public class Revision {
       }
 
       public String toPattern () {
-        return pattern;
+        return _pattern;
       }
     }
 
@@ -126,68 +141,73 @@ public class Revision {
 /**
  * Constructs a Revision object from the internal representation of a version number (m.n.s).
  */
-    public Revision (String value) {
+    public Revision (final String value) {
 //  ------------------------------
       String[] vernum = value.split("\\x2E");
       try {
-        this.major  = Integer.valueOf(vernum[0]);
-        this.minor  = Integer.valueOf(vernum[1]);
-        this.branch = Integer.valueOf(vernum[2]);
+        this._major  = Integer.valueOf(vernum[0]);
+        this._minor  = Integer.valueOf(vernum[1]);
+        this._branch = Integer.valueOf(vernum[2]);
       }
       catch (Exception e) {     // NumberFormat or OutOfBound exception if value is not of the form m.n.s
-           this.major  = 0;
-           this.minor  = 0;
-           this.branch = 0;
+           this._major  = 0;
+           this._minor  = 0;
+           this._branch = 0;
          }
     }
     public Revision () {
 //  ------------------
-      this.major  = 0;
-      this.minor  = 0;
-      this.branch = 0;
+      this._major  = 0;
+      this._minor  = 0;
+      this._branch = 0;
     }
-    private Revision (int major, int minor) {
+    private Revision (final int major, final int minor) {
 //  ---------------------------------------
-      this.major  = major;
-      this.minor  = minor;
-      this.branch = 0;
+      this._major  = major;
+      this._minor  = minor;
+      this._branch = 0;
     }
-    private Revision (int major, int minor, String branch) {
+    private Revision (final int major, final int minor, final String branch) {
 //  ------------------------------------------------------
-      this.major  = major;
-      this.minor  = minor;
-      this.branch = Integer.valueOf(branch);
+      this._major  = major;
+      this._minor  = minor;
+      this._branch = Integer.valueOf(branch);
     }
 
 //  ==============================================================================================================================
 //  Public member function
 //  ==============================================================================================================================
 
-    public Revision incrementAs (ProgressState state) {
+    public Revision incrementAs (final ProgressState state) {
 //  -------------------------------------------------
-      if      (state == ProgressState.inWORK || state == ProgressState.inDRAFT) minor += 1;
-      else if (state == ProgressState.inCHECK) {
-        major = major + 1;
-        minor = 0;
+      if      (state == ProgressState.inWORK || state == ProgressState.inDRAFT) {
+               _minor += 1;
+       } else if (state == ProgressState.inCHECK) {
+        _major = _major + 1;
+        _minor = 0;
       }
       return this;
     }
 
-    public boolean isGraterThan (Revision base) {
+    public boolean isGraterThan (final Revision base) {
 //  ------------------------------------------
-      if (this.major > base.major) return true;
-      if (this.major < base.major) return false;
-      return (this.minor > base.minor);
+      if (this._major > base._major) {
+               return true;
+       }
+      if (this._major < base._major) {
+               return false;
+       }
+      return (this._minor > base._minor);
     }
 
     public boolean isMinor () {
 //  -------------------------
-      return (minor != 0);
+      return (_minor != 0);
     }
 
     public boolean isNull () {
 //  ------------------------
-      return (major+minor == 0);
+      return (_major+_minor == 0);
     }
 /**
  * Sets the branch name of this revision.
@@ -195,19 +215,20 @@ public class Revision {
  * @param name the branch name or the internal representation of a version number (m.n.s)
  * @return this revision object
  */
-    public Revision setBranch (String name) {
+    public Revision setBranch (final String name) {
 //  ---------------------------------------
       String[] vernum = name.split("\\x2E");
 
-      branch = Integer.valueOf(vernum[vernum.length-1]);
+      _branch = Integer.valueOf(vernum[vernum.length-1]);
       return this;
     }
 /**
  * Returns the internal representation of a version number (m.n.s) represented by this Revision object.
  */
-    public String toString () {
+    @Override
+       public String toString () {
 //  -------------------------
       StringBuffer version = new StringBuffer();
-      return version.append(major).append(".").append(minor).append(".").append(branch).toString();
+      return version.append(_major).append(".").append(_minor).append(".").append(_branch).toString();
     }
 }
\ No newline at end of file
index 83cc7e2d35e1b88f68243aa0f17c1067c0ea1d40..b8a5cd73b48aad1eb4a75acf7f43aa234f6236d5 100644 (file)
@@ -6,10 +6,10 @@ package org.splat.som;
  * @copyright OPEN CASCADE 2012
  */
 
+import java.util.ArrayList;
 import java.util.Collections;
-import java.util.List;
-import java.util.Vector;
 import java.util.Iterator;
+import java.util.List;
 
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.Document;
@@ -26,38 +26,41 @@ import org.splat.service.technical.ProjectSettingsService;
 
 public class Step {
 
-       private ProjectSettingsService.Step step;
-       private ProjectElement owner;
-       private List<SimulationContext> contex;
-       private List<Publication> docums;
-       private User actor; // Actor involved in operations on published documents and requiring a time-stamp
+       private transient final ProjectSettingsService.Step _step;
+       private transient final ProjectElement _owner;
+       private transient final List<SimulationContext> _contex;
+       private transient final List<Publication> _docums;
+       private User _actor; // Actor involved in operations on published documents and requiring a time-stamp
 
        // ==============================================================================================================================
        // Constructor
        // ==============================================================================================================================
 
-       public Step(ProjectSettingsService.Step step, ProjectElement owner) {
-               // ----------------------------------------------------------------
-               this.step = step;
-               this.owner = owner;
-               this.contex = new Vector<SimulationContext>();
-               this.docums = new Vector<Publication>();
-               this.actor = null;
+       public Step(final ProjectSettingsService.Step step,
+                       final ProjectElement owner) {
+               this._step = step;
+               this._owner = owner;
+               this._contex = new ArrayList<SimulationContext>();
+               this._docums = new ArrayList<Publication>();
+               this._actor = null;
 
                // Filtering of Simulation contexts, if exist
                for (Iterator<SimulationContext> i = owner.SimulationContextIterator(); i
                                .hasNext();) {
                        SimulationContext adoc = i.next();
-                       if (!adoc.isInto(this))
+                       if (!adoc.isInto(this)) {
                                continue;
-                       this.contex.add(adoc);
+                       }
+                       this._contex.add(adoc);
                }
                // Filtering of Documents, if exist
                for (Iterator<Publication> i = owner.PublicationIterator(); i.hasNext();) {
                        Publication mydoc = i.next();
-                       if (!mydoc.value().isInto(this))
+                       if (!mydoc.value().isInto(this)) {
                                continue;
-                       this.docums.add(mydoc);
+                       }
+                       mydoc.setStep(this); //RKV
+                       this._docums.add(mydoc);
                }
        }
 
@@ -66,161 +69,161 @@ public class Step {
        // ==============================================================================================================================
 
        public User getActor() {
-               // -----------------------
-               return actor;
+               return _actor;
        }
 
        public List<Publication> getAllDocuments() {
-               // -------------------------------------------
-               return Collections.unmodifiableList(docums);
+               return Collections.unmodifiableList(_docums);
        }
 
        /**
         * Get the persistent collection of step documents.
+        * 
         * @return the list of documents
         */
        public List<Publication> getDocuments() {
-               return docums;
+               return _docums;
        }
 
        public List<SimulationContext> getAllSimulationContexts() {
-               // ----------------------------------------------------------
-               return Collections.unmodifiableList(contex);
+               return Collections.unmodifiableList(_contex);
        }
 
-       public Publication getDocument(long l) {
-               // ------------------------------------------
-               for (Iterator<Publication> i = docums.iterator(); i.hasNext();) {
+       public Publication getDocument(final long docId) {
+               for (Iterator<Publication> i = _docums.iterator(); i.hasNext();) {
                        Publication found = i.next(); // In a given study step,
-                       if (found.value().getIndex() == l)
+                       if (found.value().getIndex() == docId) {
                                return found; // there is only one publication of a given document
+                       }
                }
                return null;
        }
 
        public int getNumber() {
-               // -----------------------
-               return step.getNumber();
+               return _step.getNumber();
        }
 
        public ProjectElement getOwner() {
-               // ---------------------------------
-               return owner; // May be a Study or a Scenario
+               return _owner; // May be a Study or a Scenario
        }
 
        public Study getOwnerStudy() {
-               // -----------------------------
-               if (owner instanceof Study)
-                       return (Study) owner;
-               else
-                       return ((Scenario) owner).getOwnerStudy();
+               if (_owner instanceof Study) {
+                       return (Study) _owner;
+               } else {
+                       return ((Scenario) _owner).getOwnerStudy();
+               }
        }
 
        public String getPath() {
-               // ------------------------
-               return step.getPath();
+               return _step.getPath();
        }
 
        public List<Publication> getResultDocuments() {
-               // ----------------------------------------------
-               List<Publication> result = new Vector<Publication>();
+               List<Publication> result = new ArrayList<Publication>();
 
-               if (!docums.isEmpty())
-                       for (Iterator<Publication> i = docums.iterator(); i.hasNext();) {
+               if (!_docums.isEmpty()) {
+                       for (Iterator<Publication> i = _docums.iterator(); i.hasNext();) {
                                Publication content = i.next();
                                DocumentType type = content.value().getType();
-                               if (!type.isResultOf(this.getStep()))
+                               if (!type.isResultOf(this.getStep())) {
                                        continue;
+                               }
                                result.add(content);
                        }
+               }
                return result;
        }
 
        public ProjectSettingsService.Step getStep() {
-               // --------------------------------------
-               return step;
+               return _step;
        }
 
-       public SimulationContext getSimulationContext(long l) {
-               // ---------------------------------------------------------
-               for (Iterator<SimulationContext> i = owner.SimulationContextIterator(); i
+       public SimulationContext getSimulationContext(final long l) {
+               for (Iterator<SimulationContext> i = _owner.SimulationContextIterator(); i
                                .hasNext();) {
                        SimulationContext myctex = i.next();
-                       if (myctex.getIndex() == l)
+                       if (myctex.getIndex() == l) {
                                return myctex;
+                       }
                }
                return null;
        }
 
        public List<SimulationContext> getSimulationContext(
-                       SimulationContextType type) {
-               // --------------------------------------------------------------------------------
-               Vector<SimulationContext> result = new Vector<SimulationContext>();
+                       final SimulationContextType type) {
+               List<SimulationContext> result = new ArrayList<SimulationContext>();
 
-               for (Iterator<SimulationContext> i = owner.SimulationContextIterator(); i
+               for (Iterator<SimulationContext> i = _owner.SimulationContextIterator(); i
                                .hasNext();) {
                        SimulationContext myctex = i.next();
-                       if (myctex.getType().equals(type))
+                       if (myctex.getType().equals(type)) {
                                result.add(myctex);
+                       }
                }
                return result;
        }
 
        public boolean isStarted() {
-               // ---------------------------
-               if (!step.mayContain(KnowledgeElement.class))
-                       return !docums.isEmpty();
-
-               List<KnowledgeElement> kelm = ((Scenario) owner)
-                               .getAllKnowledgeElements();
-               if (kelm.isEmpty() && docums.isEmpty())
-                       return false;
-               return true;
+               boolean res = _step.mayContain(KnowledgeElement.class);
+               if (res) {
+                       List<KnowledgeElement> kelm = ((Scenario) _owner)
+                                       .getAllKnowledgeElements();
+                       res = (!kelm.isEmpty() || !_docums.isEmpty());
+               } else {
+                       res = (!_docums.isEmpty());
+               }
+               return res;
        }
 
        public boolean isFinished() {
-               // ----------------------------
-               if (!step.mayContain(KnowledgeElement.class)) { // Check if all result documents are approved
-                       if (docums.isEmpty())
+               if (_step.mayContain(KnowledgeElement.class)) { // Check if all result documents are approved
+                       List<KnowledgeElement> kelm = ((Scenario) _owner)
+                                       .getAllKnowledgeElements();
+                       if (kelm.isEmpty()) {
+                               return false;
+                       }
+                       for (Iterator<KnowledgeElement> i = kelm.iterator(); i.hasNext();) {
+                               KnowledgeElement content = i.next();
+                               if (content.getProgressState() != ProgressState.APPROVED) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               } else { // Check if all existing knowledges are approved
+                       if (_docums.isEmpty()) {
                                return false;
+                       }
                        boolean result = false;
-                       for (Iterator<Publication> i = docums.iterator(); i.hasNext();) {
+                       for (Iterator<Publication> i = _docums.iterator(); i.hasNext();) {
                                Document content = i.next().value();
                                DocumentType type = content.getType();
-                               if (!type.isResultOf(this.getStep()))
+                               if (!type.isResultOf(this.getStep())) {
                                        continue;
-                               if (content.getProgressState() == ProgressState.EXTERN)
+                               }
+                               if (content.getProgressState() == ProgressState.EXTERN) {
                                        continue;
+                               }
                                result = true; // There is at least 1 non external result document
-                               if (content.getProgressState() != ProgressState.APPROVED)
+                               if (content.getProgressState() != ProgressState.APPROVED) {
                                        return false;
+                               }
                        }
                        return result;
-               } else { // Check if all existing knowledges are approved
-                       List<KnowledgeElement> kelm = ((Scenario) owner)
-                                       .getAllKnowledgeElements();
-                       if (kelm.isEmpty())
-                               return false;
-                       for (Iterator<KnowledgeElement> i = kelm.iterator(); i.hasNext();) {
-                               KnowledgeElement content = i.next();
-                               if (content.getProgressState() != ProgressState.APPROVED)
-                                       return false;
-                       }
-                       return true;
                }
        }
 
-       public boolean mayContain(@SuppressWarnings("rawtypes")
-       Class type) {
-               return step.mayContain(type);
+       @SuppressWarnings("unchecked")
+       public boolean mayContain(final Class type) {
+               return _step.mayContain(type);
        }
 
-       public void setActor(User user) {
-               actor = user;
+       public void setActor(final User user) {
+               _actor = user;
        }
 
        public List<SimulationContext> getContex() {
-               return contex;
+               return _contex;
        }
 
 }
\ No newline at end of file
index 22f462b11621098d4d4007d52007aa5fd264af9a..b91efd1eadc3eb45f33654afc5ede8bb1e98d473 100644 (file)
@@ -16,17 +16,17 @@ import org.splat.service.ServiceLocatorImpl;
 
 public class StepRights {
 
-    private User     user;
-    private Step     operand;
-       public StepRights (User user, Step step) {
+    private final transient User     _user;
+    private final transient Step     _operand;
+       public StepRights (final User user, final Step step) {
 //  ----------------------------------------
-      this.user    = user;
-      this.operand = step;
+      this._user    = user;
+      this._operand = step;
     }
-    public StepRights (Step step) {
+    public StepRights (final Step step) {
 //  -----------------------------
-      this.user    = step.getOwner().getAuthor();
-      this.operand = step;
+      this._user    = step.getOwner().getAuthor();
+      this._operand = step;
     }
 
 //  ==============================================================================================================================
@@ -41,8 +41,8 @@ public class StepRights {
  */
     public boolean canAddComment () {
 //  -------------------------------
-      Study   owner = operand.getOwnerStudy();
-      return (owner.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(owner, user));
+      Study   owner = _operand.getOwnerStudy();
+      return (owner.getAuthor().equals(_user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(owner, _user));
     }
 
 /**
@@ -53,8 +53,10 @@ public class StepRights {
  */
     public boolean canCreateDocument () {
 //  -----------------------------------
-      if (!isEnabled()) return false;
-      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand.getOwnerStudy(), user);
+      if (!isEnabled()) {
+               return false;
+       }
+      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand.getOwnerStudy(), _user);
     }
 
 /**
@@ -65,7 +67,7 @@ public class StepRights {
  */
     public boolean canCreateKnowledge () {
 //  ------------------------------------
-      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand.getOwnerStudy(), user);
+      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand.getOwnerStudy(), _user);
     }
 
 /**
@@ -76,8 +78,8 @@ public class StepRights {
  */
     public boolean canEditSimulationContext () {
 //  ------------------------------------------
-      Study   owner = operand.getOwnerStudy();
-      return (owner.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(owner, user));
+      Study   owner = _operand.getOwnerStudy();
+      return (owner.getAuthor().equals(_user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(owner, _user));
     }
 
 /**
@@ -88,11 +90,13 @@ public class StepRights {
  */
     public boolean isEnabled () {
 //  ---------------------------
-      ProjectElement  owner = operand.getOwner();
+      ProjectElement  owner = _operand.getOwner();
       
       if (owner instanceof Scenario) {
         Scenario  scene = (Scenario)owner;
-        if (scene.isCheckedout()) return false;
+        if (scene.isCheckedout()) {
+                       return false;
+               }
       }
       return true;
     }
@@ -103,6 +107,6 @@ public class StepRights {
 
     public Step getOperand () {
 //  -------------------------
-      return operand;
+      return _operand;
     }
 }
\ No newline at end of file
index c4bf7f954df64b8fb91f772f224900f61782ee00..7a724e1d1c007328a3270985e258ecc20dd5c769 100644 (file)
@@ -16,23 +16,23 @@ import org.splat.service.ServiceLocatorImpl;
 
 public class StudyRights {
 
-    private User     user;
-    private Study    operand;
-    private boolean  author = false;                    // For optimizing 
-       public StudyRights (User user, Study study) {
+    private final transient User     _user;
+    private final transient Study    _operand;
+    private transient boolean  _author = false;                    // For optimizing 
+       public StudyRights (final User user, final Study study) {
 //  -------------------------------------------
-      this.user    = user;
-      this.operand = study;
+      this._user    = user;
+      this._operand = study;
 
-      if (operand != null && operand.getAuthor() != null) {
-         this.author  = operand.getAuthor().equals(user);  // user may be null
+      if (_operand != null && _operand.getAuthor() != null) {
+         this._author  = _operand.getAuthor().equals(user);  // user may be null
       }
     }
-    public StudyRights (Study study) {
+    public StudyRights (final Study study) {
 //  --------------------------------
-      this.user    = study.getAuthor();
-      this.operand = study;
-      this.author  = true;                              // In order to ignore the author in this context
+      this._user    = study.getAuthor();
+      this._operand = study;
+      this._author  = true;                              // In order to ignore the author in this context
     }
 
 //  ==============================================================================================================================
@@ -41,8 +41,10 @@ public class StudyRights {
 
     public boolean canAddScenario () {
 //  --------------------------------
-      if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
-      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
+      if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+               return false;
+       }
+      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user);
     }
 
 /**
@@ -53,12 +55,12 @@ public class StudyRights {
  */
     public boolean canEditDescription () {
 //  ------------------------------------
-      return (operand.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(operand, user));
+      return (_operand.getAuthor().equals(_user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(_operand, _user));
     }
 
     public boolean canEditProperties () {
 //  -----------------------------------
-      return author;
+      return _author;
     }
 
 /**
@@ -69,26 +71,34 @@ public class StudyRights {
  */
     public boolean canPublish () {
 //  ----------------------------
-      if (!author) return false;
-      return (!operand.isPublic());
+      if (!_author) {
+               return false;
+       }
+      return (!_operand.isPublic());
     }
 
     public boolean canPurge () {
 //  --------------------------
-      if (!author) return false;
-      return operand.isVersioned();
+      if (!_author) {
+               return false;
+       }
+      return _operand.isVersioned();
     }
 
     public boolean canRemove () {
 //  ---------------------------
-      if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
-      return author;
+      if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+               return false;
+       }
+      return _author;
     }
 
     public boolean canVersion () {
 //  ----------------------------
-      if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
-      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
+      if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
+               return false;
+       }
+      return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user);
     }
 
 //  ==============================================================================================================================
@@ -97,6 +107,6 @@ public class StudyRights {
 
     public Study getOperand () {
 //  --------------------------
-      return operand;
+      return _operand;
     }
 }
\ No newline at end of file
index 9af8ea4c422b79a1614df23b8ce1f621cd84f41d..7132e671ecdbeb5be759c6a553c1bb0414d6082d 100644 (file)
@@ -11,12 +11,12 @@ package org.splat.util;
 
 import java.util.Map;
 
-import org.splat.log.AppLogger;
-
 import net.sf.beanlib.PropertyInfo;
 import net.sf.beanlib.spi.BeanTransformerSpi;
 import net.sf.beanlib.spi.CustomBeanTransformerSpi;
 
+import org.splat.log.AppLogger;
+
 /**
  * DTO transformer used by BeanHelper.
  * 
@@ -27,13 +27,13 @@ public class DTOTransformer implements CustomBeanTransformerSpi {
        /**
         * The logger for the service.
         */
-       public final static AppLogger logger = AppLogger
+       public final static AppLogger LOG = AppLogger
                        .getLogger(DTOTransformer.class);
 
        /**
         * the bean transformer.
         */
-       private final BeanTransformerSpi _beanTransformer;
+       private final transient BeanTransformerSpi _beanTransformer;
 
        /**
         * Constructor.
@@ -54,21 +54,21 @@ public class DTOTransformer implements CustomBeanTransformerSpi {
        public <T> boolean isTransformable(final Object from,
                        final Class<T> toClass, final net.sf.beanlib.PropertyInfo info) {
                boolean ok = false;
-               if (from != null) {
+               if (from == null) {
+                       if (LOG.isDebugEnabled()) {
+                               LOG.debug("From: null; To: " + toClass.getSimpleName());
+                       }
+               } else {
                        String fromName = from.getClass().getSimpleName();
                        String toName = toClass.getSimpleName();
-                       if (logger.isDebugEnabled()) {
-                               logger.debug("From: " + fromName + "; To: " + toName);
+                       if (LOG.isDebugEnabled()) {
+                               LOG.debug("From: " + fromName + "; To: " + toName);
                                ok = (fromName.equals(toName + "DTO") || toName.equals(fromName
                                                + "DTO"));
                        }
-               } else {
-                       if (logger.isDebugEnabled()) {
-                               logger.debug("From: null; To: " + toClass.getSimpleName());
-                       }
                }
-               if (logger.isDebugEnabled()) {
-                       logger.debug("Can transform from " + info.getFromBean() + "."
+               if (LOG.isDebugEnabled()) {
+                       LOG.debug("Can transform from " + info.getFromBean() + "."
                                        + info.getPropertyName() + " to " + info.getToBean() + "."
                                        + info.getPropertyName() + ": " + ok);
                }
@@ -81,27 +81,25 @@ public class DTOTransformer implements CustomBeanTransformerSpi {
         * 
         * @see net.sf.beanlib.spi.Transformable#transform(java.lang.Object, java.lang.Class, net.sf.beanlib.PropertyInfo)
         */
+       @SuppressWarnings("unchecked")
        public <T> T transform(final Object in, final Class<T> toClass,
                        final PropertyInfo info) {
-               if (logger.isDebugEnabled()) {
-                       logger.debug("Transform " + in.getClass().getSimpleName() + ": "
+               if (LOG.isDebugEnabled()) {
+                       LOG.debug("Transform " + in.getClass().getSimpleName() + ": "
                                        + in.toString() + " to " + toClass.getSimpleName());
                }
                Map<Object, Object> cloneMap = _beanTransformer.getClonedMap();
                Object clone = cloneMap.get(in);
 
-               if (clone != null) {
-                       return (T) clone;
-               }
-
-               if (logger.isDebugEnabled()) {
-                       logger.debug("Copy bean from " + info.getFromBean() + "."
-                                       + info.getPropertyName() + " to " + info.getToBean() + "."
-                                       + info.getPropertyName());
+               if (clone == null) {
+                       if (LOG.isDebugEnabled()) {
+                               LOG.debug("Copy bean from " + info.getFromBean() + "."
+                                               + info.getPropertyName() + " to " + info.getToBean() + "."
+                                               + info.getPropertyName());
+                       }
+                       clone = BeanHelper.copyBean(in, toClass);
+                       cloneMap.put(in, clone);
                }
-               clone = BeanHelper.copyBean(in, toClass);
-               cloneMap.put(in, clone);
-
                return (T) clone;
        }
 }
index 3fd1378b2de110f7fcd5204c0af44e351798dabb..168201b6d4c3a85e765814219ce46c53ed74cd55 100644 (file)
@@ -4,7 +4,7 @@
        xsi:schemaLocation="
 http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
-<!-- Generated by Siman Generator on Wed Oct 17 14:28:24 MSD 2012 -->
+<!-- Generated by Siman Generator on Tue Nov 06 13:38:56 MSK 2012 -->
 
     <bean id="persistentDAO" parent="genericDAO"
         class="org.splat.dal.dao.kernel.PersistentDAOImpl">
@@ -50,6 +50,14 @@ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
         class="org.splat.dal.dao.som.ScenarioDAOImpl">
     </bean>
     
+    <bean id="descriptionAttributeDAO" parent="genericDAO"
+        class="org.splat.dal.dao.som.DescriptionAttributeDAOImpl">
+    </bean>
+    
+    <bean id="commentAttributeDAO" parent="genericDAO"
+        class="org.splat.dal.dao.som.CommentAttributeDAOImpl">
+    </bean>
+    
     <bean id="usesRelationDAO" parent="genericDAO"
         class="org.splat.dal.dao.som.UsesRelationDAOImpl">
     </bean>
index 596379da675c229bc07f21f111d1417435e15e13..1e9ac52fad2fc32fe8fce97d9a266b7a3ef99040 100644 (file)
@@ -28,7 +28,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
-    <bean id="genericDAO" class="org.splat.dal.dao.kernel.GenericDAOImpl"
+    <bean id="genericDAO" class="org.splat.dal.dao.kernel.AbstractGenericDAOImpl"
         abstract="true">
         <property name="sessionFactory" ref="simanSessionFactory" />
     </bean>
index 9082d0e5639126fbab93445eafc6e649a6d260e9..427925a50e3d65705ea8590ca64432f67e49d6d6 100644 (file)
@@ -2,6 +2,7 @@ package org.splat.simer;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -11,42 +12,40 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
-import java.util.Vector;
 
 import javax.servlet.ServletContext;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.NamedNodeMap;
 
 import org.apache.log4j.Logger;
 import org.splat.dal.bo.kernel.User;
-import org.splat.manox.XDOM;
 import org.splat.dal.bo.som.Document;
-import org.splat.som.DocumentRights;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.SimulationContext;
+import org.splat.manox.XDOM;
 import org.splat.service.DocumentTypeService;
 import org.splat.service.technical.ProjectSettingsService;
-import org.splat.simer.Converter;
-import org.splat.dal.bo.som.SimulationContext;
+import org.splat.som.DocumentRights;
 import org.splat.som.Step;
 import org.splat.som.StudyRights;
 import org.splat.wapp.MenuItem;
-import org.splat.wapp.PopupMenu;
 import org.splat.wapp.PopupItem;
+import org.splat.wapp.PopupMenu;
 import org.splat.wapp.SimpleMenu;
 import org.splat.wapp.ToolBar;
 import org.springframework.web.context.ServletContextAware;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 public class ApplicationSettings implements ServletContextAware {
 
        /**
         * Application settings logger.
         */
-       protected final static Logger logger = Logger
+       protected final static Logger LOG = Logger
                        .getLogger(ApplicationSettings.class);
 
        /**
@@ -56,9 +55,9 @@ public class ApplicationSettings implements ServletContextAware {
        
        private String wappserver;
        private String wappname;
-       private Properties wapprops = new Properties(); // General properties from the application properties files
+       private final Properties wapprops = new Properties(); // General properties from the application properties files
        private Locale locale; // Current user locale
-       private Map<String, SimpleMenu> menus = new HashMap<String, SimpleMenu>(); // Application menus
+       private final Map<String, SimpleMenu> menus = new HashMap<String, SimpleMenu>(); // Application menus
        private Map<Integer, ToolBar> bars = null; // Study module-bars structured by steps
        private Map<String, PopupMenu> popups = null;
        private Map<String, Map<String, Object>> filter = null; // Named search filters
@@ -66,9 +65,9 @@ public class ApplicationSettings implements ServletContextAware {
        private Map<String, String> tempfile = null; // Available template files
        private String[] viewermap = null; // List of file extensions mapped to a viewer
        private Map<String, Converter> convertmap = null; // Available document format converters
-       private Properties jndprops = new Properties(); // JNDI context for launching converters
+       private final Properties jndprops = new Properties(); // JNDI context for launching converters
 
-       private static ApplicationSettings my = null; // Singleton instance
+       private static ApplicationSettings my = new ApplicationSettings(); // Singleton instance
        /**
         * Injected project settings service.
         */
@@ -93,7 +92,7 @@ public class ApplicationSettings implements ServletContextAware {
         * @param projectSettingsService
         *            the projectSettingsService to set
         */
-       public void setProjectSettings(ProjectSettingsService projectSettingsService) {
+       public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
                _projectSettingsService = projectSettingsService;
        }
 
@@ -202,34 +201,44 @@ public class ApplicationSettings implements ServletContextAware {
                                        .confirmation("message.delete.study"));
                }
 
-               public boolean isEnabled(String name) {
-                       if (user == null)
+               @Override
+               public boolean isEnabled(final String name) {
+                       if (user == null) {
                                return false; // Should not happen
+                       }
                        Item item = Item.valueOf(name);
-                       if (item == Item.publish)
+                       if (item == Item.publish) {
                                return user.canPublish();
-                       if (item == Item.edit)
+                       }
+                       if (item == Item.edit) {
                                return user.canEditProperties();
-                       if (item == Item.script)
+                       }
+                       if (item == Item.script) {
                                return user.canAddScenario();
-                       if (item == Item.version)
+                       }
+                       if (item == Item.version) {
                                return user.canVersion();
-                       if (item == Item.remove)
+                       }
+                       if (item == Item.remove) {
                                return user.canRemove();
-                       if (item == Item.purge)
+                       }
+                       if (item == Item.purge) {
                                return user.canPurge();
+                       }
                        return false;
                }
 
-               public void setContext(String name, Object context) {
+               @Override
+               public void setContext(final String name, final Object context) {
                        if (context instanceof StudyRights) {
                                user = (StudyRights) context; // Just for optimizing
                                boolean history = user.getOperand().isVersioned();
                                PopupItem item = this.item("remove");
-                               if (history)
+                               if (history) {
                                        item.rename("menu.remove.version");
-                               else
+                               } else {
                                        item.rename("menu.remove.study");
+                               }
                        }
                }
        }
@@ -266,38 +275,50 @@ public class ApplicationSettings implements ServletContextAware {
                                        "message.delete.document"));
                }
 
-               public boolean isEnabled(String name) {
-                       if (user == null)
+               @Override
+               public boolean isEnabled(final String name) {
+                       if (user == null) {
                                return false; // Should not happen
+                       }
                        Item item = Item.valueOf(name);
-                       if (item == Item.accept)
+                       if (item == Item.accept) {
                                return user.canAccept();
-                       if (item == Item.promote)
+                       }
+                       if (item == Item.promote) {
                                return user.canPromote();
-                       if (item == Item.rename)
+                       }
+                       if (item == Item.rename) {
                                return user.canRename();
-                       if (item == Item.attach)
+                       }
+                       if (item == Item.attach) {
                                return user.canAttach();
-                       if (item == Item.version)
+                       }
+                       if (item == Item.version) {
                                return user.canVersion();
-                       if (item == Item.replace)
+                       }
+                       if (item == Item.replace) {
                                return user.canReplace();
-                       if (item == Item.purge)
+                       }
+                       if (item == Item.purge) {
                                return user.canPurge();
-                       if (item == Item.remove)
+                       }
+                       if (item == Item.remove) {
                                return user.canRemove();
+                       }
                        return false;
                }
 
-               public void setContext(String name, Object context) {
+               @Override
+               public void setContext(final String name, final Object context) {
                        if (context instanceof DocumentRights) {
                                user = (DocumentRights) context; // Just for optimizing
                                Document downer = user.getOperand();
                                PopupItem item = this.item("remove");
-                               if (downer.isVersioned())
+                               if (downer.isVersioned()) {
                                        item.rename("menu.remove.version");
-                               else
+                               } else {
                                        item.rename("menu.remove.document");
+                               }
                        }
                }
        }
@@ -325,24 +346,32 @@ public class ApplicationSettings implements ServletContextAware {
                                        "notyetimplemented").confirmation("message.purge.document"));
                }
 
-               public boolean isEnabled(String name) {
-                       if (user == null)
+               @Override
+               public boolean isEnabled(final String name) {
+                       if (user == null) {
                                return false; // Should not happen
+                       }
                        Item item = Item.valueOf(name);
-                       if (item == Item.demote)
+                       if (item == Item.demote) {
                                return user.canDemote();
-                       if (item == Item.promote)
+                       }
+                       if (item == Item.promote) {
                                return user.canReview();
-                       if (item == Item.attach)
+                       }
+                       if (item == Item.attach) {
                                return user.canAttach();
-                       if (item == Item.version)
+                       }
+                       if (item == Item.version) {
                                return user.canVersion();
-                       if (item == Item.purge)
+                       }
+                       if (item == Item.purge) {
                                return user.canPurge();
+                       }
                        return false;
                }
 
-               public void setContext(String name, Object context) {
+               @Override
+               public void setContext(final String name, final Object context) {
                        if (context instanceof DocumentRights) {
                                user = (DocumentRights) context; // Just for optimizing
                        }
@@ -351,7 +380,7 @@ public class ApplicationSettings implements ServletContextAware {
 
        private static class NotResultDocumentPopup extends PopupMenu {
                // ----------------------------------------------------------------
-               private DocumentRights user = null;
+               private final DocumentRights user = null;
 
                private NotResultDocumentPopup() {
                        addItem("demote", new PopupItem("menu.demote").icon(
@@ -390,20 +419,26 @@ public class ApplicationSettings implements ServletContextAware {
                                        .confirmation("message.approve.document"));
                }
 
-               public boolean isEnabled(String name) {
-                       if (user == null)
+               @Override
+               public boolean isEnabled(final String name) {
+                       if (user == null) {
                                return false; // Should not happen
+                       }
                        Item item = Item.valueOf(name);
-                       if (item == Item.undo)
+                       if (item == Item.undo) {
                                return user.canInvalidate();
-                       if (item == Item.demote)
+                       }
+                       if (item == Item.demote) {
                                return user.canDemote();
-                       if (item == Item.approve)
+                       }
+                       if (item == Item.approve) {
                                return user.canApprove();
+                       }
                        return false;
                }
 
-               public void setContext(String name, Object context) {
+               @Override
+               public void setContext(final String name, final Object context) {
                        if (context instanceof DocumentRights) {
                                user = (DocumentRights) context; // Just for optimizing
                        }
@@ -438,20 +473,26 @@ public class ApplicationSettings implements ServletContextAware {
                                        "message.delete.document"));
                }
 
-               public boolean isEnabled(String name) {
-                       if (user == null)
+               @Override
+               public boolean isEnabled(final String name) {
+                       if (user == null) {
                                return false; // Should not happen
+                       }
                        Item item = Item.valueOf(name);
-                       if (item == Item.rename)
+                       if (item == Item.rename) {
                                return user.canRename();
-                       if (item == Item.replace)
+                       }
+                       if (item == Item.replace) {
                                return user.canReplace();
-                       if (item == Item.remove)
+                       }
+                       if (item == Item.remove) {
                                return user.canRemove();
+                       }
                        return false;
                }
 
-               public void setContext(String name, Object context) {
+               @Override
+               public void setContext(final String name, final Object context) {
                        if (context instanceof DocumentRights) {
                                user = (DocumentRights) context; // Just for optimizing
                        }
@@ -474,7 +515,8 @@ public class ApplicationSettings implements ServletContextAware {
                                        "message.delete.context"));
                }
 
-               public boolean isEnabled(String name) {
+               @Override
+               public boolean isEnabled(final String name) {
                        Item item = Item.valueOf(name);
 
                        if (item == Item.rename) {
@@ -486,7 +528,8 @@ public class ApplicationSettings implements ServletContextAware {
                        return true;
                }
 
-               public void setContext(String name, Object context) {
+               @Override
+               public void setContext(final String name, final Object context) {
                        if (context instanceof SimulationContextFacade) {
                                owner = (SimulationContextFacade) context; // Just for optimizing
                        } else {
@@ -518,23 +561,27 @@ public class ApplicationSettings implements ServletContextAware {
                                        "message.delete.knowledge"));
                }
 
-               public boolean isEnabled(String name) {
+               @Override
+               public boolean isEnabled(final String name) {
                        Item item = Item.valueOf(name);
 
                        if (item == Item.promote) {
-                               if (owner.getProgressState() != ProgressState.inDRAFT)
+                               if (owner.getProgressState() != ProgressState.inDRAFT) {
                                        return false;
+                               }
                        } else if (item == Item.demote) {
-                               if (owner.getProgressState() != ProgressState.inCHECK)
+                               if (owner.getProgressState() != ProgressState.inCHECK) {
                                        return false;
+                               }
                        }
                        return true;
                }
 
-               public void setContext(String name, Object context) {
-                       if (context instanceof KnowledgeElement)
+               @Override
+               public void setContext(final String name, final Object context) {
+                       if (context instanceof KnowledgeElement) {
                                owner = (KnowledgeElement) context; // Just for optimizing
-                       else {
+                       else {
                                super.setContext(name, context);
                        }
                }
@@ -545,10 +592,6 @@ public class ApplicationSettings implements ServletContextAware {
        // ==============================================================================================================================
 
        public static ApplicationSettings getMe() {
-               // ------------------------------------------
-               if (my == null) {
-                       my = new ApplicationSettings();
-               }
                return my; // The application is supposed being previously created below
        }
 
@@ -557,7 +600,7 @@ public class ApplicationSettings implements ServletContextAware {
         * @param lang
         * @return
         */
-       public ApplicationSettings init(String wappurl, Locale lang)
+       public ApplicationSettings init(final String wappurl, final Locale lang)
                        throws IOException {
                ClassLoader cloader = getClass().getClassLoader();
                String[] wurl = wappurl.split("/"); // [0]="http:", [1]="", [2]="{server}:{port}", [3]="name"
@@ -570,7 +613,7 @@ public class ApplicationSettings implements ServletContextAware {
                wapprops.load(cloader.getResourceAsStream(wappname + ".properties"));
                jndprops.load(cloader.getResourceAsStream("jndi.properties"));
 
-               logger.info("Application root set to "
+               LOG.info("Application root set to "
                                + wapprops.getProperty("wapp.root"));
                if (my == null) {
                        my = this;
@@ -584,7 +627,7 @@ public class ApplicationSettings implements ServletContextAware {
        // Public member functions
        // ==============================================================================================================================
 
-       public void configure(String filename) {
+       public void configure(final String filename) {
                // ---------------------------------------
                // Non customizable settings
                menus.clear();
@@ -619,7 +662,7 @@ public class ApplicationSettings implements ServletContextAware {
                fprop.put("author", "0");
                fprop.put("reference", "");
                fprop.put("title", "");
-               fprop.put("context", new Vector<SimulationContext>());
+               fprop.put("context", new ArrayList<SimulationContext>());
 
                Map<String, Object> gprop = new HashMap<String, Object>();
                gprop.put("visibility", "PUBLIC");
@@ -629,7 +672,7 @@ public class ApplicationSettings implements ServletContextAware {
                gprop.put("author", "0");
                gprop.put("reference", "");
                gprop.put("title", "");
-               gprop.put("context", new Vector<SimulationContext>());
+               gprop.put("context", new ArrayList<SimulationContext>());
 
                defdoctype = new LinkedHashMap<String, DocumentType>();
                tempfile = new HashMap<String, String>();
@@ -644,7 +687,7 @@ public class ApplicationSettings implements ServletContextAware {
                if (config.exists()) {
                        loadCustomization(config); // Sets default document types, installed modules and available templates
                } else {
-                       logger.info("Could not find the application configuration file \""
+                       LOG.info("Could not find the application configuration file \""
                                        + config.getAbsolutePath() + "\", using default settings");
                }
                // Settings based on the customization
@@ -656,18 +699,21 @@ public class ApplicationSettings implements ServletContextAware {
                                .hasNext();) {
                        ProjectSettingsService.Step step = i.next();
                        List<String> formats = getDefaultFormats(step);
-                       if (formats.size() == 0)
+                       if (formats.size() == 0) {
                                continue;
+                       }
 
                        ToolBar bar = new ToolBar(24); // Height of the module-bar
                        HashSet<String> module = new HashSet<String>(); // For not duplicating modules
                        for (Iterator<String> j = formats.iterator(); j.hasNext();) {
                                String format = j.next();
                                String command = getApplicationProperty("executable." + format);
-                               if (command == null)
+                               if (command == null) {
                                        continue; // Module not installed
-                               if (module.contains(command))
+                               }
+                               if (module.contains(command)) {
                                        continue;
+                               }
                                module.add(command);
                                String[] parsed = command.split("/");
                                String[] name = parsed[parsed.length - 1].split("\\x2E");
@@ -689,8 +735,9 @@ public class ApplicationSettings implements ServletContextAware {
                                        File image = new File(ApplicationSettings
                                                        .getApplicationSkinPath()
                                                        + icon);
-                                       if (!image.exists())
+                                       if (!image.exists()) {
                                                icon = "tool.any.png";
+                                       }
                                        bar.addTool(tool, icon, command);
                                } else {
                                        docname = "/jsp/newDocument.jsp?type=" + docname;
@@ -698,17 +745,19 @@ public class ApplicationSettings implements ServletContextAware {
                                        File image = new File(ApplicationSettings
                                                        .getApplicationSkinPath()
                                                        + icon);
-                                       if (!image.exists())
+                                       if (!image.exists()) {
                                                icon = "tool.any.png";
+                                       }
                                        bar.addTool(name[0], icon, command, docname);
                                }
                        }
-                       if (!bar.isEmpty())
+                       if (!bar.isEmpty()) {
                                bars.put(step.getNumber(), bar);
+                       }
                }
        }
 
-       public String getApplicationProperty(String name) {
+       public String getApplicationProperty(final String name) {
                return wapprops.getProperty(name); // May be null
        }
 
@@ -724,12 +773,12 @@ public class ApplicationSettings implements ServletContextAware {
                return url.toString();
        }
 
-       public Map<String, Object> getFilter(String name) {
+       public Map<String, Object> getFilter(final String name) {
                // --------------------------------------------------
                return filter.get(name);
        }
 
-       public ToolBar getModuleBar(Step step) {
+       public ToolBar getModuleBar(final Step step) {
                // -----------------------------------------
                return bars.get(step.getNumber());
        }
@@ -758,19 +807,19 @@ public class ApplicationSettings implements ServletContextAware {
                return my.getApplicationRootPath() + "skin/";
        }
 
-       public static Converter getConverter(DocumentType type, String format) {
+       public static Converter getConverter(final DocumentType type, final String format) {
                // -----------------------------------------------------------------------
                return my.convertmap.get(format + type.getName()); // May be null;
        }
 
-       public static DocumentType getDefaultDocumentType(Step step, String format) {
+       public static DocumentType getDefaultDocumentType(final Step step, final String format) {
                // ----------------------------------------------------------------------------
                String[] table = format.split("\\x2E");
                return my.defdoctype.get(step.getNumber() + "."
                                + table[table.length - 1]); // May be null
        }
 
-       public static String getDownloadURL(User user) {
+       public static String getDownloadURL(final User user) {
                // --------------------------------------------------
                StringBuffer url = new StringBuffer("http://").append(my.wappserver)
                                .append("/download/").append(user.getUsername()).append("/");
@@ -782,12 +831,12 @@ public class ApplicationSettings implements ServletContextAware {
                return my.locale;
        }
 
-       public static SimpleMenu getMenu(String name) {
+       public static SimpleMenu getMenu(final String name) {
                // ----------------------------------------------
                return my.menus.get(name);
        }
 
-       public static PopupMenu getPopupMenu(String name) {
+       public static PopupMenu getPopupMenu(final String name) {
                // --------------------------------------------------
                return my.popups.get(name);
        }
@@ -803,8 +852,9 @@ public class ApplicationSettings implements ServletContextAware {
                // ---------------------------------------------
                String[] code = my.wapprops.getProperty("locale.supported").split(",");
                Locale[] result = new Locale[code.length];
-               for (int i = 0; i < code.length; i++)
+               for (int i = 0; i < code.length; i++) {
                        result[i] = new Locale(code[i]);
+               }
                return result;
        }
 
@@ -827,24 +877,26 @@ public class ApplicationSettings implements ServletContextAware {
        // Private services
        // ==============================================================================================================================
 
-       private List<String> getDefaultFormats(ProjectSettingsService.Step step) {
+       private List<String> getDefaultFormats(final ProjectSettingsService.Step step) {
                // ------------------------------------------------------------------
                Set<String> keys = defdoctype.keySet();
                int number = step.getNumber();
-               Vector<String> result = new Vector<String>();
+               List<String> result = new ArrayList<String>();
 
                for (Iterator<String> i = keys.iterator(); i.hasNext();) {
                        String[] key = i.next().split("\\x2E");
-                       if (Integer.valueOf(key[0]) != number)
+                       if (Integer.valueOf(key[0]) != number) {
                                continue;
-                       if (key[1].equals("pdf"))
+                       }
+                       if (key[1].equals("pdf")) {
                                continue; // PDF is not an authoring format
+                       }
                        result.add(key[1]); // Formats are unique
                }
                return result;
        }
 
-       private void loadCustomization(File config) {
+       private void loadCustomization(final File config) {
                // --------------------------------------------
                try {
                        DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory
@@ -868,16 +920,18 @@ public class ApplicationSettings implements ServletContextAware {
                        }
                        for (int i = 0; i < nlist.getLength(); i++) {
                                child = nlist.item(i);
-                               if (!child.getNodeName().equals("step"))
+                               if (!child.getNodeName().equals("step")) {
                                        continue;
+                               }
 
                                String nstep = child.getAttributes().getNamedItem("number")
                                                .getNodeValue();
                                NodeList map = child.getChildNodes();
                                for (int j = 0; j < map.getLength(); j++) {
                                        child = map.item(j);
-                                       if (!child.getNodeName().equals("mapping"))
+                                       if (!child.getNodeName().equals("mapping")) {
                                                continue;
+                                       }
                                        NamedNodeMap natr = child.getAttributes();
                                        String dext = natr.getNamedItem("extension").getNodeValue();
                                        String type = natr.getNamedItem("type").getNodeValue();
@@ -889,8 +943,9 @@ public class ApplicationSettings implements ServletContextAware {
                        nlist = child.getChildNodes();
                        for (int i = 0; i < nlist.getLength(); i++) {
                                child = nlist.item(i);
-                               if (!child.getNodeName().equals("mapping"))
+                               if (!child.getNodeName().equals("mapping")) {
                                        continue;
+                               }
 
                                NamedNodeMap natr = child.getAttributes();
                                String dext = natr.getNamedItem("extension").getNodeValue();
@@ -924,8 +979,9 @@ public class ApplicationSettings implements ServletContextAware {
                        nlist = child.getChildNodes();
                        for (int i = 0; i < nlist.getLength(); i++) {
                                child = nlist.item(i);
-                               if (!child.getNodeName().equals("document"))
+                               if (!child.getNodeName().equals("document")) {
                                        continue;
+                               }
 
                                NamedNodeMap natr = child.getAttributes();
                                String type = natr.getNamedItem("type").getNodeValue();
@@ -933,7 +989,7 @@ public class ApplicationSettings implements ServletContextAware {
                                tempfile.put(type, file);
                        }
                } catch (Exception error) {
-                       logger.info("Error in customization", error);
+                       LOG.info("Error in customization", error);
                }
        }
 
@@ -952,7 +1008,7 @@ public class ApplicationSettings implements ServletContextAware {
         * @param documentTypeService
         *            the documentTypeService to set
         */
-       public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+       public void setDocumentTypeService(final DocumentTypeService documentTypeService) {
                _documentTypeService = documentTypeService;
        }
 
@@ -961,7 +1017,7 @@ public class ApplicationSettings implements ServletContextAware {
         * @see org.apache.struts2.util.ServletContextAware#setServletContext(javax.servlet.ServletContext)
         */
        @Override
-       public void setServletContext(ServletContext context) {
+       public void setServletContext(final ServletContext context) {
                _servletContext = context;
        }
 
index b0121066549d55358b61ccb123a842daf761b30f..2efe1b0e6e630c23647bad127c5fe394073c951b 100644 (file)
@@ -4,7 +4,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Vector;
+import java.util.Map;
 
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.Document;
@@ -27,8 +27,8 @@ import org.splat.wapp.PopupMenu;
 
 public abstract class OpenObject implements Proxy {
 
-       protected static HashMap<Long, DocumentFacade> docpres = null;
-       protected static HashMap<Long, KnowledgeElementFacade> knowpres = null;
+       protected static Map<Long, DocumentFacade> docpres = null;
+       protected static Map<Long, KnowledgeElementFacade> knowpres = null;
 
        /**
         * Connected user.
@@ -168,7 +168,7 @@ public abstract class OpenObject implements Proxy {
 
        public List<Document> collectInvolvedDocuments(final DocumentType type) {
                // ------------------------------------------------------------------
-               List<Document> found = new Vector<Document>();
+               List<Document> found = new ArrayList<Document>();
                for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
                        Step step = i.next();
                        List<Publication> exist = step.getAllDocuments();
@@ -299,11 +299,11 @@ public abstract class OpenObject implements Proxy {
                                current = more.next();
                        }
 
-                       knowledge = new Vector<KnowledgeIterator>(types.size());
+                       knowledge = new ArrayList<KnowledgeIterator>(types.size());
                        for (Iterator<KnowledgeElementType> i = types.iterator(); i
                                        .hasNext();) {
                                KnowledgeElementType type = i.next();
-                               List<KnowledgeElementFacade> display = new Vector<KnowledgeElementFacade>(
+                               List<KnowledgeElementFacade> display = new ArrayList<KnowledgeElementFacade>(
                                                kelms.size());
                                while (current != null && current.getType().equals(type)) {
                                        KnowledgeElementFacade facade = knowpres.get(current
@@ -328,7 +328,7 @@ public abstract class OpenObject implements Proxy {
                if (ustep.mayContain(Document.class)) {
                        List<Publication> list = ustep.getAllDocuments();
 
-                       contents = new Vector<DocumentFacade>(list.size());
+                       contents = new ArrayList<DocumentFacade>(list.size());
                        for (Iterator<Publication> i = list.iterator(); i.hasNext();) {
                                Publication present = i.next();
                                Long index = present.getIndex();