import java.util.Iterator;
import java.util.Set;
-import org.hibernate.Session;
-import org.splat.dal.dao.som.Database;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
for (Iterator<Attribute> i=attributes.iterator(); i.hasNext(); ) {
if (!i.next().equals(field)) continue;
i.remove();
- if (this.isSaved()) Database.getSession().update(this);
+ //RKV if (this.isSaved()) Database.getCurSession().update(this);
return true;
}
return false;
public boolean setAttribute (Attribute field) {
// ------------------------------------------------
Class<?> type = field.getClass();
- Session session = Database.getSession();
+//RKV Session session = Database.getCurSession();
if (!field.getFrom().equals(this)) return false;
for (Iterator<Attribute> i=attributes.iterator(); i.hasNext(); ) {
}
attributes.add(field);
if (this.isSaved()) {
- if (!field.isSaved()) session.save(field);
- session.update(this);
+ //RKV if (!field.isSaved()) session.save(field);
+ //RKV session.update(this);
} // Else, when saving this, Hibernate will propagate the operation
return true;
}
import java.util.Set;
import java.util.Vector;
-import org.hibernate.Session;
-import org.splat.dal.dao.kernel.Database;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
if (!link.getClass().equals(type)) continue;
if (!link.getTo().equals(to)) continue;
i.remove();
- if (this.isSaved()) Database.getSession().update(this);
+ //RKV if (this.isSaved()) Database.getCurSession().update(this);
return;
}
}
import java.util.Iterator;
-import org.hibernate.Session;
-import org.splat.dal.dao.kernel.Database;
-
-
public abstract class Relation extends Any {
// Persistent fields
* @param nowner the document to which this relation is moved
* */
public void moveTo (Entity nowner) {
-// ----------------------------------
- Session session = Database.getSession();
+ //RKV Session session = Database.getCurSession();
this.owner = nowner;
nowner.getAllRelations().add(this);
// myold.getAllRelations().remove(this); Harmful as it leads to remove this relation from the database (!?)
- session.update(this);
- session.update(nowner);
+ //RKV session.update(this);
+ //RKV session.update(nowner);
if (this.isBidirectional()) {
Relation link = this.getReverse();
link.setTo(nowner);
- session.update(link);
+ //RKV session.update(link);
}
}
package org.splat.dal.bo.kernel;
-import org.splat.dal.dao.kernel.Database;
-
/**
*
* @author Daniel Brunier-Coulin
protected void setValue (String value) {
// --------------------------------------
mytext = value;
- if (this.isSaved()) Database.getSession().update(this);
+//RKV if (this.isSaved()) Database.getCurSession().update(this);
}
}
\ No newline at end of file
import java.util.HashSet;
import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.som.Database;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
// Persistent fields
private String name;
private ProgressState state;
- private String step; // List of (dash separated) steps (numbers) containing this type
+ private String step; // List of (dash separated) steps (numbers) containing this type
private String result; // Step (number ) having this type as result
private Set<DocumentType> uses;
// Public member functions
// ==============================================================================================================================
- public boolean approve () {
-// -------------------------
- if (state != ProgressState.inCHECK) return false;
- this.state = ProgressState.APPROVED; // The type name is supposed being localized
- Database.getSession().update(this);
- return true;
- }
-
public boolean equals(Object entity) {
// ------------------------------------
if (entity == null) return false;
if (result == null) return false;
return (Integer.valueOf(result) == step.getNumber());
}
+
+ /**
+ * Get the state.
+ * @return the state
+ */
+ public ProgressState getState() {
+ return state;
+ }
+ /**
+ * Set the state.
+ * @param state the state to set
+ */
+ public void setState(ProgressState state) {
+ this.state = state;
+ }
}
\ No newline at end of file
package org.splat.dal.bo.som;
+
/**
*
* @author Daniel Brunier-Coulin
* @copyright OPEN CASCADE 2012
*/
-import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
-import org.splat.dal.dao.som.Database;
-
-
public class IDBuilder {
- @SuppressWarnings("unused")
- private int cycle;
- private int base; // Number of studies created in this cycle
-
-// ==============================================================================================================================
-// Constructors
-// ==============================================================================================================================
-
- protected IDBuilder () {
- }
- public IDBuilder (Date date) {
-// -------------------------------
- SimpleDateFormat get = new SimpleDateFormat("yyyy");
- String year = get.format(date);
- cycle = Integer.valueOf(year);
- base = 0;
- }
-
-// ==============================================================================================================================
-// Public member functions
-// ==============================================================================================================================
-
- public String buildReference (String pattern, Study study) {
-// -------------------------------------------------------------
- char[] format = pattern.toCharArray();
- char[] ref = new char[80]; // Better evaluate the length of the generated string
- int next = base + 1;
-
- int count = 0;
- for (int i=0; i<format.length; i++) {
-
-// Insertion of attribute values
- if (format[i] == '%') {
- i += 1;
-
- if (format[i] == 'y') { // Insertion of year in format 2 (e.g. 09) or 4 (e.g. 2009) digits
- int n = i;
- while (format[i] == 'y') {
- i += 1;
- if (i == format.length) break;
- }
- SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
- String year = tostring.format(study.getDate());
- year = year.substring(4-(i-n), 4); // 4-(i-n) must be equal to either 0 or 2
- for (int j=0; j<year.length(); j++) {
- ref[count] = year.charAt(j);
- count += 1;
- }
- i -= 1; // Back to the last 'y' character
- } else
- if (format[i] == '0') { // Insertion of the index
- int n = i;
- while (format[i] == '0') {
- i += 1;
- if (i == format.length) break;
- }
- DecimalFormat tostring = new DecimalFormat(pattern.substring(n, i));
- String number = tostring.format(next);
- for (int j=0; j<number.length(); j++) {
- ref[count] = number.charAt(j);
- count += 1;
- }
- i -= 1; // Back to the last '0' character
- }
-// Keep the character
- } else {
- ref[count] = format[i];
- count += 1;
- }
- }
-// Incrementation of the number of study
- base = next;
- Database.getSession().update(this);
- return String.copyValueOf(ref, 0, count);
- }
+ @SuppressWarnings("unused")
+ private int cycle;
+ private int base; // Number of studies created in this cycle
+
+ // ==============================================================================================================================
+ // Constructors
+ // ==============================================================================================================================
+
+ protected IDBuilder() {
+ }
+
+ public IDBuilder(Date date) {
+ // -------------------------------
+ SimpleDateFormat get = new SimpleDateFormat("yyyy");
+ String year = get.format(date);
+ cycle = Integer.valueOf(year);
+ base = 0;
+ }
+
+ /**
+ * Get the base.
+ *
+ * @return the base
+ */
+ public int getBase() {
+ return base;
+ }
+
+ /**
+ * Set the base.
+ *
+ * @param base
+ * the base to set
+ */
+ public void setBase(int base) {
+ this.base = base;
+ }
}
\ No newline at end of file
*/
import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.som.Database;
public class KnowledgeElementType extends Persistent {
// Constructors
// ==============================================================================================================================
-// Database fetch constructor
+ // Database fetch constructor
protected KnowledgeElementType () {
}
// Initialization constructor
// Public member functions
// ==============================================================================================================================
- public boolean approve () {
-// -------------------------
- if (state != ProgressState.inCHECK) return false;
- this.state = ProgressState.APPROVED; // The type name is supposed being localized
- if (this.isSaved()) Database.getSession().update(this);
- return true;
- }
-
public boolean equals(Object entity) {
// ------------------------------------
if (entity == null) return false;
// ----------------------------
return (state == ProgressState.inWORK);
}
-
-// ==============================================================================================================================
-// Protected service
-// ==============================================================================================================================
-/**
- * Reserves this type for the management of simulation contexts.
- * For being able to get the studies in which simulation contexts are used, all study scenarios are indexed through this
- * knowledge element type, whether they include knowledge elements or not.
- */
- public boolean reserve () {
-// ----------------------------
- if (state != ProgressState.inCHECK) return false;
- this.state = ProgressState.inWORK;
- if (this.isSaved()) Database.getSession().update(this);
- return true;
- }
+ /**
+ * Get the state.
+ * @return the state
+ */
+ public ProgressState getState() {
+ return state;
+ }
+ /**
+ * Set the state.
+ * @param state the state to set
+ */
+ public void setState(ProgressState state) {
+ this.state = state;
+ }
}
\ No newline at end of file
import org.apache.log4j.Logger;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
import org.splat.kernel.ObjectProperties;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
// --------------------------------------------------
return contex.remove(oldoc);
}
-
-/**
- * Refreshes the internal data potentially out-of-date.
- * This function needs to be called when Publication objects are added to this Project Element before being saved. The reason is,
- * as saving a persistent object changes its hashcode, hashed data need to be rebuilt after saving for making functions based
- * on this hashcode such as remove(), working.
- */
- public void refresh () {
-// -------------------------
- Publication[] curdoc = docums.toArray(new Publication[docums.size()]);
-
- folders = null; // Just in case
- docums.clear();
- for (int i=0; i<curdoc.length; i++) docums.add(curdoc[i]);
-// No need to rebuild the list of SimulationContext as it does not use hashcodes
- Database.getSession().update(this);
- }
+ /**
+ * Get the docums.
+ * @return the docums
+ */
+ public Set<Publication> getDocums() {
+ return docums;
+ }
}
\ No newline at end of file
* @copyright OPEN CASCADE 2012
*/
-import java.io.FileNotFoundException;
import java.util.ArrayList;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
-import org.hibernate.Session;
import org.splat.dal.bo.kernel.Persistent;
import org.splat.dal.bo.kernel.Relation;
-import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
-import org.splat.kernel.InvalidPropertyException;
-import org.splat.kernel.NotApplicableException;
-import org.splat.manox.Reader;
-import org.splat.manox.Toolbox;
-import org.splat.som.DocumentRights;
-import org.splat.som.Revision;
import org.splat.som.Step;
else return mydoc.addRelation( new UsesRelation(mydoc, to) );
}
-/**
- * Undo the out-date operation.
- *
- * @return true if the acceptance succeeds
- * @see #outdate()
- * @see DocumentRights#canAccept()
- */
- public boolean actualize () {
-// ---------------------------
- if (!this.isOutdated()) return false;
- isnew = 'Y';
- Database.getSession().update(this);
- return true;
- }
-
/**
* Returns either the Study Scenario or the Study itself to which this publication belongs, depending on the Study Step into
* which the referenced document has been published.<br/>
public void setIsnew(char isnew) {
this.isnew = isnew;
}
-/**
- * Out-dates this publication and recursively all publications using this one.
- * Typically, a publication is out-dated when modifying a document to which it depends.
- *
- * @see #isOutdated()
- * @see #getProgressState()
- * @see #actualize()
- */
- public void outdate () {
-// ----------------------
- if (this.isOutdated()) return;
-
- List<Publication> relist = this.getRelations(UsedByRelation.class);
- for (Iterator<Publication> i = relist.iterator(); i.hasNext(); ) {
- i.next().outdate();
- }
- isnew = 'O';
- Database.getSession().update(this);
- }
-
+
/**
* Returns the document version referenced by this Publication.
*/
package org.splat.dal.bo.som;
+
/**
*
* @author Daniel Brunier-Coulin
import org.splat.dal.bo.kernel.Persistent;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
import org.splat.som.Step;
-
+/**
+ * Scenario persistent object.
+ */
public class Scenario extends ProjectElement {
-// Persistent fields
- private Study owner;
- private int sid; // Identifier unique in the scope of owner study
- private User cuser; // User having checked-out the scenario, if done
- /**
- * The persistent set of scenario knowledge elements.
- */
- private Set<KnowledgeElement> kelms;
-
-// Transient fields
- /**
- * The transient map of knowledge elements grouped by types.
- */
- transient private HashMap<Long, List<KnowledgeElement>> known;
- /**
- * The scenario transient list of knowledge elements.
- */
- transient private List<KnowledgeElement> knowl; // Copy of kelms excluding the internal Knowledge Element (ucase below)
+ // Persistent fields
+ /**
+ * Persistent property owner. It is a parent study of the scenario.
+ */
+ private Study owner;
+ /**
+ * Persistent property sid. It is an unique identifier in the scope of owner study.
+ */
+ private int sid;
+ /**
+ * Persistent property cuser. It is a user having checked-out the scenario, if done.
+ */
+ private User cuser;
+ /**
+ * The persistent set of scenario knowledge elements.
+ */
+ private Set<KnowledgeElement> kelms;
+
+ // Transient fields
+ /**
+ * The transient map of knowledge elements grouped by types.
+ */
+ transient private HashMap<Long, List<KnowledgeElement>> known;
+ /**
+ * The scenario transient list of knowledge elements.
+ */
+ transient private List<KnowledgeElement> knowl; // Copy of kelms excluding the internal Knowledge Element (ucase below)
/**
* The scenario transient "use case" knowledge element.
*/
- transient private KnowledgeElement ucase; // Internal Knowledge Element for accessing to all used simulation contexts
-
-
-// ==============================================================================================================================
-// Construction
-// ==============================================================================================================================
-
-
- /**
- * Fields initialization class.
- */
- public static class Properties extends Persistent.Properties {
-// ------------------------------------------------------------
- private Study owner = null;
- private Scenario previous = null;
- private Step base = null;
- private String title = null;
- private String summary = null;
- private User manager = null;
- private Date date = null;
-
-// - Public services
-
- public void clear () {
- super.clear();
- owner = null;
- previous = null;
- base = null;
- title = null;
- summary = null;
- manager = null;
- date = null;
- }
-// - Protected services
-
- public Step getBaseStep () {
- return base; // May be null
- }
- public Scenario getInsertAfter () {
- return previous; // May be null
- }
- public User getManager () {
- return manager;
- }
- public Properties setOwnerStudy (Study owner)
- {
- this.owner = owner;
- return this;
- }
-// - Setters of Scenario properties
-
- public Properties setBaseStep (Step base) throws InvalidPropertyException
- {
- if (!(base.getOwner() instanceof Scenario)) throw new InvalidPropertyException("step");
- this.base = base;
- return this;
- }
- public Properties setDate (Date date)
- {
- this.date = date;
- return this;
- }
- public Properties setDescription (String summary)
- {
- if (summary.length() > 0) this.summary = summary;
- return this;
- }
- public Properties setInsertAfter (Scenario previous)
- {
- this.previous = previous;
- return this;
- }
- public Properties setManager (User user)
- {
- this.manager = user;
- return this;
- }
- public Properties setTitle (String title) throws InvalidPropertyException
- {
- if (title.length() == 0) throw new InvalidPropertyException("title");
- this.title = title;
- return this;
- }
-// - Global validity check
-
- public void checkValidity() throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException
- {
- if (owner == null) throw new MissedPropertyException("owner");
- if (title == null) throw new MissedPropertyException("title");
- if (manager == null) throw new MissedPropertyException("manager");
- }
- }
-// Database fetch constructor
- protected Scenario () {
-// ---------------------
- known = null;
- knowl = null;
- ucase = null;
- }
-// Internal constructor
- public Scenario (Properties sprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
-// -------------------------------------
- super(sprop); // Throws one of the above exception if not valid
- owner = sprop.owner;
- sid = 0;
- cuser = null;
- title = sprop.title; // Inherited attribute
- known = null;
- knowl = null; // Initialized when getting all Knowledge Elements
- ucase = null;
- kelms = new HashSet<KnowledgeElement>();
-
- manager = sprop.manager;
-//RKV: The business logic is moved to business services: if (!owner.isStaffedBy(manager)) throw new InvalidPropertyException("manager");
-
- credate = sprop.date; // Inherited attribute
- if (credate == null) {
- Calendar current = Calendar.getInstance();
- credate = current.getTime(); // Today
- }
- lasdate = credate; // Inherited attribute
-
- if (sprop.summary != null) this.setAttribute( new DescriptionAttribute(this, sprop.summary) );
-
- Scenario[] scene = owner.getScenarii();
- for (int i=0; i<scene.length; i++) if (scene[i].sid > this.sid) this.sid = scene[i].sid;
- sid += 1;
- }
-
-// ==============================================================================================================================
-// Public member functions
-// ==============================================================================================================================
-
- public List<KnowledgeElement> getAllKnowledgeElements () {
-// --------------------------------------------------------
- if (knowl == null) {
- knowl = new Vector<KnowledgeElement>(kelms.size());
- for (Iterator<KnowledgeElement> i=kelms.iterator(); i.hasNext(); ) {
- KnowledgeElement kelm = i.next();
- if (kelm.getType().equals("usecase")) ucase = kelm;
- else knowl.add(kelm);
- }
- }
- return Collections.unmodifiableList(knowl);
- }
-
- public KnowledgeElement getKnowledgeElement (long l) {
-// -------------------------------------------------------
- for (Iterator<KnowledgeElement> i=kelms.iterator(); i.hasNext();) {
- KnowledgeElement mykelm = i.next();
- if (mykelm.getIndex() == l) return mykelm;
- }
- return null;
- }
-
- public List<KnowledgeElement> getKnowledgeElementsOf (KnowledgeElementType type) {
-// --------------------------------------------------------------------------------
- if (kelms.isEmpty()) return new Vector<KnowledgeElement>(); // Smarter than returning null
- if (known == null) known = new HashMap<Long, List<KnowledgeElement>>();
-
- long numtype = type.getIndex();
- List<KnowledgeElement> listype = known.get(numtype);
- if (listype == null) {
- listype = new Vector<KnowledgeElement>();
- for (Iterator<KnowledgeElement> i=kelms.iterator(); i.hasNext();) {
- KnowledgeElement kelm = i.next();
- if (kelm.getType().getIndex() == numtype) listype.add(kelm);
- }
- known.put(numtype, listype);
- }
- return listype; // No protection against this object corruption as it would not corrupt the database
- }
-
- public Study getOwnerStudy () {
-// -----------------------------
- return owner;
- }
-/**
- * Returns the local reference of this scenario. This reference is unique in the scope of the owner study.
- */
- public String getReference () {
-// -----------------------------
- return String.valueOf(sid);
- }
-
- public User getUser () {
- return cuser; // Null if the scenario has not been checked-out
- }
-
- public void setUser (User aUser) {
- cuser = aUser; // Null if the scenario has not been checked-out
- }
-
- public boolean removeKnowledgeElement (KnowledgeElement kelm) {
-// -------------------------------------------------------------
- KnowledgeElement torem = getKnowledgeElement(kelm.getIndex());
- if (torem == null) return false;
- boolean done = kelms.remove(torem);
- if (done) {
-// Update of my transient data
- List<KnowledgeElement> kelms = known.get(kelm.getType().getIndex());
- kelms.remove(torem);
- if (knowl != null) knowl.remove(torem);
- Database.getSession().update(this);
-//TODO: If the owner study is not private, remove the knowledge from the Lucene index
- return true;
- } else {
- return false;
- }
- }
-
- public boolean isCheckedout () {
-// ------------------------------
- return (cuser != null);
- }
-
-// ==============================================================================================================================
-// Private services
-// ==============================================================================================================================
+ transient private KnowledgeElement ucase; // Internal Knowledge Element for accessing to all used simulation contexts
+
+ // ==============================================================================================================================
+ // Construction
+ // ==============================================================================================================================
+
+ /**
+ * Fields initialization class.
+ */
+ public static class Properties extends Persistent.Properties {
+ // ------------------------------------------------------------
+ private Study owner = null;
+ private Scenario previous = null;
+ private Step base = null;
+ private String title = null;
+ private String summary = null;
+ private User manager = null;
+ private Date date = null;
+
+ // - Public services
+
+ public void clear() {
+ super.clear();
+ owner = null;
+ previous = null;
+ base = null;
+ title = null;
+ summary = null;
+ manager = null;
+ date = null;
+ }
+
+ // - Protected services
+
+ public Step getBaseStep() {
+ return base; // May be null
+ }
+
+ public Scenario getInsertAfter() {
+ return previous; // May be null
+ }
+
+ public User getManager() {
+ return manager;
+ }
+
+ public Properties setOwnerStudy(Study owner) {
+ this.owner = owner;
+ return this;
+ }
+
+ // - Setters of Scenario properties
+
+ public Properties setBaseStep(Step base)
+ throws InvalidPropertyException {
+ if (!(base.getOwner() instanceof Scenario))
+ throw new InvalidPropertyException("step");
+ this.base = base;
+ return this;
+ }
+
+ public Properties setDate(Date date) {
+ this.date = date;
+ return this;
+ }
+
+ public Properties setDescription(String summary) {
+ if (summary.length() > 0)
+ this.summary = summary;
+ return this;
+ }
+
+ public Properties setInsertAfter(Scenario previous) {
+ this.previous = previous;
+ return this;
+ }
+
+ public Properties setManager(User user) {
+ this.manager = user;
+ return this;
+ }
+
+ public Properties setTitle(String title)
+ throws InvalidPropertyException {
+ if (title.length() == 0)
+ throw new InvalidPropertyException("title");
+ this.title = title;
+ return this;
+ }
+
+ // - Global validity check
+
+ public void checkValidity() throws MissedPropertyException,
+ InvalidPropertyException, MultiplyDefinedException {
+ if (owner == null)
+ throw new MissedPropertyException("owner");
+ if (title == null)
+ throw new MissedPropertyException("title");
+ if (manager == null)
+ throw new MissedPropertyException("manager");
+ }
+ }
+
+ // Database fetch constructor
+ protected Scenario() {
+ // ---------------------
+ known = null;
+ knowl = null;
+ ucase = null;
+ }
+
+ // Internal constructor
+ public Scenario(Properties sprop) throws MissedPropertyException,
+ InvalidPropertyException, MultiplyDefinedException {
+ // -------------------------------------
+ super(sprop); // Throws one of the above exception if not valid
+ owner = sprop.owner;
+ sid = 0;
+ cuser = null;
+ title = sprop.title; // Inherited attribute
+ known = null;
+ knowl = null; // Initialized when getting all Knowledge Elements
+ ucase = null;
+ kelms = new HashSet<KnowledgeElement>();
+
+ manager = sprop.manager;
+ // RKV: The business logic is moved to business services: if (!owner.isStaffedBy(manager)) throw new
+ // InvalidPropertyException("manager");
+
+ credate = sprop.date; // Inherited attribute
+ if (credate == null) {
+ Calendar current = Calendar.getInstance();
+ credate = current.getTime(); // Today
+ }
+ lasdate = credate; // Inherited attribute
+
+ if (sprop.summary != null)
+ this.setAttribute(new DescriptionAttribute(this, sprop.summary));
+
+ Scenario[] scene = owner.getScenarii();
+ for (int i = 0; i < scene.length; i++)
+ if (scene[i].sid > this.sid)
+ this.sid = scene[i].sid;
+ sid += 1;
+ }
+
+ // ==============================================================================================================================
+ // Public member functions
+ // ==============================================================================================================================
+
+ public List<KnowledgeElement> getAllKnowledgeElements() {
+ // --------------------------------------------------------
+ if (knowl == null) {
+ knowl = new Vector<KnowledgeElement>(kelms.size());
+ for (Iterator<KnowledgeElement> i = kelms.iterator(); i.hasNext();) {
+ KnowledgeElement kelm = i.next();
+ if (kelm.getType().equals("usecase"))
+ ucase = kelm;
+ else
+ knowl.add(kelm);
+ }
+ }
+ return Collections.unmodifiableList(knowl);
+ }
+
+ public KnowledgeElement getKnowledgeElement(long l) {
+ // -------------------------------------------------------
+ for (Iterator<KnowledgeElement> i = kelms.iterator(); i.hasNext();) {
+ KnowledgeElement mykelm = i.next();
+ if (mykelm.getIndex() == l)
+ return mykelm;
+ }
+ return null;
+ }
+
+ public List<KnowledgeElement> getKnowledgeElementsOf(
+ KnowledgeElementType type) {
+ // --------------------------------------------------------------------------------
+ if (kelms.isEmpty())
+ return new Vector<KnowledgeElement>(); // Smarter than returning null
+ if (known == null)
+ known = new HashMap<Long, List<KnowledgeElement>>();
+
+ long numtype = type.getIndex();
+ List<KnowledgeElement> listype = known.get(numtype);
+ if (listype == null) {
+ listype = new Vector<KnowledgeElement>();
+ for (Iterator<KnowledgeElement> i = kelms.iterator(); i.hasNext();) {
+ KnowledgeElement kelm = i.next();
+ if (kelm.getType().getIndex() == numtype)
+ listype.add(kelm);
+ }
+ known.put(numtype, listype);
+ }
+ return listype; // No protection against this object corruption as it would not corrupt the database
+ }
+
+ public Study getOwnerStudy() {
+ // -----------------------------
+ return owner;
+ }
+
+ /**
+ * Returns the local reference of this scenario. This reference is unique in the scope of the owner study.
+ */
+ public String getReference() {
+ // -----------------------------
+ return String.valueOf(sid);
+ }
+
+ public User getUser() {
+ return cuser; // Null if the scenario has not been checked-out
+ }
+
+ public void setUser(User aUser) {
+ cuser = aUser; // Null if the scenario has not been checked-out
+ }
+
+ public boolean isCheckedout() {
+ // ------------------------------
+ return (cuser != null);
+ }
+
+ // ==============================================================================================================================
+ // Private services
+ // ==============================================================================================================================
/**
* Get the persistent set of knowledge elements.
+ *
* @return the persistent set of scenario knowledge elements
*/
public Set<KnowledgeElement> getKnowledgeElements() {
return kelms;
}
- /**
+
+ /**
* Get the transient list of knowledge elements.
+ *
* @return the transient list of knowledge elements
*/
public List<KnowledgeElement> getKnowledgeElementsList() {
return knowl;
}
+
/**
* Set the scenario transient "use case" knowledge element.
- * @param kelm the scenario transient "use case" knowledge element
+ *
+ * @param kelm
+ * the scenario transient "use case" knowledge element
*/
public void setUcase(KnowledgeElement kelm) {
ucase = kelm;
}
+
/**
* Get the scenario transient "use case" knowledge element.
+ *
* @return the scenario transient "use case" knowledge element
*/
public KnowledgeElement getUcase() {
return ucase;
}
+
+ /**
+ * Get the known.
+ *
+ * @return the known
+ */
+ public HashMap<Long, List<KnowledgeElement>> getKnowledgeByType() {
+ return known;
+ }
}
\ No newline at end of file
*/
import java.io.Serializable;
-import java.util.List;
-
-import org.hibernate.Session;
import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.som.Database;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
private SimulationContextType type; // User extendable types
private int step;
private ProgressState state;
- private String value;
+ private String value;
private int counter;
private static final long serialVersionUID = 422889133378471949L;
// Public member functions
// ==============================================================================================================================
- public boolean approve () {
-// -------------------------
- if (state != ProgressState.inCHECK) return false;
- this.state = ProgressState.APPROVED; // The type name is supposed being localized
- Database.getSession().update(this);
- return true;
- }
-
public boolean equals (SimulationContext given) {
// -----------------------------------------------
if (isSaved()) return (this.getIndex() == given.getIndex());
return state;
}
+ /**
+ * Set the state.
+ * @param state the state to set
+ */
+ public void setProgressState(ProgressState state) {
+ this.state = state;
+ }
+
public SimulationContextType getType () {
// ---------------------------------------
return type;
import java.io.Serializable;
import org.splat.dal.bo.kernel.Persistent;
-import org.splat.dal.dao.som.Database;
import org.splat.kernel.InvalidPropertyException;
import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.technical.ProjectSettingsService.Step;
-import org.splat.service.technical.ProjectSettingsServiceImpl;
public class SimulationContextType extends Persistent implements Serializable {
// Persistent fields
private String name;
private ProgressState state;
- private int step;
+ private int step;
// Required by the serialization
private static final long serialVersionUID = 4819425038576161242L;
public ProjectSettingsService.Step getStep () {
return step;
}
- public Properties setState (ProgressState state) {
+ public Properties setProgressState (ProgressState state) {
this.state = state;
return this;
}
// Public member functions
// ==============================================================================================================================
- public boolean approve () {
-// -------------------------
- if (state != ProgressState.inCHECK) return false;
- this.state = ProgressState.APPROVED; // The type name is supposed being localized
- Database.getSession().update(this);
- return true;
- }
-
public boolean equals(Object entity) {
// ------------------------------------
if (entity == null) return false;
}
}
- public ProjectSettingsService.Step getAttachedStep () {
-// ----------------------------------------------
- return ProjectSettingsServiceImpl.getStep(step);
- }
-
public String getName () {
// ------------------------
return name;
// ----------------------------
return (state == ProgressState.APPROVED);
}
+ /**
+ * Get the state.
+ * @return the state
+ */
+ public ProgressState getState() {
+ return state;
+ }
+ /**
+ * Set the state.
+ * @param state the state to set
+ */
+ public void setState(ProgressState state) {
+ this.state = state;
+ }
+ /**
+ * Get the step.
+ * @return the step
+ */
+ public int getStep() {
+ return step;
+ }
+ /**
+ * Set the step.
+ * @param step the step to set
+ */
+ public void setStep(int step) {
+ this.step = step;
+ }
+
}
\ No newline at end of file
* @copyright OPEN CASCADE 2012
*/
-import java.util.List;
import java.util.Vector;
import org.splat.dal.bo.kernel.Persistent;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
-import org.splat.kernel.UserDirectory;
import org.splat.service.technical.ProjectSettingsServiceImpl;
public class ValidationCycle extends Persistent {
package org.splat.dal.dao.kernel;
+
/**
*
* @author Daniel Brunier-Coulin
*/
import org.hibernate.Session;
-import org.hibernate.SessionFactory;
+import org.splat.service.technical.IndexService;
+import org.splat.service.technical.RepositoryService;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.apache.log4j.Logger;
-
-public abstract class Database implements ApplicationContextAware {
+public abstract class Database extends HibernateDaoSupport implements
+ ApplicationContextAware {
/**
* The ApplicationContext.
/**
* Spring will call this method for initialize the applicationContext.
- * @param ctx the application context
- * @throws BeansException the BeanException
+ *
+ * @param ctx
+ * the application context
+ * @throws BeansException
+ * the BeanException
*/
- public void setApplicationContext(final ApplicationContext ctx) throws BeansException {
+ public void setApplicationContext(final ApplicationContext ctx)
+ throws BeansException {
_context = ctx;
}
/**
* Static for getting the context.
+ *
* @return ApplicationContext the application context
*/
public static ApplicationContext getContext() {
return _context;
}
-
-// private static String CONFIG_FILE = "/hibernate.cfg.xml";
- private static SessionFactory mySessionFactory = null;
- protected final static Logger logger = Logger.getLogger(Database.class);
-
-// ==============================================================================================================================
-// Public services
-// ==============================================================================================================================
+ // private static String CONFIG_FILE = "/hibernate.cfg.xml";
+ protected final static Logger logger = Logger.getLogger(Database.class);
- public static Session getSession () {
-// -----------------------------------
- return getInstance().getCurrentSession();
- }
-
-// ==============================================================================================================================
-// Protected services
-// ==============================================================================================================================
+ // ==============================================================================================================================
+ // Protected services
+ // ==============================================================================================================================
- protected String getSchemaVersion () {
-// ------------------------------------
- return null;//TODO: Get schema version into specific object/table: getIDPool().getSchemaVersion();
- }
+ protected String getSchemaVersion() {
+ // ------------------------------------
+ return null;// TODO: Get schema version into specific object/table: getIDPool().getSchemaVersion();
+ }
- protected void setSchemaVersion (String version) {
-// ------------------------------------------------
-//TODO: Set schema version into specific object/table: myIDpool = new IDPool(version);
-// getSession().save(myIDpool);
- }
+ protected void setSchemaVersion(String version) {
+ // ------------------------------------------------
+ // TODO: Set schema version into specific object/table: myIDpool = new IDPool(version);
+ // getSession().save(myIDpool);
+ }
-// ==============================================================================================================================
-// Private services
-// ==============================================================================================================================
-
- private static SessionFactory getInstance () {
-// --------------------------------------------
- if (mySessionFactory == null) {
-// org.hibernate.cfg.Configuration cfg = new org.hibernate.cfg.Configuration();
- try {
- mySessionFactory = getContext().getBean(SessionFactory.class);
-// cfg.configure(); // The configuration file (hibernate.cfg.xml)) is supposed to be on the classpath
-// mySessionFactory = cfg.buildSessionFactory();
- }
- catch (Exception error) {
- logger.fatal("Could not initialize the Hibernate configuration, reason:", error);
- }
- }
- return mySessionFactory;
- }
+ // ==============================================================================================================================
+ // Private services
+ // ==============================================================================================================================
+//{
+// if (myDB == null) {
+// myDB = new Database();
+// }
+// return myDB;
+// }
}
\ No newline at end of file
import java.io.Serializable;
import java.util.List;
+import java.util.Properties;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
*/
public T findByCriteria(Criterion aCondition);
+ /**
+ * Retrieve an object that was previously persisted to the database using the given criteria.
+ *
+ * @param andParams
+ * a properties values to filter with AND condition
+ * @return an object found according to the given criteria
+ */
+ public T findByCriteria(Properties andParams);
+
/**
* Retrieve a list of all objects of the considered type T which were previously persisted to the database.
*
* @return a list of all objects of the considered type T
*/
- @SuppressWarnings("unchecked")
public List<T> getAll();
/**
* a result list order. Null is ignored and in such case the result list is unordered.
* @return an ordered list of all objects of the considered type T
*/
- @SuppressWarnings("unchecked")
- public List<T> getAll(Order anOrder);
-
+ public List<T> getAll(Order... anOrder);
+
/**
* Retrieve a list of objects which were previously persisted to the database using the given criteria.
*
* @return a list of objects filtered according to the given criteria
*/
public List<T> getFilteredList(Criterion aCondition);
+
/**
* Retrieve a list of objects which were previously persisted to the database using the given criteria.
*
* a result list order. Null is ignored and in such case the result list is unordered.
* @return a list of objects filtered according to the given criteria
*/
- @SuppressWarnings("unchecked")
- public List<T> getFilteredList(Criterion aCondition, Order anOrder);
+ public List<T> getFilteredList(Criterion aCondition, Order... anOrder);
+
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param andParams
+ * a properties values to filter with AND condition
+ * @return a list of objects filtered according to the given criteria
+ */
+ public List<T> getFilteredList(Properties andParams);
+
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param andParams
+ * a properties values to filter with AND condition
+ * @param anOrder
+ * a result list order. Null is ignored and in such case the result list is unordered.
+ * @return a list of objects filtered according to the given criteria
+ */
+ public List<T> getFilteredList(Properties andParams, Order... anOrder);
/**
* Makes detached object persistent.
+ *
* @param transientObject
* transient instance of the object to be made persistent
*/
import java.io.Serializable;
import java.util.List;
+import java.util.Properties;
import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
.uniqueResult();
}
+ /**
+ * Retrieve an object that was previously persisted to the database using the given criteria.
+ *
+ * @param andParams
+ * a properties values to filter with AND condition
+ * @return an object found according to the given criteria
+ */
+ public T findByCriteria(Properties andParams) {
+ Criterion aCondition = null;
+ for (String aName: andParams.stringPropertyNames()) {
+ aCondition = Restrictions.and(aCondition, Restrictions.eq(aName, andParams.get(aName)));
+ }
+ return findByCriteria(aCondition);
+ }
+
/**
* Retrieve a list of all objects of the considered type T which were previously persisted to the database.
*
* @return an ordered list of all objects of the considered type T
*/
@SuppressWarnings("unchecked")
- public List<T> getAll(Order anOrder) {
+ public List<T> getAll(Order ... anOrder) {
Criteria aCriteria = getSession().createCriteria(getType());
- if (anOrder != null) {
- aCriteria.addOrder(anOrder);
+ for (Order order : anOrder) {
+ if (anOrder != null) {
+ aCriteria.addOrder(order);
+ }
}
return aCriteria.list();
}
* @return a list of objects filtered according to the given criteria
*/
@SuppressWarnings("unchecked")
- public List<T> getFilteredList(Criterion aCondition, Order anOrder) {
+ public List<T> getFilteredList(Criterion aCondition, Order ... anOrder) {
Criteria aCriteria = getSession().createCriteria(getType()).add(
aCondition);
- if (anOrder != null) {
- aCriteria.addOrder(anOrder);
+ for (Order order : anOrder) {
+ if (anOrder != null) {
+ aCriteria.addOrder(order);
+ }
}
return aCriteria.list();
}
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param andParams
+ * a properties values to filter with AND condition
+ * @return a list of objects filtered according to the given criteria
+ */
+ public List<T> getFilteredList(Properties andParams) {
+ return getFilteredList(andParams);
+ }
+
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param andParams
+ * a properties values to filter with AND condition
+ * @param anOrder
+ * a result list order. Null is ignored and in such case the result list is unordered.
+ * @return a list of objects filtered according to the given criteria
+ */
+ public List<T> getFilteredList(Properties andParams, Order ... anOrder) {
+ Criterion aCondition = null;
+ for (String aName: andParams.stringPropertyNames()) {
+ aCondition = Restrictions.and(aCondition, Restrictions.eq(aName, andParams.get(aName)));
+ }
+ return getFilteredList(aCondition, anOrder);
+ }
+
/**
* Save changes made to a persistent object.
*
* @copyright OPEN CASCADE 2012
*/
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
import java.util.Properties;
-import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
-import org.hibernate.Query;
import org.hibernate.Session;
-import org.hibernate.SessionFactory;
import org.hibernate.jdbc.Work;
import org.apache.log4j.Logger;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.bo.som.IDBuilder;
-import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.bo.som.SimulationContext;
-import org.splat.dal.bo.som.SimulationContextType;
-import org.splat.kernel.UserDirectory;
-import org.splat.kernel.InvalidPropertyException;
+import org.splat.service.UserService;
import org.splat.service.technical.IndexService;
import org.splat.service.technical.RepositoryService;
+import org.springframework.transaction.annotation.Transactional;
public class Database extends org.splat.dal.dao.kernel.Database {
private int uplevel = 0; // Level of database upgrade
private RepositoryService _repositoryService;
private IndexService _indexService;
- private SessionFactory _sessionFactory;
+ private UserService _userService;
+
private static Database my = null; // Singleton instance
// Construction
// ==============================================================================================================================
- public Database getMe() {
+ private static Database myDB;
+
+ public static Database getInstance() {
+ if (myDB == null) {
+ myDB = new Database();
+ }
+ return myDB;
+ }
+
+ public static Session getCurSession() {
+ // -----------------------------------
+ return getInstance().getSession();
+ }
+
+ public Database getCheckedDB() {
// -------------------------------
if (my == null)
try {
/**
* Check version of the database schema.
*/
+ @Transactional(readOnly=true)
private void checkVersion() {
- getSessionFactory().getCurrentSession().doWork(new CheckVersion());
+ getSession().doWork(new CheckVersion());
}
// ==============================================================================================================================
getIndexService().create(); // May throw IOException if the index repository is improperly configured
// Creation of the SIMER SQL tables
- Session session = Database.getSession();
// Population of the database with customized data
this.populate();
- session.flush();
uplevel = 0; // The database is now up-to-date
}
"label.sysadmin").addRole("sysadmin").setMailAddress(
"noreply@salome-platform.org");
uprop.disableCheck();
- UserDirectory.createUser(uprop);
+ getUserService().createUser(uprop);
} catch (Exception e) {
// Let's continue, hoping the best...
}
}
/**
- * Get the sessionFactory.
- *
- * @return the sessionFactory
+ * Get the userService.
+ * @return the userService
*/
- public SessionFactory getSessionFactory() {
- return _sessionFactory;
+ public UserService getUserService() {
+ return _userService;
}
/**
- * Set the sessionFactory.
- *
- * @param sessionFactory
- * the sessionFactory to set
+ * Set the userService.
+ * @param userService the userService to set
*/
- public void setSessionFactory(SessionFactory sessionFactory) {
- _sessionFactory = sessionFactory;
+ public void setUserService(UserService userService) {
+ _userService = userService;
}
}
\ No newline at end of file
import org.apache.log4j.Logger;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.kernel.Database;
+import org.splat.service.ServiceLocatorImpl;
public class RealmLoginModule implements LoginModule {
// sharedState = state;
// options = opts;
// debug = "true".equalsIgnoreCase((String)options.get("debug"));
- logger = Logger.getLogger(Database.class);
+ logger = Logger.getLogger(RealmLoginModule.class);
}
// ==============================================================================================================================
}
// Authentication
- User found = UserDirectory.selectUser(username, password);
+ User found = ServiceLocatorImpl.getInstance().getUserService().selectUser(username, password);
if (found != null) {
identity = found;
succeeded = true;
Calendar today = java.util.Calendar.getInstance();
Date datime = today.getTime();
- logger.info("RKV:Connection of " + identity.toString() + " " + datime.toString() + ".");
+ logger.info("Connection of " + identity.toString() + " " + datime.toString() + ".");
return true;
} else {
identity = null;
succeeded = false;
- found = UserDirectory.selectUser(username);
+ found = ServiceLocatorImpl.getInstance().getUserService().selectUser(username);
String reason = "password";
if (found == null) reason = "username";
logger.info("Connection attempt as " + username + ".");
+++ /dev/null
-package org.splat.kernel;
-/**
- * Very minimal implementation of the user directory of a company department.<br/>
- * This directory can include members of the department, the two level hierarchy of these members (their n+1 and n+2 managers),
- * and all customers of the department.<br/>
- * The department hierarchy is defined through a hard-coded combination of user role and organization names (see the getManagerOf
- * function of this class). It is useful for implementing an application workflow requiring such informmation (the n+1 and n+2
- * managers are usually involved in the validation process).<br/>
- * <br/>
- * When needed, a full implementation of the company organization can be adjoin to this class by using user organization names
- * as reference to departments into this organization. In this context, the function getManagerOf(user) of this class will be
- * ineffective (it will return null).
- *
- * @author Daniel Brunier-Coulin
- * @copyright OPEN CASCADE 2012
- */
-
-import java.io.IOException;
-import java.io.File;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.hibernate.Session;
-import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
-import org.splat.manox.XDOM;
-import org.splat.manox.XMLException;
-import org.w3c.dom.Node;
-import org.apache.log4j.Logger;
-
-
-public class UserDirectory {
-
- final static Logger logger = Logger.getLogger(UserDirectory.class);
-
-// ==============================================================================================================================
-// Public services
-// ==============================================================================================================================
-
- public static User createUser (User.Properties uprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException, RuntimeException {
-// -----------------------------------------------------
- User nuser = new User(uprop);
- Session session = Database.getSession();
- session.save(nuser);
-
- return nuser;
- }
-
- @SuppressWarnings("unchecked") // For the casting List<String>
- public static Set<User> importUsers (File xfile) throws XMLException, MismatchException, RuntimeException {
-// ------------------------------------------------
- String[] name = xfile.getName().split("\\x2E"); // Split by '.' (period) character
- String fext = name[name.length-1];
- Session session = Database.getSession();
-
- if (!fext.equals("xml")) throw new MismatchException("filetype");
- try {
- DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
- org.w3c.dom.Document inDoc = dBuilder.parse(xfile);
- String xtag = inDoc.getDocumentElement().getNodeName();
- if (!xtag.equals("users")) throw new MismatchException("filetype");
- org.w3c.dom.NodeList ulist = inDoc.getElementsByTagName("user");
-
- List<String> result = (List<String>)session.createSQLQuery("SELECT * FROM users").addScalar("username").list();
- HashSet<String> members = new HashSet<String>();
- HashSet<User> imported = new HashSet<User>();
- for (Iterator<String> i=result.iterator(); i.hasNext();) members.add(i.next());
-
- for (int i=0; i<ulist.getLength(); i++) {
- HashMap<String, Node> row = XDOM.getNamedChildNodes(ulist.item(i));
- User.Properties uprop = new User.Properties();
-
-// Mandatory properties
- String uname = row.get("username").getTextContent();
- if (members.contains(uname)) continue; // This user already exists
- uprop.setUsername(uname)
- .setFirstName(row.get("first").getTextContent())
- .setName(row.get("last").getTextContent())
- .setMailAddress(row.get("mail").getTextContent())
- .addRole(row.get("role").getTextContent()); // Add all roles at a time
-
-// Optional properties
- org.w3c.dom.Node node = row.get("password");
- if (node != null) {
- uprop.setPassword(node.getTextContent());
- }
- node = row.get("display");
- if (node != null) {
- uprop.setDisplayName(node.getTextContent());
- }
- node = row.get("organization");
- if (node != null) {
- uprop.setOrganizationName(node.getTextContent());
- }
-// Addition of the user
- uprop.disableCheck(); // Existent user already checked above
- User newser = new User(uprop);
- session.save(newser);
- imported.add(newser);
- }
- return imported;
- }
- catch (IOException error) {
- throw new XMLException("XML users file not found");
- }
- catch (ParserConfigurationException e) {
- throw new XMLException("XML Organization parser not accessible");
- }
- catch (Exception e) {
- throw new XMLException("XML users file not valid");
- }
- }
-
-/**
- * Returns the manager of the given user.
- * This function is effective providing that users are defined according to the following conventions:
- * <ul>
- * <li>One user is assigned in the organization as Nx1 (n+1 manager of members of the organization)</li>
- * <li>Another user is assigned in the organization as Nx2 (n+2 manager of members of the organization)</li>
- * </ul>
- * If such users do not exit, null is returned.
- *
- * @param user the user whose manager is get
- * @return the manager of the given user, if defined
- */
- public static User getManagerOf (User user) {
-// -------------------------------------------
- User result = null;
- String orgname = user.getOrganizationName();
-
- if (orgname.equals("Nx2")) return result;
- if (orgname.equals("Nx1")) orgname = "Nx2";
- else {
- if (user.getRoleNames().equals("customer")) return result;
- orgname = "Nx1";
- }
- try {
- User.Properties uprop = new User.Properties();
- List<User> ulist = UserDirectory.selectUsersWhere(uprop.setOrganizationName(orgname));
- return ulist.get(0); // n+1 and n+2 managers are unique
- }
- catch (Exception e) {
- return null;
- }
- }
-
- @SuppressWarnings("unchecked") // For the casting List<User>
- public static List<User> selectAllUsers () {
-// ------------------------------------------
- String query = "FROM User order by last asc, first asc";
- return (List<User>)Database.getSession().createQuery(query).list();
- }
-
- public static User selectUser (String username) {
-// -----------------------------------------------
- StringBuffer query = new StringBuffer("FROM User where username='").append(username).append("'");
- return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
- }
-
- public static User selectUser (String username, String password) {
-// ----------------------------------------------------------------
-//WARNING: For not encoding the password here, we better call a selectUsersWhere(User.Properties),
-// but this requires a getPassword in User.Properties nested class.
- StringBuffer query = new StringBuffer("FROM User where username='").append(username).append("' and password");
- if (password == null) query = query.append(" is null");
- else query = query.append("='").append(String.valueOf(password.hashCode())).append("'");
-
- return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
- }
-
- public static User selectUser (int index) {
-// -----------------------------------------
- StringBuffer query = new StringBuffer("FROM User where rid='").append(index).append("'");
- return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
- }
-
- @SuppressWarnings("unchecked")
- public static List<User> selectUsersWhere (User.Properties... uprop) {
-// --------------------------------------------------------------------
- StringBuffer query = new StringBuffer("FROM User");
- String separator = " where (";
- String value;
-
- for (int i=0; i<uprop.length; i++) {
-
- value = uprop[i].getOrganizationName();
- if (value != null) {
- query = query.append(separator).append(" organid='").append(value).append("'");
-// separator = " and";
- }
- separator = ") or (";
- }
- query.append(")");
- return (List<User>)Database.getSession().createQuery(query.toString()).list();
- }
-}
\ No newline at end of file
import org.splat.service.technical.ProjectSettingsService;
import org.splat.som.Revision;
import org.splat.som.Step;
+import org.springframework.transaction.annotation.Transactional;
/**
* Document service interface.
*/
public interface DocumentService {
+ /**
+ * Get document by its path.
+ *
+ * @param path
+ * the document path
+ * @return the document if found or null
+ */
+ public Document getDocumentByPath(String path);
+
/**
* Defines this document.
*
*/
public void rename(Document aDoc, String title)
throws InvalidPropertyException;
-
+
/**
* Update a version of the given document.
*
* the new version
*/
public void updateAs(Document aDoc, Revision newvers);
-
+
/**
* Update a state of the given document.
*
import java.util.Iterator;
import java.util.List;
-import org.hibernate.Hibernate;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.splat.dal.bo.kernel.Relation;
import org.splat.dal.dao.som.FileDAO;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
-import org.splat.kernel.MultiplyDefinedException;
import org.splat.kernel.NotApplicableException;
import org.splat.manox.Reader;
import org.splat.manox.Toolbox;
String path = owner.getReference();
ProjectSettingsService.Step step = ProjectSettingsServiceImpl
.getStep(aDoc.getStep());
- aDoc.setDid(new StringBuffer(path).append(".%").append(
- Document.suformat).toString()); // Document reference
+ aDoc.setDid(new StringBuffer(path).append(".%")
+ .append(Document.suformat).toString()); // Document reference
path = new StringBuffer(year).append("/").append(path).append("/")
.append(step.getPath())
// File path relative to the repository vault
int number = getStudyService().generateLocalIndex(scope);
if (scheme == FileNaming.encoded) {
- encoding.append(scope.getReference()).append(".").append(
- tostring.format(number));
+ encoding.append(scope.getReference()).append(".")
+ .append(tostring.format(number));
} else { // title and (temporarily) asis
- encoding.append(aDoc.getTitle()).append(".").append(
- tostring.format(number));
+ encoding.append(aDoc.getTitle()).append(".")
+ .append(tostring.format(number));
}
return encoding.toString();
}
// }
aDoc.setTitle(dprop.getName());
aDoc.getFile().changePath(
- aDoc.getFile().getRelativePath().replace("%n",
- getEncodedRootName(aDoc, (Study) dprop.getOwner())));
+ aDoc.getFile()
+ .getRelativePath()
+ .replace(
+ "%n",
+ getEncodedRootName(aDoc,
+ (Study) dprop.getOwner())));
if (aDoc.getHistory() == -1)
aDoc.setHistory(0);
if (dprop.getDate() == null) {
return (aType.isResultOf(lastep));
}
+ /**
+ * Get document by its path.
+ * @param path the document path
+ * @return the document if found or null
+ */
+ @Transactional(readOnly=true)
+ public Document getDocumentByPath(String path) {
+ String[] parse = path.split("'");
+
+ path = parse[0];
+ for (int i = 1; i < parse.length; i++) {
+ path = path + "''" + parse[i];
+ }
+ Criterion aCondition = Restrictions.eq("path", path);
+ return getDocumentDAO().findByCriteria(aCondition);
+ }
+
/**
* Get the studyService.
*
/**
* Document type service interface.
- *
+ *
* @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
public interface DocumentTypeService {
* @return the list of found document types
*/
public List<DocumentType> selectTypesOf(ProjectSettingsService.Step step);
+
+ /**
+ * Approve the document type.
+ *
+ * @param aType
+ * the document type to approve
+ * @return true if approval succeeded
+ */
+ public boolean approve(DocumentType aType);
}
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.dao.som.Database;
import org.splat.dal.dao.som.DocumentTypeDAO;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
*
* @return the list of all document types
*/
- @Transactional(readOnly = true)
+// @Transactional(readOnly = true)
+ @Transactional
public List<DocumentType> selectAllTypes() {
List<DocumentType> types = getDocumentTypeDAO().getAll();
for (Iterator<DocumentType> i = types.iterator(); i.hasNext();) {
return types;
}
+ /**
+ * Approve the document type.
+ * @param aType the document type to approve
+ * @return true if approval succeeded
+ */
+ @Transactional
+ public boolean approve (DocumentType aType) {
+ if (aType.getState() != ProgressState.inCHECK) return false;
+ aType.setState(ProgressState.APPROVED); // The type name is supposed being localized
+ getDocumentTypeDAO().update(aType);
+ return true;
+ }
+
/**
* Get the documentTypeDAO.
*
* @return the found knowledge type
*/
public KnowledgeElementType selectType(long index);
+
+ /**
+ * Approve the knowledge type.
+ *
+ * @param kelt
+ * the knowledge type to approve
+ * @return true if approval succeeded
+ */
+ public boolean approve(KnowledgeElementType kelt);
+
+ /**
+ * Reserves this type for the management of simulation contexts. For being able to get the studies in which simulation contexts are
+ * used, all study scenarios are indexed through this knowledge element type, whether they include knowledge elements or not.
+ *
+ * @param kelt
+ * the knowledge type to approve
+ * @return true if approval succeeded
+ */
+ public boolean reserve(KnowledgeElementType kelt);
}
* @copyright OPEN CASCADE 2012
*****************************************************************************/
-package org.splat.service;
+package org.splat.service;
import java.util.List;
import org.splat.dal.bo.som.KnowledgeElementType;
import org.splat.dal.bo.som.ProgressState;
import org.splat.dal.dao.som.KnowledgeElementTypeDAO;
+import org.springframework.transaction.annotation.Transactional;
/**
* KnowledgeElementTypeService implementation for working with knowledge types.
- *
+ *
* @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
public class KnowledgeElementTypeServiceImpl implements
return getKnowledgeElementTypeDAO().get(index);
}
+ /**
+ * Approve the knowledge type.
+ *
+ * @param kelt
+ * the knowledge type to approve
+ * @return true if approval succeeded
+ */
+ @Transactional
+ public boolean approve(KnowledgeElementType kelt) {
+ if (kelt.getState() != ProgressState.inCHECK)
+ return false;
+ kelt.setState(ProgressState.APPROVED); // The type name is supposed being localized
+ if (kelt.isSaved()) {
+ getKnowledgeElementTypeDAO().update(kelt);
+ }
+ return true;
+ }
+
+ /**
+ * Reserves this type for the management of simulation contexts. For being able to get the studies in which simulation contexts are
+ * used, all study scenarios are indexed through this knowledge element type, whether they include knowledge elements or not.
+ *
+ * @param kelt
+ * the knowledge type to approve
+ * @return true if approval succeeded
+ */
+ @Transactional
+ public boolean reserve(KnowledgeElementType kelt) {
+ if (kelt.getState() != ProgressState.inCHECK)
+ return false;
+ kelt.setState(ProgressState.inWORK);
+ if (kelt.isSaved()) {
+ getKnowledgeElementTypeDAO().update(kelt);
+ }
+ return true;
+ }
+
/**
* Get the knowledgeElementTypeDAO.
*
import org.splat.dal.bo.som.ProjectElement;
import org.splat.som.Step;
+import org.springframework.transaction.annotation.Transactional;
/**
* Project element service interface.
+ *
* @author RKV
*
*/
/**
* Get the first activity of the project element.
- * @param elem a study or a scenario
+ *
+ * @param elem
+ * a study or a scenario
* @return the first activity (step) of the project element
*/
public Step getFirstStep(ProjectElement elem);
/**
* Get activities of the project element.
- * @param elem a study or a scenario
+ *
+ * @param elem
+ * a study or a scenario
* @return array of activities (steps).
*/
public Step[] getSteps(ProjectElement elem);
+
+ /**
+ * Refreshes the internal data potentially out-of-date. This function needs to be called when Publication objects are added to this
+ * Project Element before being saved. The reason is, as saving a persistent object changes its hashcode, hashed data need to be rebuilt
+ * after saving for making functions based on this hashcode such as remove(), working.
+ *
+ * @param elem
+ * the project element to refresh
+ */
+ public void refresh(ProjectElement elem);
}
import java.util.List;
import org.splat.dal.bo.som.ProjectElement;
+import org.splat.dal.bo.som.Publication;
+import org.splat.dal.dao.som.Database;
+import org.splat.dal.dao.som.ProjectElementDAO;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.som.Step;
+import org.springframework.transaction.annotation.Transactional;
/**
* Project element service implementation.
+ *
* @author RKV
*
*/
* Injected project settings service.
*/
private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected project element DAO.
+ */
+ private ProjectElementDAO _projectElementDAO;
- /**
+ /**
* {@inheritDoc}
+ *
* @see org.splat.service.ProjectElementService#getFirstStep(org.splat.dal.bo.som.ProjectElement)
*/
public Step getFirstStep(ProjectElement elem) {
return mystep[mystep.length - 1];
}
- /**
+ /**
* {@inheritDoc}
+ *
* @see org.splat.service.ProjectElementService#getSteps(org.splat.dal.bo.som.ProjectElement)
*/
public Step[] getSteps(ProjectElement elem) {
return elem.getFolders(); // No protection against this object corruption as it would not corrupt the database
}
+ /**
+ * Refreshes the internal data potentially out-of-date. This function needs to be called when Publication objects are added to this
+ * Project Element before being saved. The reason is, as saving a persistent object changes its hashcode, hashed data need to be rebuilt
+ * after saving for making functions based on this hashcode such as remove(), working.
+ * @param elem the project element to refresh
+ */
+ @Transactional
+ public void refresh(ProjectElement elem) {
+ // -------------------------
+ Publication[] curdoc = elem.getDocums().toArray(
+ new Publication[elem.getDocums().size()]);
+
+ elem.setFolders(null); // Just in case
+ elem.getDocums().clear();
+ for (int i = 0; i < curdoc.length; i++)
+ elem.getDocums().add(curdoc[i]);
+ // No need to rebuild the list of SimulationContext as it does not use hashcodes
+ getProjectElementDAO().update(elem);
+ }
+
/**
* Get project settings.
*
public void setProjectSettings(ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
+
+ /**
+ * Get the projectElementDAO.
+ * @return the projectElementDAO
+ */
+ public ProjectElementDAO getProjectElementDAO() {
+ return _projectElementDAO;
+ }
+
+ /**
+ * Set the projectElementDAO.
+ * @param projectElementDAO the projectElementDAO to set
+ */
+ public void setProjectElementDAO(ProjectElementDAO projectElementDAO) {
+ _projectElementDAO = projectElementDAO;
+ }
}
/**
* 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
*/
public ConvertsRelation attach(Publication aPublication, String format,
String description);
+
+ /**
+ * Undo the out-date operation.
+ *
+ * @param aPublication
+ * the publication
+ * @return true if the acceptance succeeds
+ * @see #outdate()
+ * @see DocumentRights#canAccept()
+ */
+ public boolean actualize(Publication aPublication);
+
+ /**
+ * Out-dates this publication and recursively all publications using this one. Typically, a publication is out-dated when modifying a
+ * document to which it depends.
+ *
+ * @param aPublication
+ * the publication
+ * @see #isOutdated()
+ * @see #getProgressState()
+ * @see #actualize()
+ */
+ public void outdate(Publication aPublication);
}
import org.splat.dal.bo.som.SimulationContextType;
import org.splat.dal.bo.som.Study;
import org.splat.dal.bo.som.Timestamp;
+import org.splat.dal.bo.som.UsedByRelation;
import org.splat.dal.bo.som.ValidationCycle;
import org.splat.dal.bo.som.ValidationStep;
+import org.splat.dal.dao.som.Database;
import org.splat.dal.dao.som.ProjectElementDAO;
import org.splat.dal.dao.som.PublicationDAO;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.NotApplicableException;
import org.splat.manox.Reader;
import org.splat.manox.Toolbox;
+import org.splat.som.DocumentRights;
import org.splat.som.Revision;
import org.splat.som.Step;
import org.springframework.transaction.annotation.Transactional;
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)
return; // No properties extractor available for this type of document
SimulationContextType.Properties sprop = new SimulationContextType.Properties()
- .setStep(to.getStep()).setState(ProgressState.APPROVED);
+ .setStep(to.getStep()).setProgressState(ProgressState.APPROVED);
List<SimulationContextType> contype = getSimulationContextService()
.selectTypesWhere(sprop);
if (contype.isEmpty())
return aPublication.getStep();
}
+ /**
+ * Undo the out-date operation.
+ *
+ * @param aPublication
+ * the publication
+ * @return true if the acceptance succeeds
+ * @see #outdate()
+ * @see DocumentRights#canAccept()
+ */
+ public boolean actualize(Publication aPublication) {
+ if (!aPublication.isOutdated())
+ return false;
+ aPublication.setIsnew('Y');
+ getPublicationDAO().update(aPublication);
+ return true;
+ }
+
+ /**
+ * Out-dates this publication and recursively all publications using this one. Typically, a publication is out-dated when modifying a
+ * document to which it depends.
+ *
+ * @param aPublication
+ * the publication
+ * @see #isOutdated()
+ * @see #getProgressState()
+ * @see #actualize()
+ */
+ public void outdate(Publication aPublication) {
+ if (aPublication.isOutdated())
+ return;
+
+ List<Publication> relist = aPublication
+ .getRelations(UsedByRelation.class);
+ for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
+ outdate(i.next());
+ }
+ aPublication.setIsnew('O');
+ getPublicationDAO().update(aPublication);
+ }
+
/**
* Create "Converts" relation for the given document publication and format.
*
* @return true if the scenario is empty
*/
public boolean isEmpty(Scenario scenario);
+
+ /**
+ * Remove a knowledge element from a scenario.
+ *
+ * @param scenario
+ * the scenario
+ * @param kelm
+ * the knowledge element to remove
+ * @return true if removal succeeded
+ */
+ public boolean removeKnowledgeElement(Scenario scenario,
+ KnowledgeElement kelm);
}
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
-import org.splat.kernel.UserDirectory;
import org.splat.service.technical.IndexService;
import org.splat.som.Step;
import org.springframework.transaction.annotation.Transactional;
*/
private KnowledgeElementTypeService _knowledgeElementTypeService;
+ /**
+ * Injected user service.
+ */
+ private UserService _userService;
+
/**
* Get the projectElementService.
*
update(aScenario);
} catch (IOException error) {
- logger.error("Unable to index the knowedge element '"
- + kelm.getIndex() + "', reason:", error);
+ logger.error(
+ "Unable to index the knowedge element '" + kelm.getIndex()
+ + "', reason:", error);
kelm = null;
}
getScenarioDAO().create(scenario); // Must be done after updating this study because of the back reference to the study
if (sprop.getBaseStep() != null) {
// No need to update the Knowledge Element index as Knowledge Elements are not copied
- scenario.refresh(); // Because saving the scenario changes the hashcode of copied Publications
+ getProjectElementService().refresh(scenario); // Because saving the scenario changes the hashcode of copied Publications
}
- KnowledgeElementType ucase = getKnowledgeElementTypeService().selectType(
- "usecase");
+ KnowledgeElementType ucase = getKnowledgeElementTypeService()
+ .selectType("usecase");
KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
- User admin = UserDirectory.selectUser(1); // First user created when creating the database
- kprop.setType(ucase).setTitle(aStudy.getTitle()).setValue(
- scenario.getTitle()).setAuthor(admin); // Internal Knowledge Element required by the validation process of
+ User admin = getUserService().selectUser(1); // First user created when creating the database
+ kprop.setType(ucase).setTitle(aStudy.getTitle())
+ .setValue(scenario.getTitle()).setAuthor(admin); // Internal Knowledge Element required by the validation process of
// knowledges
addKnowledgeElement(scenario, kprop);
return scenario;
}
+ /**
+ * Remove a knowledge element from a scenario.
+ *
+ * @param scenario
+ * the scenario
+ * @param kelm
+ * the knowledge element to remove
+ * @return true if removal succeeded
+ */
+ public boolean removeKnowledgeElement(Scenario scenario,
+ KnowledgeElement kelm) {
+ // -------------------------------------------------------------
+ KnowledgeElement torem = scenario.getKnowledgeElement(kelm.getIndex());
+ if (torem == null)
+ return false;
+ boolean done = scenario.getKnowledgeElements().remove(torem);
+ if (done) {
+ // Update of my transient data
+ List<KnowledgeElement> kelms = scenario.getKnowledgeByType().get(
+ kelm.getType().getIndex());
+ kelms.remove(torem);
+ if (scenario.getKnowledgeElementsList() != null)
+ scenario.getKnowledgeElementsList().remove(torem);
+ getScenarioDAO().update(scenario);
+ // TODO: If the owner study is not private, remove the knowledge from the Lucene index
+ return true;
+ } else {
+ return false;
+ }
+ }
+
/**
* Get the knowledgeElementDAO.
*
/**
* Get the studyService.
+ *
* @return the studyService
*/
public StudyService getStudyService() {
/**
* Set the studyService.
- * @param studyService the studyService to set
+ *
+ * @param studyService
+ * the studyService to set
*/
public void setStudyService(StudyService studyService) {
_studyService = studyService;
}
+ /**
+ * Get the userService.
+ * @return the userService
+ */
+ public UserService getUserService() {
+ return _userService;
+ }
+
+ /**
+ * Set the userService.
+ * @param userService the userService to set
+ */
+ public void setUserService(UserService userService) {
+ _userService = userService;
+ }
+
}
* @copyright OPEN CASCADE 2012
*****************************************************************************/
-package org.splat.service;
+package org.splat.service;
/**
* The service locator interface.
- *
+ *
* @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
@Deprecated
public interface ServiceLocator {
/**
* Get study service.
+ *
* @return study service
*/
StudyService getStudyService();
+
+ /**
+ * Set the studyService.
+ *
+ * @param studyService
+ * the studyService to set
+ */
+ public void setStudyService(StudyService studyService);
+
+ /**
+ * Get the userService.
+ *
+ * @return the userService
+ */
+ public UserService getUserService();
+
+ /**
+ * Set the userService.
+ *
+ * @param userService
+ * the userService to set
+ */
+ public void setUserService(UserService userService);
}
* Injected study service.
*/
private StudyService _studyService;
+ /**
+ * Injected user service.
+ */
+ private UserService _userService;
/**
* Get the studyService.
public void setStudyService(StudyService studyService) {
_studyService = studyService;
}
+
+ /**
+ * Get the userService.
+ * @return the userService
+ */
+ public UserService getUserService() {
+ return _userService;
+ }
+
+ /**
+ * Set the userService.
+ * @param userService the userService to set
+ */
+ public void setUserService(UserService userService) {
+ _userService = userService;
+ }
}
/**
* Get simulation context types by example.
- * @param sprop the example
+ *
+ * @param sprop
+ * the example
* @return list of found context types
*/
public List<SimulationContextType> selectTypesWhere(
/**
* Get a simulation context type by its name.
- * @param name name of the context type
+ *
+ * @param name
+ * name of the context type
* @return found context type
*/
public SimulationContextType selectType(String name);
*/
List<SimulationContext> getSimulationContextList();
+ /**
+ * Approve the simulation context type.
+ *
+ * @param simCtxType
+ * the type to approve
+ * @return true if approval succeeded
+ */
+ public boolean approve(SimulationContextType simCtxType);
+
+ /**
+ * @param simCtxType
+ * @return
+ */
+ public ProjectSettingsService.Step getAttachedStep(
+ SimulationContextType simCtxType);
}
import org.splat.dal.bo.som.ProgressState;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.dao.som.SimulationContextDAO;
import org.splat.dal.dao.som.SimulationContextTypeDAO;
import org.splat.kernel.InvalidPropertyException;
import org.splat.log.AppLogger;
import org.splat.service.technical.ProjectSettingsService;
+import org.splat.service.technical.ProjectSettingsServiceImpl;
import org.springframework.transaction.annotation.Transactional;
/**
// .append("'");
// separator = " and";
- aCondition = Restrictions.and(aCondition, Restrictions.eq("value",
- value));
+ aCondition = Restrictions.and(aCondition,
+ Restrictions.eq("value", value));
}
if (state != null) {
// query = query.append(separator).append(" state='").append(state)
// order = " order by type asc";
anOrder = Order.asc("type");
}
- aCondition = Restrictions.and(aCondition, Restrictions.eq("state",
- state));
+ aCondition = Restrictions.and(aCondition,
+ Restrictions.eq("state", state));
}
// query.append(order);
// return (List<SimulationContext>) Database.getSession().createQuery(
*
* @see org.splat.service.SimulationContextService#selectAllTypes()
*/
- @SuppressWarnings("unchecked")
public List<SimulationContextType> selectAllTypes() {
// Useless to order by names as the result mixes localized
// and non localized types
- return getSimulationContextTypeDAO().getFilteredList(null,
- Order.asc("step"));
+ return getSimulationContextTypeDAO().getAll(Order.asc("step"));
}
/**
*
* @see org.splat.service.SimulationContextService#selectTypesOf(org.splat.service.technical.ProjectSettingsService.Step[])
*/
- @SuppressWarnings("unchecked")
public List<SimulationContextType> selectTypesOf(
ProjectSettingsService.Step... step) {
- // --------------------------------------------------------------------------------------
- StringBuffer query = new StringBuffer(
- "from SimulationContextType where step='").append(
- step[0].getNumber()).append("'");
+ // StringBuffer query = new StringBuffer(
+ // "from SimulationContextType where step='").append(
+ // step[0].getNumber()).append("'");
+ // for (int i = 1; i < step.length; i++) { // Useless to order as the result mixes localized and non localized types
+ // query = query.append(" or step='").append(step[i].getNumber())
+ // .append("'");
+ // }
+ // query = query.append(" order by step asc");
+ Criterion aCondition = Restrictions.eq("step", step[0].getNumber());
for (int i = 1; i < step.length; i++) { // Useless to order as the result mixes localized and non localized types
- query = query.append(" or step='").append(step[i].getNumber())
- .append("'");
+ aCondition = Restrictions.or(aCondition,
+ Restrictions.eq("step", step[i].getNumber()));
}
- query = query.append(" order by step asc");
- return Database.getSession().createQuery(query.toString()).list();
+ return getSimulationContextTypeDAO().getFilteredList(aCondition,
+ Order.asc("step"));
}
/**
*
* @see org.splat.service.SimulationContextService#selectTypesWhere(org.splat.dal.bo.som.SimulationContextType.Properties)
*/
- @SuppressWarnings("unchecked")
public List<SimulationContextType> selectTypesWhere(
SimulationContextType.Properties sprop) {
- StringBuffer query = new StringBuffer("from SimulationContextType");
- String separator = " where";
+ // StringBuffer query = new StringBuffer("from SimulationContextType");
+ // String separator = " where";
ProjectSettingsService.Step step = sprop.getStep();
ProgressState state = sprop.getProgressState();
- String order = " order by step asc";
-
+ // String order = " order by step asc";
+ //
+ // if (step != null) {
+ // query = query.append(separator).append(" step='")
+ // .append(step.getNumber()).append("'");
+ // separator = " and";
+ // order = " order by state desc"; // APPROVED (upper case A) is grater than inCHECK (lower case i)
+ // }
+ // if (state != null) {
+ // query = query.append(separator).append(" state='")
+ // .append(state.toString()).append("'");
+ // // separator = " and";
+ // if (step != null) {
+ // if (state != ProgressState.APPROVED)
+ // order = " order by name asc";
+ // else
+ // order = ""; // Approved types are localized
+ // }
+ // }
+ // query = query.append(order);
+ Criterion aCondition = null;
+ Order anOrder = Order.asc("step");
if (step != null) {
- query = query.append(separator).append(" step='").append(
- step.getNumber()).append("'");
- separator = " and";
- order = " order by state desc"; // APPROVED (upper case A) is grater than inCHECK (lower case i)
+ aCondition = Restrictions.eq("step", step.getNumber());
+ anOrder = Order.desc("state"); // APPROVED (upper case A) is grater than inCHECK (lower case i)
}
if (state != null) {
- query = query.append(separator).append(" state='").append(
- state.toString()).append("'");
- // separator = " and";
+ aCondition = Restrictions.and(aCondition,
+ Restrictions.eq("state", state));
if (step != null) {
- if (state != ProgressState.APPROVED)
- order = " order by name asc";
- else
- order = ""; // Approved types are localized
+ if (state != ProgressState.APPROVED) {
+ anOrder = Order.asc("name");
+ } else {
+ anOrder = null; // Approved types are localized
+ }
}
}
- query = query.append(order);
- return Database.getSession().createQuery(query.toString()).list();
+ return getSimulationContextTypeDAO().getFilteredList(aCondition,
+ anOrder);
}
/**
}
}
+ /**
+ * Approve the simulation context.
+ *
+ * @param simCtx
+ * the context to approve
+ * @return true if approval succeeded
+ */
+ public boolean approve(SimulationContext simCtx) {
+ if (simCtx.getProgressState() != ProgressState.inCHECK)
+ return false;
+ simCtx.setProgressState(ProgressState.APPROVED); // The type name is supposed being localized
+ if (simCtx.isSaved()) {
+ getSimulationContextDAO().update(simCtx);
+ }
+ return true;
+ }
+
+ /**
+ * Approve the simulation context type.
+ *
+ * @param simCtxType
+ * the type to approve
+ * @return true if approval succeeded
+ */
+ public boolean approve(SimulationContextType simCtxType) {
+ if (simCtxType.getState() != ProgressState.inCHECK)
+ return false;
+ simCtxType.setState(ProgressState.APPROVED); // The type name is supposed being localized
+ getSimulationContextTypeDAO().update(simCtxType);
+ return true;
+ }
+
+ /**
+ * @param simCtxType
+ * @return
+ */
+ public ProjectSettingsService.Step getAttachedStep(
+ SimulationContextType simCtxType) {
+ return ProjectSettingsServiceImpl.getStep(simCtxType.getStep());
+ }
+
/**
* Get the simulationContextDAO.
*
package org.splat.service;
import java.io.IOException;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
-import org.splat.kernel.UserDirectory;
import org.splat.log.AppLogger;
import org.splat.service.technical.IndexService;
import org.splat.service.technical.ProjectSettingsService;
*/
private DocumentTypeService _documentTypeService;
+ /**
+ * Injected user service.
+ */
+ private UserService _userService;
+
/**
* {@inheritDoc}
*
boolean isOk = false;
try {
getStudyDAO().update(aStudy); // Update of relational base
- setShortCuts(aStudy); //RKV: initialize transient actors set
+ setShortCuts(aStudy); // RKV: initialize transient actors set
getIndex().update(aStudy); // Update of Lucene index
isOk = true;
} catch (Exception error) {
tool = new IDBuilder(aStudy.getDate());
getIDBuilderDAO().create(tool);
}
- aStudy.setReference(tool.buildReference(pattern, aStudy));
+ aStudy.setReference(buildReference(tool, pattern, aStudy));
return true;
}
+ /**
+ * Build reference for the study. The reference of the study is stored as a new reference pattern (IDBuilder).
+ *
+ * @param aBuilder
+ * the id builder
+ * @param study
+ * the study
+ * @param pattern
+ * the reference pattern
+ * @return true if reference building is succeded
+ */
+ @Transactional
+ public String buildReference(IDBuilder aBuilder, String pattern, Study study) {
+ char[] format = pattern.toCharArray();
+ char[] ref = new char[80]; // Better evaluate the length of the generated string
+ int next = aBuilder.getBase() + 1;
+
+ int count = 0;
+ for (int i = 0; i < format.length; i++) {
+
+ // Insertion of attribute values
+ if (format[i] == '%') {
+ i += 1;
+
+ if (format[i] == 'y') { // Insertion of year in format 2 (e.g. 09) or 4 (e.g. 2009) digits
+ int n = i;
+ while (format[i] == 'y') {
+ i += 1;
+ if (i == format.length)
+ break;
+ }
+ SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
+ String year = tostring.format(study.getDate());
+ year = year.substring(4 - (i - n), 4); // 4-(i-n) must be equal to either 0 or 2
+ for (int j = 0; j < year.length(); j++) {
+ ref[count] = year.charAt(j);
+ count += 1;
+ }
+ i -= 1; // Back to the last 'y' character
+ } else if (format[i] == '0') { // Insertion of the index
+ int n = i;
+ while (format[i] == '0') {
+ i += 1;
+ if (i == format.length)
+ break;
+ }
+ DecimalFormat tostring = new DecimalFormat(
+ pattern.substring(n, i));
+ String number = tostring.format(next);
+ for (int j = 0; j < number.length(); j++) {
+ ref[count] = number.charAt(j);
+ count += 1;
+ }
+ i -= 1; // Back to the last '0' character
+ }
+ // Keep the character
+ } else {
+ ref[count] = format[i];
+ count += 1;
+ }
+ }
+ // Incrementation of the number of study
+ aBuilder.setBase(next);
+ getIDBuilderDAO().update(aBuilder);
+ return String.copyValueOf(ref, 0, count);
+ }
+
/**
* Find an id builder by date.
*
if (actype[i] == Actor.manager) {
actor = from.getAuthor();
} else if (actype[i] == Actor.Nx1) {
- List<User> manager = UserDirectory
+ List<User> manager = getUserService()
.selectUsersWhere(uprop
.setOrganizationName("Nx1"));
if (manager.size() == 1)
actor = manager.get(0);
} else if (actype[i] == Actor.Nx2) {
- List<User> manager = UserDirectory
+ List<User> manager = getUserService()
.selectUsersWhere(uprop
.setOrganizationName("Nx2"));
if (manager.size() == 1)
public void setDocumentTypeService(DocumentTypeService documentTypeService) {
_documentTypeService = documentTypeService;
}
+
+ /**
+ * Get the userService.
+ * @return the userService
+ */
+ public UserService getUserService() {
+ return _userService;
+ }
+
+ /**
+ * Set the userService.
+ * @param userService the userService to set
+ */
+ public void setUserService(UserService userService) {
+ _userService = userService;
+ }
}
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 21.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service;
+
+import java.io.File;
+import java.util.List;
+import java.util.Set;
+
+import org.splat.dal.bo.kernel.User;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MismatchException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
+import org.splat.manox.XMLException;
+
+/**
+ * User service interface.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public interface UserService {
+
+ public User createUser(User.Properties uprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException;
+
+ public Set<User> importUsers(File xfile) throws XMLException,
+ MismatchException;
+
+ /**
+ * Returns the manager of the given user. This function is effective providing that users are defined according to the following
+ * conventions:
+ * <ul>
+ * <li>One user is assigned in the organization as Nx1 (n+1 manager of members of the organization)</li>
+ * <li>Another user is assigned in the organization as Nx2 (n+2 manager of members of the organization)</li>
+ * </ul>
+ * If such users do not exit, null is returned.
+ *
+ * @param user
+ * the user whose manager is get
+ * @return the manager of the given user, if defined
+ */
+ public User getManagerOf(User user);
+
+ public List<User> selectAllUsers();
+
+ public User selectUser(String username);
+
+ public User selectUser(String username, String password);
+
+ public User selectUser(long index);
+
+ public List<User> selectUsersWhere(User.Properties... uprop);
+}
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 21.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.dao.kernel.UserDAO;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MismatchException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
+import org.splat.manox.XDOM;
+import org.splat.manox.XMLException;
+import org.springframework.transaction.annotation.Transactional;
+import org.w3c.dom.Node;
+
+/**
+ * User service implementation.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class UserServiceImpl implements UserService {
+
+ /**
+ * The service logger.
+ */
+ final static Logger logger = Logger.getLogger(UserServiceImpl.class);
+
+ /**
+ * Injected user DAO.
+ */
+ private UserDAO _userDAO;
+
+ // ==============================================================================================================================
+ // Public services
+ // ==============================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.UserService#createUser(org.splat.dal.bo.kernel.User.Properties)
+ */
+ @Transactional
+ public User createUser(User.Properties uprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException, RuntimeException {
+ User nuser = new User(uprop);
+ getUserDAO().create(nuser);
+ return nuser;
+ }
+
+ // For the casting List<String>
+ @Transactional
+ public Set<User> importUsers(File xfile) throws XMLException,
+ MismatchException {
+ String[] name = xfile.getName().split("\\x2E"); // Split by '.' (period) character
+ String fext = name[name.length - 1];
+
+ if (!fext.equals("xml"))
+ throw new MismatchException("filetype");
+ try {
+ DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
+ org.w3c.dom.Document inDoc = dBuilder.parse(xfile);
+ String xtag = inDoc.getDocumentElement().getNodeName();
+ if (!xtag.equals("users"))
+ throw new MismatchException("filetype");
+ org.w3c.dom.NodeList ulist = inDoc.getElementsByTagName("user");
+
+ // List<String> result = (List<String>) session
+ // .createSQLQuery("SELECT * FROM users")
+ // .addScalar("username").list();
+ List<User> users = getUserDAO().getAll();
+ HashSet<String> members = new HashSet<String>();
+ HashSet<User> imported = new HashSet<User>();
+ for (Iterator<User> i = users.iterator(); i.hasNext();)
+ members.add(i.next().getUsername());
+
+ for (int i = 0; i < ulist.getLength(); i++) {
+ HashMap<String, Node> row = XDOM.getNamedChildNodes(ulist
+ .item(i));
+ User.Properties uprop = new User.Properties();
+
+ // Mandatory properties
+ String uname = row.get("username").getTextContent();
+ if (members.contains(uname))
+ continue; // This user already exists
+ uprop.setUsername(uname)
+ .setFirstName(row.get("first").getTextContent())
+ .setName(row.get("last").getTextContent())
+ .setMailAddress(row.get("mail").getTextContent())
+ .addRole(row.get("role").getTextContent()); // Add all roles at a time
+
+ // Optional properties
+ org.w3c.dom.Node node = row.get("password");
+ if (node != null) {
+ uprop.setPassword(node.getTextContent());
+ }
+ node = row.get("display");
+ if (node != null) {
+ uprop.setDisplayName(node.getTextContent());
+ }
+ node = row.get("organization");
+ if (node != null) {
+ uprop.setOrganizationName(node.getTextContent());
+ }
+ // Addition of the user
+ uprop.disableCheck(); // Existent user already checked above
+ User newser = new User(uprop);
+ getUserDAO().create(newser);
+ imported.add(newser);
+ }
+ return imported;
+ } catch (IOException error) {
+ throw new XMLException("XML users file not found");
+ } catch (ParserConfigurationException e) {
+ throw new XMLException("XML Organization parser not accessible");
+ } catch (Exception e) {
+ throw new XMLException("XML users file not valid");
+ }
+ }
+
+ /**
+ * Returns the manager of the given user. This function is effective providing that users are defined according to the following
+ * conventions:
+ * <ul>
+ * <li>One user is assigned in the organization as Nx1 (n+1 manager of members of the organization)</li>
+ * <li>Another user is assigned in the organization as Nx2 (n+2 manager of members of the organization)</li>
+ * </ul>
+ * If such users do not exit, null is returned.
+ *
+ * @param user
+ * the user whose manager is get
+ * @return the manager of the given user, if defined
+ */
+ public User getManagerOf(User user) {
+ User result = null;
+ String orgname = user.getOrganizationName();
+
+ if (orgname.equals("Nx2"))
+ return result;
+ if (orgname.equals("Nx1"))
+ orgname = "Nx2";
+ else {
+ if (user.getRoleNames().equals("customer"))
+ return result;
+ orgname = "Nx1";
+ }
+ try {
+ User.Properties uprop = new User.Properties();
+ List<User> ulist = selectUsersWhere(uprop
+ .setOrganizationName(orgname));
+ return ulist.get(0); // n+1 and n+2 managers are unique
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ @Transactional(readOnly = true)
+ public List<User> selectAllUsers() {
+ // String query = "FROM User order by last asc, first asc";
+ return getUserDAO().getAll(Order.asc("last"), Order.asc("first"));
+ }
+
+ @Transactional(readOnly = true)
+ public User selectUser(String username) {
+ return getUserDAO().findByCriteria(
+ Restrictions.eq("username", username));
+ }
+
+ public User selectUser(String username, String password) {
+ // WARNING: For not encoding the password here, we better call a selectUsersWhere(User.Properties),
+ // but this requires a getPassword in User.Properties nested class.
+ Criterion aCondition = Restrictions.eq("username", username);
+ if (password == null) {
+ aCondition = Restrictions.and(aCondition,
+ Restrictions.isNull("password"));
+ } else {
+ aCondition = Restrictions.and(
+ aCondition,
+ Restrictions.eq("password",
+ String.valueOf(password.hashCode())));
+ }
+ return getUserDAO().findByCriteria(aCondition);
+ }
+
+ @Transactional(readOnly = true)
+ public User selectUser(long index) {
+ return getUserDAO().get(index);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<User> selectUsersWhere(User.Properties... uprop) {
+// StringBuffer query = new StringBuffer("FROM User");
+// String separator = " where (";
+// String value;
+//
+// for (int i = 0; i < uprop.length; i++) {
+//
+// value = uprop[i].getOrganizationName();
+// if (value != null) {
+// query = query.append(separator).append(" organid='")
+// .append(value).append("'");
+// // separator = " and";
+// }
+// separator = ") or (";
+// }
+// query.append(")");
+ Criterion aCondition = null;
+ String value;
+ for (int i = 0; i < uprop.length; i++) {
+ value = uprop[i].getOrganizationName();
+ if (value != null) {
+ if (aCondition == null) {
+ aCondition = Restrictions.eq("organid", value);
+ } else {
+ aCondition = Restrictions.or(aCondition, Restrictions.eq("organid", value));
+ }
+ }
+ }
+ return getUserDAO().getFilteredList(aCondition);
+ }
+
+ /**
+ * Get the userDAO.
+ *
+ * @return the userDAO
+ */
+ public UserDAO getUserDAO() {
+ return _userDAO;
+ }
+
+ /**
+ * Set the userDAO.
+ *
+ * @param userDAO
+ * the userDAO to set
+ */
+ public void setUserDAO(UserDAO userDAO) {
+ _userDAO = userDAO;
+ }
+}
if (!steps.isEmpty())
return; // Project already configured
- Database base = getDatabase().getMe();
+ Database base = getDatabase().getCheckedDB();
File config = new File(filename);
if (config.exists()) {
loadCustomization(config);
}
concycles.add(new ProjectSettingsValidationCycle()); // Adds the built-in validation cycle
- if (getDatabase().getMe().isInitialized())
+ if (getDatabase().getCheckedDB().isInitialized())
return; // No need to load object type definitions as they are already stored
// Documents tag
tprop.disableCheck();
tdoc = getDocumentTypeService().createType(tprop); // Creation of Document Types
- tdoc.approve();
+ getDocumentTypeService().approve(tdoc);
maptype.put(type, tdoc);
}
} catch (Exception error) {
try {
KnowledgeElementType ktype = getKnowledgeElementTypeService()
.createType("usecase"); // Internal reserved knowledge element type
- ktype.reserve();
+ getKnowledgeElementTypeService().reserve(ktype);
for (Iterator<String> i = kname.iterator(); i.hasNext();) {
String type = i.next();
ktype = getKnowledgeElementTypeService().createType(type); // Knowledge Elements Types defined in the configuration
- ktype.approve();
+ getKnowledgeElementTypeService().approve(ktype);
}
} catch (Exception error) {
logger.warn("Error creating knowledge types, reason:", error); // Should not happen
}
tctex = getSimulationContextService().createType(type,
mapstep.get(type)); // Creation of Simulation Context Types
- tctex.approve();
+ getSimulationContextService().approve(tctex);
}
} catch (Exception error) {
logger.warn("Error creating context types, reason:", error); // Should not happen
class="org.splat.service.ServiceLocatorImpl"
factory-method="getInstance">
<property name="studyService" ref="studyService" />
+ <property name="userService" ref="userService" />
</bean>
+ <bean id="userService" class="org.splat.service.UserServiceImpl">
+ <property name="userDAO" ref="userDAO"/>
+ </bean>
<bean id="projectElementService"
class="org.splat.service.ProjectElementServiceImpl">
<property name="projectSettings" ref="projectSettings" />
+ <property name="projectElementDAO" ref="projectElementDAO" />
</bean>
<bean id="documentTypeService"
<property name="stepService" ref="stepService" />
<property name="studyService" ref="studyService" />
<property name="knowledgeElementDAO" ref="knowledgeElementDAO" />
- <property name="scenarioDAO" ref="scenarioDAO" />
+ <property name="scenarioDAO" ref="scenarioDAO" />
+ <property name="studyDAO" ref="studyDAO" />
<property name="knowledgeElementTypeService"
ref="knowledgeElementTypeService" />
+ <property name="userService" ref="userService" />
</bean>
<bean id="searchService"
<property name="IDBuilderDAO" ref="iDBuilderDAO" />
<property name="validationCycleDAO" ref="validationCycleDAO" />
<property name="documentTypeService" ref="documentTypeService" />
+ <property name="userService" ref="userService" />
</bean>
<bean id="userRights" abstract="true" scope="session">
</bean>
<!-- TODO: Replace database by services and DAOs -->
- <bean id="database" class="org.splat.dal.dao.som.Database">
+ <bean id="database" class="org.splat.dal.dao.som.Database" factory-method="getInstance">
<property name="sessionFactory" ref="simanSessionFactory" />
- <property name="indexService" ref="indexService" />
+ <property name="indexService" ref="indexService" />
+ <property name="userService" ref="userService" />
<property name="repositoryService" ref="repositoryService" />
</bean>
import org.splat.dal.bo.som.ValidationCycle;
import org.splat.dal.dao.som.Database;
import org.splat.kernel.Do;
-import org.splat.kernel.UserDirectory;
import org.splat.manox.Reader;
import org.splat.manox.Toolbox;
import org.splat.manox.Writer;
<!-- Initialization
=============================================================================================================================
-->
-<% String path = request.getParameter("open");
+<%
+ String path = request.getParameter("open");
OpenStudy simer = (OpenStudy)session.getAttribute("study.open");
ApplicationRights rights = (ApplicationRights)session.getAttribute("user.rights");
String name;
boolean ishared;
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
if (path == null) {
int j = Integer.valueOf(item[0]);
int i;
for (i=0; i<scene.length; i++) {
- if (scene[i].getIndex() == j) break;
+ if (scene[i].getIndex() == j) break;
}
//TODO: RKV: scene[i].checkout(rights.getUser());
<!-- Initialization
=============================================================================================================================
-->
-<% String path = request.getParameter("open");
+<%
+ String path = request.getParameter("open");
OpenStudy simer = (OpenStudy)session.getAttribute("study.open");
ApplicationRights rights = (ApplicationRights)session.getAttribute("user.rights");
String name;
boolean ishared;
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
if (path == null) {
--- /dev/null
+# Connection properties
+connection.url=jdbc:postgresql://localhost:5432/simer
+connection.username=simer
+connection.password=admin
+connection.driver_class=org.postgresql.Driver
+#connection.driver_class=com.p6spy.engine.spy.P6SpyDriver
+
+# Hibernate config
+hibernate.hbm2ddl.auto=update
+hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
+hibernate.current_session_context_class=thread
+
+# Log properties
+hibernate.show_sql=true
+root.logger.appender=<appender-ref ref="console"/>
+root.logger.level=DEBUG
+com.opensymphony.logger.level=DEBUG
+org.apache.struts2.logger.level=DEBUG
+org.springframework.logger.level=DEBUG
+org.hibernate.logger.level=DEBUG
+org.splat.siman.logger.level=DEBUG
+log4j.logger.org.hibernate.logger.level=DEBUG
+com.opensymphony.xwork2.validator.logger.level=DEBUG
+org.apache.struts2.interceptor.validation.logger.level=DEBUG
+
+# Generated file header
+file.header=Don't edit manually. See the source in @config.src.dir@.
+
+wapp.root=c:/work/SIMAN/SIMAN_SRC/Workspace/Siman/WebContent/
+
+
+
public String doSave() {
// -----------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
try {
// Getting user inputs
public String doVersion() {
// --------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
try {
// Getting user inputs
public static ApplicationSettings getMe() {
// ------------------------------------------
+ if (my == null) {
+ my = new ApplicationSettings();
+ }
return my; // The application is supposed being previously created below
}
logger.info("Application root set to "
+ wapprops.getProperty("wapp.root"));
- my = this;
- return this;
+ if (my == null) {
+ my = this;
+ }
+//RKV my = this;
+//RKV return this;
+ return my;
}
// ==============================================================================================================================
module.add(command);
String[] parsed = command.split("/");
String[] name = parsed[parsed.length - 1].split("\\x2E");
- String docname = my.defdoctype.get(
- step.getNumber() + "." + format).getName();
+ DocumentType dtype = my.defdoctype.get(
+ step.getNumber() + "." + format);
+ String docname = "";
+ if (dtype != null) {
+ docname = dtype.getName();
+ }
if (tempfile.get(docname) == null) { // No available template
String tool = parsed[parsed.length - 1];
String icon = name[0];
import javax.security.auth.Subject;
import javax.security.auth.callback.*;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.splat.dal.bo.kernel.User;
import org.splat.som.ApplicationRights;
-import org.splat.dal.dao.som.Database;
import java.io.IOException;
import javax.security.auth.login.FailedLoginException;
-
public class ConnectionAction extends Action {
- private String username = null;
- private String password = null;
- private String backmenu = null;
+ private String username = null;
+ private String password = null;
+ private String backmenu = null;
/**
* Serial version ID.
*/
- private static final long serialVersionUID = 6095471616361606231L;
-
+ private static final long serialVersionUID = 6095471616361606231L;
+
private class Handler implements CallbackHandler {
-// ------------------------------------------------
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
- {
- for (int i = 0; i < callbacks.length; i++) {
- if (callbacks[i] instanceof TextOutputCallback) {
-// Display a message according to a specified type
-
- } else if (callbacks[i] instanceof NameCallback) {
-// Get the username
- NameCallback call = (NameCallback)callbacks[i];
- call.setName(username);
-
- } else if (callbacks[i] instanceof PasswordCallback) {
-// Get the password
- if (password != null) {
- PasswordCallback call = (PasswordCallback)callbacks[i];
- call.setPassword(password.toCharArray());
- }
- } else {
- throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
- }
- }
- }
+ // ------------------------------------------------
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ if (callbacks[i] instanceof TextOutputCallback) {
+ // Display a message according to a specified type
+
+ } else if (callbacks[i] instanceof NameCallback) {
+ // Get the username
+ NameCallback call = (NameCallback) callbacks[i];
+ call.setName(username);
+
+ } else if (callbacks[i] instanceof PasswordCallback) {
+ // Get the password
+ if (password != null) {
+ PasswordCallback call = (PasswordCallback) callbacks[i];
+ call.setPassword(password.toCharArray());
+ }
+ } else {
+ throw new UnsupportedCallbackException(callbacks[i],
+ "Unrecognized Callback");
+ }
+ }
+ }
}
-// ==============================================================================================================================
-// Action execution
-// ==============================================================================================================================
+ // ==============================================================================================================================
+ // Action execution
+ // ==============================================================================================================================
+
+ @SuppressWarnings("unchecked")
+ public String doLogin() throws Exception {
+ // ------------------------
+ if (username == null || username.length() == 0)
+ return INPUT;
+ if (password != null && password.length() == 0)
+ password = null; // User having no password
+ try {
+ LoginContext context = new LoginContext("Simer", new Handler());
+ context.login();
+
+ Subject identity = context.getSubject();
+ Set<User> table = identity.getPrincipals(User.class);
+ if (table.isEmpty())
+ throw new Exception();
+
+ User user = table.iterator().next(); // The user is (apparently...) the 1st principal
+ ApplicationRights logged = new ApplicationRights(user);
+ if (logged.canContributeToStudy() || logged.canValidate()) {
+ // TODO: Set the search filter according to user preferences
+ Map<String, Object> session = getSession();
+ // Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
+ Map<String, Object> sfilter = (Map<String, Object>) session
+ .get("study.filter");
+
+ sfilter.put("state", "ANY");
+ sfilter.put("visibility", "PRIVATE");
+ if (logged.canCreateStudy())
+ sfilter.put("author", String.valueOf(user.getIndex()));
+ }
+ this.connect(context, user); // Updates the session context
+ return backmenu;
+ } catch (FailedLoginException error) {
+ setErrorCode("message.error.login." + error.getMessage());
+ return INPUT;
+ } catch (Exception error) {
+ logger.error("Reason:", error);
+ return ERROR;
+ }
+ }
@SuppressWarnings("unchecked")
- public String doLogin () throws Exception {
-// ------------------------
- if (username == null || username.length() == 0) return INPUT;
- if (password != null && password.length() == 0) password = null; // User having no password
- try {
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
- LoginContext context = new LoginContext("Simer", new Handler());
- context.login();
- transax.commit();
-
- Subject identity = context.getSubject();
- Set<User> table = identity.getPrincipals(User.class);
- if (table.isEmpty()) throw new Exception();
-
- User user = table.iterator().next(); // The user is (apparently...) the 1st principal
- ApplicationRights logged = new ApplicationRights(user);
- if (logged.canContributeToStudy() || logged.canValidate()) {
-//TODO: Set the search filter according to user preferences
- Map<String,Object> session = getSession();
-// Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
- Map<String,Object> sfilter = (Map<String, Object>)session.get("study.filter");
-
- sfilter.put("state", "ANY");
- sfilter.put("visibility", "PRIVATE");
- if (logged.canCreateStudy()) sfilter.put("author", String.valueOf(user.getIndex()));
- }
- this.connect(context, user); // Updates the session context
- return backmenu;
- }
- catch (FailedLoginException error) {
- setErrorCode("message.error.login." + error.getMessage());
- return INPUT;
- }
- catch (Exception error) {
- logger.error("Reason:", error);
- return ERROR;
- }
+ public String doLogout() {
+ // -------------------------
+ try {
+ Map<String, Object> session = getSession();
+ // Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
+ Map<String, Object> sfilter = (Map<String, Object>) session
+ .get("study.filter");
+ LoginContext context = (LoginContext) session.get("login.context");
+
+ logger.info("Deconnection of " + getConnectedUser().toString()
+ + ".");
+ context.logout();
+
+ // TODO: ProjectSettings.deleteDownloadDirectory(user);
+ sfilter.put("state", "ANY");
+ sfilter.put("author", "0");
+
+ this.disconnect(); // Updates the session context
+ return backmenu;
+ } catch (Exception error) {
+ logger.error("Reason:", error);
+ return ERROR;
+ }
+ }
+
+ // ==============================================================================================================================
+ // Getters and setters
+ // ==============================================================================================================================
+
+ public String getUsername() {
+ // ----------------------------
+ return username;
}
- @SuppressWarnings("unchecked")
- public String doLogout () {
-// -------------------------
- try {
- Map<String,Object> session = getSession();
-// Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
- Map<String,Object> sfilter = (Map<String, Object>)session.get("study.filter");
- LoginContext context = (LoginContext)session.get("login.context");
-
- logger.info("Deconnection of " + getConnectedUser().toString() + ".");
- context.logout();
-
-//TODO: ProjectSettings.deleteDownloadDirectory(user);
- sfilter.put("state", "ANY");
- sfilter.put("author", "0");
-
- this.disconnect(); // Updates the session context
- return backmenu;
- }
- catch (Exception error) {
- logger.error("Reason:", error);
- return ERROR;
- }
- }
-
-// ==============================================================================================================================
-// Getters and setters
-// ==============================================================================================================================
-
- public String getUsername () {
-// ----------------------------
- return username;
- }
- public String getPassword () {
-// ----------------------------
- return password;
- }
-
- public void setUsername (String value) {
-// --------------------------------------
- this.username = value;
- }
- public void setPassword (String value) {
-// --------------------------------------
- this.password = value;
- }
- public void setBackMenu (String menu) {
-// -------------------------------------
- this.backmenu = menu;
- }
+ public String getPassword() {
+ // ----------------------------
+ return password;
+ }
+
+ public void setUsername(String value) {
+ // --------------------------------------
+ this.username = value;
+ }
+
+ public void setPassword(String value) {
+ // --------------------------------------
+ this.password = value;
+ }
+
+ public void setBackMenu(String menu) {
+ // -------------------------------------
+ this.backmenu = menu;
+ }
}
\ No newline at end of file
public String doOpen () {
// -----------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
myknelm = getOpenKnowledge();
public String doSelectStep () {
// -----------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
myknelm = getOpenKnowledge();
public String doOpen () {
// -----------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
Study study;
public String doSelectStep () {
// -----------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
mystudy = getOpenStudy();
import java.io.File;
import java.util.Calendar;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.splat.kernel.InvalidPropertyException;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.ConvertsRelation;
import org.splat.service.PublicationService;
}
public String doSetDocument() {
- // ------------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
try {
mystudy = getOpenStudy();
getPublicationService().rename(doc, title);
// Useless to update the document presentation
} else if (todo == Execute.accept) {
- doc.actualize();
+ getPublicationService().actualize(doc);
mystudy.update(doc);
} else if (todo == Execute.promote) {
getPublicationService().promote(doc,
mystudy.update(doc);
mystudy.getMenu().refreshSelectedItem(); // Updates the menu icon, in case of other documents in approved state
}
- transax.commit();
return SUCCESS;
} catch (RuntimeException saverror) {
logger.error("Reason:", saverror);
- if (transax != null && transax.isActive()) {
- // Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
return ERROR;
} catch (InvalidPropertyException error) {
- transax.commit();
return INPUT;
}
}
public String doAttach() {
// -------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
+// Session connex = Database.getCurSession();
+// Transaction transax = connex.beginTransaction();
try {
// Getting user inputs
mystudy = getOpenStudy();
upfile.renameTo(export.getTo().asFile());
mystudy.update(edited);
- transax.commit();
+// transax.commit();
return SUCCESS;
} catch (Exception error) {
logger.error("Reason:", error);
}
public String doDeleteDocument() {
- // ---------------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
try {
mystudy = getOpenStudy();
Publication doctag = step.getDocument(Integer.valueOf(index));
getStepService().removeDocument(step, doctag); // Updates the data structure
- transax.commit();
mystudy.remove(doctag); // Updates the presentation
return SUCCESS;
} catch (RuntimeException saverror) {
logger.error("Reason:", saverror);
- if (transax != null && transax.isActive()) {
- // Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
return ERROR;
}
}
KnowledgeElement kelm = scene.getKnowledgeElement(Integer
.valueOf(myindex));
- scene.removeKnowledgeElement(kelm); // The knowledge element necessarily exists
+ getScenarioService().removeKnowledgeElement(scene, kelm); // The knowledge element necessarily exists
mystudy.remove(kelm);
getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of last removed document
import java.text.SimpleDateFormat;
import java.util.ResourceBundle;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Scenario;
import org.splat.service.ProjectElementService;
import org.splat.service.ScenarioService;
}
public String doCheckin() {
- // --------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
Step step;
mystudy = getOpenStudy();
myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
getScenarioService().checkin(myscenario);
- transax.commit();
mystudy.getMenu().refreshGivenStepItem(
getProjectElementService().getFirstStep(myscenario)); // For updating the scenario icon
import java.util.Arrays;
import java.util.List;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.ProjectElement;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
// ==============================================================================================================================
public String doInitialize() {
- // -----------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
mystudy = getOpenStudy();
contype = getInvolvedContexts();
- transax.commit();
if (contype.isEmpty())
return "create";
else
}
public String doSelectContext() {
- // --------------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
- try {
- mystudy = getOpenStudy();
- int typid = Integer.valueOf(selectype);
- if (typid == 0)
- return "create";
+ mystudy = getOpenStudy();
+ int typid = Integer.valueOf(selectype);
+ if (typid == 0)
+ return "create";
- SimulationContext.Properties cprop = new SimulationContext.Properties();
- type = getSimulationContextService().selectType(typid);
- newtype = type.getName();
- contype = getInvolvedContexts();
- contelm = getSimulationContextService()
- .selectSimulationContextsWhere(cprop.setType(type));
+ SimulationContext.Properties cprop = new SimulationContext.Properties();
+ type = getSimulationContextService().selectType(typid);
+ newtype = type.getName();
+ contype = getInvolvedContexts();
+ contelm = getSimulationContextService()
+ .selectSimulationContextsWhere(cprop.setType(type));
- return "set";
- } finally {
- transax.commit();
- }
+ return "set";
}
public String doCreateContext() {
// --------------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
try {
mystudy = getOpenStudy();
if (newtype.length() == 0 || value.length() == 0)
contex = getStepService().addSimulationContext(step, cprop); // Re-indexes knowledges only
mystudy.add(contex);
- transax.commit();
return SUCCESS;
} catch (RuntimeException saverror) {
logger.error("Reason:", saverror);
- if (transax != null && transax.isActive()) {
- // Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
return ERROR;
} catch (Exception error) {
- transax.commit();
return INPUT;
}
}
public String doDeleteContext() {
- // --------------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
try {
mystudy = getOpenStudy();
getStepService().removeSimulationContext(step, context); // Re-indexes knowledges only
mystudy.remove(context);
- transax.commit();
return SUCCESS;
} catch (RuntimeException saverror) {
logger.error("Reason:", saverror);
- if (transax != null && transax.isActive()) {
- // Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
return ERROR;
}
}
public String doSetContext() {
// -----------------------------
String[] input = value.split(",");
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
+// Session connex = Database.getCurSession();
+// Transaction transax = connex.beginTransaction();
try {
mystudy = getOpenStudy();
mystudy.add(contex);
contype = getInvolvedContexts();
- transax.commit();
+// transax.commit();
return SUCCESS;
} catch (RuntimeException saverror) {
logger.error("Reason:", saverror);
- if (transax != null && transax.isActive()) {
- // Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
return ERROR;
} catch (Exception error) {
value = input[0];
- transax.commit();
return INPUT;
}
}
package org.splat.simer;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Study;
import org.splat.service.StudyService;
// ==============================================================================================================================
public String doEdition () {
-// --------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
try {
mystudy = getOpenStudy();
else if (todo == Execute.promote) getStudyService().moveToReference(study);
mystudy.getPopup().setContext("study", mystudy.getStudyRights()); // The context has changed
-// Useless to update the open study
- transax.commit();
return SUCCESS;
}
catch (RuntimeException saverror) {
logger.error("Reason:", saverror);
- if (transax != null && transax.isActive()) {
-// Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
return ERROR;
}
}
*/
public String doInitialize() {
// -----------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
User user = getConnectedUser();
File updir = getRepositoryService().getDownloadDirectory(user);
setErrorCode("import.type");
return ERROR;
}
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
try {
// Getting user inputs
// -------------------------
if (action == ToDo.cancel) return "cancel";
- Session session = Database.getSession();
- Transaction transax = session.beginTransaction();
+// Session session = Database.getCurSession();
+// Transaction transax = session.beginTransaction();
try { mystudy = getOpenStudy();
selection = getMenu("scenario").getSelection();
Study study = mystudy.getStudyObject();
sprop.setBaseStep(step[number-bastep]);
}
bascene = getScenarioService().addScenario(study, sprop);
- transax.commit();
+// transax.commit();
// Update of the display
if (step != null) for (int i=0; i<number-bastep+1; i++) {
}
catch (RuntimeException saverror) {
logger.error("Reason:", saverror);
- if (transax != null && transax.isActive()) {
-// Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
return ERROR;
}
catch (Exception error) {
import java.util.List;
import java.util.ResourceBundle;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Scenario;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
}
public String doCreate() throws Exception {
- // -------------------------
String[] input = context.split(",");
int valid = Integer.valueOf(input[0]);
String value = ""; // input[1] if exists
- Session session = Database.getSession();
- Transaction transax = session.beginTransaction();
Study.Properties sprop = new Study.Properties();
// Check arguments and creation of the study
.selectType("product");
contelm = getSimulationContextService()
.selectSimulationContextsWhere(cprop.setType(product));
- transax.commit();
return INPUT; // Title empty, simply wait for input without error message
}
try {
// Update of the session
number += 1;
open(study); // Opens the study,
- transax.commit();
return SUCCESS;
} catch (Exception error) {
logger.error("Unable to save the study, reason:", error);
- if (transax != null && transax.isActive()) {
- // Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
return ERROR;
}
}
import java.util.ResourceBundle;
import org.apache.log4j.Logger;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.splat.kernel.Do;
import org.splat.dal.bo.kernel.User;
import org.splat.manox.Toolbox;
import org.splat.manox.Writer;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.ProgressState;
+import org.splat.service.DocumentService;
import org.splat.service.DocumentTypeService;
import org.splat.service.StepService;
import org.splat.service.StudyService;
* Injected document type service.
*/
private DocumentTypeService _documentTypeService;
-
+ /**
+ * Injected document service.
+ */
+ private DocumentService _documentService;
/**
* The injected Study service.
*/
if (!template.exists())
return null;
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
+// Session connex = Database.getCurSession();
+// Transaction transax = connex.beginTransaction();
try {
File udir = getRepositoryService().getDownloadDirectory(author);
File credoc = new File(udir.getPath() + "/" + filename);
Document medoc = getStepService().createDocument(step,
dprop.setType(type).setFormat("xml").setAuthor(author))
.value();
- transax.commit();
+// transax.commit();
// Instantiation of the template into the user download directory
if (!udir.exists())
+ filename);
} catch (Exception saverror) {
logger.error("Reason:", saverror);
- if (transax != null && transax.isActive()) {
- // Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
return null;
}
}
if (docurl.startsWith(prefix))
try {
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
String path = docurl.substring(prefix.length());
- String[] parse = path.split("'");
-
- path = parse[0];
- for (int i = 1; i < parse.length; i++)
- path = path + "''" + parse[i];
- // Better call Database.selectDocument(path), but this service does not exist (overloading issue)
- String query = "from Document where path='" + path + "'";
- Document value = (Document) Database.getSession().createQuery(
- query).uniqueResult();
+ Document value = getDocumentService().getDocumentByPath(path);
selecdoc = ustep.getDocument(value.getIndex());
- transax.commit();
} catch (Exception error) {
logger.error("Reason:", error);
}
public void setStudyService(StudyService studyService) {
_studyService = studyService;
}
+
+ /**
+ * Get the documentService.
+ * @return the documentService
+ */
+ public DocumentService getDocumentService() {
+ return _documentService;
+ }
+
+ /**
+ * Set the documentService.
+ * @param documentService the documentService to set
+ */
+ public void setDocumentService(DocumentService documentService) {
+ _documentService = documentService;
+ }
}
\ No newline at end of file
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.Name;
import org.splat.dal.bo.kernel.User;
-import org.splat.kernel.UserDirectory;
import org.splat.som.ApplicationRights;
import org.splat.dal.dao.som.Database;
import org.splat.service.SimulationContextService;
+import org.splat.service.UserService;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.service.dto.Proxy;
import org.splat.dal.bo.som.SimulationContext;
*/
private SimulationContextService _simulationContextService;
+ /**
+ * Injected user service.
+ */
+ private UserService _userService;
+
enum UserAction {
refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext
}
action = UserAction.cancelSelect;
}
// Execution of the user action
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
String done;
try {
// ---------------------------------------
SimulationContext.Properties sprop = new SimulationContext.Properties();
- newtype = getSimulationContextService().selectType(Integer.valueOf(ctype));
+ newtype = getSimulationContextService().selectType(
+ Integer.valueOf(ctype));
newvalue = getSimulationContextService().selectSimulationContextsWhere(
sprop.setType(newtype));
if (cindex.length() > 0 && Integer.valueOf(cindex) == 0)
protected void setCandidates() {
// -------------------------------
manager = new Vector<Name>();
- List<User> users = UserDirectory.selectAllUsers();
+ List<User> users = getUserService().selectAllUsers();
User me = getConnectedUser(); // May be null
for (Iterator<User> i = users.iterator(); i.hasNext();) {
User next = i.next();
SimulationContextType[] types = critext
.toArray(new SimulationContextType[critext.size()]);
ContextTypeComparator compare = new ContextTypeComparator();
- ProjectSettingsService.Step step = types[0].getAttachedStep();
+ ProjectSettingsService.Step step = getSimulationContextService()
+ .getAttachedStep(types[0]);
int from = 0;
int to = 0;
while (to < types.length - 1) {
if (to > from + 1)
Arrays.sort(types, from, to, compare);
from = to;
- step = types[to].getAttachedStep();
+ step = getSimulationContextService().getAttachedStep(types[to]);
}
if (to > from)
Arrays.sort(types, from, to + 1, compare);
SimulationContextService simulationContextService) {
_simulationContextService = simulationContextService;
}
+
+ /**
+ * Get the userService.
+ * @return the userService
+ */
+ public UserService getUserService() {
+ return _userService;
+ }
+
+ /**
+ * Set the userService.
+ * @param userService the userService to set
+ */
+ public void setUserService(UserService userService) {
+ _userService = userService;
+ }
}
\ No newline at end of file
import org.splat.kernel.InvalidPropertyException;
import org.splat.dal.bo.kernel.User;
-import org.splat.kernel.UserDirectory;
import org.splat.service.KnowledgeElementTypeService;
import org.splat.service.SearchService;
import org.splat.service.SimulationContextService;
+import org.splat.service.UserService;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.KnowledgeElementType;
import org.splat.dal.bo.som.ProgressState;
*/
private KnowledgeElementTypeService _knowledgeElementTypeService;
+ /**
+ * Injected user service.
+ */
+ private UserService _userService;
+
// ==============================================================================================================================
// Action methods
// ==============================================================================================================================
sprop.setSimulationContexts(context);
int index = Integer.valueOf(author);
if (index > 0) {
- User him = UserDirectory.selectUser(index);
+ User him = getUserService().selectUser(index);
sprop.setAuthor(him);
}
// Set of the visibility
KnowledgeElementTypeService knowledgeElementTypeService) {
_knowledgeElementTypeService = knowledgeElementTypeService;
}
+
+ /**
+ * Get the userService.
+ * @return the userService
+ */
+ public UserService getUserService() {
+ return _userService;
+ }
+
+ /**
+ * Set the userService.
+ * @param userService the userService to set
+ */
+ public void setUserService(UserService userService) {
+ _userService = userService;
+ }
}
\ No newline at end of file
import org.hibernate.Transaction;
import org.splat.kernel.InvalidPropertyException;
import org.splat.dal.bo.kernel.User;
-import org.splat.kernel.UserDirectory;
import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.ProgressState;
import org.splat.service.SearchService;
import org.splat.service.SimulationContextService;
+import org.splat.service.UserService;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
* Injected simulation context service.
*/
private SimulationContextService _simulationContextService;
+ /**
+ * Injected user service.
+ */
+ private UserService _userService;
/**
* Serial version ID.
public String doInitialize () {
// -----------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
try {
loadFilter();
if (context.size() > 0) sprop.setSimulationContexts(context);
int index = Integer.valueOf(author);
if (index > 0) {
- User him = UserDirectory.selectUser(index);
+ User him = getUserService().selectUser(index);
sprop.setManager(him);
}
// Set of the visibility
SimulationContextService simulationContextService) {
_simulationContextService = simulationContextService;
}
+
+ /**
+ * Get the userService.
+ * @return the userService
+ */
+ public UserService getUserService() {
+ return _userService;
+ }
+
+ /**
+ * Set the userService.
+ * @param userService the userService to set
+ */
+ public void setUserService(UserService userService) {
+ _userService = userService;
+ }
}
\ No newline at end of file
public String doInitialize () throws Exception {
// -----------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
+// Session connex = Database.getSession();
+// Transaction transax = connex.beginTransaction();
StringBuffer wappurl = request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
logger.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
session.put("study.filter", wapp.getFilter("study"));
session.put("knowledge.filter", wapp.getFilter("knowledge"));
- transax.commit();
+// transax.commit();
return SUCCESS;
}
catch (Exception error) {
logger.fatal("Reason:", error);
- if (transax != null && transax.isActive()) {
-// Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
return ERROR;
}
}
import java.util.List;
import java.util.Vector;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.Name;
import org.splat.dal.bo.kernel.User;
-import org.splat.kernel.UserDirectory;
import org.splat.service.DocumentTypeService;
import org.splat.service.StudyService;
+import org.splat.service.UserService;
import org.splat.som.ApplicationRights;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.Study;
import org.splat.som.StudyRights;
*/
private DocumentTypeService _documentTypeService;
+ /**
+ * Injected user service.
+ */
+ private UserService _userService;
+
/**
* Save operation type enumeration pointing which section of properties has been edited.
*/
}
public String doEditTitle() {
- // ----------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
+// Session connex = Database.getCurSession();
+// Transaction transax = connex.beginTransaction();
mystudy = getOpenStudy();
validation = new Vector<ValidationFacade>();
validor = null;
other = null;
- transax.commit();
+// transax.commit();
return SUCCESS;
}
public String doEditContributors() {
- // -----------------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
+// Session connex = Database.getCurSession();
+// Transaction transax = connex.beginTransaction();
mystudy = getOpenStudy();
validation = new Vector<ValidationFacade>();
if (validefault != null)
validation.add(validefault); // In order to be at the end
member = getStudyService().getContributors(study);
- staff = UserDirectory.selectAllUsers();
+ staff = getUserService().selectAllUsers();
validor = null;
other = null;
User me = this.getConnectedUser();
|| !he.canContributeToStudy())
i.remove();
}
- transax.commit();
+// transax.commit();
return SUCCESS;
}
public String doEditCycle() {
- // ----------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
+// Session connex = Database.getCurSession();
+// Transaction transax = connex.beginTransaction();
mystudy = getOpenStudy();
validation = new Vector<ValidationFacade>();
member = getStudyService().getContributors(study);
validor = new Vector<Name>();
staff = null;
- List<User> user = UserDirectory.selectAllUsers();
+ List<User> user = getUserService().selectAllUsers();
for (Iterator<User> i = user.iterator(); i.hasNext();) {
User next = i.next();
ApplicationRights he = new ApplicationRights(next);
validor.add(next);
}
}
- transax.commit();
+// transax.commit();
return SUCCESS;
}
public String doEdition() {
// --------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
+// Session connex = Database.getCurSession();
+// Transaction transax = connex.beginTransaction();
Study study = getOpenStudy().getStudyObject();
if (tosave == Save.title) {
if (parsenew[i].length() == 0)
continue; // No any new contributor
int index = Integer.valueOf(parsenew[i].trim());
- User newser = UserDirectory.selectUser(index);
+ User newser = getUserService().selectUser(index);
getStudyService().addContributor(study, newser);
}
DocumentType apply = getDocumentTypeService().selectType(type);
ValidationCycle.Properties vprop = new ValidationCycle.Properties();
if (publisher > 0) {
- User actor = UserDirectory.selectUser(publisher);
+ User actor = getUserService().selectUser(publisher);
vprop.setActor(ValidationStep.PROMOTION, actor);
}
if (reviewer > 0) {
- User actor = UserDirectory.selectUser(reviewer);
+ User actor = getUserService().selectUser(reviewer);
vprop.setActor(ValidationStep.REVIEW, actor);
}
if (approver > 0) {
- User actor = UserDirectory.selectUser(approver);
+ User actor = getUserService().selectUser(approver);
vprop.setActor(ValidationStep.APPROVAL, actor);
}
getStudyService().setValidationCycle(study, apply, vprop);
}
- transax.commit();
+// transax.commit();
doInitialize(); // Re-initialization following the above edition
return SUCCESS;
public void setDocumentTypeService(DocumentTypeService documentTypeService) {
_documentTypeService = documentTypeService;
}
+
+ /**
+ * Get the userService.
+ * @return the userService
+ */
+ public UserService getUserService() {
+ return _userService;
+ }
+
+ /**
+ * Set the userService.
+ * @param userService the userService to set
+ */
+ public void setUserService(UserService userService) {
+ _userService = userService;
+ }
}
\ No newline at end of file
public String doInitialize() {
// -----------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
User user = getConnectedUser();
File updir = getRepositoryService().getDownloadDirectory(user);
if (action == ToDo.cancel)
return "cancel";
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
try {
// Getting user inputs
for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
Publication using = i.next();
if (!compatible.contains(using.getIndex()))
- using.outdate();
+ getPublicationService().outdate(using);
}
// Update of the open study
mystudy.setSelection(mystudy.getSelection()); // Rebuilds the presentation
public String doInitialize () {
// -----------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
newstudies = getImportedStudy().selectAll();
public String doIndexing () {
// ---------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
String[] ridlist = indices.split(",");
@SuppressWarnings("unchecked")
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.splat.dal.bo.kernel.User;
-import org.splat.kernel.UserDirectory;
+import org.splat.service.UserService;
import org.splat.service.technical.RepositoryService;
import org.splat.simer.UploadBaseNextAction;
import org.splat.dal.dao.som.Database;
*/
private RepositoryService _repositoryService;
+ /**
+ * Injected user service.
+ */
+ private UserService _userService;
+
// ==============================================================================================================================
// Action methods
// ==============================================================================================================================
public String doImport () {
// -------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
try {
User user = getConnectedUser(); // The database administrator
File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
- newsers = UserDirectory.importUsers(upfile);
- users = UserDirectory.selectAllUsers();
+ newsers = getUserService().importUsers(upfile);
+ users = getUserService().selectAllUsers();
for (Iterator<User> i=users.iterator(); i.hasNext(); ) {
User next = i.next();
if (!next.equals(user)) continue;
public void setRepositoryService(RepositoryService repositoryService) {
_repositoryService = repositoryService;
}
+
+ /**
+ * Get the userService.
+ * @return the userService
+ */
+ public UserService getUserService() {
+ return _userService;
+ }
+
+ /**
+ * Set the userService.
+ * @param userService the userService to set
+ */
+ public void setUserService(UserService userService) {
+ _userService = userService;
+ }
}
\ No newline at end of file
public List<ImportedStudy> selectAll () {
// ----------------------------------------------
- Session session = Database.getSession();
+ Session session = Database.getCurSession();
SelectStudies query = new SelectStudies(getSearchService());
session.doWork(query);
public String doInitialize() {
// -----------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
try {
SimulationContext.Properties cprop = new SimulationContext.Properties();
public String doSelect() {
// -------------------------
- Session connex = Database.getSession();
+ Session connex = Database.getCurSession();
Transaction transax = connex.beginTransaction();
try {
SimulationContext.Properties cprop = new SimulationContext.Properties();
kprop.setSimulationContexts(selected).setState(
ProgressState.inWORK));
- step = edition.getType().getAttachedStep();
+ step = getSimulationContextService().getAttachedStep(edition.getType());
owner = new HashSet<ProjectElementFacade>();
for (Iterator<Proxy> i = kelm.iterator(); i.hasNext();) {
KnowledgeElement next = getKnowledgeElementService()
}
SimulationContextType.Properties sprop = new SimulationContextType.Properties();
List<SimulationContextType> types = getSimulationContextService()
- .selectTypesWhere(sprop.setState(ProgressState.APPROVED));
+ .selectTypesWhere(sprop.setProgressState(ProgressState.APPROVED));
Locale[] support = ApplicationSettings.getSupportedLocales();
// Sort localized type names
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
<!-- configuration i18n -->
<bean id="i18nUtils" class="org.splat.i18n.I18nUtils">
- <property name="resourceBundleMessageSource"
- ref="messageSource" />
+ <property name="resourceBundleMessageSource" ref="messageSource" />
</bean>
<bean id="messageSource"
</property>
</bean>
<!-- ref 'baseMessageSource' into Siman-common\src\spring\globalContext.xml -->
- <!-- property name="parentMessageSource" ref="baseMessageSource"/-->
+ <!-- property name="parentMessageSource" ref="baseMessageSource"/ -->
- <bean id="applicationSettings"
- class="org.splat.simer.ApplicationSettings">
+ <bean id="applicationSettings" class="org.splat.simer.ApplicationSettings"
+ factory-method="getMe">
<property name="projectSettings" ref="projectSettings" />
<property name="documentTypeService" ref="documentTypeService" />
</bean>
scope="prototype" />
<bean id="slidMenu" scope="session" abstract="true">
- <property name="projectElementService"
- ref="projectElementService" />
+ <property name="projectElementService" ref="projectElementService" />
<property name="scenarioService" ref="scenarioService" />
</bean>
- <bean id="studyMenu" class="org.splat.simer.StudyMenu"
- scope="session" parent="slidMenu" />
+ <bean id="studyMenu" class="org.splat.simer.StudyMenu" scope="session"
+ parent="slidMenu" />
<bean id="newScenarioMenu" class="org.splat.simer.NewScenarioMenu"
scope="session" parent="slidMenu" />
- <bean id="openObject" abstract="true"
- class="org.splat.simer.OpenObject" scope="session">
- <property name="projectElementService"
- ref="projectElementService" />
+ <bean id="openObject" abstract="true" class="org.splat.simer.OpenObject"
+ scope="session">
+ <property name="projectElementService" ref="projectElementService" />
<property name="projectSettings" ref="projectSettings" />
- <property name="knowledgeElementTypeService"
- ref="knowledgeElementTypeService" />
+ <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
</bean>
- <bean id="openStudy" class="org.splat.simer.OpenStudy"
- parent="openObject" scope="session">
- <property name="projectElementService"
- ref="projectElementService" />
+ <bean id="openStudy" class="org.splat.simer.OpenStudy" parent="openObject"
+ scope="session">
+ <property name="projectElementService" ref="projectElementService" />
<property name="publicationService" ref="publicationService" />
<property name="studyService" ref="studyService" />
<property name="stepService" ref="stepService" />
<property name="repositoryService" ref="repositoryService" />
<property name="menu" ref="studyMenu" />
<property name="documentTypeService" ref="documentTypeService" />
+ <property name="documentService" ref="documentService" />
</bean>
<bean id="openKnowledge" class="org.splat.simer.OpenKnowledge"
parent="openObject" scope="session">
</bean>
- <bean id="baseAction" class="org.splat.simer.Action"
- scope="prototype" abstract="true">
+ <bean id="baseAction" class="org.splat.simer.Action" scope="prototype"
+ abstract="true">
<property name="openStudy" ref="openStudy" />
<property name="openKnowledge" ref="openKnowledge" />
</bean>
- <!--========= Inherited from baseAction =========-->
+ <!--========= Inherited from baseAction ========= -->
<bean id="newStudyAction" class="org.splat.simer.NewStudyAction"
parent="baseAction" scope="prototype">
- <property name="simulationContextService"
- ref="simulationContextService" />
+ <property name="simulationContextService" ref="simulationContextService" />
+ <property name="scenarioService" ref="scenarioService" />
<property name="studyService" ref="studyService" />
</bean>
- <bean id="newScenarioAction"
- class="org.splat.simer.NewScenarioAction" parent="baseAction"
- scope="prototype">
- <property name="projectElementService"
- ref="projectElementService" />
+ <bean id="newScenarioAction" class="org.splat.simer.NewScenarioAction"
+ parent="baseAction" scope="prototype">
+ <property name="projectElementService" ref="projectElementService" />
<property name="scenarioService" ref="scenarioService" />
<property name="menu" ref="newScenarioMenu" />
</bean>
- <bean id="importDocumentAction"
- class="org.splat.simer.ImportDocumentAction" scope="prototype"
- parent="baseAction">
+ <bean id="importDocumentAction" class="org.splat.simer.ImportDocumentAction"
+ scope="prototype" parent="baseAction">
<property name="stepService" ref="stepService" />
<property name="projectSettings" ref="projectSettings" />
<property name="publicationService" ref="publicationService" />
<property name="documentTypeService" ref="documentTypeService" />
</bean>
- <bean id="displayStudyStepAction"
- class="org.splat.simer.DisplayStudyStepAction" parent="baseAction"
- scope="prototype">
+ <bean id="displayStudyStepAction" class="org.splat.simer.DisplayStudyStepAction"
+ parent="baseAction" scope="prototype">
<property name="studyService" ref="studyService" />
</bean>
- <!--========= Inherited from displayStudyStepAction =========-->
+ <!--========= Inherited from displayStudyStepAction ========= -->
- <bean id="studyPropertiesAction"
- class="org.splat.simer.StudyPropertiesAction" scope="prototype"
- parent="displayStudyStepAction">
+ <bean id="studyPropertiesAction" class="org.splat.simer.StudyPropertiesAction"
+ scope="prototype" parent="displayStudyStepAction">
<property name="documentTypeService" ref="documentTypeService" />
+ <property name="userService" ref="userService" />
</bean>
<bean id="editStudyAction" class="org.splat.simer.EditStudyAction"
scope="prototype" parent="displayStudyStepAction">
</bean>
- <bean id="editScenarioPropertiesAction"
- class="org.splat.simer.EditScenarioPropertiesAction" scope="prototype"
- parent="displayStudyStepAction">
- <property name="projectElementService"
- ref="projectElementService" />
+ <bean id="editScenarioPropertiesAction" class="org.splat.simer.EditScenarioPropertiesAction"
+ scope="prototype" parent="displayStudyStepAction">
+ <property name="projectElementService" ref="projectElementService" />
<property name="scenarioService" ref="scenarioService" />
</bean>
- <bean id="editSimulationContextAction"
- class="org.splat.simer.EditSimulationContextAction" scope="prototype"
- parent="displayStudyStepAction">
+ <bean id="editSimulationContextAction" class="org.splat.simer.EditSimulationContextAction"
+ scope="prototype" parent="displayStudyStepAction">
<property name="stepService" ref="stepService" />
- <property name="simulationContextService"
- ref="simulationContextService" />
+ <property name="simulationContextService" ref="simulationContextService" />
</bean>
- <bean id="editDocumentAction"
- class="org.splat.simer.EditDocumentAction" scope="prototype"
- parent="displayStudyStepAction">
+ <bean id="editDocumentAction" class="org.splat.simer.EditDocumentAction"
+ scope="prototype" parent="displayStudyStepAction">
<property name="stepService" ref="stepService" />
<property name="publicationService" ref="publicationService" />
<property name="repositoryService" ref="repositoryService" />
</bean>
- <bean id="editKnowledgeElementAction"
- class="org.splat.simer.EditKnowledgeElementAction" scope="prototype"
- parent="displayStudyStepAction">
- <property name="knowledgeElementService"
- ref="knowledgeElementService" />
- <property name="knowledgeElementTypeService"
- ref="knowledgeElementTypeService" />
+ <bean id="editKnowledgeElementAction" class="org.splat.simer.EditKnowledgeElementAction"
+ scope="prototype" parent="displayStudyStepAction">
+ <property name="knowledgeElementService" ref="knowledgeElementService" />
+ <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
<property name="scenarioService" ref="scenarioService" />
</bean>
<!-- End of Inherited from displayStudyStepAction -->
- <bean id="startAction" class="org.splat.simer.StartAction"
- scope="prototype">
+ <bean id="startAction" class="org.splat.simer.StartAction" scope="prototype">
<property name="applicationSettings" ref="applicationSettings" />
<property name="projectSettings" ref="projectSettings" />
</bean>
scope="prototype">
</bean>
- <bean id="menuAction" class="org.splat.simer.MenuAction"
- scope="prototype">
+ <bean id="menuAction" class="org.splat.simer.MenuAction" scope="prototype">
</bean>
- <bean id="notYetImplementedAction"
- class="org.splat.simer.NotYetImplementedAction" scope="prototype">
+ <bean id="notYetImplementedAction" class="org.splat.simer.NotYetImplementedAction"
+ scope="prototype">
</bean>
- <bean id="searchStudyAction"
- class="org.splat.simer.SearchStudyAction" scope="prototype">
+ <bean id="searchStudyAction" class="org.splat.simer.SearchStudyAction"
+ scope="prototype">
<property name="projectSettings" ref="projectSettings" />
<property name="searchService" ref="searchService" />
- <property name="simulationContextService"
- ref="simulationContextService" />
+ <property name="simulationContextService" ref="simulationContextService" />
+ <property name="userService" ref="userService" />
</bean>
- <bean id="searchKnowledgeAction"
- class="org.splat.simer.SearchKnowledgeAction" scope="prototype">
+ <bean id="searchKnowledgeAction" class="org.splat.simer.SearchKnowledgeAction"
+ scope="prototype">
<property name="searchService" ref="searchService" />
- <property name="simulationContextService"
- ref="simulationContextService" />
- <property name="knowledgeElementTypeService"
- ref="knowledgeElementTypeService" />
+ <property name="simulationContextService" ref="simulationContextService" />
+ <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
+ <property name="userService" ref="userService" />
</bean>
- <bean id="searchDocumentAction"
- class="org.splat.simer.SearchDocumentAction" scope="prototype">
+ <bean id="searchDocumentAction" class="org.splat.simer.SearchDocumentAction"
+ scope="prototype">
</bean>
- <bean id="displayKnowledgeAction"
- class="org.splat.simer.DisplayKnowledgeAction" scope="prototype">
- <property name="knowledgeElementService"
- ref="knowledgeElementService" />
+ <bean id="displayKnowledgeAction" class="org.splat.simer.DisplayKnowledgeAction"
+ scope="prototype">
+ <property name="knowledgeElementService" ref="knowledgeElementService" />
</bean>
<bean id="uploadAction" class="org.splat.simer.UploadAction"
<property name="repositoryService" ref="repositoryService" />
</bean>
- <bean id="versionDocumentAction"
- class="org.splat.simer.VersionDocumentAction" scope="prototype">
+ <bean id="versionDocumentAction" class="org.splat.simer.VersionDocumentAction"
+ scope="prototype">
<property name="projectSettings" ref="projectSettings" />
<property name="publicationService" ref="publicationService" />
<property name="stepService" ref="stepService" />
<property name="repositoryService" ref="repositoryService" />
</bean>
- <bean id="databaseIndexingAction"
- class="org.splat.simer.admin.DatabaseIndexingAction"
+ <bean id="databaseIndexingAction" class="org.splat.simer.admin.DatabaseIndexingAction"
scope="prototype">
<property name="studyService" ref="studyService" />
<property name="importedStudy" ref="importedStudy" />
<property name="searchService" ref="searchService" />
</bean>
- <bean id="importUserAction"
- class="org.splat.simer.admin.ImportUserAction" scope="prototype">
+ <bean id="importUserAction" class="org.splat.simer.admin.ImportUserAction"
+ scope="prototype">
<property name="repositoryService" ref="repositoryService" />
+ <property name="userService" ref="userService" />
</bean>
- <bean id="simulationContextAction"
- class="org.splat.simer.admin.SimulationContextAction"
+ <bean id="simulationContextAction" class="org.splat.simer.admin.SimulationContextAction"
scope="prototype">
- <property name="knowledgeElementService"
- ref="knowledgeElementService" />
+ <property name="knowledgeElementService" ref="knowledgeElementService" />
<property name="searchService" ref="searchService" />
<property name="projectSettings" ref="projectSettings" />
- <property name="simulationContextService"
- ref="simulationContextService" />
+ <property name="simulationContextService" ref="simulationContextService" />
</bean>
- <bean id="knowledgeElementAction"
- class="org.splat.simer.admin.KnowledgeElementAction"
+ <bean id="knowledgeElementAction" class="org.splat.simer.admin.KnowledgeElementAction"
scope="prototype">
</bean>
- <bean id="saveDocumentAction"
- class="org.splat.module.SaveDocumentAction" scope="prototype">
+ <bean id="saveDocumentAction" class="org.splat.module.SaveDocumentAction"
+ scope="prototype">
<property name="documentTypeService" ref="documentTypeService" />
<property name="publicationService" ref="publicationService" />
<property name="repositoryService" ref="repositoryService" />
<property name="scenarioService" ref="scenarioService" />
<property name="stepService" ref="stepService" />
- <property name="simulationContextService"
- ref="simulationContextService" />
+ <property name="simulationContextService" ref="simulationContextService" />
</bean>
</beans>