Salome HOME
Id now is Long instead of Integer. First unit test is created. hibernate-3.5.jar...
authorrkv <rkv@opencascade.com>
Mon, 15 Oct 2012 06:32:32 +0000 (06:32 +0000)
committerrkv <rkv@opencascade.com>
Mon, 15 Oct 2012 06:32:32 +0000 (06:32 +0000)
testng-6.8.jar is added to Siman-Common.

56 files changed:
Workspace/SPlat/.classpath
Workspace/SPlat/lib/hibernate-3.5.jar [deleted file]
Workspace/SPlat/lib/mysql-connector-java-5.1.5-bin.jar [deleted file]
Workspace/Siman-Common/.classpath
Workspace/Siman-Common/.springBeans
Workspace/Siman-Common/lib/hibernate-3.5.jar [new file with mode: 0644]
Workspace/Siman-Common/lib/mysql-connector-java-5.1.5-bin.jar [new file with mode: 0644]
Workspace/Siman-Common/lib/testng-6.8.jar [new file with mode: 0644]
Workspace/Siman-Common/src/log4j.xml [new file with mode: 0644]
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Persistent.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Persistent.java
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/User.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/DocumentType.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/KnowledgeElementType.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/ProjectElement.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/Scenario.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/SimulationContextType.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/Database.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/kernel/GenericDAOImpl.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAO.java
Workspace/Siman-Common/src/org/splat/dal/dao/som/KnowledgeElementDAOImpl.java
Workspace/Siman-Common/src/org/splat/kernel/Name.java
Workspace/Siman-Common/src/org/splat/kernel/UserDirectory.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/StudyService.java
Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/dto/Proxy.java
Workspace/Siman-Common/src/org/splat/service/technical/IndexServiceImpl.java
Workspace/Siman-Common/src/org/splat/som/Step.java
Workspace/Siman-Common/src/spring/datasourceContext.xml [new file with mode: 0644]
Workspace/Siman-Common/src/spring/globalContext.xml
Workspace/Siman-Common/src/test/hibernate.properties [new file with mode: 0644]
Workspace/Siman-Common/src/test/jdbc.properties [new file with mode: 0644]
Workspace/Siman-Common/src/test/siman.properties [new file with mode: 0644]
Workspace/Siman-Common/src/test/splat/common/BaseTest.java [new file with mode: 0644]
Workspace/Siman-Common/src/test/splat/common/TestListingAndOrder.java [new file with mode: 0644]
Workspace/Siman-Common/src/test/splat/dao/TestKnowledgeElementDAO.java [new file with mode: 0644]
Workspace/Siman-Common/src/test/spring/ut-applicationContext.xml [new file with mode: 0644]
Workspace/Siman-Common/src/test/spring/ut-datasourceContext.xml [new file with mode: 0644]
Workspace/Siman-Common/testng.xml [new file with mode: 0644]
Workspace/Siman/.settings/org.eclipse.wst.common.component
Workspace/Siman/src/org/splat/simer/DocumentFacade.java
Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java
Workspace/Siman/src/org/splat/simer/NewScenarioAction.java
Workspace/Siman/src/org/splat/simer/NewScenarioMenu.java
Workspace/Siman/src/org/splat/simer/OpenKnowledge.java
Workspace/Siman/src/org/splat/simer/OpenObject.java
Workspace/Siman/src/org/splat/simer/OpenStudy.java
Workspace/Siman/src/org/splat/simer/StudyMenu.java
Workspace/Siman/src/org/splat/simer/StudyPropertiesAction.java
Workspace/Siman/src/org/splat/simer/ValidationFacade.java
Workspace/Siman/src/org/splat/simer/admin/ProjectElementFacade.java
Workspace/Siman/src/spring/applicationContext.xml

index dbb0b6d288b131271e93817261d536fe46f6f6ca..98292fd7a987befb4b98dd8e318ddeb1358a585d 100644 (file)
@@ -6,13 +6,11 @@
        <classpathentry exported="true" kind="lib" path="lib/antlr-2.7.6.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/commons-collections-3.1.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/dom4j-1.6.1.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/hibernate-3.5.jar" sourcepath="/3dparty_src/hibernate/hibernate-distribution-3.5.3-Final-dist.zip"/>
        <classpathentry exported="true" kind="lib" path="lib/jta-1.1.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.15.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/lucene-core-2.9.2.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/lucene-queries-2.9.2.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/mailapi.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/mysql-connector-java-5.1.5-bin.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/poi-3.7-20101029.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/poi-ooxml-3.7-20101029.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/poi-ooxml-schemas-3.7-20101029.jar"/>
diff --git a/Workspace/SPlat/lib/hibernate-3.5.jar b/Workspace/SPlat/lib/hibernate-3.5.jar
deleted file mode 100644 (file)
index c84d3e6..0000000
Binary files a/Workspace/SPlat/lib/hibernate-3.5.jar and /dev/null differ
diff --git a/Workspace/SPlat/lib/mysql-connector-java-5.1.5-bin.jar b/Workspace/SPlat/lib/mysql-connector-java-5.1.5-bin.jar
deleted file mode 100644 (file)
index e9d2529..0000000
Binary files a/Workspace/SPlat/lib/mysql-connector-java-5.1.5-bin.jar and /dev/null differ
index 746d69464afb80a784a73d47f62adbf487a932a3..b8b79e304c7e866cc9ef14b31e92cff61be5ca57 100644 (file)
        <classpathentry exported="true" kind="lib" path="lib/p6spy.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/aopalliance.jar"/>
        <classpathentry exported="true" kind="lib" path="dist/siman-common.jar" sourcepath="src"/>
+       <classpathentry kind="lib" path="lib/testng-6.8.jar"/>
+       <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.1.jar"/>
+       <classpathentry exported="true" kind="lib" path="lib/beanlib-5.0.1beta.jar"/>
+       <classpathentry kind="lib" path="lib/hibernate-3.5.jar"/>
+       <classpathentry kind="lib" path="lib/mysql-connector-java-5.1.5-bin.jar"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index 832a43d0f6ce9f84a22c9d8124312e226dc28ff2..62d072c2def585ab6640f79876fd30fdb36dc281 100644 (file)
@@ -8,6 +8,9 @@
                <config>src/spring/businessServiceContext.xml</config>
                <config>src/spring/technicalServiceContext.xml</config>
                <config>src/spring/daoContext.xml</config>
+               <config>src/spring/datasourceContext.xml</config>
+               <config>src/test/spring/ut-applicationContext.xml</config>
+               <config>src/test/spring/ut-datasourceContext.xml</config>
        </configs>
        <configSets>
                <configSet>
                                <config>src/spring/businessServiceContext.xml</config>
                                <config>src/spring/technicalServiceContext.xml</config>
                                <config>src/spring/daoContext.xml</config>
+                               <config>src/spring/datasourceContext.xml</config>
+                       </configs>
+               </configSet>
+               <configSet>
+                       <name><![CDATA[Siman Unit Tests Beans]]></name>
+                       <allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
+                       <incomplete>false</incomplete>
+                       <configs>
+                               <config>src/spring/businessServiceContext.xml</config>
+                               <config>src/spring/daoContext.xml</config>
+                               <config>src/spring/globalContext.xml</config>
+                               <config>src/spring/technicalServiceContext.xml</config>
+                               <config>src/test/spring/ut-applicationContext.xml</config>
+                               <config>src/test/spring/ut-datasourceContext.xml</config>
                        </configs>
                </configSet>
        </configSets>
diff --git a/Workspace/Siman-Common/lib/hibernate-3.5.jar b/Workspace/Siman-Common/lib/hibernate-3.5.jar
new file mode 100644 (file)
index 0000000..c84d3e6
Binary files /dev/null and b/Workspace/Siman-Common/lib/hibernate-3.5.jar differ
diff --git a/Workspace/Siman-Common/lib/mysql-connector-java-5.1.5-bin.jar b/Workspace/Siman-Common/lib/mysql-connector-java-5.1.5-bin.jar
new file mode 100644 (file)
index 0000000..e9d2529
Binary files /dev/null and b/Workspace/Siman-Common/lib/mysql-connector-java-5.1.5-bin.jar differ
diff --git a/Workspace/Siman-Common/lib/testng-6.8.jar b/Workspace/Siman-Common/lib/testng-6.8.jar
new file mode 100644 (file)
index 0000000..dd6c8bb
Binary files /dev/null and b/Workspace/Siman-Common/lib/testng-6.8.jar differ
diff --git a/Workspace/Siman-Common/src/log4j.xml b/Workspace/Siman-Common/src/log4j.xml
new file mode 100644 (file)
index 0000000..1511364
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "../WebContent/META-INF/dtds/log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+       <!-- Configuration for unit tests -->
+       
+    <appender name="console" class="org.apache.log4j.ConsoleAppender">
+        <layout class="org.apache.log4j.PatternLayout"> 
+            <param name="ConversionPattern" value="[%t] %-5p %-11c{1} - %m%n"/> 
+        </layout> 
+    </appender>
+    
+    <appender name="logfile" class="org.apache.log4j.RollingFileAppender">
+        <param name="File"           value="${catalina.home}/logs/siman.log" />
+        <param name="MaxFileSize"    value="500KB" />
+        <param name="MaxBackupIndex" value="10" />
+        <param name="Append" value="false" />
+        <layout class="org.apache.log4j.PatternLayout"> 
+            <param name="ConversionPattern" value="[%t] %-5p %-11c{1} - %m%n"/>             
+        </layout> 
+    </appender>
+    <!-- specify the logging level for loggers from other libraries -->
+    <logger name="com.opensymphony">
+        <level value="INFO" />
+    </logger>
+
+    <logger name="org.apache.struts2">
+        <level value="INFO" />
+    </logger>
+
+    <logger name="log4j.logger.org.apache.struts">
+        <level value="DEBUG" />
+    </logger>
+
+    <logger name="org.springframework">
+        <level value="INFO" />
+    </logger>
+
+    <logger name="org.hibernate">
+        <level value="DEBUG" />
+    </logger>
+
+    <logger name="org.splat.siman">
+        <level value="DEBUG" />
+    </logger>
+    
+    <logger name="test">
+        <level value="DEBUG" />
+    </logger>
+  
+    <logger name="log4j.logger.org.hibernate">
+        <level value="DEBUG" />
+    </logger>
+
+    <category name="com.opensymphony.xwork2.validator">
+      <priority value="INFO"/>
+   </category>
+
+   <category name="org.apache.struts2.interceptor.validation">
+      <priority value="INFO"/>
+   </category>
+   
+
+   <!-- for all other loggers log only debug and above log messages -->
+     <root>
+        <priority value="INFO"/> 
+        <appender-ref ref="logfile" /> 
+               <appender-ref ref="console"/> 
+     </root> 
+
+</log4j:configuration>
index 998846b717127038329c0865abd8042807df482a..132e51a039dd373ad321c91bc34a5c3dbaffa4b4 100644 (file)
@@ -16,7 +16,7 @@
 <!--     <id name="rid" column="rid" access="field">
       <generator class="sequence"/>
     </id> -->
-       <id name="rid" column="rid" access="field">
+       <id name="rid" column="rid" access="field" type="long">
         <generator class="org.hibernate.id.enhanced.SequenceStyleGenerator">
                <param name="sequence_name">persistent_id</param>
                <param name="initial_value">1000</param>
