<?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
public abstract class Any extends Persistent {
- private Set<Attribute> attributes;
+ private Set<Attribute> attributes = new HashSet<Attribute>();
// ==============================================================================================================================
// Constructors
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]);
}
}
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;
}
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);
//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
<?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
// ==============================================================================================================================
// Database fetch constructor.
- protected Attribute () {
+ public Attribute () {
}
// Initialization constructor
protected Attribute (Any from) {
<?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
public abstract class Entity extends Any {
- private Set<Relation> relations;
+ private Set<Relation> relations = new HashSet<Relation>();
// ==============================================================================================================================
// Constructors
protected Entity (ObjectProperties prop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
// ----------------------------------------
super(prop);
- relations = new HashSet<Relation>();
}
// ==============================================================================================================================
-->
<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
<?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
// Initialization constructor
protected Relation (Entity from) {
// --------------------------------
- super((Attribute)null); // For building the collection of attributes
this.owner = from;
this.reverse = null; // Initialized by subclasses
}
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);
<?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
// ==============================================================================================================================
// Database fetch constructor.
- protected TextAttribute () {
+ public TextAttribute () {
}
// Initialization constructor
// Protected services
// ==============================================================================================================================
- protected void setValue (String value) {
+ public void setValue (String value) {
// --------------------------------------
mytext = value;
//RKV if (this.isSaved()) Database.getCurSession().update(this);
<?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
<?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
// ==============================================================================================================================
// Database fetch constructor.
- protected DescriptionAttribute () {
+ public DescriptionAttribute () {
}
/**
* Constructs the description of a study or a scenario.
<!-- <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
-
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
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]);
}
// ==============================================================================================================================
public Set<DocumentType> getDefaultUses () {
// -------------------------------------------
- return uses;
+ return getUses();
}
public boolean isApproved () {
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
<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 -->
<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 -->
<!-- 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>
<!-- <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" />
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;
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;
}
<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 -->
/**
* The persistent set of scenario knowledge elements.
*/
- private Set<KnowledgeElement> kelms;
+ private Set<KnowledgeElement> kelms = new HashSet<KnowledgeElement>();
// Transient fields
/**
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
/**
* 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.
manager = sprop.manager;
docount = 0;
history = 0;
- scenarii = new LinkedList<Scenario>();
+//RKV scenarii = new LinkedList<Scenario>();
visibility = Visibility.PRIVATE;
state = ProgressState.inWORK;
<!-- <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 -->
<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 -->
* @return merged persistent object
*/
public T merge(T transientObject);
+
+ /**
+ * Synchronize the session data with the database.
+ */
+ public void flush();
}
return (T) getSession().merge(transientObject);
}
+ /**
+ * Synchronize the session data with the database.
+ */
+ public void flush() {
+ getSession().flush();
+ }
+
/**
* Get persistent object type.
*
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;
* Injected file DAO.
*/
private FileDAO _fileDAO;
+ /**
+ * Injected study DAO.
+ */
+ private StudyDAO _studyDAO;
/**
* {@inheritDoc}
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);
public void release(Document aDoc) {
aDoc.setCountag(aDoc.getCountag() - 1);
if (aDoc.isSaved()) {
- getDocumentDAO().update(aDoc);
+ getDocumentDAO().merge(aDoc);
}
}
// 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);
_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;
+ }
+
}
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;
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;
*/
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.
*
/**
* 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
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
/**
* 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
/**
* 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
/**
* 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
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
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;
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;
*/
public class PublicationServiceImpl implements PublicationService {
+ /**
+ * Logger for this class.
+ */
+ protected final static Logger logger = Logger
+ .getLogger(PublicationServiceImpl.class);
+
/**
* Injected study service.
*/
* Injected project element DAO.
*/
private ProjectElementDAO _projectElementDAO;
+ /**
+ * Injected repository service.
+ */
+ private RepositoryService _repositoryService;
/**
* {@inheritDoc}
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}
*
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)
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)
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());
}
/**
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;
+ }
}
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;
* Injected project element DAO.
*/
private ProjectElementDAO _projectElementDAO;
+ /**
+ * Injected versions relation DAO.
+ */
+ private VersionsRelationDAO _versionsRelationDAO;
/**
* {@inheritDoc}
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();
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;
+ }
}
<property name="documentTypeDAO" ref="documentTypeDAO" />
<property name="repositoryService" ref="repositoryService" />
<property name="fileDAO" ref="fileDAO" />
+ <property name="studyDAO" ref="studyDAO" />
</bean>
<bean id="knowledgeElementService"
<property name="studyService" ref="studyService" />
<property name="publicationDAO" ref="publicationDAO" />
<property name="projectElementDAO" ref="projectElementDAO" />
+ <property name="repositoryService" ref="repositoryService" />
</bean>
<bean id="scenarioService"
<property name="userDAO" ref="userDAO" />
<property name="knowledgeElementTypeDAO"
ref="knowledgeElementTypeDAO" />
- <property name="simulationContextService"
- ref="simulationContextService" />
+ <property name="simulationContextService"
+ ref="simulationContextService" />
</bean>
<bean id="searchService"
<property name="simulationContextDAO"
ref="simulationContextDAO" />
<property name="projectElementDAO" ref="projectElementDAO" />
+ <property name="versionsRelationDAO" ref="versionsRelationDAO" />
</bean>
<bean id="simulationContextService"
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;
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
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
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);
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;
}
this.index = index;
}
- public void setUsedBy(String list) {
+ public void setUsedBy(long[] list) {
// -----------------------------------
this.docusedby = list;
}