Salome HOME
Mapping is fixed. Relation in the mapping is inherited from Persistent now. Versionin...
authorrkv <rkv@opencascade.com>
Mon, 29 Oct 2012 11:37:36 +0000 (11:37 +0000)
committerrkv <rkv@opencascade.com>
Mon, 29 Oct 2012 11:37:36 +0000 (11:37 +0000)
33 files changed:
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Any.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Any.java
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Attribute.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Attribute.java
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Entity.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Entity.java
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Persistent.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Relation.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Relation.java
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/TextAttribute.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/TextAttribute.java
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/User.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/som/Attributes.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/som/DescriptionAttribute.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/Document.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/som/DocumentType.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/File.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/som/KnowledgeElement.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/som/ProjectElement.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/som/ProjectElement.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/Publication.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/som/Scenario.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/Timestamp.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/som/ValidationCycle.hbm.xml
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/service/DocumentServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/PublicationService.java
Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java
Workspace/Siman-Common/src/spring/businessServiceContext.xml
Workspace/Siman/src/org/splat/simer/VersionDocumentAction.java

index 5bc0fd675b8154e3701fb55f49751b6045f9f9d7..0a391d3e80b4701d0f8cb039e8325a089b7dd1fe 100644 (file)
@@ -1,32 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
 <!--
-  - Mapping of the root abstract class supporting dynamic attributes.
-  - All objects instance of a subclass of Any are uniquely identified by the rid primary key through the IDGenerator identifier generator class.
-  -
-  - @author    Daniel Brunier-Coulin
-  - @copyright OPEN CASCADE 2012
-  -->
+       - Mapping of the root abstract class supporting dynamic attributes.
+       - All objects instance of a subclass of Any are uniquely identified by the rid primary key through the IDGenerator identifier generator class.
+       -
+       - @author    Daniel Brunier-Coulin
+       - @copyright OPEN CASCADE 2012
+-->
 
 <hibernate-mapping>
+       <union-subclass name="org.splat.dal.bo.kernel.Any"
+               extends="org.splat.dal.bo.kernel.Persistent" abstract="true"
+               table="any">
 
- <!--  <class name="org.splat.dal.bo.kernel.Any" abstract="true"> -->
-  <union-subclass name="org.splat.dal.bo.kernel.Any" extends="org.splat.dal.bo.kernel.Persistent" abstract="true" table="any">
-    <!-- int     rid   -->    
-<!--     <id name="rid" type="int" column="rid" unsaved-value="0" access="field">
-      <generator class="org.splat.dal.bo.kernel.IDGenerator"/>
-    </id> -->
-
-<!--     <id name="rid" column="rid" access="field">
-      <generator class="native"/>
-    </id>-->
-
-    <!-- Set<Attribute> attributes -->
-    <set name="attributes" inverse="true" lazy="false" cascade="all-delete-orphan" access="field">
-      <key         column="owner" />
-      <one-to-many class="org.splat.dal.bo.kernel.Attribute" />
-    </set>
-
-  </union-subclass>
-
+               <!-- Set<Attribute> attributes -->
+               <set name="attributes" inverse="true" lazy="false"
+                       cascade="all-delete-orphan" access="field">
+                       <key column="owner" />
+                       <one-to-many class="org.splat.dal.bo.kernel.Attribute" />
+               </set>
+       </union-subclass>
 </hibernate-mapping>