index 8ceda827edad4f4962f2edb3c0fb04db277f31c2..11aa5c432a6d7a64cda966e270d8ec2a05c7cd07 100644 (file)
@@ -36,7 +36,7 @@ import org.splat.kernel.ObjectProperties;
 
 public abstract class Persistent {
 
-    private  int rid;                                     // Primary key of persistent objects
+    private  long rid;                                     // Primary key of persistent objects
 
     protected abstract static class Properties implements ObjectProperties {
 //  ----------------------------------------------------------------------
@@ -83,8 +83,8 @@ public abstract class Persistent {
       if (entity == null) return false;
       if (entity.getClass().equals(this.getClass())) {
         Persistent object = (Persistent)entity;
-        int   he = object.getIndex();                     // getIndex() is supposed fetching the index if not yet done
-        int   me = this.getIndex();                       // getIndex() is supposed fetching the index if not yet done
+        long   he = object.getIndex();                     // getIndex() is supposed fetching the index if not yet done
+        long   me = this.getIndex();                       // getIndex() is supposed fetching the index if not yet done
         if (me*he != 0) return (he == me);
         if (me+he == 0) return (this == object);
       }
@@ -98,11 +98,19 @@ public abstract class Persistent {
  * @return the PID of this, or 0 if this is not saved.
  * @see    isSaved()
  */
-    public int getIndex () {
+    public long getIndex () {
 //  ----------------------
       return rid;
     }
 
+       /**
+        * Set an id for the object.
+        * @param anId id to set
+        */
+       public void setIndex(long anId) {
+               rid = anId;
+       }
+       
     public int hashCode () {
 //  ----------------------
       return toString().hashCode();
@@ -126,7 +134,7 @@ public abstract class Persistent {
  */
     public String toString () {
 //  -------------------------
-      int oid = getIndex();                               // getIndex() is supposed fetching the index if not yet done
+      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();
     }
index 5ab556b2156df4077cceda3a78d3acd18027ab23..50479c7564f5973698bb8ae2fa509975b4f5b2c5 100644 (file)
@@ -12,7 +12,7 @@
 
 <!-- Class User 
   -->
-  <union-subclass name="org.splat.dal.bo.kernel.User" extends="org.splat.dal.bo.kernel.Persistent" table="user" lazy="false">
+  <union-subclass name="org.splat.dal.bo.kernel.User" extends="org.splat.dal.bo.kernel.Persistent" table="users" lazy="false">
 <!--     <natural-id>-->
       <property    name="username" column="username" access="field" />
       <many-to-one name="role"     column="username" insert="false" update="false" unique="true" cascade="save-update" access="field" />
index 4f664c98b3684c2af9d98b3086aa31885721f61a..ec7fcb3c890709472d3ce06d753ca088794a8d5c 100644 (file)
@@ -571,7 +571,7 @@ public class Document extends Entity {
                                .uniqueResult();
        }
 
-       public static DocumentType selectType(int index) {
+       public static DocumentType selectType(long index) {
                // -------------------------------------------------
                String query = new StringBuffer("from DocumentType where rid='")
                                .append(index).append("'").toString();
index 29288c5a3d1e8f16a5ec78d554369b024856d554..6b83936e84ea8b541941c1ee1dfedf40fe43dc4d 100644 (file)
@@ -116,8 +116,8 @@ public class DocumentType extends Persistent {
       } else
       if (entity instanceof DocumentType) {
         DocumentType object = (DocumentType)entity;
-        int   he = object.getIndex();
-        int   me = this.getIndex();
+        long   he = object.getIndex();
+        long   me = this.getIndex();
         if (me*he != 0) return (he == me);
         else            return this.getName().equals(object.getName());
       } else {
index 887ec926a6699c7bc551d374263afa9ecc99a00b..41cad5a429d9ceb74f2c359452189af6b9e0869f 100644 (file)
@@ -22,7 +22,7 @@ public class KnowledgeElementType extends Persistent {
     protected KnowledgeElementType () {
     }
 //  Initialization constructor
-    protected KnowledgeElementType (String name) {
+    public KnowledgeElementType (String name) {
 //  --------------------------------------------
       super();
       this.name  = name;
@@ -49,8 +49,8 @@ public class KnowledgeElementType extends Persistent {
       } else
       if (entity instanceof KnowledgeElementType) {
         KnowledgeElementType object = (KnowledgeElementType)entity;
-        int   he = object.getIndex();
-        int   me = this.getIndex();
+        long   he = object.getIndex();
+        long   me = this.getIndex();
         if (me*he != 0) return (he == me);
         else            return this.getName().equals(object.getName());
       } else {
index d728901c5eae31370d4a372d93aa969c003d4b4a..7bf47337a1619cf1ae7034da60ff138283bc1460 100644 (file)
@@ -118,7 +118,7 @@ public abstract class ProjectElement extends Entity {
  */
     public Publication getPublication (Document doc) {
 //  ------------------------------------------------
-      int  index = doc.getIndex();
+      long  index = doc.getIndex();
       for (Iterator<Publication> i=docums.iterator(); i.hasNext(); ) {
        Publication  found = i.next();
        if (found.value().getIndex() == index) return found;   // A document publication is unique in a given ProjectElement
@@ -137,7 +137,7 @@ public abstract class ProjectElement extends Entity {
 
     public boolean publishes (Document doc) {
 //  ---------------------------------------
-      int  index = doc.getIndex();
+      long  index = doc.getIndex();
       for (Iterator<Publication> i=docums.iterator(); i.hasNext(); ) {
        Document  found = i.next().value();
        if (found.getIndex() == index) return true;
index 7a822e1780c247f62e9c16e79c58395ed5528d8f..54a119f4170df4a40645c1b6f606ff0f073bb28a 100644 (file)
@@ -39,7 +39,7 @@ public class Scenario extends ProjectElement {
     private Set<KnowledgeElement> kelms;
 
 //  Transient fields
-    private HashMap<Integer, List<KnowledgeElement>> known;
+    private HashMap<Long, List<KnowledgeElement>> known;
     private List<KnowledgeElement>                   knowl;  // Copy of kelms excluding the internal Knowledge Element (ucase below)
        private KnowledgeElement                         ucase;  // Internal Knowledge Element for accessing to all used simulation contexts
 
@@ -184,11 +184,11 @@ public class Scenario extends ProjectElement {
       return  Collections.unmodifiableList(knowl);
     }
 
-    public KnowledgeElement getKnowledgeElement (int index) {
+    public KnowledgeElement getKnowledgeElement (long l) {
 //  -------------------------------------------------------
       for (Iterator<KnowledgeElement> i=kelms.iterator(); i.hasNext();) {
            KnowledgeElement mykelm = i.next();
-        if (mykelm.getIndex() == index) return mykelm;
+        if (mykelm.getIndex() == l) return mykelm;
       }
       return null;
     }
@@ -196,9 +196,9 @@ public class Scenario extends ProjectElement {
     public List<KnowledgeElement> getKnowledgeElementsOf (KnowledgeElementType type) {
 //  --------------------------------------------------------------------------------
       if (kelms.isEmpty()) return  new Vector<KnowledgeElement>();   // Smarter than returning null
-      if (known == null)   known = new HashMap<Integer, List<KnowledgeElement>>();
+      if (known == null)   known = new HashMap<Long, List<KnowledgeElement>>();
 
-      int                    numtype = type.getIndex();
+      long                    numtype = type.getIndex();
       List<KnowledgeElement> listype = known.get(numtype);
       if (listype == null) {
         listype = new Vector<KnowledgeElement>();
index c7b587cac91a6f6bc96c783fa805ba6e197b0ba5..881d086a9bbb732157785ae64ea0191d5992f46b 100644 (file)
@@ -82,8 +82,8 @@ public class SimulationContextType extends Persistent implements Serializable {
       } else
       if (entity instanceof SimulationContextType) {
          SimulationContextType object = (SimulationContextType)entity;
-        int   he = object.getIndex();
-        int   me = this.getIndex();
+        long   he = object.getIndex();
+        long   me = this.getIndex();
         if (me*he != 0) return (he == me);
         else            return this.getName().equals(object.getName());
       } else {
index ece7223f4f3b004cf46e87bfe995370b39219782..9ebba991a994d7316a302023ef0c991480170b8f 100644 (file)
@@ -14,10 +14,11 @@ import org.hibernate.jdbc.Work;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
 import org.apache.log4j.Logger;
 
 
-public abstract class Database  implements ApplicationContextAware {
+public abstract class Database implements ApplicationContextAware {
 
        /**
         * The ApplicationContext.
index 5ea89df318d3890748da9ff1a2df4e9a584f6448..d6fefe6fe89f57a9c29ea42481c2bc6f629dda41 100644 (file)
@@ -12,22 +12,42 @@ package org.splat.dal.dao.kernel;
 import java.io.Serializable;
 
 /**
- * @author rkv
+ * Generic DAO interface.
  * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ * 
+ * @param <T>
+ *            Persistent object class
+ * @param <PK>
+ *            Primary key class
  */
 public interface GenericDAO<T, PK extends Serializable> {
 
-       /** Persist the newInstance object into database */
+       /**
+        * Persist the newInstance object into database.
+        * 
+        * @param newInstance
+        *            new object as a transient instance
+        * @return new primary key for the created persistent object
+        */
        PK create(T newInstance);
 
        /**
-        * Retrieve an object that was previously persisted to the database using the indicated id as primary key
+        * 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
         */
        T read(PK id);
 
-       /** Save changes made to a persistent object. */
+       /** Save changes made to a persistent object.
+        * @param transientObject transient instance of the object to update
+        */
        void update(T transientObject);
 
-       /** Remove an object from persistent storage in the database */
+       /** Remove an object from persistent storage in the database.
+        * @param persistentObject a persistent object to delete from the database
+        */
        void delete(T persistentObject);
 }
index c19d1cfa837cb2f9b2d3d9f4bc742706cdaacd5b..f54184bc5b369c34cc5ed2de5ac4b8df843104ff 100644 (file)
@@ -13,52 +13,90 @@ import java.io.Serializable;
 
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
 
 /**
- * @author rkv
+ * 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> implements
+public abstract class GenericDAOImpl<T, PK extends Serializable> extends HibernateDaoSupport implements
                GenericDAO<T, PK> {
-       private SessionFactory _sessionFactory;
+//     /**
+//      * Hibernate session factory.
+//      */
+//     private SessionFactory _sessionFactory;
 
-       public PK create(T o) {
-               return (PK) getSession().save(o);
+       /**
+        * 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 read(PK id) {
                return (T) getSession().get(getType(), id);
        }
 
-       public void update(T o) {
-               getSession().update(o);
-       }
-
-       public void delete(T o) {
-               getSession().delete(o);
-       }
-
-       abstract protected Class<T> getType();
-       /**
-        * @return hibernate session
+       /** Save changes made to a persistent object.
+        * @param transientObject transient instance of the object to update
         */
-       private Session getSession() {
-               return getSessionFactory().getCurrentSession();
+       public void update(T transientObject) {
+               getSession().update(transientObject);
        }
-       
-       /**
-        * Get the sessionFactory.
-        * @return the sessionFactory
+
+       /** Remove an object from persistent storage in the database.
+        * @param persistentObject a persistent object to delete from the database
         */
-       public SessionFactory getSessionFactory() {
-               return _sessionFactory;
+       public void delete(T persistentObject) {
+               getSession().delete(persistentObject);
        }
 
        /**
-        * Set the sessionFactory.
-        * @param sessionFactory the sessionFactory to set
+        * Get persistent object type.
+        * @return Persistent object class to be processed by this DAO
         */
-       public void setSessionFactory(SessionFactory sessionFactory) {
-               _sessionFactory = sessionFactory;
-       }
+       abstract protected Class<T> getType();
+       
+//     /**
+//      * Get the current hibernate session factory.
+//      * @return hibernate session
+//      */
+//     private Session getSession() {
+//             return getSessionFactory().getCurrentSession();
+//     }
+//     
+//     /**
+//      * Get the hibernate session factory.
+//      * @return the hibernate session factory
+//      */
+//     public SessionFactory getSessionFactory() {
+//             return _sessionFactory;
+//     }
+//
+//     /**
+//      * Set the hibernate session factory.
+//      * @param sessionFactory the hibernate session factory to set
+//      */
+//     public void setSessionFactory(SessionFactory sessionFactory) {
+//             _sessionFactory = sessionFactory;
+//     }
 }
\ No newline at end of file
index 4652efbd8f127971a695d0481de48e1332bc045c..ccf72ec4b9ec2d1390c136a1422a5c87e060cc61 100644 (file)
@@ -13,7 +13,8 @@ import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.dao.kernel.GenericDAO;
 
 /**
- * @author RKV
+ * KnowledgeElement DAO class implementation.
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  *
  */
 public interface KnowledgeElementDAO extends GenericDAO<KnowledgeElement, Long> {
index f19b5ede9c6b80945f11baa1187e1210471c2957..3b4adaa07fc9613a10de827cdc0ff7b7b55465a6 100644 (file)
@@ -11,6 +11,7 @@ package org.splat.dal.dao.som;
 
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.dao.kernel.GenericDAOImpl;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Knowledge element DAO.
index f5d444b64337667350dd4486c74082b80dc2770c..37eeefdd36e1f9c02f1c9443fc55cc2a082acfbb 100644 (file)
@@ -10,6 +10,6 @@ package org.splat.kernel;
 
 public interface Name {
 
-    public int    getIndex ();
+    public long    getIndex ();
     public String toString ();
 }
\ No newline at end of file
index e33de80148b59f94fc1e5d5e864fd950b301a6c5..e9eefeb66405989e0cad0241ca750b8982cd0e2d 100644 (file)
@@ -69,7 +69,7 @@ public class UserDirectory {
        if (!xtag.equals("users")) throw new MismatchException("filetype");
                org.w3c.dom.NodeList   ulist    = inDoc.getElementsByTagName("user");
        
-        List<String>    result   = (List<String>)session.createSQLQuery("SELECT * FROM user").addScalar("username").list();
+        List<String>    result   = (List<String>)session.createSQLQuery("SELECT * FROM users").addScalar("username").list();
        HashSet<String> members  = new HashSet<String>();
        HashSet<User>   imported = new HashSet<User>();
        for (Iterator<String> i=result.iterator(); i.hasNext();) members.add(i.next());
@@ -155,13 +155,13 @@ public class UserDirectory {
        @SuppressWarnings("unchecked")                            // For the casting List<User>
        public static List<User> selectAllUsers () {
 //  ------------------------------------------
-         String query = "from User order by last asc, first asc";
+         String query = "FROM users order by last asc, first asc";
          return (List<User>)Database.getSession().createQuery(query).list();
        }
 
        public static User selectUser (String username) {
 //  -----------------------------------------------
-         StringBuffer  query = new StringBuffer("from User where username='").append(username).append("'");
+         StringBuffer  query = new StringBuffer("FROM users where username='").append(username).append("'");
          return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
        }
 
@@ -169,7 +169,7 @@ public class UserDirectory {
 //  ----------------------------------------------------------------
 //WARNING: For not encoding the password here, we better call a selectUsersWhere(User.Properties),
 //         but this requires a getPassword in User.Properties nested class.
-         StringBuffer  query = new StringBuffer("from User where username='").append(username).append("' and password");
+         StringBuffer  query = new StringBuffer("FROM users where username='").append(username).append("' and password");
          if (password == null) query = query.append(" is null");
          else                  query = query.append("='").append(String.valueOf(password.hashCode())).append("'");
          
@@ -178,14 +178,14 @@ public class UserDirectory {
 
     public static User selectUser (int index) {
 //  -----------------------------------------
-      StringBuffer  query = new StringBuffer("from User where rid='").append(index).append("'");
+      StringBuffer  query = new StringBuffer("FROM users where rid='").append(index).append("'");
       return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
        }
 
     @SuppressWarnings("unchecked")
        public static List<User> selectUsersWhere (User.Properties... uprop) {
 //  --------------------------------------------------------------------
-      StringBuffer query     = new StringBuffer("from User");
+      StringBuffer query     = new StringBuffer("FROM users");
       String       separator = " where (";
       String       value;
 
index 12cdc275274c3a65aae6654514e454912b32ee96..62cec624baa806f0114df6f76ef47754cca96664 100644 (file)
@@ -27,5 +27,5 @@ public interface KnowledgeElementService {
        public void rename(KnowledgeElement knowledgeElement, String title)
                        throws InvalidPropertyException;
 
-       public KnowledgeElement selectKnowledgeElement(int index);
+       public KnowledgeElement selectKnowledgeElement(long index);
 }
index b2c9b39e2a3be0c379ce39202a66a2cefe8381c6..485ce628f36009d202a5a3c9cfed94933025046e 100644 (file)
@@ -68,7 +68,7 @@ public class KnowledgeElementServiceImpl implements KnowledgeElementService {
       update(knowledgeElement);
     }
 
-       public KnowledgeElement selectKnowledgeElement(int index) {
+       public KnowledgeElement selectKnowledgeElement(long index) {
                // -----------------------------------------------------------------
                StringBuffer query = new StringBuffer(
                                "from KnowledgeElement where rid='").append(index).append("'");
index ad509b380bfc92edf588313aaeb86248d0580b83..1c00bf7ec84516249d912178d90ae25884f96324 100644 (file)
@@ -38,7 +38,7 @@ public interface StudyService {
        
        public int generateLocalIndex(Study aStudy);
 
-       public Study selectStudy(int index);
+       public Study selectStudy(long index);
 
        public Study createStudy(Study.Properties sprop)
                        throws MissedPropertyException, InvalidPropertyException,
index 0af12a2baf98965dc31336e154ba1ebaa28b9a80..ef71552cc0e829f95739f0626cbd1b3ebedd8376 100644 (file)
@@ -90,7 +90,7 @@ public class StudyServiceImpl implements StudyService {
            return resList;
        }
        
-       public Study selectStudy(int index) {
+       public Study selectStudy(long index) {
                // -------------------------------------------
                StringBuffer query = new StringBuffer("from Study where rid='").append(
                                index).append("'");
index 8b2c6e6b896e9be993c4dd8edf3ceff7a4a02d28..b17d99ea174175c96b874ab3795b7b36c29c0a31 100644 (file)
@@ -37,7 +37,7 @@ public interface Proxy {
  * for selecting the corresponding persistent object from the database.
  * @return the internal persistent identifier of the object represented by this proxy.
  */
-    public Integer       getIndex ();
+    public Long       getIndex ();
 
        public ProgressState getProgressState ();
 
index 3caed85bf7864281201373d251aa5bd83dde7e96..be622eb304c4afd6a977e132ca58f8b782c99220 100644 (file)
@@ -170,7 +170,7 @@ public class IndexServiceImpl implements IndexService {
     }      
     public static class ObjectProxy implements Proxy, Serializable {
 //  --------------------------------------------------------------
-      private int           rid;
+      private Long           rid;
       private String        sid;
       private ProgressState state;
       private String        title;
@@ -179,7 +179,7 @@ public class IndexServiceImpl implements IndexService {
       private static final long serialVersionUID = -4386494192709562221L;
           
       public ObjectProxy (org.apache.lucene.document.Document ludoc) {
-        rid   = Integer.valueOf(ludoc.get("index"));
+        rid   = Long.valueOf(ludoc.get("index"));
         sid   = ludoc.get("ref");
         state = ProgressState.valueOf(ludoc.get("state"));
         title = ludoc.get("title");
@@ -188,7 +188,7 @@ public class IndexServiceImpl implements IndexService {
       public String getAuthorName () {
         return name;
       }
-      public Integer getIndex () {
+      public Long getIndex () {
         return rid;
       }
       public ProgressState getProgressState () {
index ebac98cabfad70920e8b35b7cf60f34274388c0a..46e44661c895d7c27370071565c84ad450462127 100644 (file)
@@ -94,11 +94,11 @@ public class Step {
       return  Collections.unmodifiableList(contex);
     }
 
-    public Publication getDocument (int index) {
+    public Publication getDocument (long l) {
 //  ------------------------------------------
       for (Iterator<Publication> i=docums.iterator(); i.hasNext();) {
        Publication found = i.next();                          // In a given study step,
-       if (found.value().getIndex() == index) return found;   // there is only one publication of a given document
+       if (found.value().getIndex() == l) return found;   // there is only one publication of a given document
       }
       return null;
     }
@@ -142,11 +142,11 @@ public class Step {
       return step;
     }
 
-    public SimulationContext getSimulationContext (int index) {
+    public SimulationContext getSimulationContext (long l) {
 //  ---------------------------------------------------------
       for (Iterator<SimulationContext> i=owner.SimulationContextIterator(); i.hasNext();) {
         SimulationContext myctex = i.next();
-        if (myctex.getIndex() == index) return myctex;
+        if (myctex.getIndex() == l) return myctex;
       }
       return null;
     }
diff --git a/Workspace/Siman-Common/src/spring/datasourceContext.xml b/Workspace/Siman-Common/src/spring/datasourceContext.xml
new file mode 100644 (file)
index 0000000..b47e59d
--- /dev/null
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:aop="http://www.springframework.org/schema/aop"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:tx="http://www.springframework.org/schema/tx"
+    xsi:schemaLocation="
+http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+http://www.springframework.org/schema/aop
+http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+http://www.springframework.org/schema/context
+http://www.springframework.org/schema/context/spring-context-3.0.xsd
+http://www.springframework.org/schema/tx
+http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
+
+    <!--    <bean id="simanDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+        <property name="jndiName" value="jdbc/ibatis"/>
+        </bean> -->
+
+    <!--    <bean id="simanDatasource"
+        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+        <property name="driverClassName"
+            value="${connection.driver_class}" />
+        <property name="url" value="${connection.url}" />
+        <property name="username" value="${connection.username}" />
+        <property name="password" value="${connection.password}" />
+    </bean>
+    -->
+
+    <bean id="simanDatasource"
+        class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
+        <property name="driverClassName"
+            value="${connection.driver_class}" />
+        <property name="url" value="${connection.url}" />
+        <property name="username" value="${connection.username}" />
+        <property name="password" value="${connection.password}" />
+        <property name="suppressClose" value="true" />
+        <property name="autoCommit" value="false" />
+    </bean>
+
+    <bean id="p6spySimanDatasource"
+        class="com.p6spy.engine.spy.P6DataSource">
+        <constructor-arg>
+            <ref local="simanDatasource" />
+        </constructor-arg>
+    </bean>
+
+
+    <bean id="hibernateProperties"
+        class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+        <property name="properties">
+            <props>
+                <!-- normal properties -->
+            </props>
+        </property>
+        <!-- hibernate.config should be defined somewhere in the spring.properties layers -->
+        <property name="locations">
+            <list>
+                <value>classpath:${hibernate.config.file}</value>
+            </list>
+        </property>
+    </bean>
+
+    <bean id="simanSessionFactory"
+        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+        <property name="dataSource" ref="simanDatasource" />
+<!--         <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />-->
+
+        <property name="mappingResources">
+            <list>
+                <value>
+                    org/splat/dal/bo/kernel/Persistent.hbm.xml
+                </value>
+                <value>org/splat/dal/bo/kernel/Any.hbm.xml</value>
+                <value>org/splat/dal/bo/kernel/Entity.hbm.xml</value>
+                <value>org/splat/dal/bo/kernel/Attribute.hbm.xml</value>
+                <value>org/splat/dal/bo/kernel/Relation.hbm.xml</value>
+                <value>
+                    org/splat/dal/bo/kernel/TextAttribute.hbm.xml
+                </value>
+                <value>org/splat/dal/bo/kernel/User.hbm.xml</value>
+
+                <value>
+                    org/splat/dal/bo/som/ProjectElement.hbm.xml
+                </value>
+                <value>org/splat/dal/bo/som/Study.hbm.xml</value>
+                <value>org/splat/dal/bo/som/Scenario.hbm.xml</value>
+                <value>org/splat/dal/bo/som/Attributes.hbm.xml</value>
+                <value>org/splat/dal/bo/som/Relations.hbm.xml</value>
+                <value>org/splat/dal/bo/som/File.hbm.xml</value>
+                <value>org/splat/dal/bo/som/Document.hbm.xml</value>
+                <value>org/splat/dal/bo/som/Publication.hbm.xml</value>
+                <value>
+                    org/splat/dal/bo/som/ValidationCycle.hbm.xml
+                </value>
+                <value>org/splat/dal/bo/som/Timestamp.hbm.xml</value>
+                <value>
+                    org/splat/dal/bo/som/SimulationContext.hbm.xml
+                </value>
+                <value>
+                    org/splat/dal/bo/som/KnowledgeElement.hbm.xml
+                </value>
+                <value>org/splat/dal/bo/som/IDBuilder.hbm.xml</value>
+            </list>
+        </property>
+        <!-- hibernate.connection.driver_class=com.p6spy.engine.spy.P6SpyDriver -->
+
+        <property name="hibernateProperties">
+            <ref local="hibernateProperties" />
+        </property>
+        <!-- The following property is used temporary to be able to manage transactions manually. -->
+        <!-- TODO: use annotations to mark transaction methods 
+            instead of programmatic transaction management  -->
+        <property name="exposeTransactionAwareSessionFactory">
+            <value>false</value>
+        </property>
+    </bean>
+
+    <bean id="txManager"
+        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+        <property name="sessionFactory" ref="simanSessionFactory" />
+    </bean>
+
+    <tx:annotation-driven transaction-manager="txManager" />
+
+</beans>
index bc9b67ae74e53cb5ba99f3e06ce8a73f0aaf326d..ac60f7f47f9314f07d9c190671bb58da9c9b345b 100644 (file)
@@ -3,16 +3,13 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
-       xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="
 http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/aop
 http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
 http://www.springframework.org/schema/context
-http://www.springframework.org/schema/context/spring-context-3.0.xsd
-http://www.springframework.org/schema/tx
-http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
+http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
        <bean id="baseMessageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
                <property name="basenames">
@@ -22,119 +19,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                        </list>
                </property>
        </bean>
-
-       <!--    <bean id="simanDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
-               <property name="jndiName" value="jdbc/ibatis"/>
-               </bean> -->
-
-       <!--    <bean id="simanDatasource"
-               class="org.springframework.jdbc.datasource.DriverManagerDataSource">
-               <property name="driverClassName"
-                       value="${connection.driver_class}" />
-               <property name="url" value="${connection.url}" />
-               <property name="username" value="${connection.username}" />
-               <property name="password" value="${connection.password}" />
-       </bean>
-       -->
-
-       <context:property-placeholder
-               location="classpath:siman.properties,classpath:jdbc.properties"
-               ignore-unresolvable="true" />
-
-       <bean id="simanDatasource"
-               class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
-               <property name="driverClassName"
-                       value="${connection.driver_class}" />
-               <property name="url" value="${connection.url}" />
-               <property name="username" value="${connection.username}" />
-               <property name="password" value="${connection.password}" />
-               <property name="suppressClose" value="true" />
-               <property name="autoCommit" value="false" />
-       </bean>
-
-       <bean id="p6spySimanDatasource"
-               class="com.p6spy.engine.spy.P6DataSource">
-               <constructor-arg>
-                       <ref local="simanDatasource" />
-               </constructor-arg>
-       </bean>
-
-
-       <bean id="hibernateProperties"
-               class="org.springframework.beans.factory.config.PropertiesFactoryBean">
-               <property name="properties">
-                       <props>
-                               <!-- normal properties -->
-                       </props>
-               </property>
-               <!-- hibernate.config should be defined somewhere in the spring.properties layers -->
-               <property name="locations">
-                       <list>
-                               <value>classpath:${hibernate.config.file}</value>
-                       </list>
-               </property>
-       </bean>
-
-       <bean id="simanSessionFactory"
-               class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
-               <property name="dataSource" ref="simanDatasource" />
-               <property name="mappingResources">
-                       <list>
-                               <value>
-                                       org/splat/dal/bo/kernel/Persistent.hbm.xml
-                               </value>
-                               <value>org/splat/dal/bo/kernel/Any.hbm.xml</value>
-                               <value>org/splat/dal/bo/kernel/Entity.hbm.xml</value>
-                               <value>org/splat/dal/bo/kernel/Attribute.hbm.xml</value>
-                               <value>org/splat/dal/bo/kernel/Relation.hbm.xml</value>
-                               <value>
-                                       org/splat/dal/bo/kernel/TextAttribute.hbm.xml
-                               </value>
-                               <value>org/splat/dal/bo/kernel/User.hbm.xml</value>
-
-                               <value>
-                                       org/splat/dal/bo/som/ProjectElement.hbm.xml
-                               </value>
-                               <value>org/splat/dal/bo/som/Study.hbm.xml</value>
-                               <value>org/splat/dal/bo/som/Scenario.hbm.xml</value>
-                               <value>org/splat/dal/bo/som/Attributes.hbm.xml</value>
-                               <value>org/splat/dal/bo/som/Relations.hbm.xml</value>
-                               <value>org/splat/dal/bo/som/File.hbm.xml</value>
-                               <value>org/splat/dal/bo/som/Document.hbm.xml</value>
-                               <value>org/splat/dal/bo/som/Publication.hbm.xml</value>
-                               <value>
-                                       org/splat/dal/bo/som/ValidationCycle.hbm.xml
-                               </value>
-                               <value>org/splat/dal/bo/som/Timestamp.hbm.xml</value>
-                               <value>
-                                       org/splat/dal/bo/som/SimulationContext.hbm.xml
-                               </value>
-                               <value>
-                                       org/splat/dal/bo/som/KnowledgeElement.hbm.xml
-                               </value>
-                               <value>org/splat/dal/bo/som/IDBuilder.hbm.xml</value>
-                       </list>
-               </property>
-               <!-- hibernate.connection.driver_class=com.p6spy.engine.spy.P6SpyDriver -->
-
-               <property name="hibernateProperties">
-                       <ref local="hibernateProperties" />
-               </property>
-               <!-- The following property is used temporary to be able to manage transactions manually. -->
-               <!-- TODO: use annotations to mark transaction methods 
-                       instead of programmatic transaction management  -->
-               <property name="exposeTransactionAwareSessionFactory">
-                       <value>false</value>
-               </property>
-       </bean>
-
-       <bean id="txManager"
-               class="org.springframework.orm.hibernate3.HibernateTransactionManager">
-               <property name="sessionFactory" ref="simanSessionFactory" />
-       </bean>
-
-       <tx:annotation-driven transaction-manager="txManager" />
-
+       
        <!-- TODO: Replace database by services and DAOs -->
        <bean id="database" class="org.splat.dal.dao.som.Database">
                <property name="sessionFactory" ref="simanSessionFactory" />
diff --git a/Workspace/Siman-Common/src/test/hibernate.properties b/Workspace/Siman-Common/src/test/hibernate.properties
new file mode 100644 (file)
index 0000000..94db428
--- /dev/null
@@ -0,0 +1,12 @@
+# Generated at 12/10/2012 07:20:45
+# Don't edit manually. See the source in D:\users\rkv\SIMAN\SIMAN_SRC\Workspace\Siman\conf\templates.
+# Connection properties
+connection.driver_class=com.mysql.jdbc.Driver
+
+# Hibernate config
+hibernate.hbm2ddl.auto=update
+hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
+hibernate.current_session_context_class=thread
+
+# Log properties
+hibernate.show_sql=true
diff --git a/Workspace/Siman-Common/src/test/jdbc.properties b/Workspace/Siman-Common/src/test/jdbc.properties
new file mode 100644 (file)
index 0000000..bf33af7
--- /dev/null
@@ -0,0 +1,5 @@
+# Connection properties for unit tests
+connection.url=jdbc:mysql://localhost/siman_unit_tests
+connection.username=simer
+connection.password=admin
+connection.driver_class=com.mysql.jdbc.Driver
diff --git a/Workspace/Siman-Common/src/test/siman.properties b/Workspace/Siman-Common/src/test/siman.properties
new file mode 100644 (file)
index 0000000..e2220c9
--- /dev/null
@@ -0,0 +1,14 @@
+schema.version     = D-0.3
+
+wapp.version       = D-0.5
+wapp.root          = D:/users/rkv/SIMAN/SIMAN_SRC/Workspace/Siman/WebContent/
+wapp.login         = conf/login.conf
+wapp.configuration = conf/som.xml
+wapp.customization = conf/my.xml
+wapp.website       = http://www.salome-platform.org
+wapp.onlinehelp    = http://docs.salome-platform.org/salome_6_3_1/gui/GUI_index.html
+wapp.context       = repository
+
+locale.supported   = fr,en
+
+hibernate.config.file=hibernate.properties
\ No newline at end of file
diff --git a/Workspace/Siman-Common/src/test/splat/common/BaseTest.java b/Workspace/Siman-Common/src/test/splat/common/BaseTest.java
new file mode 100644 (file)
index 0000000..74dee2e
--- /dev/null
@@ -0,0 +1,251 @@
+/*****************************************************************************
+ * Company         EURIWARE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   12 Oct 2012
+ * @author         $Author$
+ * @version        $Revision$
+ *****************************************************************************/
+
+package test.splat.common;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.hibernate.SessionFactory;
+import org.splat.log.AppLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+import org.springframework.orm.hibernate3.HibernateTemplate;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.transaction.TransactionConfiguration;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.DefaultTransactionDefinition;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Base Siman Test class. Each test method is transactional by default.
+ * Use <code>NotTransactional</code> annotation to declare test method as not transactional.
+ * By default all operations on database are rolledback after each test method.
+ * To avoid this use <code>Rollback(false)</code> annotation.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ * 
+ */
+
+@ContextConfiguration(locations = { 
+               "/test/spring/ut-applicationContext.xml",
+               "/test/spring/ut-datasourceContext.xml",
+               "/spring/businessServiceContext.xml", 
+               "/spring/daoContext.xml",
+               "/spring/globalContext.xml",
+               "/spring/technicalServiceContext.xml" 
+})
+@TransactionConfiguration(defaultRollback = true, transactionManager = "txManager")
+@Test(sequential=true, groups = {"service", "functional", "business"})
+public class BaseTest extends TestListingAndOrder {
+
+       // ========================================= static methods
+       /**
+        * Logger for the class.
+        */
+       private static final AppLogger LOG = AppLogger.getLogger(BaseTest.class);
+       
+       /**
+        * The helper class to work with hibernate session.
+        */
+       private HibernateTemplate _hibernateTemplate;
+       
+       /**
+        * Get the hibernateTemplate.
+        * @return the hibernateTemplate
+        */
+       @Test(enabled = false)
+       public HibernateTemplate getHibernateTemplate() {
+               return _hibernateTemplate;
+       }
+
+       // ======================================= static variables
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests#setDataSource(javax.sql.DataSource)
+        */
+       @Override
+       @Autowired
+       @Test(enabled = false)
+//     public void setDataSource(@Qualifier("p6spyiBatisDatasource")
+       @SuppressWarnings("deprecation")
+       public void setDataSource(@Qualifier("simanDatasource")
+       final DataSource dataSource) {
+               this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
+       }
+
+       /**
+        * Set a hibernate session factory.
+        * @param aSessionFactory the hibernate session factory
+        */
+       @Autowired
+       @Test(enabled = false)
+       public void setSessionFactory(@Qualifier("simanSessionFactory") SessionFactory aSessionFactory) {
+               _hibernateTemplate = new HibernateTemplate(aSessionFactory);
+       }
+       
+       /**
+        * Method for the test data creation. It is called before the first test
+        * starting.
+        */
+       @BeforeClass
+       public void initClass() {
+               try {
+                       // Initialize UserContext
+//                     initUserContext();
+                       
+               } catch (Exception e) {
+                       Assert.fail("Exception occured during the testing data creation. ", e);
+               }
+       }
+       
+       
+       /**
+        * Insert base data before each method : matricule, department, language, reference.
+        */
+       @BeforeMethod
+       public void insertBaseDataBeforeMethod() {
+               LOG.debug(" >>>>>>>>>>>>>>> COMMON - insertBaseDataBeforeMethod");
+               
+       }
+
+       // [PRIVATE METHOD] ------------------------------ 
+       
+       // [DATA PROVIDER METHOD : Insert / Select] ------------------------------ 
+       /**
+        * Insert data for test : document. 
+        * @param document BO
+        */
+//     protected void insertData(final DocumentWithBLOBs document) {
+//             // Insert document
+//             _documentDAO.insert(document);
+//     }
+       
+       /**
+        * Uses the current transaction to execute SQL statement in order to be able to 
+        * see the current state of the database.
+        * @param statement the sql statement
+        */
+       @SuppressWarnings("deprecation")
+       protected void executeAndDisplaySqlStatement(final String statement) {
+               List<Map<String, Object>> resultSet = simpleJdbcTemplate.queryForList(statement);
+               displayResultset(resultSet);
+       }
+       
+       /**
+        * Uses the current transaction to execute SQL statement in order to be able to 
+        * see the current state of the database.
+        * @param statement the sql statement
+        * @param args the sql statement parameters
+        */
+       @SuppressWarnings("deprecation")
+       protected void executeAndDisplaySqlStatement(final String statement, final Object...args) {
+               List<Map<String, Object>> resultSet = simpleJdbcTemplate.queryForList(statement, args);
+               displayResultset(resultSet);
+       }
+
+       /**
+        * Displays resultset in log.
+        * @param resultSet the resultset to display.
+        */
+       private void displayResultset(final List<Map<String, Object>> resultSet) {
+               if(!resultSet.isEmpty()) {
+                       Map<String, Object> firstElement = resultSet.get(0);
+                       LOG.debug(firstElement.keySet().toString());
+                       
+                       for (Map<String, Object> line : resultSet) {
+                               StringBuilder logLine = new StringBuilder("[");
+                               logLine.append(line.values());
+                               logLine.append("[");
+                               LOG.debug(logLine.toString());
+                       }
+               }
+       }
+       
+       
+       // ==========================================================================
+       // NESTED TRANSACTIONS MANAGEMENT
+       // ==========================================================================
+       
+       /**
+        * Used for nested transactions management.
+        */
+       private transient TransactionStatus _nestedTxStatus;
+       
+       /**
+        * Use this method to start a new transaction within an existing one. 
+     * Consider the following test scenario:
+        *   testXX():
+        *     1: check service.XX on valid data:
+        *        - createInitialData();
+        *        - service.XX(); (performs some changes on initial data)
+        *     2: check service.XX on invalid data:
+        *        - deleteInitialData(); (as data were changed by previous call)
+        *        - createInitialData();
+        *        - adjustInitialData();
+        *        - service.XX();
+        * To make such a test we need to provide deleteInitialData() method and call
+        * createInitialData() twice. The latter might lead to significant increasing of
+        * the test execution time.
+        * 
+        * Consider an alternative approach:
+        *   testXX():
+        *     1: check service.XX on valid data:
+        *        - createInitialData();
+        *        - startNestedTransaction();
+        *        - service.XX();
+        *        - rollbackNestedTransaction();
+        *     2: check service.XX on invalid data:
+        *        - startNestedTransaction();
+        *        - adjustInitialData();
+        *        - service.XX();
+        *        - rollbackNestedTransaction();
+        * Thus you're able to create and manage the nested transactions programmatically.
+        * @see test.areva.hewis.mlst2.service.gpao.rpta.TaBaseService#rollbackNestedTransaction()     
+        */
+       protected void startNestedTransaction() {
+               DataSourceTransactionManager txManager = 
+                       (DataSourceTransactionManager) applicationContext.getBean("txManager");
+               
+               DefaultTransactionDefinition txDefinition = new DefaultTransactionDefinition();
+               txDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_NESTED);
+               
+               _nestedTxStatus = txManager.getTransaction(txDefinition);
+}
+       
+       /**
+        * Rollbacks the nested transaction.
+        * @see test.areva.hewis.mlst2.service.gpao.rpta.TaBaseService#startNestedTransaction()
+        */
+       protected void rollbackNestedTransaction() {
+               DataSourceTransactionManager txManager = 
+                       (DataSourceTransactionManager) applicationContext.getBean("txManager");
+               txManager.rollback(_nestedTxStatus);
+       }
+       
+
+       /**
+        * Rollbacks the nested transaction and start a new one.
+        * @see test.areva.hewis.mlst2.service.gpao.rpta.TaBaseService#startNestedTransaction()
+        * @see test.areva.hewis.mlst2.service.gpao.rpta.TaBaseService#rollbackNestedTransaction()
+        */
+       protected void rollbackAndRestartNestedTransaction() {
+               rollbackNestedTransaction();
+               startNestedTransaction();
+       }
+}
diff --git a/Workspace/Siman-Common/src/test/splat/common/TestListingAndOrder.java b/Workspace/Siman-Common/src/test/splat/common/TestListingAndOrder.java
new file mode 100644 (file)
index 0000000..c9fe7dd
--- /dev/null
@@ -0,0 +1,281 @@
+/*****************************************************************************
+ * Company         EURIWARE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   12 Oct 2012
+ * @author         $Author$
+ * @version        $Revision$
+ *****************************************************************************/
+
+package test.splat.common; 
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Abstract class for specific search functionality tests. It is necessary to 
+ * define method, returning expected search list size, array of properties.
+ * 
+ * @author <a href="mailto:vera.polyanskikh@opencascade.com">Vera POLYANSKIKH (VPH)</a>
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+@Test(sequential=true, groups = {"service", "functional", "business"})
+public class TestListingAndOrder extends AbstractTransactionalTestNGSpringContextTests {
+
+
+               
+               /**
+                * Current Specific method name.
+                */
+               protected String _methodName;
+               /**
+                * Common message suffix used to inform that corresponding method should be overridden if this common functionality is used. 
+                */             
+               private static final String NO_METHOD_OVERRIDEN_MSG_SUFFIX = " should be overridden in test class if common test pagination and order engine is used";
+               
+               /**
+                * Error message has been appeared when null object exist in business method result set.
+                */             
+               private static final String NULL_OBJECT_EXIST_IN_RESULTSET = "Null object exist in business method result set";
+
+               //////////////////////////////////////////////////////////////////////////////////////////
+               //////////////////////////////////////////////////////////////////////////////////////////
+                                                                       /**METHODS TO BE OVERRIDDEN**/
+                                                       /**Throw UnsupportedOperationException if not**/
+               //////////////////////////////////////////////////////////////////////////////////////////
+               //////////////////////////////////////////////////////////////////////////////////////////
+               
+               /**
+                * Return expected size of the whole retrieved list or a page of the objects.
+                * @param methodName - specific search method to be called
+                * @return size  of list
+                */
+               @Test(enabled = false)
+               public int getExpectedWholeListSize(final String methodName){
+                       // empty default implementation
+                       // should be overridden if test of pagination or order is necessary
+                       throw new UnsupportedOperationException("TestListingAndOrder.getExpectedWholeListSize"+NO_METHOD_OVERRIDEN_MSG_SUFFIX);
+               }
+               
+
+               /**
+                * Returns array of DTO properties which can be used to test order of page or list. 
+                * @param methodName - specific search method to be called
+                * @return array of order criteria.
+                */
+               @Test(enabled = false)
+               public String[][] getOrderCriteria(final String methodName){
+                       // empty default implementation
+                       // should be overridden if test of pagination or order is necessary
+                       throw new UnsupportedOperationException("TestListingAndOrder.getOrderCriteria"+NO_METHOD_OVERRIDEN_MSG_SUFFIX);
+               }
+               
+               /**
+                * Wrapper for call of specific not paginated search method.
+                * @param <T> object type class
+                * @param methodName - specific search method to be called
+                * @return template list
+                */             
+               @Test(enabled = false)
+               public <T>List<T>  searchListWrapper(final String methodName){
+                       // empty default implementation
+                       // should be overridden if test of pagination or order is necessary
+                       throw new UnsupportedOperationException("TestListingAndOrder.searchListWrapper"+NO_METHOD_OVERRIDEN_MSG_SUFFIX);
+               }
+               
+               //////////////////////////////////////////////////////////////////////////////////////////
+               //////////////////////////////////////////////////////////////////////////////////////////
+                                                                               /**END OF SECTION**/
+               //////////////////////////////////////////////////////////////////////////////////////////
+               //////////////////////////////////////////////////////////////////////////////////////////
+               
+
+               /**
+                * Returns result of default comparison of two objects by given array of properties.
+                * @param o1 - object 1
+                * @param o2 - object 2
+                * @param methodName - specific search method name
+                * @param propertyNames - properties to be compared by
+                * @param ascDirection -  order direction (asc if true, desc - otherwise)
+                * @return result of comparison.
+                */
+               @Test(enabled = false)          
+               protected  int specificCompare(final Object o1, final Object o2, final String methodName,final String[] propertyNames,final boolean ascDirection){
+                       int result = 0;
+                       int i=0;                        
+                       while(result==0 && i<propertyNames.length){                                             
+                               result =internalCompare(o1,o2, propertyNames[i]);
+                               i++;
+                       }
+                       
+                       if(!ascDirection){
+                               result = result*(-1);
+                       }
+                       return result;
+               }
+       
+               /**
+                * Perform test of not paginated search method.
+                * @param <T> object type class
+                * @param methodName - specific search method to be called
+                */
+               @Test(enabled = false)
+               protected <T> void internalTestSearchList(final String methodName) {
+                       setMethodName(methodName);
+                       try {
+                               // compare the whole set size with expected
+                               List<T> list = searchList();
+                               Assert.assertEquals(list.size(),  getExpectedWholeListSize(methodName),"The whole list size is unexpected!");
+                                                               
+                               // check ordering by all given criteria
+                               String[] orderCriteria = getOrderCriteria(_methodName)[0];      
+                               
+                               Assert.assertTrue(checkOrdering(list,orderCriteria,true),"Asc Ordering of list by properties "+orderCriteria[0].toString()+" is wrong!");
+
+                       } catch (Exception e) {
+                               Assert.fail("Exception occured", e);
+                       }
+               }
+
+               /**
+                * Get the methodName.
+                * @return the methodName
+                */
+               @Test(enabled = false)
+               private String getMethodName() {
+                       return _methodName;
+               }
+
+
+
+
+               /**
+                * Set the methodName.
+                * @param methodName the methodName to set
+                */
+               @Test(enabled = false)
+               private void setMethodName(final String methodName) {
+                       this._methodName = methodName;
+               }
+               
+
+               /**
+                * Test of not paginated search method. Specific service method to be called for tests.
+                * @param <T> object type class
+                * @return list -template list
+                */
+               @Test(enabled = false)
+               private <T>List<T> searchList() {
+                       return searchListWrapper(_methodName);
+               }
+
+               /**
+                * Order list given list by given order criteria.
+                * @param <T> - object type class
+                * @param list - list of the objects
+                * @param orderCriteria - property to order by
+                * @param ascDirection - order direction (asc if true, desc - otherwise)
+                * @return ordered list
+                */
+               @Test(enabled = false)
+               private <T>List<T> getOrderedList(final List<T> list,
+                                                                          final String[] orderCriteria,
+                                                                          final boolean ascDirection){
+                       // check ordering
+
+                       Collections.sort(list,new  Comparator<T>(){                     
+                               public int compare(final T o1, final T o2){
+                                       return specificCompare(o1,o2,null,orderCriteria,ascDirection);
+                               }       
+                       });
+                       return list;
+               }
+
+               /**
+                * Check if given list is ordered by given criteria.
+                * @param <T> - object type class
+                * @param list - list of the objects
+                * @param orderCriteria - property to order by
+                * @param ascDirection - order direction (asc if true, desc - otherwise)
+                * @return boolean
+                */
+               @Test(enabled = false)
+               private <T> boolean checkOrdering(final List<T> list,
+                                  final String[] orderCriteria,
+                                  final boolean ascDirection){
+                       boolean result = true;
+
+                       List<T> oldList = new ArrayList<T>();
+                       for(T item:list){
+                               oldList.add(item);
+                       }
+                       List<T> sortedList = getOrderedList(list,orderCriteria,ascDirection);
+                       int i = 0 ;
+                       for(i=0;i<sortedList.size();i++){       
+                               if(oldList.get(i)==null){
+                                       Assert.fail(NULL_OBJECT_EXIST_IN_RESULTSET);
+                               }
+                               if(!oldList.get(i).equals(sortedList.get(i))){
+                                       result = false;
+                                       break;
+                               }
+                       }
+                       return result;
+               }
+
+
+               /**
+                * Performs internal default compare by given property.
+                * @param o1 - object 1
+                * @param o2 - object 2
+                * @param propertyName - property to be compared by
+                * @return result
+                */
+               @Test(enabled = false)
+               private  int internalCompare(final Object o1, final Object o2, final String propertyName){
+                       int result = -2;
+                       try {
+                               // Use getter method for the given property name.
+                               Method getter = o1.getClass().getMethod(
+                                       "get" + propertyName.substring(0, 1).toUpperCase()
+                                                       + propertyName.substring(1));
+                               // Get property values by means of the getter method.
+                               Object v1 = getter.invoke(o1);
+                               Object v2 = getter.invoke(o2);
+                               // Compare values.
+                               if(v1==null && v2==null) {
+                                       result = 0;
+                               }else{
+                                       if(v1==null && v2!=null) {
+                                               result = 1;
+                                       }else{
+                                               if(v1!=null && v2==null){
+                                                       result = -1;
+                                               }else{
+                                                       if (v1 instanceof Comparable) {
+                                                               result = ((Comparable)v1).compareTo(v2);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }catch (IllegalAccessException e) {
+
+                               Assert.fail("IllegalAccessException was thrown by BeanUtils.getProperty ", e);
+                       } catch (InvocationTargetException e) {
+
+                               Assert.fail("InvocationTargetException was thrown by BeanUtils.getProperty ", e);
+                       } catch (NoSuchMethodException e) {
+
+                               Assert.fail("NoSuchMethodException was thrown by BeanUtils.getProperty: " + e.getMessage(), e);
+                       }
+                       return result;
+               }       
+}
diff --git a/Workspace/Siman-Common/src/test/splat/dao/TestKnowledgeElementDAO.java b/Workspace/Siman-Common/src/test/splat/dao/TestKnowledgeElementDAO.java
new file mode 100644 (file)
index 0000000..7c0ee94
--- /dev/null
@@ -0,0 +1,203 @@
+/*****************************************************************************
+ * Company         EURIWARE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   12 Oct 2012
+ * @author         $Author$
+ * @version        $Revision$
+ *****************************************************************************/
+package test.splat.dao;
+
+import java.util.Date;
+
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.KnowledgeElement;
+import org.splat.dal.bo.som.KnowledgeElementType;
+import org.splat.dal.bo.som.Scenario;
+import org.splat.dal.bo.som.Study;
+import org.splat.dal.dao.som.KnowledgeElementDAO;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
+import org.splat.log.AppLogger;
+import org.splat.service.StudyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.orm.hibernate3.HibernateTemplate;
+import org.springframework.test.annotation.Rollback;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import test.splat.common.BaseTest;
+
+/**
+ * Test class for KnowledgeElementDAO.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ * 
+ */
+public class TestKnowledgeElementDAO extends BaseTest {
+
+       /**
+        * Logger for the class.
+        */
+       private static final AppLogger LOG = AppLogger
+                       .getLogger(TestKnowledgeElementDAO.class);
+
+       /**
+        * The tested KnowledgeElementDAO. Later injected by Spring.
+        */
+       @Autowired
+       @Qualifier("knowledgeElementDAO")
+       private transient KnowledgeElementDAO _knowledgeElementDAO;
+
+       /**
+        * The StudyService injected bean.
+        */
+       @Autowired
+       @Qualifier("studyService")
+       private StudyService _studyService;
+
+       /**
+        * Test creation of a knowledge element.<BR>
+        * <B>Description :</B> <BR>
+        * <i>Create a knowledge element.</i><BR>
+        * <B>Action : </B><BR>
+        * <i>1. call DAO's create method for a good transient knowledge element.</i><BR>
+        * <i>2. call DAO's create method for a knowledge element with non-zero id.</i><BR>
+        * <B>Test data : </B><BR>
+        * <i>no input parameters</i><BR>
+        * <i>no input parameters</i><BR>
+        * 
+        * <B>Outcome results:</B><BR>
+        * <i>
+        * <ul>
+        * <li>Object is created in the database successfully<BR>
+        * </li>
+        * <li>Exception is thrown<BR>
+        * </li>
+        * </ul>
+        * </i>
+        * 
+        * @throws InvalidPropertyException
+        *             if an invalid property is used when creating objects
+        * @throws MultiplyDefinedException
+        *             when trying to create an object with already existing id
+        * @throws MissedPropertyException
+        *             if a mandatory property is not defined for an object to be created
+        * 
+        */
+       @Test
+       public void testCreate() throws InvalidPropertyException,
+                       MissedPropertyException, MultiplyDefinedException {
+               LOG.debug(">>>>> RUN testCreate()");
+
+               KnowledgeElement aKelm = getKnowledgeElement();
+               // Call DAO's create method for a good transient knowledge element.
+               Long id = _knowledgeElementDAO.create(aKelm);
+               Assert.assertNotNull(id,
+                               "Create method returns null instead of a new id.");
+               Assert.assertTrue(id > 0, "The new id is not a positive number.");
+               KnowledgeElement aKelmFound = getHibernateTemplate().get(
+                               KnowledgeElement.class, id);
+               Assert.assertNotNull(aKelmFound,
+                               "Created object is not found in the database.");
+               Assert.assertEquals(aKelmFound.getAuthor(), aKelm.getAuthor(),
+                               "Knowledge Element author is not saved.");
+               Assert.assertEquals(aKelmFound.getDate(), aKelm.getDate(),
+                               "Knowledge Element date is not saved.");
+               Assert
+                               .assertEquals(aKelmFound.getOwnerScenario(), aKelm
+                                               .getOwnerScenario(),
+                                               "Knowledge Element scenario is not saved.");
+               Assert.assertEquals(aKelmFound.getProgressState(), aKelm
+                               .getProgressState(), "Knowledge Element state is not saved.");
+               Assert.assertEquals(aKelmFound.getTitle(), aKelm.getTitle(),
+                               "Knowledge Element title is not saved.");
+               Assert.assertEquals(aKelmFound.getType(), aKelm.getType(),
+                               "Knowledge Element type is not saved.");
+               Assert.assertEquals(aKelmFound.getValue(), aKelm.getValue(),
+                               "Knowledge Element value is not saved.");
+               Assert.assertEquals(aKelmFound.getIndex(), aKelm.getIndex(),
+                               "Knowledge Element index is not saved.");
+
+               // Call DAO's create method for a knowledge element with non-zero id.
+               KnowledgeElement aBadKelm = new KnowledgeElement(
+                               (new KnowledgeElement.Properties())
+                                               .setTitle("Test knowledge element")
+                                               .setAuthor(aKelm.getAuthor())
+                                               .setOwnerScenario(aKelm.getOwnerScenario())
+                                               .setType(aKelm.getType())
+                                               .setDate(aKelm.getDate())
+                                               .setValue(
+                                                               "This is another test knowledge element.\nIt is created by the unit test."));
+               aBadKelm.setIndex(aKelmFound.getIndex());
+               try {
+                       _knowledgeElementDAO.create(aBadKelm);
+                       getHibernateTemplate().flush();
+                       Assert.fail("Creation with existing id must be failed.");
+               } catch (Exception e) {
+                       LOG.debug("Expected exception is thrown: "
+                                       + e.getClass().getSimpleName() + ": " + e.getMessage());
+               }
+       }
+
+       /**
+        * Create a transient KnowledgeElement for tests.
+        * 
+        * @return a transient KnowledgeElement
+        * @throws InvalidPropertyException
+        *             if an invalid property is used when creating objects
+        * @throws MultiplyDefinedException
+        *             when trying to create an object with already existing id
+        * @throws MissedPropertyException
+        *             if a mandatory property is not defined for an object to be created
+        */
+       private KnowledgeElement getKnowledgeElement()
+                       throws InvalidPropertyException, MissedPropertyException,
+                       MultiplyDefinedException {
+               // Create a test knowledge type
+               HibernateTemplate ht = getHibernateTemplate();
+
+               KnowledgeElement.Properties kprops = new KnowledgeElement.Properties();
+               KnowledgeElementType aKType = new KnowledgeElementType("TST_kelmtype");
+               ht.save(aKType);
+               // Create a test user
+               User.Properties uprop = new User.Properties();
+               uprop.setUsername("TST_Username").setName("TST_SimanUnitTestsUser")
+                               .setFirstName("TST_FirstName").setDisplayName("TST_test.user")
+                               .addRole("TST_user").setMailAddress(
+                                               "noreply@salome-platform.org");
+               uprop.disableCheck();
+               User anAuthor = new User(uprop);
+               ht.update(anAuthor);
+               // Create a test study
+               Study.Properties stprops = new Study.Properties().setReference(
+                               "TST_SID_01").setTitle("TST_Study").setManager(anAuthor);
+               Study aStudy = new Study(stprops);
+               ht.saveOrUpdate(aStudy);
+               // Create a test scenario
+               Scenario.Properties sprops = new Scenario.Properties().setTitle(
+                               "TST_Study").setManager(anAuthor).setOwnerStudy(aStudy);
+               Scenario aScenario = new Scenario(sprops);
+               aStudy.getScenariiList().add(aScenario);
+               ht.saveOrUpdate(anAuthor);
+               ht.saveOrUpdate(aKType);
+               ht.update(aStudy);
+               ht.saveOrUpdate(aScenario);
+
+               Date aDate = new Date();
+
+               // Prepare a knowledge element transient object
+               kprops
+                               .setTitle("Test knowledge element")
+                               .setAuthor(anAuthor)
+                               .setOwnerScenario(aScenario)
+                               .setType(aKType)
+                               .setDate(aDate)
+                               .setValue(
+                                               "This is the test knowledge element.\nIt is created by the unit test.");
+
+               return new KnowledgeElement(kprops);
+       }
+}
diff --git a/Workspace/Siman-Common/src/test/spring/ut-applicationContext.xml b/Workspace/Siman-Common/src/test/spring/ut-applicationContext.xml
new file mode 100644 (file)
index 0000000..221c133
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:aop="http://www.springframework.org/schema/aop"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xsi:schemaLocation="
+http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+http://www.springframework.org/schema/aop
+http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+http://www.springframework.org/schema/context
+http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+           
+           
+    <context:property-placeholder
+        location="classpath:test/siman.properties,classpath:test/jdbc.properties"
+        ignore-unresolvable="true" />
+        
+    <!-- configuration i18n -->
+    <bean id="i18nUtils"
+        class="org.splat.i18n.I18nUtils">
+        <property name="resourceBundleMessageSource"
+            ref="messageSource" />
+    </bean>
+
+    <bean id="messageSource"
+        class="org.springframework.context.support.ResourceBundleMessageSource">
+        <property name="basenames">
+            <list>
+                <value>application</value>
+                <value>log-messages</value>
+            </list>
+        </property>
+    </bean>
+    <!-- ref 'baseMessageSource' into Siman-common\src\spring\globalContext.xml -->
+    <!-- property name="parentMessageSource" ref="baseMessageSource"/-->
+</beans>
diff --git a/Workspace/Siman-Common/src/test/spring/ut-datasourceContext.xml b/Workspace/Siman-Common/src/test/spring/ut-datasourceContext.xml
new file mode 100644 (file)
index 0000000..8b57e51
--- /dev/null
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:aop="http://www.springframework.org/schema/aop"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:tx="http://www.springframework.org/schema/tx"
+    xsi:schemaLocation="
+http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+http://www.springframework.org/schema/aop
+http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+http://www.springframework.org/schema/context
+http://www.springframework.org/schema/context/spring-context-3.0.xsd
+http://www.springframework.org/schema/tx
+http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
+
+    <!--    <bean id="simanDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+        <property name="jndiName" value="jdbc/ibatis"/>
+        </bean> -->
+
+    <!--    <bean id="simanDatasource"
+        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+        <property name="driverClassName"
+            value="${connection.driver_class}" />
+        <property name="url" value="${connection.url}" />
+        <property name="username" value="${connection.username}" />
+        <property name="password" value="${connection.password}" />
+    </bean>
+    -->
+
+    <bean id="simanDatasource"
+        class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
+        <property name="driverClassName"
+            value="${connection.driver_class}" />
+        <property name="url" value="${connection.url}" />
+        <property name="username" value="${connection.username}" />
+        <property name="password" value="${connection.password}" />
+        <property name="suppressClose" value="true" />
+        <property name="autoCommit" value="false" />
+    </bean>
+
+    <bean id="p6spySimanDatasource"
+        class="com.p6spy.engine.spy.P6DataSource">
+        <constructor-arg>
+            <ref local="simanDatasource" />
+        </constructor-arg>
+    </bean>
+
+
+    <bean id="hibernateProperties"
+        class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+        <property name="properties">
+            <props>
+                <!-- normal properties -->
+            </props>
+        </property>
+        <!-- hibernate.config should be defined somewhere in the spring.properties layers -->
+        <property name="locations">
+            <list>
+                <value>classpath:test/${hibernate.config.file}</value>
+            </list>
+        </property>
+    </bean>
+
+    <bean id="simanSessionFactory"
+        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+        <property name="dataSource" ref="simanDatasource" />
+        <property name="mappingResources">
+            <list>
+                <value>
+                    org/splat/dal/bo/kernel/Persistent.hbm.xml
+                </value>
+                <value>org/splat/dal/bo/kernel/Any.hbm.xml</value>
+                <value>org/splat/dal/bo/kernel/Entity.hbm.xml</value>
+                <value>org/splat/dal/bo/kernel/Attribute.hbm.xml</value>
+                <value>org/splat/dal/bo/kernel/Relation.hbm.xml</value>
+                <value>
+                    org/splat/dal/bo/kernel/TextAttribute.hbm.xml
+                </value>
+                <value>org/splat/dal/bo/kernel/User.hbm.xml</value>
+
+                <value>
+                    org/splat/dal/bo/som/ProjectElement.hbm.xml
+                </value>
+                <value>org/splat/dal/bo/som/Study.hbm.xml</value>
+                <value>org/splat/dal/bo/som/Scenario.hbm.xml</value>
+                <value>org/splat/dal/bo/som/Attributes.hbm.xml</value>
+                <value>org/splat/dal/bo/som/Relations.hbm.xml</value>
+                <value>org/splat/dal/bo/som/File.hbm.xml</value>
+                <value>org/splat/dal/bo/som/Document.hbm.xml</value>
+                <value>org/splat/dal/bo/som/Publication.hbm.xml</value>
+                <value>
+                    org/splat/dal/bo/som/ValidationCycle.hbm.xml
+                </value>
+                <value>org/splat/dal/bo/som/Timestamp.hbm.xml</value>
+                <value>
+                    org/splat/dal/bo/som/SimulationContext.hbm.xml
+                </value>
+                <value>
+                    org/splat/dal/bo/som/KnowledgeElement.hbm.xml
+                </value>
+                <value>org/splat/dal/bo/som/IDBuilder.hbm.xml</value>
+            </list>
+        </property>
+        <!-- hibernate.connection.driver_class=com.p6spy.engine.spy.P6SpyDriver -->
+
+        <property name="hibernateProperties">
+            <ref local="hibernateProperties" />
+        </property>
+        <!-- The following property is used temporary to be able to manage transactions manually. -->
+        <!-- TODO: use annotations to mark transaction methods 
+            instead of programmatic transaction management  -->
+<!--         <property name="exposeTransactionAwareSessionFactory">
+            <value>false</value>
+        </property>-->
+<!--         <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />-->
+    </bean>
+
+    <bean id="txManager"
+        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+        <property name="sessionFactory" ref="simanSessionFactory" />
+    </bean>
+
+    <tx:annotation-driven transaction-manager="txManager" />
+
+</beans>
diff --git a/Workspace/Siman-Common/testng.xml b/Workspace/Siman-Common/testng.xml
new file mode 100644 (file)
index 0000000..52eb788
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="SimanCommonTests" verbose="1">
+       <test name="all">
+               <method-selectors>
+                       <method-selector>
+                               <script language="beanshell">
+                                       <![CDATA[
+                (groups.containsKey("business") || groups.containsKey("functional") || groups.containsKey("service") ) && method.getName().toUpperCase().startsWith("TEST")             
+              ]]>
+                               </script>
+                       </method-selector>
+               </method-selectors>
+        <groups>
+            <!-- 
+                <define name="all">
+                <include name="business"/>
+                <include name="functional"/>
+                <include name="service"/>
+                </define>
+                <define name="new">
+                <include name="newservice"/>
+                </define>
+                <run>
+                <include name="all"/>
+                <exclude name="old"/>
+                </run>
+            -->
+
+        </groups>
+               <packages>
+                       <package name="test.*" />
+               </packages>
+       </test>
+</suite>
index 97e1bec59b97d3795358e95ef4cd053804612767..d34656d9eb6b958483a0127802b5e3bbf297d769 100644 (file)
@@ -4,9 +4,6 @@
         <wb-resource deploy-path="/" source-path="/WebContent"/>
         <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
         <wb-resource deploy-path="/WEB-INF/classes" source-path="/.apt_src"/>
-        <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/SPlat/lib/hibernate-3.5.jar">
-            <dependency-type>uses</dependency-type>
-        </dependent-module>
         <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/org.springframework.aop-3.1.2.RELEASE.jar">
             <dependency-type>uses</dependency-type>
         </dependent-module>
@@ -97,9 +94,6 @@
         <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/SPlat/lib/mailapi.jar">
             <dependency-type>uses</dependency-type>
         </dependent-module>
-        <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/SPlat/lib/mysql-connector-java-5.1.5-bin.jar">
-            <dependency-type>uses</dependency-type>
-        </dependent-module>
         <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/SPlat/lib/poi-3.7-20101029.jar">
             <dependency-type>uses</dependency-type>
         </dependent-module>
         <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/cglib-nodep-2.2.3.jar">
             <dependency-type>uses</dependency-type>
         </dependent-module>
+        <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/commons-logging-1.1.1.jar">
+            <dependency-type>uses</dependency-type>
+        </dependent-module>
+        <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/beanlib-5.0.1beta.jar">
+            <dependency-type>uses</dependency-type>
+        </dependent-module>
+        <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/hibernate-3.5.jar">
+            <dependency-type>uses</dependency-type>
+        </dependent-module>
+        <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/Siman-Common/lib/mysql-connector-java-5.1.5-bin.jar">
+            <dependency-type>uses</dependency-type>
+        </dependent-module>
         <property name="java-output-path" value="build/classes"/>
         <property name="context-root" value="siman"/>
     </wb-module>
index a51a9d546cda0a649700321a5945ba82421c5fd5..074b9e439e4dddb0ff01e8d15016b3c2fe11a93e 100644 (file)
@@ -124,7 +124,7 @@ public class DocumentFacade implements HistoryFacade {
                                uses = new ArrayList<DocumentFacade>(relist.size());
                                for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
                                        Publication used = i.next();
-                                       Integer index = used.getIndex();
+                                       long index = used.getIndex();
                                        DocumentFacade facade = OpenObject.docpres.get(index);
                                        if (facade == null) {
                                                facade = new DocumentFacade(owner, used, getProjectSettings(), getPublicationService());
index b565afbd382a845b549d7ece165e16b80291285f..6508745562dde7e78c4204f4a5e51cd7dc32deb9 100644 (file)
@@ -30,7 +30,7 @@ import org.splat.som.Step;
 public class ImportDocumentAction extends UploadBaseNextAction {
 
        private List<DocumentType> doctypes = null;
-       private int doctype = 0;
+       private long doctype = 0;
        private String docref = null; // Reference extracted from the imported file, if exist
        private String docver = ""; // Version number extracted from the imported file, if exist
        private String date = ""; // Date extracted from the imported file, if exist
@@ -154,7 +154,7 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                        mystudy = getOpenStudy();
                        User user = getConnectedUser();
                        Step step = mystudy.getSelectedStep();
-                       DocumentType type = Document.selectType(doctype);
+                       DocumentType type = Document.selectType((int)doctype);
                        File updir = Database.getDownloadDirectory(user);
                        File upfile = new File(updir.getPath() + "/" + filename);
                        String[] table = filename.split("\\x2E");
@@ -264,7 +264,7 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                return doctypes;
        }
 
-       public int getDocumentType() {
+       public long getDocumentType() {
                // -----------------------------
                return doctype;
        }
index 03106d28a1fa6555f85d4ea935a15dd83b4b35aa..bc9b0ba781dacdc0218f8b60454dd613874b1b86 100644 (file)
@@ -24,7 +24,7 @@ public class NewScenarioAction extends Action {
        private  List<Scenario>   myscene;
        private  String           mytitle;
     private  String           selection;
-    private  int              scindex;
+    private  long              scindex;
     private  int              bastep;
     private  ToDo             action;
        private StudyService _studyService;
@@ -137,7 +137,7 @@ public class NewScenarioAction extends Action {
 //  ------------------------------------
       return myscene;
     }
-    public int getSelectedScenarioIndex () {
+    public long getSelectedScenarioIndex () {
 //  --------------------------------------
       return scindex;
     }
index f5914a6b4992607ec932847a335b1e489f9977b3..a741099a1ef12e6191397993cd558584aa2b62e5 100644 (file)
@@ -75,7 +75,7 @@ public class NewScenarioMenu extends SlidMenu {
                                Step step = i.next();
                                int number = step.getNumber();
                                Scenario group = (Scenario) step.getOwner(); // The menu includes first scenario steps only
-                               int index = group.getIndex();
+                               long index = group.getIndex();
                                String value = index + "." + number;
                                String icon;
                                if (getScenarioService().isEmpty(group))
@@ -119,7 +119,7 @@ public class NewScenarioMenu extends SlidMenu {
                                if (number == askdex)
                                        stopen = step;
                                Scenario group = (Scenario) step.getOwner();
-                               int index = group.getIndex();
+                               long index = group.getIndex();
                                String value = index + "." + number;
                                if (index != scenew.getIndex()) {
                                        if (getScenarioService().isEmpty(group))
index 402abfe97e999b678bb32badd31c83a862676106..81202a4256618bd548597eebff105f9279683f8a 100644 (file)
@@ -103,7 +103,7 @@ public class OpenKnowledge extends OpenObject {
                return credate;
        }
 
-       public Integer getIndex() {
+       public Long getIndex() {
                // -------------------------
                return myknelm.getIndex();
        }
index b00ad00f71a7e597f2d340ada6d3482521e1bf5b..465b4fc8847c665c17afe7cf8ae2b80f809a1de6 100644 (file)
@@ -37,8 +37,8 @@ public abstract class OpenObject implements Proxy {
        private ProjectSettingsService _projectSettingsService;
        private PublicationService _publicationService;
 
-    protected static HashMap<Integer, DocumentFacade>         docpres  = null;
-    protected static HashMap<Integer, KnowledgeElementFacade> knowpres = null;
+    protected static HashMap<Long, DocumentFacade>         docpres  = null;
+    protected static HashMap<Long, KnowledgeElementFacade> knowpres = null;
 
        public class KnowledgeIterator {
 //  ------------------------------
@@ -71,8 +71,8 @@ public abstract class OpenObject implements Proxy {
     protected OpenObject () {
 //  -----------------------
 //    All member fields are supposed initialized by subclasses 
-      if (docpres == null)  docpres  = new HashMap<Integer, DocumentFacade>();
-      if (knowpres == null) knowpres = new HashMap<Integer, KnowledgeElementFacade>();
+      if (docpres == null)  docpres  = new HashMap<Long, DocumentFacade>();
+      if (knowpres == null) knowpres = new HashMap<Long, KnowledgeElementFacade>();
     }
 
 //  ==============================================================================================================================
@@ -254,7 +254,7 @@ public abstract class OpenObject implements Proxy {
         contents = new Vector<DocumentFacade>(list.size());
         for (Iterator<Publication> i=list.iterator(); i.hasNext();) {
           Publication     present = i.next();
-          Integer         index   = present.getIndex();
+          Long         index   = present.getIndex();
           DocumentFacade  facade  = docpres.get(index);
           if (facade == null) {
             facade = new DocumentFacade(this, present, getProjectSettings(), getPublicationService());
index 8fdc2868f013fc18a878413ae600d5b4bcdad9c2..9d1edc110641d5cbf98f2fe90b7a3b5889dd138a 100644 (file)
@@ -110,7 +110,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
 //  -----------------------------
       return mystudy.getAuthor().toString();
     }
-    public Integer getIndex() {
+    public Long getIndex() {
 //  -------------------------
       return mystudy.getIndex();
     }
@@ -351,7 +351,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
 
     protected void remove (KnowledgeElement kelm) {
 //  ---------------------------------------------
-      KnowledgeIterator       known  = knowledge.get(kelm.getType().getIndex() - 2);
+      KnowledgeIterator       known  = knowledge.get((int)(kelm.getType().getIndex() - 2));
                                    // Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
       knowpres.remove(kelm.getIndex());
       for (Iterator<KnowledgeElementFacade> i=known.list.iterator(); i.hasNext(); ) {
index ff571ab78825ea1898a70900fc914a5c3f61ffc8..e530e68f6348ec63dfde03f3eb291297d9b49634 100644 (file)
@@ -91,7 +91,7 @@ public class StudyMenu extends SlidMenu {
 //          WARNING: The selection number must end the action's parameters for the need of refreshGivenStepItem()
           } else {
                Scenario group = (Scenario)step.getOwner();
-               int      index = group.getIndex();
+               long      index = group.getIndex();
                String   value = index + "." + number;
                if      (group.isCheckedout()) icon = "icon.checkedout.png";
                else if (getScenarioService().isEmpty(group))      icon = "icon.empty.png";
@@ -140,7 +140,7 @@ public class StudyMenu extends SlidMenu {
                addItem("0." + number, "menu.step." + number, icon, "step-study?selection=0." + number);
           } else {
                Scenario group = (Scenario)step.getOwner();
-               int      index = group.getIndex();
+               long      index = group.getIndex();
                String   value = index + "." + number;
                if (index != scenew.getIndex()) {
               if      (group.isCheckedout()) icon = "icon.checkedout.png";
index 6560b703f8b32e80464a20d0be38f0ffc9e0e84e..4f348c5de519f9206363a3e522cc6a2c57ffbccb 100644 (file)
@@ -37,7 +37,7 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
     private String                 stitle;         // Title of the study
     private String                 contributors;   // List of existing contributors, some of them may have been removed
     private String                 candidates;     // List of added contributors
-    private int                    type;           // Type of document to be included in the validation process
+    private long                    type;           // Type of document to be included in the validation process
     private int                    publisher;
     private int                    reviewer;
     private int                    approver;
@@ -220,7 +220,7 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
           if (parsekept[i].length() == 0) continue;   // Yet no contributor
           int  index = Integer.valueOf(parsekept[i].trim());
           for (Iterator<User> j=toremove.iterator(); j.hasNext(); ){
-            int present = j.next().getIndex();
+            long present = j.next().getIndex();
             if (present != index) continue;
             j.remove();
             break;
@@ -286,7 +286,7 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
 //  -----------------------------------------------
       return validefault;
     }
-    public int getDocumentTypeIndex () {
+    public long getDocumentTypeIndex () {
 //  ----------------------------------
       return type;
     }
index f67a45df228d7c3da68811ca8bae62c4a4ab3b84..34c665dc0fa5bd15c22a3bcd30b3dfb0379045c6 100644 (file)
@@ -19,9 +19,9 @@ public class ValidationFacade {
     protected static abstract class UserOption implements Name {
 //  ----------------------------------------------------------
       protected String name;
-      protected int    index;
+      protected long    index;
 
-      public int getIndex() {
+      public long getIndex() {
        return index;
       }
       public String toString () {
@@ -84,7 +84,7 @@ public class ValidationFacade {
 //  --------------------------------
       return myname;
     }
-    public int getApproverIndex () {
+    public long getApproverIndex () {
 //  ------------------------------
       return myapprover.getIndex();
     }
@@ -96,7 +96,7 @@ public class ValidationFacade {
 //  ------------------------
       return myicon;
     }
-    public int getPublisherIndex () {
+    public long getPublisherIndex () {
 //  -------------------------------
       return mypublisher.getIndex();
     }
@@ -104,7 +104,7 @@ public class ValidationFacade {
 //  ---------------------------------
       return mypublisher.toString();
     }
-    public int getReviewerIndex () {
+    public long getReviewerIndex () {
 //  ------------------------------
       return myreviewer.getIndex();
     }
index a2e819f06e5e3ab93b1155f62c51db55d1e70166..c75000a3648d81b900d10f6d087d55e98fd9fa06 100644 (file)
@@ -8,7 +8,7 @@ import org.splat.dal.bo.som.Study;
 
 public class ProjectElementFacade {
 
-    private int     index;        // For checking the equality between ProjectElementFacade objects
+    private long     index;        // For checking the equality between ProjectElementFacade objects
     private Study   my;
     private String  subtitle;
     private String  step;
@@ -42,7 +42,7 @@ public class ProjectElementFacade {
     }
     public int hashCode () {
 //  ----------------------
-      return  index;
+      return  (int) index;
     }
 
 //  ==============================================================================================================================
index efe62eb1539456e35f7fa15bff423dd34176458c..16e6b0a4d3b27881d7240c5dd44759a9cc5cc825 100644 (file)
@@ -2,12 +2,19 @@
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:aop="http://www.springframework.org/schema/aop"
+    xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans  
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/aop  
-http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
-           
+http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+http://www.springframework.org/schema/context
+http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
            
+    <context:property-placeholder
+        location="classpath:siman.properties,classpath:jdbc.properties"
+        ignore-unresolvable="true" />
+
        <!-- configuration i18n -->
        <bean id="i18nUtils"
                class="org.splat.i18n.I18nUtils">