\ No newline at end of file
index b047d8fa0c52aa7da6ca0476f50f7406dd3a6d32..5366bc74d79351ec702ec5442481db22d8d6174e 100644 (file)
@@ -21,7 +21,7 @@ import org.splat.kernel.ObjectProperties;
 
 public abstract class Any extends Persistent {
 
-    private  Set<Attribute> attributes;
+    private  Set<Attribute> attributes = new HashSet<Attribute>();
 
 //  ==============================================================================================================================
 //  Constructors
@@ -34,14 +34,12 @@ public abstract class Any extends Persistent {
     protected Any (ObjectProperties oprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
 //  --------------------------------------
       super(oprop);
-      attributes = new HashSet<Attribute>();
     }
     protected Any (Attribute... field) {
 //  ----------------------------------
-      attributes = new HashSet<Attribute>();
       for (int i=0; i<field.length; i++) {
        if (field[i] == null) continue;     // Happen when newing an Any object without property 
-        if (field[i].getFrom().equals(this)) attributes.add(field[i]);
+        if (field[i].getFrom().equals(this)) getAttributes().add(field[i]);
       }
     }
 
@@ -51,7 +49,7 @@ public abstract class Any extends Persistent {
 
     public Attribute getAttribute (Class<? extends Attribute> type) {
 //  ---------------------------------------------------------------
-      for (Iterator<Attribute> i=attributes.iterator(); i.hasNext(); ) {
+      for (Iterator<Attribute> i=getAttributes().iterator(); i.hasNext(); ) {
        Attribute field = i.next();
         if (field.getClass().equals(type)) return field;
       }
@@ -64,7 +62,7 @@ public abstract class Any extends Persistent {
 
     protected boolean removeAttribute (Attribute field) {
 //  ---------------------------------------------------
-      for (Iterator<Attribute> i=attributes.iterator(); i.hasNext(); ) {
+      for (Iterator<Attribute> i=getAttributes().iterator(); i.hasNext(); ) {
         if (!i.next().equals(field)) continue;
        i.remove();
        //RKV        if (this.isSaved()) Database.getCurSession().update(this);
@@ -79,16 +77,23 @@ public abstract class Any extends Persistent {
 //RKV      Session  session = Database.getCurSession();
 
       if (!field.getFrom().equals(this)) return false;
-      for (Iterator<Attribute> i=attributes.iterator(); i.hasNext(); ) {
+      for (Iterator<Attribute> i=getAttributes().iterator(); i.hasNext(); ) {
         if (!i.next().getClass().equals(type)) continue;
         i.remove();
        break;
       }
-      attributes.add(field);
-      if (this.isSaved()) {
+      getAttributes().add(field);
+    //RKVif (this.isSaved()) {
        //RKV        if (!field.isSaved()) session.save(field);
        //RKV           session.update(this);
-      }     // Else, when saving this, Hibernate will propagate the operation
+    //RKV}     // Else, when saving this, Hibernate will propagate the operation
       return true;
     }
+       /**
+        * Get the attributes.
+        * @return the attributes
+        */
+       protected Set<Attribute> getAttributes() {
+               return attributes;
+       }
 }
\ No newline at end of file
index 79c5a852e6c7fec6a7f0cb0288f003792f6a3425..12f0c0addb62418899ffdbe4dbe845372a71838a 100644 (file)
@@ -1,26 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
 <!--
-  - Mapping of the Attribute class hierarchy.
-  - The attribute hierarchy is mapped to a single table using a String discriminator.
-  -
-  - @author    Daniel Brunier-Coulin
-  - @copyright OPEN CASCADE 2012
-  -->
+       - Mapping of the Attribute class hierarchy.
+       - The attribute hierarchy is mapped to a single table using a String discriminator.
+       -
+       - @author    Daniel Brunier-Coulin
+       - @copyright OPEN CASCADE 2012
+-->
 
 <hibernate-mapping>
+       <union-subclass name="org.splat.dal.bo.kernel.Attribute"
+               abstract="true" table="attribute"
+               extends="org.splat.dal.bo.kernel.Persistent">
 
-  <class name="org.splat.dal.bo.kernel.Attribute" abstract="true" table="attribute">
-  
-    <!-- int     rid   -->    
-    <id name="rid" column="rid" access="field">
-      <generator class="native"/>
-    </id>
-    <discriminator column="type" type="string"/>
-
-    <!-- Any     owner -->    
-    <many-to-one name="owner" column="owner" access="field" not-null="true" />
-
-  </class>
+               <!-- Any     owner -->
+               <many-to-one name="owner" column="owner" access="field"
+                       not-null="true" />
 
+       </union-subclass>
 </hibernate-mapping>
\ No newline at end of file
index c3096c792f29b522b342f12a7fea48b98842726c..50f94c281394f4786128d36dddbe01f04362e8f8 100644 (file)
@@ -16,7 +16,7 @@ public abstract class Attribute extends Persistent {
 //  ==============================================================================================================================
 
 //  Database fetch constructor.
-    protected Attribute () {
+    public Attribute () {
     }
 //  Initialization constructor
     protected Attribute (Any from) {
index e024f44b1340b5c817975121161f0c98db09e8d9..0992d7dbd537463ec4c0b450077f8d0c3bc510dc 100644 (file)
@@ -1,35 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
 <!--
-  - Mapping of the root abstract class supporting relations.
-  -
-  -
-  - @author    Daniel Brunier-Coulin
-  - @copyright OPEN CASCADE 2012
-  -->
+       - Mapping of the root abstract class supporting relations.
+       -
+       -
+       - @author    Daniel Brunier-Coulin
+       - @copyright OPEN CASCADE 2012
+-->
 
 <hibernate-mapping>
+       <union-subclass name="org.splat.dal.bo.kernel.Entity"
+               abstract="true" extends="org.splat.dal.bo.kernel.Any"
+               table="entity">
 
-<!--   <class name="org.splat.dal.bo.kernel.Entity"     abstract="true"> -->
-  <union-subclass name="org.splat.dal.bo.kernel.Entity" abstract="true" extends="org.splat.dal.bo.kernel.Any" table="entity">
-  
-    <!-- int     rid   -->    
-<!--     <id name="rid" type="int" column="rid" unsaved-value="0" access="field">
-      <generator class="org.splat.dal.bo.kernel.IDGenerator"/>
-    </id>-->
-
-    <!-- Set<Attribute> attributes -->
-<!--    <set name="attributes" inverse="true" lazy="false" cascade="all-delete-orphan" access="field">
-      <key         column="owner" />
-      <one-to-many class="org.splat.dal.bo.kernel.Attribute" />
-    </set> -->
-
-    <!-- Set<Relation>  relations  -->
-    <set name="relations" inverse="true" lazy="false" cascade="all-delete-orphan" access="field">
-      <key         column="owner" />
-      <one-to-many class="org.splat.dal.bo.kernel.Relation" />
-    </set>
-
-  </union-subclass>
+               <!-- Set<Relation>  relations  -->
+               <set name="relations" inverse="true" lazy="false"
+                       cascade="all-delete-orphan" access="field">
+                       <key column="owner" />
+                       <one-to-many class="org.splat.dal.bo.kernel.Relation" />
+               </set>
 
+       </union-subclass>
 </hibernate-mapping>
\ No newline at end of file
index d423d2507d6d22ec53387c3aeeeed7aea265de3f..ebe08746deb696206e96d21474e984e38e9e4378 100644 (file)
@@ -24,7 +24,7 @@ import org.splat.kernel.ObjectProperties;
 
 public abstract class Entity extends Any {
 
-    private Set<Relation> relations;
+    private Set<Relation> relations = new HashSet<Relation>();
 
 //  ==============================================================================================================================
 //  Constructors
@@ -37,7 +37,6 @@ public abstract class Entity extends Any {
     protected Entity (ObjectProperties prop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
 //  ----------------------------------------
       super(prop);
-      relations = new HashSet<Relation>();
     }
 
 //  ==============================================================================================================================
index 132e51a039dd373ad321c91bc34a5c3dbaffa4b4..a4a9ef9f2c96b816b4b57e4a2b7958ea64718155 100644 (file)
@@ -9,20 +9,12 @@
   -->
 
 <hibernate-mapping>
-
   <class name="org.splat.dal.bo.kernel.Persistent" abstract="true">
-
-
-<!--     <id name="rid" column="rid" access="field">
-      <generator class="sequence"/>
-    </id> -->
        <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>
         </generator>
        </id>
-       
   </class>
-
 </hibernate-mapping>
\ No newline at end of file
index 47b7ab86bb702bc86ed2688f7e1680438567430b..2ffa7f558ef9194c237d0f5782241f535b401301 100644 (file)
@@ -1,39 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
 <!--
-  - Mapping of the Relation class hierarchy.
-  - The entire hierarchy is mapped to one single table using a String discriminator.
-  -
-  - @author    Daniel Brunier-Coulin
-  - @copyright OPEN CASCADE 2012
-  -->
+       - Mapping of the Relation class hierarchy.
+       - The entire hierarchy is mapped to one single table using a String discriminator.
+       -
+       - @author    Daniel Brunier-Coulin
+       - @copyright OPEN CASCADE 2012
+-->
 
 <hibernate-mapping>
+       <union-subclass name="org.splat.dal.bo.kernel.Relation"
+               extends="org.splat.dal.bo.kernel.Any" abstract="true">
 
-<!--   <class name="org.splat.dal.bo.kernel.Relation" abstract="true" table="relation"> -->
-  <class name="org.splat.dal.bo.kernel.Relation" abstract="true">
-
-    <!-- int     rid   -->    
-<!--     <id name="rid" type="int" column="rid" unsaved-value="0" access="field">
-      <generator class="org.splat.dal.bo.kernel.IDGenerator"/>
-    </id>-->
-       <id name="rid" column="rid" access="field">
-        <generator class="org.hibernate.id.enhanced.SequenceStyleGenerator">
-               <param name="sequence_name">relation_id</param>
-        </generator>
-       </id>
-       <!-- <discriminator column="name" type="string"/>-->
-
-    <!-- Set<Attribute> attributes -->
-    <set name="attributes" inverse="true" lazy="false" cascade="all-delete-orphan" access="field">
-      <key         column="owner" />
-      <one-to-many class="org.splat.dal.bo.kernel.Attribute" />
-    </set>
-
-    <!-- Entity  owner -->    
-    <many-to-one name="owner" column="owner" access="field" not-null="true" />
-
-       <!-- <property name="to" column="refer" access="property" not-null="true" />-->
-  </class>
-
+               <!-- Entity  owner -->
+               <many-to-one name="owner" column="owner" access="field"
+                       not-null="true" />
+       </union-subclass>
 </hibernate-mapping>
\ No newline at end of file
index 9f8964fb6bb8dd1ea392d57e53a663f5a8c72066..b176ad0d0d2464d694763053959cb39879e5be70 100644 (file)
@@ -38,7 +38,6 @@ public abstract class Relation extends Any {
 //  Initialization constructor
     protected Relation (Entity from) {
 //  --------------------------------
-      super((Attribute)null);       // For building the collection of attributes
       this.owner   = from;
       this.reverse = null;          // Initialized by subclasses
     }
@@ -88,8 +87,10 @@ public abstract class Relation extends Any {
     public void moveTo (Entity nowner) {
        //RKV      Session  session = Database.getCurSession();
 
+      Entity oldOwner = this.owner;
       this.owner = nowner;
       nowner.getAllRelations().add(this);
+      oldOwner.getAllRelations().remove(this);
 //    myold.getAllRelations().remove(this);  Harmful as it leads to remove this relation from the database (!?)
     //RKV      session.update(this);
     //RKV      session.update(nowner);
index 7b5fe9bb7659d15905c9a17c8501bbd3720caef1..6f7fd2461726174a771a1fa71979770c858cfe29 100644 (file)
@@ -1,14 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
 <!--
-  -
-  - @author    Daniel Brunier-Coulin
-  - @copyright OPEN CASCADE 2012
-  -->
+       -
+       - @author    Daniel Brunier-Coulin
+       - @copyright OPEN CASCADE 2012
+-->
 
 <hibernate-mapping>
-  <joined-subclass name="org.splat.dal.bo.kernel.TextAttribute" extends="org.splat.dal.bo.kernel.Attribute" table="text_attr">
-       <key column="rid"/>
-           <property name="mytext" column="value" type="text" access="field" not-null="true"/>
-  </joined-subclass>
+       <union-subclass name="org.splat.dal.bo.kernel.TextAttribute"
+               extends="org.splat.dal.bo.kernel.Attribute" table="text_attr"
+               abstract="true">
+
+               <property name="mytext" column="value" type="text"
+                       access="field" not-null="true" />
+       </union-subclass>
 </hibernate-mapping>
\ No newline at end of file
index 36c6fa0d6961298b52002725b3a02c45455f1d9c..1ebf2e4b96fb4b0d05cb2e9080ec5de304ce32de 100644 (file)
@@ -17,7 +17,7 @@ public abstract class TextAttribute extends Attribute {
 //  ==============================================================================================================================
 
 //  Database fetch constructor.
-    protected TextAttribute () {
+    public TextAttribute () {
     }
 
 //  Initialization constructor
@@ -40,7 +40,7 @@ public abstract class TextAttribute extends Attribute {
 //  Protected services
 //  ==============================================================================================================================
 
-    protected void setValue (String value) {
+    public void setValue (String value) {
 //  --------------------------------------
       mytext = value;
 //RKV      if (this.isSaved()) Database.getCurSession().update(this);
index 50479c7564f5973698bb8ae2fa509975b4f5b2c5..ffa5d73850b512423198492e3cf94c439b005db3 100644 (file)
@@ -1,37 +1,46 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
 <!--
-  - Mapping of the User class and its corresponding Role definition.
-  - User and Role are associated by a one-to-one association on the username User foreign key.
-  -
-  - @author    Daniel Brunier-Coulin
-  - @copyright OPEN CASCADE 2012
-  -->
+       - Mapping of the User class and its corresponding Role definition.
+       - User and Role are associated by a one-to-one association on the username User foreign key.
+       -
+       - @author    Daniel Brunier-Coulin
+       - @copyright OPEN CASCADE 2012
+-->
 
 <hibernate-mapping>
 
-<!-- Class User 
-  -->
-  <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" />
-      <property    name="email"    column="email"    access="field" />
-<!--     </natural-id>-->
-    <property    name="password"   column="password" access="field" />
-    <property    name="first"      column="first"    access="field" not-null="true" />
-    <property    name="last"       column="last"     access="field" not-null="true" />
-    <property    name="display"    column="display"  access="field" />
-    <property    name="organid"    column="organid"  access="field" />
-  </union-subclass>
-  
-<!-- Class Role 
-  -->
-  <class name="org.splat.dal.bo.kernel.Role" table="role" lazy="false">
-    <id name="username" column="username" access="field">
-      <generator class="assigned"/>
-    </id>
-    <property    name="role"     column="role"     access="field" not-null="true" />
-  </class>
-  
+       <!-- Class User 
+       -->
+       <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" />
+               <property name="email" column="email" access="field" />
+               <!--     </natural-id>-->
+               
+               <property name="password" column="password" access="field" />
+               <property name="first" column="first" access="field"
+                       not-null="true" />
+               <property name="last" column="last" access="field"
+                       not-null="true" />
+               <property name="display" column="display" access="field" />
+               <property name="organid" column="organid" access="field" />
+       </union-subclass>
+
+       <!-- Class Role 
+       -->
+       <class name="org.splat.dal.bo.kernel.Role" table="role"
+               lazy="false">
+               <id name="username" column="username" access="field">
+                       <generator class="assigned" />
+               </id>
+               <property name="role" column="role" access="field"
+                       not-null="true" />
+       </class>
+
 </hibernate-mapping>
\ No newline at end of file
index 7aefad519797ba0e10cdf0f4cb52cbbd9cb1d45c..cda4ad8e98e10e0ee92a66c3e7480492d6bb517f 100644 (file)
@@ -1,22 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
 <!--
-  - Mapping of the Attribute concrete subclasses.
-  -
-  - @author    Daniel Brunier-Coulin
-  - @copyright OPEN CASCADE 2012
-  -->
+       - Mapping of the Attribute concrete subclasses.
+       -
+       - @author    Daniel Brunier-Coulin
+       - @copyright OPEN CASCADE 2012
+-->
 
 <hibernate-mapping>
 
-<!-- Description attribute
-  -->
-     <subclass name="org.splat.dal.bo.som.DescriptionAttribute" extends="org.splat.dal.bo.kernel.TextAttribute" discriminator-value="description">
-    </subclass>
+       <!-- Description attribute
+       -->
+       <union-subclass name="org.splat.dal.bo.som.DescriptionAttribute"
+               extends="org.splat.dal.bo.kernel.TextAttribute" table="descr_attr">
+       </union-subclass>
 
-<!-- Comment attribute
-  -->
-     <subclass name="org.splat.dal.bo.som.CommentAttribute"     extends="org.splat.dal.bo.kernel.TextAttribute" discriminator-value="comment">
-    </subclass>
+       <!-- Comment attribute
+       -->
+       <union-subclass name="org.splat.dal.bo.som.CommentAttribute"
+               extends="org.splat.dal.bo.kernel.TextAttribute" table="comment_attr">
+       </union-subclass>
 
 </hibernate-mapping>
\ No newline at end of file
index 421315699f7d0887227eafc82362c3739740f10b..c6ce6a8e1b5b8d6688e501fc6889b1055787e7c5 100644 (file)
@@ -17,7 +17,7 @@ public class DescriptionAttribute extends TextAttribute {
 //  ==============================================================================================================================
 
 //  Database fetch constructor.
-    protected DescriptionAttribute () {
+    public DescriptionAttribute () {
     }
 /**
  * Constructs the description of a study or a scenario.
index ca6e18475c208a82aca15bf5cee3a1f433d9963d..2207b7a6e9ffbf1f132affb7a216a70402132c42 100644 (file)
 
 <!--   <class name="org.splat.dal.bo.som.Document" table="document" lazy="false"> -->
        <union-subclass name="org.splat.dal.bo.som.Document" extends="org.splat.dal.bo.kernel.Entity" table="document" lazy="false">
-<!-- Properties inherited from Entity
-  -->
-    <!-- <id name="rid" type="int" column="rid" unsaved-value="0" access="field">
-      <generator class="org.splat.dal.bo.kernel.IDGenerator"/>
-    </id>
-    
-    <set name="attributes" inverse="true" lazy="false" cascade="all-delete-orphan" access="field">
-      <key         column="owner" />
-      <one-to-many class="org.splat.dal.bo.kernel.Attribute" />
-    </set> 
-    <set name="relations" inverse="true" lazy="false" cascade="all-delete-orphan" access="field">
-      <key         column="owner" />
-      <one-to-many class="org.splat.dal.bo.kernel.Relation" />
-    </set>-->
   
 <!-- Document properties
   -
index 2a55dd138411083ffd763cadd68c0bbc3b4ca472..ca954a6abbba7fc15998bf962f406bacf67c97bb 100644 (file)
@@ -22,7 +22,7 @@ public class DocumentType extends Persistent {
     private ProgressState     state;
        private String            step;     // List of (dash separated) steps (numbers) containing this type
     private String            result;   // Step (number ) having this type as result
-    private Set<DocumentType> uses;
+    private Set<DocumentType> uses = new HashSet<DocumentType>();
 
 //  ==============================================================================================================================
 //  Construction
@@ -89,8 +89,7 @@ public class DocumentType extends Persistent {
       state  = ProgressState.inCHECK;
       step   = dprop.step;
       result = dprop.result;     // May be null
-      uses   = new HashSet<DocumentType>();
-      if (dprop.uses != null) for (int i=0; i<dprop.uses.length; i++) uses.add(dprop.uses[i]);
+      if (dprop.uses != null) for (int i=0; i<dprop.uses.length; i++) getUses().add(dprop.uses[i]);
     }
 
 //  ==============================================================================================================================
@@ -121,7 +120,7 @@ public class DocumentType extends Persistent {
 
     public Set<DocumentType> getDefaultUses () {
 //  -------------------------------------------
-      return uses;
+      return getUses();
     }
 
     public boolean isApproved () {
@@ -188,4 +187,11 @@ public class DocumentType extends Persistent {
        public void setState(ProgressState state) {
                this.state = state;
        }
+       /**
+        * Get the uses.
+        * @return the uses
+        */
+       protected Set<DocumentType> getUses() {
+               return uses;
+       }
 }
\ No newline at end of file
index b586829017d866c9ad4b0d6d122f58070b6b5bd0..cedbb1bf4734ffb02c0cb0f5cb965cc773b28d34 100644 (file)
 
   <union-subclass name="org.splat.dal.bo.som.File" extends="org.splat.dal.bo.kernel.Persistent" table="file" lazy="false">
 
-<!-- Properties inherited Persistent
-  -->
-<!--    <id name="rid" column="rid" access="field">
-      <generator class="native"/>
-    </id>-->
-
 <!-- File properties
   -->
     <!-- String  format -->
index d471b0f79bbb2669df64da5885e005dca5821a5f..5ca13512acc13d1dd49074708911454c0bf29619 100644 (file)
 
   <union-subclass name="org.splat.dal.bo.som.KnowledgeElement" extends="org.splat.dal.bo.kernel.Persistent" table="knowelm" lazy="false">
   
-<!-- Properties inherited Persistent
-  -->
-<!--     <id name="rid" column="rid" access="field">
-      <generator class="native"/>
-    </id> -->
-    
 <!-- KnowledgeElement properties
   -->
     <!-- KnowledgeElementType  type -->    
@@ -44,9 +38,6 @@
 <!-- Class KnowledgeElementType
   -->
   <union-subclass name="org.splat.dal.bo.som.KnowledgeElementType" extends="org.splat.dal.bo.kernel.Persistent" table="knowtype" lazy="false">
-<!--     <id name="rid" column="rid" access="field">
-      <generator class="increment"/>
-    </id>-->
     <property name="name"  column="name"  access="field" not-null="true" />
     <property name="state" column="state" type="ProgressState" access="field" not-null="true" />    
   </union-subclass>
index d98a3cca94fa22689598bdaf710fcc13d71118a5..0a13cf30a7c4d1fbfbe31ae18305a10f9933db99 100644 (file)
 <!--   <class name="org.splat.dal.bo.som.ProjectElement" abstract="true"> -->
   <union-subclass name="org.splat.dal.bo.som.ProjectElement" extends="org.splat.dal.bo.kernel.Entity" abstract="true">
   
-<!-- Properties inherited from Entity
-  -->
-    <!-- <id name="rid" type="int" column="rid" unsaved-value="0" access="field">
-      <generator class="org.splat.dal.bo.kernel.IDGenerator"/>
-    </id>
-    <set name="attributes" inverse="true" lazy="false" cascade="all-delete-orphan" access="field">
-      <key         column="owner" />
-      <one-to-many class="org.splat.dal.bo.kernel.Attribute" />
-    </set>
-    <set name="relations" inverse="true" lazy="false" cascade="all-delete-orphan" access="field">
-      <key         column="owner" />
-      <one-to-many class="org.splat.dal.bo.kernel.Relation" />
-    </set> -->
-  
 <!-- ProjectElement properties common to Study and Scenario
   -->
     <property    name="title"    column="title"    access="field" not-null="true" />
index 9e8655d23ad4203e7443867d00a9dd9589e4e64d..fd8d747c97a3c5e57b0d62dbf23cb16dcbac2b3c 100644 (file)
@@ -30,8 +30,8 @@ public abstract class ProjectElement extends Entity {
     protected  User                     manager;
     protected  Date                     credate;    // Object creation date
     protected  Date                     lasdate;    // Object Last modification date
-    private    List<SimulationContext>  contex;     // Structured by the Step transient class
-    private    Set<Publication>         docums;     // Structured by the Step transient class
+    private    List<SimulationContext>  contex = new Vector<SimulationContext>();     // Structured by the Step transient class
+    private    Set<Publication>         docums = new LinkedHashSet<Publication>();     // Structured by the Step transient class
 
 //  Transient field
     private    Step[]                   folders;
@@ -69,8 +69,8 @@ public abstract class ProjectElement extends Entity {
       title    = null;     // Initialized by subclasses
       credate  = null;     // Initialized by subclasses
       lasdate  = null;     // Initialized by subclasses
-      docums   = new LinkedHashSet<Publication>();
-      contex   = new Vector<SimulationContext>();
+//RKV      docums   = new LinkedHashSet<Publication>();
+//RKV      contex   = new Vector<SimulationContext>();
       
       folders  = null;
     }
index 827b91289a3bafffb97f73e86d1119a0e21529f8..c4f261eba09bfd4ceaccc47c7c932c2f65bb429a 100644 (file)
 
   <union-subclass name="org.splat.dal.bo.som.Publication" extends="org.splat.dal.bo.kernel.Persistent" table="doctag" lazy="false">
   
-<!-- Properties inherited Persistent
-  -->
-<!--     <id name="rid" column="rid" access="field">
-      <generator class="native"/>
-    </id>-->
-
 <!-- Publication properties
   -->
     <!-- Document       mydoc -->    
index f473093bc1395c7d0fe114a03cf0a5fa8e645060..b2e154b9bc9188fddc5bd3ac1de09c3b6f8d0715 100644 (file)
@@ -44,7 +44,7 @@ public class Scenario extends ProjectElement {
        /**
         * The persistent set of scenario knowledge elements.
         */
-       private Set<KnowledgeElement> kelms;
+       private Set<KnowledgeElement> kelms = new HashSet<KnowledgeElement>();
 
        // Transient fields
        /**
@@ -178,7 +178,6 @@ public class Scenario extends ProjectElement {
                known = null;
                knowl = null; // Initialized when getting all Knowledge Elements
                ucase = null;
-               kelms = new HashSet<KnowledgeElement>();
 
                manager = sprop.manager;
                // RKV: The business logic is moved to business services: if (!owner.isStaffedBy(manager)) throw new
index 1fd88f4b560c76a4bd8c021330a0306cc273f649..3af40f510235100300fb0e56211c0485208d0826 100644 (file)
@@ -52,7 +52,7 @@ public class Study extends ProjectElement {
        /**
         * Persistent list of study scenarii.
         */
-       private List<Scenario> scenarii;
+       private List<Scenario> scenarii = new LinkedList<Scenario>();
        private String version;
        /**
         * Persistent history property. It is a number of studies versioning this one, if any.
@@ -242,7 +242,7 @@ public class Study extends ProjectElement {
                manager = sprop.manager;
                docount = 0;
                history = 0;
-               scenarii = new LinkedList<Scenario>();
+//RKV          scenarii = new LinkedList<Scenario>();
                visibility = Visibility.PRIVATE;
                state = ProgressState.inWORK;
 
index 8a8f5379578a0424631864706068cf145f1add9e..e162fded63aa8abf2d255633923006702af8d9a5 100644 (file)
 <!--   <class name="org.splat.dal.bo.som.Timestamp" table="stamp" lazy="false"> -->
   <union-subclass name="org.splat.dal.bo.som.Timestamp" extends="org.splat.dal.bo.kernel.Any" table="stamp" lazy="false">
 
-<!-- Properties inherited from Any
-  -->
-    <!-- <id name="rid" type="int" column="rid" unsaved-value="0" access="field">
-      <generator class="org.splat.dal.bo.kernel.IDGenerator"/>
-    </id>
-    <set name="attributes" inverse="true" lazy="false" cascade="all-delete-orphan" access="field">
-      <key         column="owner" />
-      <one-to-many class="org.splat.dal.bo.kernel.Attribute" />
-    </set> -->
-
 <!-- Timestamp properties
   -->
     <!-- StampRelation        context -->    
index 0a60a6750eece15e6c041bb2747f0d0d379f33c6..29793e65505f09730ca3cf7a222c2e7db0d61787 100644 (file)
 
   <union-subclass name="org.splat.dal.bo.som.ValidationCycle" extends="org.splat.dal.bo.kernel.Persistent" table="cycle" lazy="false">
   
-<!-- Properties inherited Persistent
-  -->
- <!--    <id name="rid" column="rid" access="field">
-      <generator class="native"/>
-    </id>-->
-
 <!-- ValidationCycle properties
   -->
     <!-- ValidationCycleRelation  context -->    
index bfed9c5ecc74fb9a13e2bf4e60924b5c17d82303..415ec25e8af878d8480abb4452215b6b0d661b90 100644 (file)
@@ -152,4 +152,9 @@ public interface GenericDAO<T, PK extends Serializable> {
         * @return merged persistent object
         */
        public T merge(T transientObject);
+
+       /**
+        * Synchronize the session data with the database.
+        */
+       public void flush();
 }
index 88420adb4de1923016879dc1b3f9fe4be87de114..55ed8bbe30a2bf6ef60524b14f816e642966437f 100644 (file)
@@ -214,6 +214,13 @@ public abstract class GenericDAOImpl<T, PK extends Serializable> extends
                return (T) getSession().merge(transientObject);
        }
 
+       /**
+        * Synchronize the session data with the database.
+        */
+       public void flush() {
+               getSession().flush();
+       }
+
        /**
         * Get persistent object type.
         * 
index 325bfd19acec845fbcabae94ac1af47429629081..f7e811c7480ad516d317d67084f4c0262546737c 100644 (file)
@@ -34,6 +34,7 @@ import org.splat.dal.bo.som.Document.Properties;
 import org.splat.dal.dao.som.DocumentDAO;
 import org.splat.dal.dao.som.DocumentTypeDAO;
 import org.splat.dal.dao.som.FileDAO;
+import org.splat.dal.dao.som.StudyDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.NotApplicableException;
@@ -78,6 +79,10 @@ public class DocumentServiceImpl implements DocumentService {
         * Injected file DAO.
         */
        private FileDAO _fileDAO;
+       /**
+        * Injected study DAO.
+        */
+       private StudyDAO _studyDAO;
 
        /**
         * {@inheritDoc}
@@ -114,6 +119,9 @@ public class DocumentServiceImpl implements DocumentService {
                else
                        owner = ((Scenario) dprop.getOwner()).getOwnerStudy();
 
+               // Synchronize the object with the current Hibernate session.
+               owner = getStudyDAO().get(owner.getIndex());
+               
                SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
                String year = tostring.format(owner.getDate());
                String filename = generateEncodedName(aDoc, owner);
@@ -449,7 +457,7 @@ public class DocumentServiceImpl implements DocumentService {
        public void release(Document aDoc) {
                aDoc.setCountag(aDoc.getCountag() - 1);
                if (aDoc.isSaved()) {
-                       getDocumentDAO().update(aDoc);
+                       getDocumentDAO().merge(aDoc);
                }
        }
 
@@ -527,7 +535,7 @@ public class DocumentServiceImpl implements DocumentService {
                // Update this document and the previous version, if exit
                if (previous != null) {
                        previous.setHistory(previous.getHistory() + 1);
-                       getDocumentDAO().update(previous);
+                       getDocumentDAO().merge(previous);
                }
                aDoc.setProgressState(state);
                getDocumentDAO().update(aDoc);
@@ -702,4 +710,20 @@ public class DocumentServiceImpl implements DocumentService {
                _fileDAO = fileDAO;
        }
 
+       /**
+        * Get the studyDAO.
+        * @return the studyDAO
+        */
+       public StudyDAO getStudyDAO() {
+               return _studyDAO;
+       }
+
+       /**
+        * Set the studyDAO.
+        * @param studyDAO the studyDAO to set
+        */
+       public void setStudyDAO(StudyDAO studyDAO) {
+               _studyDAO = studyDAO;
+       }
+
 }
index 192dc66a66e9f558f5f6c751184865fd51539e04..2a3051ccea156a3f3e7e550384ff391acd786b6e 100644 (file)
 package org.splat.service;
 
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.util.Date;
+import java.util.List;
 
+import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.ConvertsRelation;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.ProgressState;
@@ -20,6 +23,9 @@ import org.splat.dal.bo.som.Publication;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.Timestamp;
 import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MismatchException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
 import org.splat.kernel.NotApplicableException;
 import org.splat.som.DocumentRights;
 import org.splat.som.Revision;
@@ -43,6 +49,13 @@ public interface PublicationService {
         */
        public Publication copy(Publication aPublication, ProjectElement publisher);
 
+       public void versionDocument(Step step, User user, String filename,
+                       long docIndex, String docver, String summary, ProgressState state,
+                       Date date, String[] docuses, long[] docusedby/*, List<Step> steps*/)
+                       throws MissedPropertyException, InvalidPropertyException,
+                       MultiplyDefinedException, IOException, MismatchException,
+                       NotApplicableException, InterruptedException;
+
        /**
         * Returns the study Step into which the document version referenced by this publication has been published.
         * 
@@ -54,10 +67,9 @@ public interface PublicationService {
 
        /**
         * Promotes the document referenced by this publication from In-Check to Approved state, if not out-dated, and attaches the
-        * corresponding time-stamp to the document.<br/>
-        * If the promoted document is the final result of the owner study, the study is itself is promoted as well.<br/>
-        * <br/>
-        * Limitation: the way this promotion is propagated to the study supposes that the study has only ONE final result document.
+        * corresponding time-stamp to the document.<br/> If the promoted document is the final result of the owner study, the study is itself
+        * is promoted as well.<br/> <br/> Limitation: the way this promotion is propagated to the study supposes that the study has only ONE
+        * final result document.
         * 
         * @param aPublication
         *            the document publication
@@ -72,11 +84,10 @@ public interface PublicationService {
        public Timestamp approve(Publication aPublication, Date adate);
 
        /**
-        * Demotes the document referenced by this publication to In-Work state, and removes the Promoter of the document, if exist.<br/>
-        * The In-Draft state is skipped (direct demotion to In-Work) if the validation cycle of the document does not include the review step.<br/>
-        * If the demoted document is the final result of the owner study, the study is itself is demoted as well.<br/>
-        * <br/>
-        * Limitation: the way this demotion is propagated to the study supposes that the study has only ONE final result document.
+        * Demotes the document referenced by this publication to In-Work state, and removes the Promoter of the document, if exist.<br/> The
+        * In-Draft state is skipped (direct demotion to In-Work) if the validation cycle of the document does not include the review step.<br/>
+        * If the demoted document is the final result of the owner study, the study is itself is demoted as well.<br/> <br/> Limitation: the
+        * way this demotion is propagated to the study supposes that the study has only ONE final result document.
         * 
         * @param aPublication
         *            the document publication
@@ -89,9 +100,7 @@ public interface PublicationService {
 
        /**
         * Undo the review operation by demoting the document referenced by this publication from In-Check to In-Draft state and removing the
-        * Reviewer.<br/>
-        * If the demoted document is the final result of the owner study, the study is itself is demoted as well.<br/>
-        * <br/>
+        * Reviewer.<br/> If the demoted document is the final result of the owner study, the study is itself is demoted as well.<br/> <br/>
         * Limitation: the way this demotion is propagated to the study supposes that the study has only ONE final result document.
         * 
         * @param aPublication
@@ -106,13 +115,10 @@ public interface PublicationService {
 
        /**
         * Promotes the document referenced by this publication from In-Work to In-Draft or In-Check state, if not out-dated, and attaches the
-        * corresponding time-stamp to the document.<br/>
-        * The In-Draft state is skipped (direct promotion to In-Check) if the validation cycle of the document does not include the review
-        * step.<br/>
-        * Also, if the promoted document is the final result of the owner study, the study is itself promoted as well.<br/>
-        * This operation can be undo-ed by demote().<br/>
-        * <br/>
-        * Limitation: the way this promotion is propagated to the study supposes that the study has only ONE final result document.
+        * corresponding time-stamp to the document.<br/> The In-Draft state is skipped (direct promotion to In-Check) if the validation cycle
+        * of the document does not include the review step.<br/> Also, if the promoted document is the final result of the owner study, the
+        * study is itself promoted as well.<br/> This operation can be undo-ed by demote().<br/> <br/> Limitation: the way this promotion is
+        * propagated to the study supposes that the study has only ONE final result document.
         * 
         * @param aPublication
         *            the document publication
@@ -128,11 +134,9 @@ public interface PublicationService {
 
        /**
         * Promotes the document referenced by this publication from In-Draft to In-Check state, if not out-dated, and attaches the
-        * corresponding time-stamp to the document.<br/>
-        * If the promoted document is the final result of the owner study, the study is itself is promoted as well.<br/>
-        * This operation can be undo-ed by invalidate().<br/>
-        * <br/>
-        * Limitation: the way this promotion is propagated to the study supposes that the study has only ONE final result document.
+        * corresponding time-stamp to the document.<br/> If the promoted document is the final result of the owner study, the study is itself
+        * is promoted as well.<br/> This operation can be undo-ed by invalidate().<br/> <br/> Limitation: the way this promotion is
+        * propagated to the study supposes that the study has only ONE final result document.
         * 
         * @param aPublication
         *            the document publication
@@ -165,11 +169,11 @@ public interface PublicationService {
                        throws FileNotFoundException, NotApplicableException;
 
        /**
-        * Publishes the document referenced by this publication into the owner Project Element under the given revision number.<br/>
-        * The state of the referenced document is supposed being automatically set according to the given revision number, but, due to the
-        * versioning scheme, as it is not possible to differentiate In-Work and In-Draft states, this function has been deprecated (it is
-        * currently used only for the need of integration of Microsoft Office which anyway has to be redesigned). <br/>
-        * Note: in the context of branch versioning, the given revision may be modified by an update of the branch name.
+        * Publishes the document referenced by this publication into the owner Project Element under the given revision number.<br/> The state
+        * of the referenced document is supposed being automatically set according to the given revision number, but, due to the versioning
+        * scheme, as it is not possible to differentiate In-Work and In-Draft states, this function has been deprecated (it is currently used
+        * only for the need of integration of Microsoft Office which anyway has to be redesigned). <br/> Note: in the context of branch
+        * versioning, the given revision may be modified by an update of the branch name.
         * 
         * @param aPublication
         *            the document publication
index e5a6634855878a2646d3aa8bf72b22320dab9763..b77bf919a4117d81da9497b718e289e58fa38081 100644 (file)
@@ -9,12 +9,16 @@
 
 package org.splat.service;
 
+import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.ConvertsRelation;
 import org.splat.dal.bo.som.Document;
@@ -29,13 +33,16 @@ import org.splat.dal.bo.som.Timestamp;
 import org.splat.dal.bo.som.UsedByRelation;
 import org.splat.dal.bo.som.ValidationCycle;
 import org.splat.dal.bo.som.ValidationStep;
-import org.splat.dal.dao.som.Database;
 import org.splat.dal.dao.som.ProjectElementDAO;
 import org.splat.dal.dao.som.PublicationDAO;
 import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MismatchException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
 import org.splat.kernel.NotApplicableException;
 import org.splat.manox.Reader;
 import org.splat.manox.Toolbox;
+import org.splat.service.technical.RepositoryService;
 import org.splat.som.DocumentRights;
 import org.splat.som.Revision;
 import org.splat.som.Step;
@@ -48,6 +55,12 @@ import org.springframework.transaction.annotation.Transactional;
  */
 public class PublicationServiceImpl implements PublicationService {
 
+       /**
+        * Logger for this class.
+        */
+       protected final static Logger logger = Logger
+                       .getLogger(PublicationServiceImpl.class);
+
        /**
         * Injected study service.
         */
@@ -76,6 +89,10 @@ public class PublicationServiceImpl implements PublicationService {
         * Injected project element DAO.
         */
        private ProjectElementDAO _projectElementDAO;
+       /**
+        * Injected repository service.
+        */
+       private RepositoryService _repositoryService;
 
        /**
         * {@inheritDoc}
@@ -94,6 +111,95 @@ public class PublicationServiceImpl implements PublicationService {
                return copy;
        }
 
+       @Transactional
+       public void versionDocument(Step step, User user, String filename,
+                       long docIndex, String docver, String summary, ProgressState state,
+                       Date date, String[] docuses, long[] docusedby/*, List<Step> steps*/)
+                       throws MissedPropertyException, InvalidPropertyException,
+                       MultiplyDefinedException, IOException, MismatchException,
+                       NotApplicableException, InterruptedException {
+               File updir = getRepositoryService().getDownloadDirectory(user);
+               File upfile = new File(updir.getPath() + "/" + filename);
+
+               // Versioning of the document
+               Document.Properties dprop = new Document.Properties();
+               Publication current = step.getDocument(docIndex);
+               Publication next;
+
+               if (docver.length() == 0) { // Importation of a foreign document
+                       next = getStepService().versionDocument(step, current,
+                                       dprop.setAuthor(user).setDescription(summary));
+                       updir = next.getSourceFile().asFile();
+                       if (logger.isInfoEnabled())
+                               logger.info("Moving \"" + upfile.getName() + "\" to \""
+                                               + updir.getPath() + "\".");
+                       upfile.renameTo(updir);
+                       try {
+                               saveAs(next, state); // May throw FileNotFound if rename was not done
+                       } catch (FileNotFoundException saverror) {
+                               Thread.sleep(1000);
+                               logger.info("Waiting for the file.");
+                               upfile.renameTo(updir);
+                               saveAs(next, state); // Forget it if throw again FileNotFound
+                       }
+               } else {
+                       if (date != null) {
+                               dprop.setDate(date);
+                       }
+                       next = getStepService().versionDocument(step, current,
+                                       dprop.setAuthor(user).setDescription(summary));
+                       updir = next.getSourceFile().asFile();
+                       if (logger.isInfoEnabled())
+                               logger.info("Moving \"" + upfile.getName() + "\" to \""
+                                               + updir.getPath() + "\".");
+                       upfile.renameTo(updir);
+                       try {
+                               saveAs(next, new Revision(docver));
+                       } catch (FileNotFoundException saverror) {
+                               Thread.sleep(1000);
+                               logger.info("Waiting for the file.");
+                               upfile.renameTo(updir);
+                               saveAs(next, state);
+                       }
+               }
+               // TODO: Remove current document details from the contents of open study
+
+               // Creation of uses relations
+               if (docuses != null) {
+                       for (int i = 0; i < docuses.length; i++) {
+                               Long index = Long.valueOf(docuses[i].trim());
+                               Publication used = getPublicationDAO().get(index);//RKV: getPublication(index, steps);
+                               next.addDependency(used);
+                       }
+               }
+               // Outdating impacted document
+               HashSet<Long> compatible = new HashSet<Long>();
+               if (docusedby != null) {
+                       for (int i = 0; i < docusedby.length; i++) {
+                               compatible.add(docusedby[i]);
+                       }
+               }
+               List<Publication> relist = current.getRelations(UsedByRelation.class);
+               for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
+                       Publication using = i.next();
+                       if (!compatible.contains(using.getIndex()))
+                               outdate(using);
+               }
+
+       }
+
+/*     protected Publication getPublication(int index, List<Step> steps) {
+               for (Iterator<Step> i = steps.iterator(); i.hasNext();) {
+                       List<Publication> published = i.next().getAllDocuments();
+                       for (Iterator<Publication> j = published.iterator(); j.hasNext();) {
+                               Publication found = j.next(); // In a given study step,
+                               if (found.value().getIndex() == index)
+                                       return found; // there is only one publication of a given document
+                       }
+               }
+               return null;
+       }
+*/
        /**
         * {@inheritDoc}
         * 
@@ -110,8 +216,8 @@ public class PublicationServiceImpl implements PublicationService {
                ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
                                type);
                User approver = cycle.getActor(ValidationStep.APPROVAL);
-               Timestamp stamp = new Timestamp(ValidationStep.APPROVAL,
-                               aPublication.value(), approver, adate);
+               Timestamp stamp = new Timestamp(ValidationStep.APPROVAL, aPublication
+                               .value(), approver, adate);
                if (!getDocumentService().promote(aPublication.value(), stamp))
                        return null;
                if (getDocumentService().isStudyResult(type)
@@ -221,8 +327,8 @@ public class PublicationServiceImpl implements PublicationService {
                ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
                                type);
                User reviewer = cycle.getActor(ValidationStep.REVIEW);
-               Timestamp stamp = new Timestamp(ValidationStep.REVIEW,
-                               aPublication.value(), reviewer, rdate);
+               Timestamp stamp = new Timestamp(ValidationStep.REVIEW, aPublication
+                               .value(), reviewer, rdate);
                if (!getDocumentService().promote(aPublication.value(), stamp))
                        return null;
                if (getDocumentService().isStudyResult(type)
@@ -307,15 +413,17 @@ public class PublicationServiceImpl implements PublicationService {
                if (previous != null) {
                        Publication oldoc = step.getDocument(previous.getIndex());
                        boolean done = getStepService().remove(step, oldoc); // Decrements the configuration tag count of document
-                       if (done)
+                       if (done) {
+                               oldoc = getPublicationDAO().merge(oldoc); //RKV: to avoid: NonUniqueObjectException: a different object with the same identifier value was already associated with the session
                                getPublicationDAO().delete(oldoc); // WARNING: Potential problem because it's not automatically done as orphan object
+                       }
                }
                getStepService().add(step, aPublication); // Increments the configuration tag count of document
 
                // Import the document properties and update of the study
                forwardProperties(aPublication, aPublication.value().getSourceFile()
                                .asFile(), step);
-               getProjectElementDAO().update(aPublication.getOwner());
+               getProjectElementDAO().merge(aPublication.getOwner());
        }
 
        /**
@@ -615,4 +723,23 @@ public class PublicationServiceImpl implements PublicationService {
        public void setProjectElementDAO(ProjectElementDAO projectElementDAO) {
                _projectElementDAO = projectElementDAO;
        }
+
+       /**
+        * Get the repositoryService.
+        * 
+        * @return the repositoryService
+        */
+       public RepositoryService getRepositoryService() {
+               return _repositoryService;
+       }
+
+       /**
+        * Set the repositoryService.
+        * 
+        * @param repositoryService
+        *            the repositoryService to set
+        */
+       public void setRepositoryService(RepositoryService repositoryService) {
+               _repositoryService = repositoryService;
+       }
 }
index d40b87a50d22c329a76ec721b96721a337ea5b29..5472c81e2ee51f692dbcf26e2078429172f6ef5b 100644 (file)
@@ -32,6 +32,7 @@ import org.splat.dal.dao.som.DocumentDAO;
 import org.splat.dal.dao.som.FileDAO;
 import org.splat.dal.dao.som.ProjectElementDAO;
 import org.splat.dal.dao.som.SimulationContextDAO;
+import org.splat.dal.dao.som.VersionsRelationDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MismatchException;
 import org.splat.kernel.MissedPropertyException;
@@ -87,6 +88,10 @@ public class StepServiceImpl implements StepService {
         * Injected project element DAO.
         */
        private ProjectElementDAO _projectElementDAO;
+       /**
+        * Injected versions relation DAO.
+        */
+       private VersionsRelationDAO _versionsRelationDAO;
 
        /**
         * {@inheritDoc}
@@ -358,11 +363,11 @@ public class StepServiceImpl implements StepService {
                getDocumentDAO().create(newdoc);
 
                // Versioning
-               if (summary == null)
-                       newdoc.addRelation(new VersionsRelation(newdoc, previous));
-               else
-                       newdoc.addRelation(new VersionsRelation(newdoc, previous, summary));
-
+               VersionsRelation aRel;
+               aRel = new VersionsRelation(newdoc, previous, summary);
+//             getVersionsRelationDAO().create(aRel);
+               newdoc.addRelation(aRel);
+               
                // Update of usedby relations, if exist
                List<Relation> relist = previous.getRelations(UsedByRelation.class);
                Study scope = aStep.getOwnerStudy();
@@ -615,4 +620,20 @@ public class StepServiceImpl implements StepService {
        public void setDocumentTypeService(DocumentTypeService documentTypeService) {
                _documentTypeService = documentTypeService;
        }
+
+       /**
+        * Get the versionsRelationDAO.
+        * @return the versionsRelationDAO
+        */
+       public VersionsRelationDAO getVersionsRelationDAO() {
+               return _versionsRelationDAO;
+       }
+
+       /**
+        * Set the versionsRelationDAO.
+        * @param versionsRelationDAO the versionsRelationDAO to set
+        */
+       public void setVersionsRelationDAO(VersionsRelationDAO versionsRelationDAO) {
+               _versionsRelationDAO = versionsRelationDAO;
+       }
 }
index 2bb17ee80ccbfbd941676a7d62441a4bbe941026..f4389b2d2d4332bc844e1c2ecedba7ada3a44dff 100644 (file)
@@ -40,6 +40,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                <property name="documentTypeDAO" ref="documentTypeDAO" />
                <property name="repositoryService" ref="repositoryService" />
                <property name="fileDAO" ref="fileDAO" />
+               <property name="studyDAO" ref="studyDAO" />
        </bean>
 
        <bean id="knowledgeElementService"
@@ -64,6 +65,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                <property name="studyService" ref="studyService" />
                <property name="publicationDAO" ref="publicationDAO" />
                <property name="projectElementDAO" ref="projectElementDAO" />
+               <property name="repositoryService" ref="repositoryService" />
        </bean>
 
        <bean id="scenarioService"
@@ -83,8 +85,8 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                <property name="userDAO" ref="userDAO" />
                <property name="knowledgeElementTypeDAO"
                        ref="knowledgeElementTypeDAO" />
-        <property name="simulationContextService"
-            ref="simulationContextService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
        </bean>
 
        <bean id="searchService"
@@ -106,6 +108,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                <property name="simulationContextDAO"
                        ref="simulationContextDAO" />
                <property name="projectElementDAO" ref="projectElementDAO" />
+               <property name="versionsRelationDAO" ref="versionsRelationDAO" />
        </bean>
 
        <bean id="simulationContextService"
index 529d48aa84a351f007dd0819f2bff18ac769d3ff..0af6bc1da7f3949f48110cb6942a53f66e06d4c5 100644 (file)
@@ -4,6 +4,7 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -35,7 +36,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
 
        private String index = null; // Versioned document index
        private List<Publication> usedby = null;
-       private String docusedby = null;
+       private long[] docusedby = null;
        private String summary = null; // Summary of changes in the new version
        private String docver = ""; // Version number extracted from the imported file, if exist
        private String date = ""; // Date extracted from the imported file, if exist
@@ -166,14 +167,28 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                if (action == ToDo.cancel)
                        return "cancel";
 
-               Session connex = Database.getCurSession();
-               Transaction transax = connex.beginTransaction();
                try {
                        // Getting user inputs
                        mystudy = getOpenStudy();
                        User user = getConnectedUser();
                        Step step = mystudy.getSelectedStep();
-                       File updir = getRepositoryService().getDownloadDirectory(user);
+//                     List<Step> steps = mystudy.getInvolvedSteps();
+                       Date aDate = null;
+                       if (date.length() > 0) {
+                               ResourceBundle locale = ResourceBundle.getBundle("som",
+                                               ApplicationSettings.getCurrentLocale());
+                               SimpleDateFormat get = new SimpleDateFormat(
+                                               locale.getString("date.format"));
+                               aDate = get.parse(date);
+                       }
+                       
+                       String[] listDocuses = null;
+                       if (docuses != null) {
+                               listDocuses = docuses.split(",");
+                       }
+                       getPublicationService().versionDocument(step, user, filename, Integer.valueOf(index), docver, 
+                                       summary, state, aDate, listDocuses, docusedby/*, steps*/);
+                       /*                      File updir = getRepositoryService().getDownloadDirectory(user);
                        File upfile = new File(updir.getPath() + "/" + filename);
 
                        // Versioning of the document
@@ -246,11 +261,11 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                                if (!compatible.contains(using.getIndex()))
                                        getPublicationService().outdate(using);
                        }
+*/
                        // Update of the open study
                        mystudy.setSelection(mystudy.getSelection()); // Rebuilds the presentation
                        // TODO: Look is an optimization is possible (for example by updating the presentation of versioned document)
 
-                       transax.commit();
                        return SUCCESS;
                } catch (FileNotFoundException error) {
                        logger.error("Reason:", error);
@@ -259,14 +274,6 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                        logger.error("Reason:", error);
                        setErrorCode("internal");
                }
-               if (transax != null && transax.isActive()) {
-                       // Second try-catch as the rollback could fail as well
-                       try {
-                               transax.rollback();
-                       } catch (HibernateException backerror) {
-                               logger.debug("Error rolling back transaction", backerror);
-                       }
-               }
                return ERROR;
        }
 
@@ -320,7 +327,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                this.index = index;
        }
 
-       public void setUsedBy(String list) {
+       public void setUsedBy(long[] list) {
                // -----------------------------------
                this.docusedby = list;
        }