if (oid == 0) oid = super.hashCode(); //WARNING: Must not call super.toString() as it goes back here (this.toString())
return new StringBuffer("object ").append(getClass().getName()).append("@").append(oid).toString();
}
+
+/**
+ * Get the rid.
+ * @return the rid
+ */
+public long getRid() {
+ return rid;
+}
+
+/**
+ * Set the rid.
+ * @param rid the rid to set
+ */
+public void setRid(long rid) {
+ this.rid = rid;
+}
}
\ No newline at end of file
return did;
}
- public java.io.File getSaveDirectory() {
- // ---------------------------------------
- String mypath = Database.getRepositoryVaultPath()
- + myfile.getRelativePath();
- String[] table = mypath.split("/");
-
- // Cutting the filename
- StringBuffer path = new StringBuffer(table[0]);
- for (int i = 1; i < table.length - 1; i++)
- path = path.append("/").append(table[i]);
- return new java.io.File(path.append("/").toString());
- }
-
public File getSourceFile() {
// ----------------------------
return myfile;
// --------------------------
return (counter > 1);
}
-
-// ==============================================================================================================================
-// Public services
-// ==============================================================================================================================
-
- public static SimulationContextType createType (String name, ProjectSettingsService.Step step) throws InvalidPropertyException, RuntimeException {
-// ---------------------------------------------------------------------------------------
-//TODO: Check for duplicate definition
- SimulationContextType type = new SimulationContextType(name, step);
- Session session = Database.getSession();
- session.save(type);
-
- return type;
- }
-
- @SuppressWarnings("unchecked")
- public static List<SimulationContextType> selectAllTypes () {
-// -----------------------------------------------------------
- StringBuffer query = new StringBuffer("from SimulationContextType"); // Useless to order by names as the result mixes localized and non localized types
- query = query.append(" order by step asc");
- return Database.getSession().createQuery(query.toString()).list();
- }
-
- @SuppressWarnings("unchecked")
- public static List<SimulationContextType> selectTypesOf (ProjectSettingsService.Step... step) {
-// --------------------------------------------------------------------------------------
- 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");
- return Database.getSession().createQuery(query.toString()).list();
- }
-
- @SuppressWarnings("unchecked")
- public static List<SimulationContextType> selectTypesWhere (SimulationContextType.Properties sprop) {
-// ---------------------------------------------------------------------------------------------------
- StringBuffer query = new StringBuffer("from SimulationContextType");
- String separator = " where";
- ProjectSettingsService.Step step = sprop.getStep();
- ProgressState state = sprop.getProgressState();
- 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);
- return Database.getSession().createQuery(query.toString()).list();
- }
-
- public static SimulationContextType selectType (String name) {
-// ------------------------------------------------------------
- StringBuffer query = new StringBuffer("from SimulationContextType where name='").append(name).append("'");
- return (SimulationContextType)Database.getSession().createQuery(query.toString()).uniqueResult();
- }
-
- public static SimulationContextType selectType (int index) {
-// ----------------------------------------------------------
- StringBuffer query = new StringBuffer("from SimulationContextType where rid='").append(index).append("'");
- return (SimulationContextType)Database.getSession().createQuery(query.toString()).uniqueResult();
- }
-
-// ==============================================================================================================================
-// Protected services
-// ==============================================================================================================================
-
- public void hold () {
-// ----------------------
- counter += 1;
- if (this.isSaved()) Database.getSession().update(this);
- }
-
- public void release () {
-// -------------------------
- counter -= 1;
- if (this.isSaved()) Database.getSession().update(this);
- }
+ /**
+ * Get counter.
+ * @return counter
+ */
+ public int getCounter() {
+ return counter;
+ }
+ /**
+ * Set counter.
+ * @param aValue a counter value to set
+ */
+ public void setCounter(int aValue) {
+ counter = aValue;
+ }
}
\ No newline at end of file
private ProgressState state = null;
private ProjectSettingsService.Step step = null;
- protected ProgressState getProgressState () {
+ public ProgressState getProgressState () {
return state;
}
- protected ProjectSettingsService.Step getStep () {
+ public ProjectSettingsService.Step getStep () {
return step;
}
public Properties setState (ProgressState state) {
protected SimulationContextType () {
}
// Initialization constructor
- protected SimulationContextType (String name, ProjectSettingsService.Step step) throws InvalidPropertyException {
+ public SimulationContextType (String name, ProjectSettingsService.Step step) throws InvalidPropertyException {
// ------------------------------------------------------------------------
super();
this.name = name;
* @copyright OPEN CASCADE 2012
*/
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
-import org.hibernate.jdbc.Work;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.apache.log4j.Logger;
// private static String CONFIG_FILE = "/hibernate.cfg.xml";
private static SessionFactory mySessionFactory = null;
- protected class CreateTables implements Work {
-// -----------------------------------------------
- protected Statement request;
-
- public void execute(Connection connex) throws SQLException
- {
- request = connex.createStatement();
-
-// Last identifier of Any objects
- String create = "CREATE TABLE `any` (" +
- "`rid` int(10) UNSIGNED NOT NULL," +
- "`version` tinytext NOT NULL," +
- "PRIMARY KEY (`rid`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
-// Relation from entities
- create = "CREATE TABLE `relation` (" +
- "`rid` int(10) UNSIGNED NOT NULL," +
- "`name` tinytext NOT NULL," +
- "`owner` int(10) NOT NULL," +
- "`refer` int(10) NOT NULL," +
- "PRIMARY KEY (`rid`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
-// Attribute objects
- create = "CREATE TABLE `attribute` (" +
- "`rid` int(10) UNSIGNED NOT NULL auto_increment," +
- "`type` tinytext NOT NULL," +
- "`owner` int(10) NOT NULL," +
- "`value` int(10) NOT NULL," +
- "PRIMARY KEY (`rid`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
-// Java String objects
- create = "CREATE TABLE `text` (" +
- "`rid` int(10) UNSIGNED NOT NULL auto_increment," +
- "`value` longtext NOT NULL," +
- "PRIMARY KEY (`rid`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
-// User and role objects
- create = "CREATE TABLE `user` (" +
- "`rid` int(10) UNSIGNED NOT NULL auto_increment," +
- "`username` varchar(32) NOT NULL," +
- "`password` varchar(32)," +
- "`first` tinytext NOT NULL," +
- "`last` tinytext NOT NULL," +
- "`display` tinytext," +
- "`email` tinytext," +
- "`organid` tinytext," +
- "PRIMARY KEY (`rid`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
- create = "CREATE TABLE `role` (" +
- "`username` varchar(32) NOT NULL," +
- "`role` varchar(32) NOT NULL," +
- "PRIMARY KEY (`username`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
- }
- }
-
protected final static Logger logger = Logger.getLogger(Database.class);
// ==============================================================================================================================
package org.splat.dal.dao.kernel;
import java.io.Serializable;
+import java.util.List;
+
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
/**
* Generic DAO interface.
*/
T get(PK id);
- /** Save changes made to a persistent object.
- * @param transientObject transient instance of the object to update
+ /**
+ * Save changes made to a persistent object.
+ *
+ * @param transientObject
+ * transient instance of the object to update
*/
void update(T transientObject);
- /** Remove an object from persistent storage in the database.
- * @param persistentObject a persistent object to delete from the database
+ /**
+ * Remove an object from persistent storage in the database.
+ *
+ * @param persistentObject
+ * a persistent object to delete from the database
*/
void delete(T persistentObject);
+
+ /**
+ * Retrieve an object that was previously persisted to the database using the given criteria.
+ *
+ * @param aCondition
+ * a search condition
+ * @return an object found according to the given criteria
+ */
+ public T findByCriteria(Criterion aCondition);
+
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param aCondition
+ * a search condition
+ * @return a list of objects filtered according to the given criteria
+ */
+ public List<T> getFilteredList(Criterion aCondition);
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param aCondition
+ * a search condition
+ * @param anOrder
+ * a result list order. Null is ignored and in such case the result list is unordered.
+ * @return a list of objects filtered according to the given criteria
+ */
+ @SuppressWarnings("unchecked")
+ public List<T> getFilteredList(Criterion aCondition, Order anOrder);
}
package org.splat.dal.dao.kernel;
import java.io.Serializable;
+import java.util.List;
+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;
/**
* @param <PK>
* Primary key class
*/
-public abstract class GenericDAOImpl<T, PK extends Serializable> extends HibernateDaoSupport implements
- GenericDAO<T, PK> {
+public abstract class GenericDAOImpl<T, PK extends Serializable> extends
+ HibernateDaoSupport implements GenericDAO<T, PK> {
/**
* Persist the newInstance object into database.
*
return (T) getSession().get(getType(), id);
}
- /** Save changes made to a persistent object.
- * @param transientObject transient instance of the object to update
+ /**
+ * Retrieve an object that was previously persisted to the database using the given criteria.
+ *
+ * @param aCondition
+ * a search condition
+ * @return an object found according to the given criteria
+ */
+ @SuppressWarnings("unchecked")
+ public T findByCriteria(Criterion aCondition) {
+ return (T) getSession().createCriteria(getType()).add(aCondition)
+ .uniqueResult();
+ }
+
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param aCondition
+ * a search condition
+ * @return a list of objects filtered according to the given criteria
+ */
+ @SuppressWarnings("unchecked")
+ public List<T> getFilteredList(Criterion aCondition) {
+ return getSession().createCriteria(getType()).add(aCondition).list();
+ }
+
+ /**
+ * Retrieve a list of objects which were previously persisted to the database using the given criteria.
+ *
+ * @param aCondition
+ * a search condition
+ * @param anOrder
+ * a result list order. Null is ignored and in such case the result list is unordered.
+ * @return a list of objects filtered according to the given criteria
+ */
+ @SuppressWarnings("unchecked")
+ public List<T> getFilteredList(Criterion aCondition, Order anOrder) {
+ Criteria aCriteria = getSession().createCriteria(getType()).add(
+ aCondition);
+ if (anOrder != null) {
+ aCriteria.addOrder(anOrder);
+ }
+ return aCriteria.list();
+ }
+
+ /**
+ * Save changes made to a persistent object.
+ *
+ * @param transientObject
+ * transient instance of the object to update
*/
public void update(T transientObject) {
getSession().update(transientObject);
}
- /** Remove an object from persistent storage in the database.
- * @param persistentObject a persistent object to delete from the database
+ /**
+ * Remove an object from persistent storage in the database.
+ *
+ * @param persistentObject
+ * a persistent object to delete from the database
*/
public void delete(T persistentObject) {
getSession().delete(persistentObject);
/**
* Get persistent object type.
+ *
* @return Persistent object class to be processed by this DAO
*/
abstract protected Class<T> getType();
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.kernel;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
import org.apache.log4j.Logger;
import org.splat.dal.bo.kernel.User;
-import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.IDBuilder;
-import org.splat.dal.bo.som.KnowledgeElement;
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.bo.som.Study;
import org.splat.kernel.UserDirectory;
import org.splat.kernel.InvalidPropertyException;
import org.splat.service.technical.IndexService;
public class Database extends org.splat.dal.dao.kernel.Database {
private int uplevel = 0; // Level of database upgrade
- private String basepath = null; // Path of the root directory of repository
private RepositoryService _repositoryService;
private IndexService _indexService;
private SessionFactory _sessionFactory;
private static Database my = null; // Singleton instance
- protected class CreateTables extends
- org.splat.dal.dao.kernel.Database.CreateTables {
- // ---------------------------------------------------------------------------
- public void execute(Connection connex) throws SQLException {
- super.execute(connex);
-
- // Study Entity
- String create = "CREATE TABLE `study` ("
- + "`rid` int(10) UNSIGNED NOT NULL,"
- + "`sid` tinytext NOT NULL,"
- + "`title` tinytext NOT NULL,"
- + "`state` enum('inWORK','inDRAFT','inCHECK','APPROVED', 'TEMPLATE') NOT NULL default 'inWORK',"
- + "`area` enum('PRIVATE','PUBLIC','REFERENCE') NOT NULL default 'PRIVATE',"
- + "`manager` int(10) NOT NULL,"
- + "`version` tinytext NOT NULL,"
- + "`docount` int(10) UNSIGNED NOT NULL,"
- + "`history` int(10) UNSIGNED NOT NULL,"
- + "`credate` date NOT NULL,"
- + "`lasdate` date NOT NULL," + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
- // Scenario Entity
- create = "CREATE TABLE `scenario` ("
- + "`rid` int(10) UNSIGNED NOT NULL,"
- + "`sid` int(10) UNSIGNED NOT NULL,"
- + "`owner` int(10) NOT NULL,"
- + "`scendex` int(3) NOT NULL,"
- + "`title` tinytext NOT NULL,"
- + "`manager` int(10) NOT NULL," + "`cuser` int(10),"
- + "`credate` date NOT NULL,"
- + "`lasdate` date NOT NULL," + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
- // Document Entity and document tag (Publication)
- create = "CREATE TABLE `document` ("
- + "`rid` int(10) UNSIGNED NOT NULL,"
- + "`did` tinytext NOT NULL,"
- + "`type` int(10) NOT NULL,"
- + "`step` int(10) NOT NULL,"
- + "`state` enum('inWORK','inDRAFT','inCHECK','APPROVED','EXTERN') NOT NULL default 'inWORK',"
- + "`name` tinytext NOT NULL,"
- + "`author` int(10) NOT NULL," + "`version` tinytext,"
- + "`countag` int(10) UNSIGNED NOT NULL,"
- + "`history` int(10) NOT NULL,"
- + "`myfile` int(10) NOT NULL,"
- + "`lasdate` date NOT NULL," + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
- create = "CREATE TABLE `doctag` ("
- + "`rid` int(10) UNSIGNED NOT NULL auto_increment,"
- + "`doc` int(10) NOT NULL,"
- + "`owner` int(10) NOT NULL,"
- + "`isnew` char(1) NOT NULL," + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
- // Document types
- create = "CREATE TABLE `doctype` ("
- + "`rid` int(10) UNSIGNED NOT NULL auto_increment,"
- + "`name` tinytext NOT NULL,"
- + "`state` enum('inCHECK','APPROVED') NOT NULL default 'inCHECK',"
- + "`step` tinytext NOT NULL," + "`result` tinytext,"
- + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
- // Document types dependencies
- create = "CREATE TABLE `docuse` (" + "`owner` int(10) NOT NULL,"
- + "`rid` int(10) NOT NULL"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
- // ValidationCycle related object
- create = "CREATE TABLE `cycle` ("
- + "`rid` int(10) UNSIGNED NOT NULL auto_increment,"
- + "`type` int(10) NOT NULL," + "`publisher` int(10),"
- + "`reviewer` int(10)," + "`approver` int(10),"
- + "`signatory` int(10)," + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
- // Timestamp related object
- create = "CREATE TABLE `stamp` ("
- + "`rid` int(10) UNSIGNED NOT NULL auto_increment,"
- + "`type` enum('PROMOTION','REVIEW','APPROVAL','ACCEPTANCE','DISTRIBUTION','REFUSAL') NOT NULL,"
- + "`author` int(10) NOT NULL,"
- + "`date` datetime NOT NULL," + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
- // KnowledgeElements objects
- create = "CREATE TABLE `knowelm` ("
- + "`rid` int(10) UNSIGNED NOT NULL auto_increment,"
- + "`type` int(10) NOT NULL,"
- + "`owner` int(10) NOT NULL,"
- + "`state` enum('inWORK','inDRAFT','inCHECK','APPROVED') NOT NULL default 'inDRAFT',"
- + "`title` tinytext NOT NULL,"
- + "`value` text NOT NULL,"
- + "`author` int(10) NOT NULL,"
- + "`date` date NOT NULL," + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
- // KnowledgeElement types
- create = "CREATE TABLE `knowtype` ("
- + "`rid` int(10) UNSIGNED NOT NULL auto_increment,"
- + "`name` tinytext NOT NULL,"
- + "`state` enum('inWORK','inCHECK','APPROVED') NOT NULL default 'inCHECK',"
- + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
- // SimulationContext objects
- create = "CREATE TABLE `contelm` ("
- + "`rid` int(10) UNSIGNED NOT NULL auto_increment,"
- + "`type` int(10) NOT NULL,"
- + "`step` int(10) NOT NULL,"
- + "`state` enum('inCHECK','APPROVED') NOT NULL default 'inCHECK',"
- + "`value` text NOT NULL,"
- + "`counter` int(10) UNSIGNED NOT NULL,"
- + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
- // SimulationContext types
- create = "CREATE TABLE `contype` ("
- + "`rid` int(10) UNSIGNED NOT NULL auto_increment,"
- + "`name` tinytext NOT NULL,"
- + "`state` enum('inCHECK','APPROVED') NOT NULL default 'inCHECK',"
- + "`step` int(10) NOT NULL," + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
- // Many-to-many association between ProjectElement (Study and Scenario) and SimulationContext
- create = "CREATE TABLE `projext` (" + "`owner` int(10) NOT NULL,"
- + "`ordex` int(10) NOT NULL," + "`rid` int(10) NOT NULL"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
- // File objects
- create = "CREATE TABLE `file` ("
- + "`rid` int(10) UNSIGNED NOT NULL,"
- + "`format` tinytext NOT NULL,"
- + "`path` tinytext NOT NULL,"
- + "`date` date NOT NULL," + "PRIMARY KEY (`rid`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
- // Reference objects
- create = "CREATE TABLE `refid` (" + "`cycle` int(10) NOT NULL,"
- + "`base` int(10) NOT NULL," + "PRIMARY KEY (`cycle`)"
- + ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
- }
- }
-
+ /**
+ * The job-class for database schema version ckeck.
+ * @author dbc
+ *
+ */
protected class CheckVersion implements Work {
- // --------------------------------------------
+ /**
+ * {@inheritDoc}
+ * @see org.hibernate.jdbc.Work#execute(java.sql.Connection)
+ */
public void execute(Connection connex) throws SQLException {
DatabaseMetaData dbmdata = connex.getMetaData();
String dbname = connex.getCatalog();
private Database() {
}
+ /**
+ * Check version of the database schema.
+ */
private void checkVersion() {
getSessionFactory().getCurrentSession().doWork(new CheckVersion());
}
// Creation of the SIMER SQL tables
Session session = Database.getSession();
- session.doWork(new CreateTables()); // May throw SQLException if the SIMER database does not exist
- session.flush();
// Population of the database with customized data
this.populate();
public void configure(Properties reprop) throws IOException {
// --------------------------------------------
- basepath = reprop.getProperty("repository");
+ String basepath = reprop.getProperty("repository");
getRepositoryService().setBasepath(basepath);
getIndexService().configure();
}
// Public services
// ==============================================================================================================================
- public static File getDownloadDirectory(User user) {
- return my.getRepositoryService().getDownloadDirectory(user);
- }
-
- public static String getTemplatePath() {
- return my.getRepositoryService().getTemplatePath();
- }
-
public static String getRepositoryVaultPath() {
return my.getRepositoryService().getRepositoryVaultPath();
}
- public static Document selectDocument(int index) {
- // -------------------------------------------------
- StringBuffer query = new StringBuffer("from Document where rid='")
- .append(index).append("'");
- return (Document) Database.getSession().createQuery(query.toString())
- .uniqueResult();
- }
-
- public static Document selectDocument(String refid, String version) {
- // --------------------------------------------------------------------
- StringBuffer query = new StringBuffer("from Document where did='")
- .append(refid).append("' and version='").append(version)
- .append("'");
- return (Document) Database.getSession().createQuery(query.toString())
- .uniqueResult();
- }
-
- public static SimulationContext selectSimulationContext(int index) {
- // -------------------------------------------------------------------
- StringBuffer query = new StringBuffer(
- "from SimulationContext where rid='").append(index).append("'");
- return (SimulationContext) Database.getSession().createQuery(
- query.toString()).uniqueResult();
- }
-
- public static SimulationContext selectSimulationContext(
- SimulationContextType celt, String value) {
- // --------------------------------------------------------------------------------------------------
- SimulationContext result = null;
- try {
- SimulationContext.Properties cprop = new SimulationContext.Properties();
- List<SimulationContext> clist = selectSimulationContextsWhere(cprop
- .setType(celt).setValue(value));
- if (!clist.isEmpty())
- result = clist.get(0); // Supposed being the most used one if many exist
- } catch (InvalidPropertyException error) {
- logger.info("Attempt to select a simulation context \""
- + celt.getName() + "\" with an invalid value.");
- }
- return result;
- }
-
- @SuppressWarnings("unchecked")
- public static List<SimulationContext> selectSimulationContextsWhere(
- SimulationContext.Properties cprop) {
- // --------------------------------------------------------------------------------------------------------
- StringBuffer query = new StringBuffer("from SimulationContext");
- String separator = " where";
- SimulationContextType celt = cprop.getType();
- String value = cprop.getValue();
- ProgressState state = cprop.getProgressState();
- String order = "";
-
- if (celt != null) {
- query = query.append(separator).append(" type='").append(
- celt.getIndex()).append("'");
- separator = " and";
- order = " order by value asc";
- }
- if (value != null) {
- query = query.append(separator).append(" value='").append(value)
- .append("'");
- separator = " and";
- }
- if (state != null) {
- query = query.append(separator).append(" state='").append(state)
- .append("'");
- if (celt == null)
- order = " order by type asc";
- }
- query.append(order);
- return (List<SimulationContext>) Database.getSession().createQuery(
- query.toString()).list();
- }
-
- protected static IDBuilder selectIDBuilder(int cycle) {
- // ------------------------------------------------------
- StringBuffer buffer = new StringBuffer("from IDBuilder where cycle='")
- .append(cycle).append("'");
- String qstring = buffer.toString();
- Query query = Database.getSession().createQuery(qstring);
- IDBuilder result = (IDBuilder) query.uniqueResult();
-
- return result;
- }
-
- public static IDBuilder selectIDBuilder(Date date) {
- // ------------------------------------------------------
- SimpleDateFormat year = new SimpleDateFormat("yyyy");
- String cycle = year.format(date);
- StringBuffer buffer = new StringBuffer("from IDBuilder where cycle='")
- .append(cycle).append("'");
- String qstring = buffer.toString();
- Query query = Database.getSession().createQuery(qstring);
- IDBuilder result = (IDBuilder) query.uniqueResult();
-
- return result;
- }
-
/**
* @return
*/
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
* Creation date 06.10.2012
* @author $Author$
* @version $Revision$
+ * Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012
*****************************************************************************/
package org.splat.dal.dao.som;
@SuppressWarnings("unchecked") // For the casting List<User>
public static List<User> selectAllUsers () {
// ------------------------------------------
- String query = "FROM users order by last asc, first asc";
+ 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 users where username='").append(username).append("'");
+ StringBuffer query = new StringBuffer("FROM User where username='").append(username).append("'");
return (User)Database.getSession().createQuery(query.toString()).uniqueResult();
}
// ----------------------------------------------------------------
//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 users where username='").append(username).append("' and password");
+ 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("'");
public static User selectUser (int index) {
// -----------------------------------------
- StringBuffer query = new StringBuffer("FROM users where rid='").append(index).append("'");
+ 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 users");
+ StringBuffer query = new StringBuffer("FROM User");
String separator = " where (";
String value;
package org.splat.service;
import org.splat.dal.bo.som.Document;
-import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.Document.Properties;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.som.Step;
/**
+ * Document service interface.
+ *
* @author RKV
*
*/
/**
* Defines this document.
*
+ * @param aDoc
+ * the document to define
* @param dprop
* the properties of the document
- *
+ * @throws MissedPropertyException
+ * if a mandatory property is missed
+ * @throws InvalidPropertyException
+ * if a property doesn't exist
+ * @throws NotApplicableException
+ * if the document is undefined
* @see Step#createDocument(Properties)
* @see #isUndefined()
*/
throws MissedPropertyException, InvalidPropertyException,
NotApplicableException;
+ /**
+ * Find a document by its id.
+ *
+ * @param index
+ * document id
+ * @return found document
+ */
+ public Document selectDocument(long index);
+
+ /**
+ * Find a document by its reference and version.
+ *
+ * @param refid
+ * document reference
+ * @param version
+ * document version
+ * @return found document
+ */
+ public Document selectDocument(String refid, String version);
+
+ /**
+ * Generate document reference.
+ *
+ * @param aDoc
+ * the document
+ * @param dprop
+ * document properties (owner project element is used)
+ */
public void generateDocumentId(Document aDoc, Properties dprop);
+
+ /**
+ * Get a directory where the document file is saved.
+ * @param aDoc the document
+ * @return a directory
+ */
+ public java.io.File getSaveDirectory(Document aDoc);
}
* @version $Revision$
*****************************************************************************/
-package org.splat.service;
+package org.splat.service;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import org.splat.dal.bo.som.Study;
import org.splat.dal.bo.som.Document.Properties;
import org.splat.dal.dao.som.Database;
+import org.splat.dal.dao.som.DocumentDAO;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.NotApplicableException;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.service.technical.ProjectSettingsServiceImpl;
import org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming;
-import org.splat.som.Step;
+import org.springframework.transaction.annotation.Transactional;
/**
+ * Document service implementation.
+ *
* @author RKV
- *
+ *
*/
public class DocumentServiceImpl implements DocumentService {
+ /**
+ * Injected study service.
+ */
private StudyService _studyService;
+ /**
+ * Injected project settings service.
+ */
private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected document service.
+ */
+ private DocumentDAO _documentDAO;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.DocumentService#selectDocument(long)
+ */
+ @Transactional(readOnly = true)
+ public Document selectDocument(long index) {
+ // -------------------------------------------------
+ return getDocumentDAO().get(index);
+ }
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.DocumentService#selectDocument(java.lang.String, java.lang.String)
+ */
+ public Document selectDocument(String refid, String version) {
+ // --------------------------------------------------------------------
+ StringBuffer query = new StringBuffer("from Document where did='")
+ .append(refid).append("' and version='").append(version)
+ .append("'");
+ return (Document) Database.getSession().createQuery(query.toString())
+ .uniqueResult();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.DocumentService#generateDocumentId(org.splat.dal.bo.som.Document, org.splat.dal.bo.som.Document.Properties)
+ */
public void generateDocumentId(Document aDoc, Properties dprop) {
Study owner = null;
if (dprop.getOwner() instanceof Study)
String path = owner.getReference();
ProjectSettingsService.Step step = ProjectSettingsServiceImpl
.getStep(aDoc.getStep());
- aDoc.setDid( new StringBuffer(path).append(".%").append(aDoc.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
- .append(filename).append(".").append(aDoc.getFile().getFormat()) // File name and extension
+ .append(step.getPath())
+ // File path relative to the repository vault
+ .append(filename).append(".")
+ .append(aDoc.getFile().getFormat()) // File name and extension
.toString();
aDoc.getFile().changePath(path);
}
+ /**
+ * Generate encoded document file name according to the naming scheme from project settings.
+ *
+ * @param aDoc
+ * the document
+ * @param scope
+ * the study
+ * @return document reference name
+ */
private String generateEncodedName(Document aDoc, Study scope) {
// ------------------------------------------------
StringBuffer encoding = new StringBuffer();
FileNaming scheme = getProjectSettings().getFileNamingScheme();
- DecimalFormat tostring = new DecimalFormat(aDoc.suformat);
+ DecimalFormat tostring = new DecimalFormat(Document.suformat);
int number = getStudyService().generateLocalIndex(scope);
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();
}
+ /**
+ * Get encoded root name for a document file.
+ *
+ * @param aDoc
+ * the document
+ * @param scope
+ * the study
+ * @return file name
+ */
private String getEncodedRootName(Document aDoc, Study scope) {
// -----------------------------------------------
FileNaming scheme = getProjectSettings().getFileNamingScheme();
}
/**
- * Defines this document.
- *
- * @param dprop
- * the properties of the document
+ * {@inheritDoc}
*
- * @see Step#createDocument(Properties)
- * @see #isUndefined()
+ * @see org.splat.service.DocumentService#initialize(org.splat.dal.bo.som.Document, org.splat.dal.bo.som.Document.Properties)
*/
- public void initialize(Document aDoc, Properties dprop) throws MissedPropertyException,
- InvalidPropertyException, NotApplicableException {
+ public void initialize(Document aDoc, Properties dprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ NotApplicableException {
// --------------------------------------------
if (!aDoc.isUndefined())
throw new NotApplicableException(
// throw new InvalidPropertyException("step");
// }
aDoc.setTitle(dprop.getName());
- aDoc.getFile().changePath(aDoc.getFile().getRelativePath().replace("%n",
- getEncodedRootName(aDoc, (Study) dprop.getOwner())));
+ aDoc.getFile().changePath(
+ aDoc.getFile().getRelativePath().replace("%n",
+ getEncodedRootName(aDoc, (Study) dprop.getOwner())));
if (aDoc.getHistory() == -1)
- aDoc.setHistory( 0 );
+ aDoc.setHistory(0);
if (dprop.getDate() == null) {
Calendar current = Calendar.getInstance();
aDoc.setLastModificationDate(current.getTime()); // Today
Database.getSession().update(aDoc);
}
+ public java.io.File getSaveDirectory(Document aDoc) {
+ String mypath = Database.getRepositoryVaultPath()
+ + aDoc.getSourceFile().getRelativePath();
+ String[] table = mypath.split("/");
+
+ // Cutting the filename
+ StringBuffer path = new StringBuffer(table[0]);
+ for (int i = 1; i < table.length - 1; i++)
+ path = path.append("/").append(table[i]);
+ return new java.io.File(path.append("/").toString());
+ }
+
/**
* 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;
_projectSettingsService = projectSettingsService;
}
+ /**
+ * Get the documentDAO.
+ *
+ * @return the documentDAO
+ */
+ public DocumentDAO getDocumentDAO() {
+ return _documentDAO;
+ }
+
+ /**
+ * Set the documentDAO.
+ *
+ * @param documentDAO
+ * the documentDAO to set
+ */
+ public void setDocumentDAO(DocumentDAO documentDAO) {
+ _documentDAO = documentDAO;
+ }
+
}
import org.splat.som.Step;
/**
+ * Project element service interface.
* @author RKV
*
*/
public interface ProjectElementService {
+ /**
+ * Get the first activity of the project element.
+ * @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
+ * @return array of activities (steps).
+ */
public Step[] getSteps(ProjectElement elem);
}
import org.splat.dal.bo.som.ProjectElement;
import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.technical.ProjectSettingsServiceImpl;
import org.splat.som.Step;
/**
+ * Project element service implementation.
* @author RKV
*
*/
public class ProjectElementServiceImpl implements ProjectElementService {
+ /**
+ * Injected project settings service.
+ */
private ProjectSettingsService _projectSettingsService;
+ /**
+ * {@inheritDoc}
+ * @see org.splat.service.ProjectElementService#getFirstStep(org.splat.dal.bo.som.ProjectElement)
+ */
public Step getFirstStep(ProjectElement elem) {
- // ---------------------------
return getSteps(elem)[0];
}
public Step getLastStep(ProjectElement elem) {
- // --------------------------
Step[] mystep = getSteps(elem); // For getting the folders length, if null
return mystep[mystep.length - 1];
}
+ /**
+ * {@inheritDoc}
+ * @see org.splat.service.ProjectElementService#getSteps(org.splat.dal.bo.som.ProjectElement)
+ */
public Step[] getSteps(ProjectElement elem) {
- // -------------------------
if (elem.getFolders() == null) {
List<ProjectSettingsService.Step> steps = getProjectSettings()
.getStepsOf(elem.getClass());
import org.splat.som.Step;
/**
- * @author RKV
+ * Publication service interface.
*
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
public interface PublicationService {
+ /**
+ * Copy the publication to the given project element.
+ *
+ * @param aPublication
+ * the publication to copy
+ * @param publisher
+ * the target project element
+ * @return the created copy of the publication
+ */
public Publication copy(Publication aPublication, ProjectElement publisher);
/**
* Returns the study Step into which the document version referenced by this publication has been published.
+ *
+ * @param aPublication
+ * the document publication
+ * @return study step
*/
public Step getInvolvedStep(Publication aPublication);
/**
* 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
+ * 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
* @param adate
* the date of approval
* @return true if the approval succeeded
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
+ * 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
* @return true if the demotion succeeded
* @see #getProgressState()
* @see DocumentRights#canDemote()
/**
* 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
+ * the document publication
* @return true if the demotion succeeded
* @see #getProgressState()
* @see #review()
/**
* 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
+ * 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
+ * @param pdate
+ * the date of promotion
* @return true if the promotion succeeded
* @see #getProgressState()
* @see #demote()
/**
* 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
* @param rdate
* the date of review
* @return true if the review succeeded
* the document being automatically set accordingly. If the given state is In-Draft and the document is final result of the owner study,
* this automatically promotes the study to In-Draft.
*
+ * @param aPublication
+ * the document publication
* @param state
* the required progress state
* @throws FileNotFoundException
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
* @param newvers
* the required revision number
* @throws FileNotFoundException
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;
/**
- * @author RKV
+ * Publication service implementation.
*
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
public class PublicationServiceImpl implements PublicationService {
+ /**
+ * Injected study service.
+ */
private StudyService _studyService;
+ /**
+ * Injected study service.
+ */
private StepService _stepService;
+ /**
+ * Injected study service.
+ */
private DocumentTypeService _documentTypeService;
+ /**
+ * Injected study service.
+ */
private ProjectElementService _projectElementService;
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.PublicationService#copy(org.splat.dal.bo.som.Publication, org.splat.dal.bo.som.ProjectElement)
+ */
public Publication copy(Publication aPublication, ProjectElement publisher) {
- // -----------------------------------------------------
Publication copy = new Publication();
copy.setValue(aPublication.value());
copy.setStep(aPublication.getStep()); // May not be initialized yet
}
/**
- * 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.
+ * {@inheritDoc}
*
- * @param adate
- * the date of approval
- * @return true if the approval succeeded
- * @see #getProgressState()
- * @see DocumentRights#canApprove()
- * @see DocumentType#isStudyResult()
- * @see Study#getApproverOf(Publication)
+ * @see org.splat.service.PublicationService#approve(org.splat.dal.bo.som.Publication, java.util.Date)
*/
public Timestamp approve(Publication aPublication, Date adate) {
// -------------------------------------
Study owner = aPublication.getOwnerStudy();
ValidationCycle cycle = owner.getValidationCycleOf(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 (!aPublication.value().promote(stamp))
return null;
if (getDocumentTypeService().isStudyResult(type)
}
/**
- * 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.
+ * {@inheritDoc}
*
- * @return true if the demotion succeeded
- * @see #getProgressState()
- * @see DocumentRights#canDemote()
- * @see DocumentType#isStudyResult()
+ * @see org.splat.service.PublicationService#demote(org.splat.dal.bo.som.Publication)
*/
public boolean demote(Publication aPublication) {
// ------------------------
}
/**
- * Undo the review operation by demoting the document referenced by this publication from In-Check to In-Draft state and removing the
- * 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.
+ * {@inheritDoc}
*
- * @return true if the demotion succeeded
- * @see #getProgressState()
- * @see #review()
- * @see DocumentRights#canInvalidate()
- * @see DocumentType#isStudyResult()
+ * @see org.splat.service.PublicationService#invalidate(org.splat.dal.bo.som.Publication)
*/
public boolean invalidate(Publication aPublication) {
// ----------------------------
}
/**
- * Promotes the document referenced by this publication from In-Work to In-Draft or In-Check state, if not out-dated, and attaches the
- * 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.
+ * {@inheritDoc}
*
- * @return true if the promotion succeeded
- * @see #getProgressState()
- * @see #demote()
- * @see DocumentRights#canPromote()
- * @see DocumentType#isStudyResult()
+ * @see org.splat.service.PublicationService#promote(org.splat.dal.bo.som.Publication, java.util.Date)
*/
public Timestamp promote(Publication aPublication, Date pdate) {
if (aPublication.isOutdated())
}
/**
- * 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.
+ * {@inheritDoc}
*
- * @param rdate
- * the date of review
- * @return true if the review succeeded
- * @see #getProgressState()
- * @see #invalidate()
- * @see DocumentRights#canReview()
- * @see DocumentType#isStudyResult()
- * @see Study#getReviewerOf(Publication)
+ * @see org.splat.service.PublicationService#review(org.splat.dal.bo.som.Publication, java.util.Date)
*/
public Timestamp review(Publication aPublication, Date rdate) {
if (aPublication.isOutdated())
Study owner = aPublication.getOwnerStudy();
ValidationCycle cycle = owner.getValidationCycleOf(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 (!aPublication.value().promote(stamp))
return null;
if (getDocumentTypeService().isStudyResult(type)
}
/**
- * 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.
+ * {@inheritDoc}
*
- * @param newvers
- * the required revision number
- * @throws FileNotFoundException
- * If the referenced document is empty
- * @throws NotApplicableException
- * If the referenced document is undefined
+ * @see org.splat.service.PublicationService#saveAs(org.splat.dal.bo.som.Publication, org.splat.som.Revision)
* @deprecated
*/
public void saveAs(Publication aPublication, Revision newvers)
}
/**
- * Publishes the document referenced by this publication into the owner Project Element under the given state, the revision number of
- * the document being automatically set accordingly. If the given state is In-Draft and the document is final result of the owner study,
- * this automatically promotes the study to In-Draft.
+ * {@inheritDoc}
*
- * @param state
- * the required progress state
- * @throws FileNotFoundException
- * If the referenced document is empty
- * @throws NotApplicableException
- * If the referenced document is undefined
+ * @see org.splat.service.PublicationService#saveAs(org.splat.dal.bo.som.Publication, org.splat.dal.bo.som.ProgressState)
*/
public void saveAs(Publication aPublication, ProgressState state)
throws FileNotFoundException, NotApplicableException {
throw new FileNotFoundException();
if (state == ProgressState.inWORK || state == ProgressState.EXTERN) {
- Database.getSession().save(aPublication); // Must be done before updating the study in order to fix this final (rid-based) hascode
+ Database.getSession().save(aPublication); // Must be done before updating the study in order to fix this final (rid-based)
+ // hascode
aPublication.value().updateAs(state);
} else {
DocumentType mytype = aPublication.value().getType();
+ " state");
}
Database.getSession().save(aPublication); // Must be done before updating the study in order to fix this final (rid-based)
- // hascode
+ // hascode
aPublication.value().updateAs(ProgressState.inWORK);
promote(aPublication, aPublication.value()
updateOwner(aPublication);
}
- public void updateOwner(Publication aPublication) {
- // ---------------------------
+ /**
+ * Update an owner of the publication.
+ *
+ * @param aPublication
+ * the document publication
+ */
+ private void updateOwner(Publication aPublication) {
Session session = Database.getSession();
Step step = getInvolvedStep(aPublication);
session.update(aPublication.getOwner());
}
+ /**
+ * Propagate simulation contexts from the given config file to the publication's owner (study or step).
+ *
+ * @param aPublication
+ * the document publication
+ * @param from
+ * the config file
+ * @param to
+ * the study step
+ */
private void forwardProperties(Publication aPublication, java.io.File from,
Step to) {
// -----------------------------------------------------------
SimulationContextType.Properties sprop = new SimulationContextType.Properties()
.setStep(to.getStep()).setState(ProgressState.APPROVED);
- List<SimulationContextType> contype = SimulationContext
+ List<SimulationContextType> contype = getSimulationContextService()
.selectTypesWhere(sprop);
if (contype.isEmpty())
return; // No approved property type configured at this step
/**
* Returns the study Step into which the document version referenced by this publication has been published.
+ *
+ * @param aPublication
+ * the document publication
+ * @return the study step where the document is published
*/
public Step getInvolvedStep(Publication aPublication) {
if (aPublication.getStep() == null) {
- Step[] step = getProjectElementService().getSteps(aPublication.getOwner());
+ Step[] step = getProjectElementService().getSteps(
+ aPublication.getOwner());
for (int i = 0; i < step.length; i++) {
aPublication.setStep(step[i]); // The involved step necessarily exists
if (aPublication.value().isInto(aPublication.getStep()))
}
/**
- * @return
+ * Get the projectElementService.
+ *
+ * @return the projectElementService
*/
- private StepService getStepService() {
- return _stepService;
+ public ProjectElementService getProjectElementService() {
+ return _projectElementService;
}
- public void setStepService(StepService stepService) {
- _stepService = stepService;
+ /**
+ * Set the projectElementService.
+ *
+ * @param projectElementService
+ * the projectElementService to set
+ */
+ public void setProjectElementService(
+ ProjectElementService projectElementService) {
+ _projectElementService = projectElementService;
+ }
+
+ /**
+ * Get the simulationContextService.
+ *
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ *
+ * @param simulationContextService
+ * the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
}
/**
- * @return
+ * Get the studyService.
+ * @return the studyService
*/
public StudyService getStudyService() {
return _studyService;
}
+ /**
+ * Set the studyService.
+ * @param studyService the studyService to set
+ */
public void setStudyService(StudyService studyService) {
_studyService = studyService;
}
/**
- * @return
+ * Get the stepService.
+ * @return the stepService
*/
- public DocumentTypeService getDocumentTypeService() {
- return _documentTypeService;
+ public StepService getStepService() {
+ return _stepService;
}
- public void setDocumentTypeService(DocumentTypeService documentTypeService) {
- _documentTypeService = documentTypeService;
+ /**
+ * Set the stepService.
+ * @param stepService the stepService to set
+ */
+ public void setStepService(StepService stepService) {
+ _stepService = stepService;
}
/**
- * Get the projectElementService.
- * @return the projectElementService
+ * Get the documentTypeService.
+ * @return the documentTypeService
*/
- public ProjectElementService getProjectElementService() {
- return _projectElementService;
+ public DocumentTypeService getDocumentTypeService() {
+ return _documentTypeService;
}
/**
- * Set the projectElementService.
- * @param projectElementService the projectElementService to set
+ * Set the documentTypeService.
+ * @param documentTypeService the documentTypeService to set
*/
- public void setProjectElementService(ProjectElementService projectElementService) {
- _projectElementService = projectElementService;
+ public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+ _documentTypeService = documentTypeService;
}
}
--- /dev/null
+/*****************************************************************************
+ * Company EURIWARE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 16.10.2012
+ * @author $Author$
+ * @version $Revision$
+ *****************************************************************************/
+
+package org.splat.service;
+
+import java.util.List;
+
+import org.splat.dal.bo.som.SimulationContext;
+import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.service.technical.ProjectSettingsService;
+
+/**
+ * Simulation context service interface.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ *
+ */
+public interface SimulationContextService {
+
+ /**
+ * Get simulation context by its id.
+ *
+ * @param index
+ * simulation context id.
+ * @return found context
+ */
+ public SimulationContext selectSimulationContext(long index);
+
+ /**
+ * Find simulation context by its type and value.
+ *
+ * @param celt
+ * context type
+ * @param value
+ * context value
+ * @return found context
+ */
+ public SimulationContext selectSimulationContext(
+ SimulationContextType celt, String value);
+
+ /**
+ * Find simulation contexts by example.
+ *
+ * @param cprop
+ * example properties
+ * @return list of contexts
+ */
+ public List<SimulationContext> selectSimulationContextsWhere(
+ SimulationContext.Properties cprop);
+
+ /**
+ * Create a simulation context type.
+ *
+ * @param name
+ * context type name
+ * @param step
+ * activity related to this context type
+ * @return the created context type
+ * @throws InvalidPropertyException
+ * if some property of the type to be created is invalid
+ */
+ public SimulationContextType createType(String name,
+ ProjectSettingsService.Step step) throws InvalidPropertyException;
+
+ /**
+ * Get all simulation context types.
+ *
+ * @return list of context types
+ */
+ public List<SimulationContextType> selectAllTypes();
+
+ /**
+ * Get simulation context types related to given activities.
+ *
+ * @param step
+ * the activity
+ * @return list of found context types
+ */
+ public List<SimulationContextType> selectTypesOf(
+ ProjectSettingsService.Step... step);
+
+ /**
+ * Get simulation context types by example.
+ * @param sprop the example
+ * @return list of found context types
+ */
+ public List<SimulationContextType> selectTypesWhere(
+ SimulationContextType.Properties sprop);
+
+ /**
+ * Get a simulation context type by its name.
+ * @param name name of the context type
+ * @return found context type
+ */
+ public SimulationContextType selectType(String name);
+
+ /**
+ * Get simulation context type by its id.
+ *
+ * @param index
+ * simulation context type id.
+ * @return found context type
+ */
+ public SimulationContextType selectType(long index);
+
+ /**
+ * Hold the simulation context.
+ *
+ * @param simCtx
+ * the context to hold.
+ */
+ public void hold(SimulationContext simCtx);
+
+ /**
+ * Release the simulation context.
+ *
+ * @param simCtx
+ * the context to release
+ */
+ public void release(SimulationContext simCtx);
+
+ /**
+ * Get the simulation context list for displaying drop-down list values populating on the "Create new study" screen.
+ *
+ * @return List of the simulation contexts.
+ */
+ List<SimulationContext> getSimulationContextList();
+
+}
--- /dev/null
+/*****************************************************************************
+ * Company EURIWARE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 16.10.2012
+ * @author $Author$
+ * @version $Revision$
+ *****************************************************************************/
+
+package org.splat.service;
+
+import java.util.List;
+
+import org.hibernate.Criteria;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Example;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.PropertyExpression;
+import org.hibernate.criterion.Restrictions;
+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.springframework.transaction.annotation.Transactional;
+
+/**
+ * Simulation context service implementation.
+ *
+ * @author rkv
+ *
+ */
+public class SimulationContextServiceImpl implements SimulationContextService {
+
+ /**
+ * logger for the service.
+ */
+ public final static AppLogger logger = AppLogger
+ .getLogger(SimulationContextServiceImpl.class);
+ /**
+ * Injected simulation context DAO.
+ */
+ private SimulationContextDAO _simulationContextDAO;
+
+ /**
+ * Injected simulation context type DAO.
+ */
+ private SimulationContextTypeDAO _simulationContextTypeDAO;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.SimulationContextService#selectSimulationContext(int)
+ */
+ public SimulationContext selectSimulationContext(long index) {
+ return getSimulationContextDAO().get(index);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.SimulationContextService#selectSimulationContext(org.splat.dal.bo.som.SimulationContextType, java.lang.String)
+ */
+ public SimulationContext selectSimulationContext(
+ SimulationContextType celt, String value) {
+ SimulationContext result = null;
+ try {
+ SimulationContext.Properties cprop = new SimulationContext.Properties();
+ List<SimulationContext> clist = selectSimulationContextsWhere(cprop
+ .setType(celt).setValue(value));
+ if (!clist.isEmpty())
+ result = clist.get(0); // Supposed being the most used one if many exist
+ } catch (InvalidPropertyException error) {
+ logger.info("Attempt to select a simulation context \""
+ + celt.getName() + "\" with an invalid value.");
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.SimulationContextService#selectSimulationContextsWhere(org.splat.dal.bo.som.SimulationContext.Properties)
+ */
+ @Transactional(readOnly=true)
+ public List<SimulationContext> selectSimulationContextsWhere(
+ SimulationContext.Properties cprop) {
+// StringBuffer query = new StringBuffer("from SimulationContext");
+// String separator = " where";
+ SimulationContextType celt = cprop.getType();
+ String value = cprop.getValue();
+ ProgressState state = cprop.getProgressState();
+// String order = "";
+ Criterion aCondition = null;
+ Order anOrder = null;
+
+ if (celt != null) {
+// query = query.append(separator).append(" type='").append(
+// celt.getIndex()).append("'");
+// separator = " and";
+// order = " order by value asc";
+ aCondition = Restrictions.eq("type", celt);
+ anOrder = Order.asc("value");
+ }
+ if (value != null) {
+// query = query.append(separator).append(" value='").append(value)
+// .append("'");
+// separator = " and";
+
+ aCondition = Restrictions.and(aCondition, Restrictions.eq("value", value));
+ }
+ if (state != null) {
+// query = query.append(separator).append(" state='").append(state)
+// .append("'");
+ if (celt == null) {
+// order = " order by type asc";
+ anOrder = Order.asc("type");
+ }
+ aCondition = Restrictions.and(aCondition, Restrictions.eq("state", state));
+ }
+// query.append(order);
+// return (List<SimulationContext>) Database.getSession().createQuery(
+// query.toString()).list();
+ return getSimulationContextDAO().getFilteredList(aCondition, anOrder);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.SimulationContextService#getSimulationContextList()
+ */
+ @Transactional(readOnly = true)
+ public List<SimulationContext> getSimulationContextList() {
+ SimulationContext.Properties cprop = new SimulationContext.Properties();
+ SimulationContextType product = selectType("product");
+ List<SimulationContext> resList = selectSimulationContextsWhere(cprop
+ .setType(product));
+ return resList;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.SimulationContextService#createType(java.lang.String, org.splat.service.technical.ProjectSettingsService.Step)
+ */
+ @Transactional
+ public SimulationContextType createType(String name,
+ ProjectSettingsService.Step step) throws InvalidPropertyException {
+ // TODO: Check for duplicate definition
+ SimulationContextType type = new SimulationContextType(name, step);
+ getSimulationContextTypeDAO().create(type);
+
+ return type;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.SimulationContextService#selectAllTypes()
+ */
+ @SuppressWarnings("unchecked")
+ public List<SimulationContextType> selectAllTypes() {
+ // -----------------------------------------------------------
+ StringBuffer query = new StringBuffer("from SimulationContextType"); // Useless to order by names as the result mixes localized
+ // and non localized types
+ query = query.append(" order by step asc");
+ return Database.getSession().createQuery(query.toString()).list();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @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("'");
+ 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");
+ return Database.getSession().createQuery(query.toString()).list();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @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";
+ ProjectSettingsService.Step step = sprop.getStep();
+ ProgressState state = sprop.getProgressState();
+ 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);
+ return Database.getSession().createQuery(query.toString()).list();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.SimulationContextService#selectType(java.lang.String)
+ */
+ @Transactional(readOnly=true)
+ public SimulationContextType selectType(String name) {
+ return getSimulationContextTypeDAO().findByCriteria(
+ Restrictions.eq("name", name));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.SimulationContextService#selectType(long)
+ */
+ public SimulationContextType selectType(long index) {
+ return getSimulationContextTypeDAO().get(index);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.SimulationContextService#hold(org.splat.dal.bo.som.SimulationContext)
+ */
+ public void hold(SimulationContext simCtx) {
+ simCtx.setCounter(simCtx.getCounter() + 1);
+ if (simCtx.isSaved()) {
+ getSimulationContextDAO().update(simCtx);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.SimulationContextService#release(org.splat.dal.bo.som.SimulationContext)
+ */
+ public void release(SimulationContext simCtx) {
+ simCtx.setCounter(simCtx.getCounter() - 1);
+ if (simCtx.isSaved()) {
+ getSimulationContextDAO().update(simCtx);
+ }
+ }
+
+ /**
+ * Get the simulationContextDAO.
+ *
+ * @return the simulationContextDAO
+ */
+ public SimulationContextDAO getSimulationContextDAO() {
+ return _simulationContextDAO;
+ }
+
+ /**
+ * Set the simulationContextDAO.
+ *
+ * @param simulationContextDAO
+ * the simulationContextDAO to set
+ */
+ public void setSimulationContextDAO(
+ SimulationContextDAO simulationContextDAO) {
+ _simulationContextDAO = simulationContextDAO;
+ }
+
+ /**
+ * Get the simulationContextTypeDAO.
+ *
+ * @return the simulationContextTypeDAO
+ */
+ public SimulationContextTypeDAO getSimulationContextTypeDAO() {
+ return _simulationContextTypeDAO;
+ }
+
+ /**
+ * Set the simulationContextTypeDAO.
+ *
+ * @param simulationContextTypeDAO
+ * the simulationContextTypeDAO to set
+ */
+ public void setSimulationContextTypeDAO(
+ SimulationContextTypeDAO simulationContextTypeDAO) {
+ _simulationContextTypeDAO = simulationContextTypeDAO;
+ }
+}
import org.splat.som.Step;
/**
- * @author RKV
- *
+ * Step service interface.
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
public interface StepService {
import org.splat.som.Step;
/**
- * @author RKV
- *
+ * Step service implementation.
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
public class StepServiceImpl implements StepService {
+ /**
+ * Injected index service.
+ */
private IndexService _indexService;
+ /**
+ * Injected document service.
+ */
private DocumentService _documentService;
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
public SimulationContext addSimulationContext(Step aStep,
SimulationContext.Properties dprop) throws MissedPropertyException,
public SimulationContext addSimulationContext(Step aStep,
SimulationContext context) {
// -------------------------------------------------------------------------
- context.hold(); // Increments the reference count of simulation context
+ getSimulationContextService().hold(context); // Increments the reference count of simulation context
if (aStep.getOwner().isSaved())
try {
Session session = Database.getSession();
aStep.getContex().remove(torem);
session.update(aStep.getOwner());
if (torem.isShared()) {
- torem.release();
+ getSimulationContextService().release(torem);
session.update(torem);
} else {
session.delete(torem);
getDocumentService().generateDocumentId(newdoc, dprop);
// Creation of the save directory
- File wdir = newdoc.getSaveDirectory();
+ File wdir = getDocumentService().getSaveDirectory(newdoc);
if (!wdir.exists()) if (!wdir.mkdirs()) throw new IOException("Cannot create the repository vault directory");
// Identification and save
String refid = dprop.getReference();
if (refid == null) return null;
- Document slot = Database.selectDocument(refid, new Revision().toString());
+ Document slot = getDocumentService().selectDocument(refid, new Revision().toString());
if ( slot == null ) return null;
if (!slot.isUndefined()) return null; // Should not happen
public void setDocumentService(DocumentService documentService) {
_documentService = documentService;
}
+
+ /**
+ * Get the simulationContextService.
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ * @param simulationContextService the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
+ }
}
package org.splat.service;
-import java.util.List;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.Publication;
*/
public interface StudyService {
- /**
- * Get the simulation context list for displaying drop-down list values populating
- * on the "Create new study" screen.
- * @return List of the simulation contexts.
- */
- List<SimulationContext> getSimulationContextList();
-
public int generateLocalIndex(Study aStudy);
public Study selectStudy(long index);
package org.splat.service;
import java.io.IOException;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import org.apache.log4j.Logger;
+import org.hibernate.Query;
import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.splat.dal.bo.kernel.Relation;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.ActorRelation;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.Scenario;
import org.splat.dal.bo.som.SimulationContext;
-import org.splat.dal.bo.som.SimulationContextType;
import org.splat.dal.bo.som.Study;
import org.splat.dal.bo.som.ValidationCycle;
import org.splat.dal.bo.som.ValidationCycleRelation;
import org.splat.dal.bo.som.Visibility;
import org.splat.dal.bo.som.Study.Properties;
import org.splat.dal.dao.som.Database;
+import org.splat.dal.dao.som.StudyDAO;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
import org.splat.service.technical.IndexService;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.som.Revision;
+import org.springframework.transaction.annotation.Transactional;
/**
* This class defines all methods for creation, modification the study.
+ *
* @author Maria KRUCHININA
- *
+ *
*/
public class StudyServiceImpl implements StudyService {
/**
* logger for the service.
*/
- public final static AppLogger logger = AppLogger.getLogger(StudyServiceImpl.class);
+ public final static AppLogger logger = AppLogger
+ .getLogger(StudyServiceImpl.class);
+ /**
+ * Injected index service.
+ */
private IndexService _indexService;
+ /**
+ * Injected step service.
+ */
private StepService _stepService;
+ /**
+ * Injected scenario service.
+ */
private ScenarioService _scenarioService;
+ /**
+ * Injected project service.
+ */
private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected project element service.
+ */
private ProjectElementService _projectElementService;
-
+
/**
- * Get the simulation context list for displaying drop-down list values populating
- * on the "Create new study" screen.
+ * Injected study DAO.
+ */
+ private StudyDAO _studyDAO;
+
+ /**
* {@inheritDoc}
- * @see org.splat.service.StudyService#getSimulationContextList()
+ * @see org.splat.service.StudyService#selectStudy(long)
*/
- public List<SimulationContext> getSimulationContextList() {
- //TODO: remove the commit transaction ...
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
-
- SimulationContext.Properties cprop = new SimulationContext.Properties();
- SimulationContextType product = SimulationContext.selectType("product");
- List<SimulationContext> resList = Database.selectSimulationContextsWhere(cprop.setType(product));
-
- transax.commit();
-
- return resList;
- }
-
+ @Transactional
public Study selectStudy(long index) {
- // -------------------------------------------
- StringBuffer query = new StringBuffer("from Study where rid='").append(
- index).append("'");
- Study result = (Study) Database.getSession().createQuery(
- query.toString()).uniqueResult();
-
+ Study result = getStudyDAO().get(index);
result.loadWorkflow();
return result;
}
return result;
}
+ @Transactional
public Study createStudy(Study.Properties sprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException, RuntimeException {
Study study = new Study(sprop);
buildReference(study);
- Database.getSession().save(study); // TODO: use StudyDAO and throw out Database.
+ getStudyDAO().create(study);
try {
IndexService lucin = getIndex();
lucin.add(study);
public boolean buildReference(Study aStudy) {
String pattern = aStudy.getReference(); // The study being supposed just created, its reference is the reference pattern
- IDBuilder tool = Database.selectIDBuilder(aStudy.getDate());
+ IDBuilder tool = selectIDBuilder(aStudy.getDate());
if (tool == null) {
tool = new IDBuilder(aStudy.getDate());
Database.getSession().save(tool);
return true;
}
+ public IDBuilder selectIDBuilder(Date date) {
+ // ------------------------------------------------------
+ SimpleDateFormat year = new SimpleDateFormat("yyyy");
+ String cycle = year.format(date);
+ StringBuffer buffer = new StringBuffer("from IDBuilder where cycle='")
+ .append(cycle).append("'");
+ String qstring = buffer.toString();
+ Query query = Database.getSession().createQuery(qstring);
+ IDBuilder result = (IDBuilder) query.uniqueResult();
+
+ return result;
+ }
+
public boolean publishes(Study aStudy, Document doc) {
// ---------------------------------------
if (!aStudy.publishes(doc)) {
KnowledgeElementType ucase = KnowledgeElement.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
- // knowledges
+ kprop.setType(ucase).setTitle(aStudy.getTitle()).setValue(
+ scenario.getTitle()).setAuthor(admin); // Internal Knowledge Element required by the validation process of
+ // knowledges
getScenarioService().addKnowledgeElement(scenario, kprop);
return scenario;
}
}
}
- /**
- * @return
- */
- public IndexService getIndexService() {
- return _indexService;
- }
-
- public void setIndexService(IndexService indexService) {
- _indexService = indexService;
- }
-
/**
* Get project settings.
*
/**
* Get the stepService.
+ *
* @return the stepService
*/
public StepService getStepService() {
/**
* Set the stepService.
- * @param stepService the stepService to set
+ *
+ * @param stepService
+ * the stepService to set
*/
public void setStepService(StepService stepService) {
_stepService = stepService;
}
+
+ /**
+ * Get the indexService.
+ * @return the indexService
+ */
+ public IndexService getIndexService() {
+ return _indexService;
+ }
+
+ /**
+ * Set the indexService.
+ * @param indexService the indexService to set
+ */
+ public void setIndexService(IndexService indexService) {
+ _indexService = indexService;
+ }
+
+ /**
+ * Get the studyDAO.
+ * @return the studyDAO
+ */
+ public StudyDAO getStudyDAO() {
+ return _studyDAO;
+ }
+
+ /**
+ * Set the studyDAO.
+ * @param studyDAO the studyDAO to set
+ */
+ public void setStudyDAO(StudyDAO studyDAO) {
+ _studyDAO = studyDAO;
+ }
}
package org.splat.service.technical;
+
/**
*
* @author Daniel Brunier-Coulin
import org.splat.dal.bo.som.ValidationCycle.Actor;
import org.splat.dal.dao.som.Database;
import org.splat.manox.XDOM;
-
+import org.splat.service.SimulationContextService;
public class ProjectSettingsServiceImpl implements ProjectSettingsService {
-// Non persistent configuration information
- private Properties reprop; // Repository settings
- private String pattern; // Pattern of study references
- private FileNaming naming; // Scheme of file names stored into the repository
- private String versioning; // Pattern of the presentation of version numbers
- private Vector<ProjectSettingsService.Step> steps; // Ordered list of (transient) study steps
- private Vector<ProjectSettingsValidationCycle> concycles; // Configuration document validation cycles
-
-// Temporary attributes initialized from the configuration file for populating the database with object types
- private LinkedHashMap<String,String> mapuse; // Document type names and uses mapping
- private Vector<String> context; // Simulation Context type names
- private Vector<String> kname; // Knowledge Element type names
- private Vector<NamedNodeMap> flows; // Document flows
- private Vector<NamedNodeMap> sclass; // Study classifications
-
-// Other resources
- private static ProjectSettingsServiceImpl my = null; // Singleton instance
+ // Non persistent configuration information
+ private Properties reprop; // Repository settings
+ private String pattern; // Pattern of study references
+ private FileNaming naming; // Scheme of file names stored into the repository
+ private String versioning; // Pattern of the presentation of version numbers
+ private Vector<ProjectSettingsService.Step> steps; // Ordered list of (transient) study steps
+ private Vector<ProjectSettingsValidationCycle> concycles; // Configuration document validation cycles
+
+ // Temporary attributes initialized from the configuration file for populating the database with object types
+ private LinkedHashMap<String, String> mapuse; // Document type names and uses mapping
+ private Vector<String> context; // Simulation Context type names
+ private Vector<String> kname; // Knowledge Element type names
+ private Vector<NamedNodeMap> flows; // Document flows
+ private Vector<NamedNodeMap> sclass; // Study classifications
+
+ // Other resources
+ private static ProjectSettingsServiceImpl my = null; // Singleton instance
private Database _database;
- protected final static Logger logger = Logger.getLogger(ProjectSettingsServiceImpl.class);
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
+ protected final static Logger logger = Logger
+ .getLogger(ProjectSettingsServiceImpl.class);
+
+ public enum FileNaming {
+ title, encoded, asis
+ }
- public enum FileNaming { title, encoded, asis }
public static class ProjectSettingsValidationCycle {
-// -----------------------------------
- private String name;
- private Actor[] actor;
-
- private ProjectSettingsValidationCycle () {
- this.name = "built-in";
- this.actor = new Actor[] { null, null, null };
- }
- private ProjectSettingsValidationCycle (String name, Actor[] actor) {
- this.name = name;
- this.actor = actor;
- }
- public String getName () {
- return name;
- }
- public Actor[] getActorTypes () {
- return actor;
- }
- }
-
-// ==============================================================================================================================
-// Construction
-// ==============================================================================================================================
- protected ProjectSettingsServiceImpl () {
-// ----------------------------
- reprop = new Properties();
- steps = new Vector<ProjectSettingsService.Step>();
- my = this;
- }
-
-// ==============================================================================================================================
-// Public functions
-// ==============================================================================================================================
-
- public void configure (String filename) throws IOException, SQLException {
-// ---------------------------------------
- if (!steps.isEmpty()) return; // Project already configured
-
- Database base = getDatabase().getMe();
- File config = new File(filename);
- if (config.exists()) {
- loadCustomization(config);
- } else {
- logger.fatal("Could not find the database configuration file \"" + config.getAbsolutePath() + "\"");
- throw new FileNotFoundException();
- }
- base.configure(reprop);
- if (!base.isInitialized()) {
- base.initialize();
- initialize(); // Populates the database with all necessary stuff
- }
+ // -----------------------------------
+ private String name;
+ private Actor[] actor;
+
+ private ProjectSettingsValidationCycle() {
+ this.name = "built-in";
+ this.actor = new Actor[] { null, null, null };
+ }
+
+ private ProjectSettingsValidationCycle(String name, Actor[] actor) {
+ this.name = name;
+ this.actor = actor;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Actor[] getActorTypes() {
+ return actor;
+ }
}
- public List<ProjectSettingsService.Step> getAllSteps () {
-// ---------------------------------------
- return steps;
- }
+ // ==============================================================================================================================
+ // Construction
+ // ==============================================================================================================================
+ protected ProjectSettingsServiceImpl() {
+ // ----------------------------
+ reprop = new Properties();
+ steps = new Vector<ProjectSettingsService.Step>();
+ my = this;
+ }
+
+ // ==============================================================================================================================
+ // Public functions
+ // ==============================================================================================================================
+
+ public void configure(String filename) throws IOException, SQLException {
+ // ---------------------------------------
+ if (!steps.isEmpty())
+ return; // Project already configured
+
+ Database base = getDatabase().getMe();
+ File config = new File(filename);
+ if (config.exists()) {
+ loadCustomization(config);
+ } else {
+ logger.fatal("Could not find the database configuration file \""
+ + config.getAbsolutePath() + "\"");
+ throw new FileNotFoundException();
+ }
+ base.configure(reprop);
+ if (!base.isInitialized()) {
+ base.initialize();
+ initialize(); // Populates the database with all necessary stuff
+ }
+ }
+
+ public List<ProjectSettingsService.Step> getAllSteps() {
+ // ---------------------------------------
+ return steps;
+ }
+
+ /**
+ * Return the validation cycles of result documents defined in the workflow, ordered by study activities and ending by the default
+ * validation cycle, if defined.
+ *
+ * @return the validation cycles of the workflow
+ */
+ public static List<ProjectSettingsValidationCycle> getAllValidationCycles() {
+ // -------------------------------------------------------------
+ return my.concycles;
+ }
+
+ public FileNaming getFileNamingScheme() {
+ // -----------------------------------------------
+ return naming;
+ }
+
+ public static ProjectSettingsValidationCycle getNewValidationCycle() {
+ // ------------------------------------------------------
+ return new ProjectSettingsValidationCycle();
+ }
+
+ public String getReferencePattern() {
+ return pattern;
+ }
+
+ public String getRevisionPattern() {
+ // ------------------------------------------
+ return versioning;
+ }
+
+ public static ProjectSettingsService.Step getStep(int number) {
+ // ---------------------------------------
+ for (int i = 0; i < my.steps.size(); i++) {
+ ProjectSettingsService.Step step = my.steps.get(i);
+ if (step.number == number)
+ return step;
+ }
+ return null;
+ }
+
+ public List<ProjectSettingsService.Step> getStepsOf(
+ Class<? extends ProjectElement> level) {
+ // ---------------------------------------------------------------------------
+ Vector<ProjectSettingsService.Step> result = new Vector<ProjectSettingsService.Step>();
+
+ for (int i = 0; i < steps.size(); i++) {
+ ProjectSettingsService.Step step = steps.get(i);
+ if (step.appliesTo(level))
+ result.add(step);
+ }
+ return result;
+ }
+
+ // ==============================================================================================================================
+ // Protected member function
+ // ==============================================================================================================================
+
+ public void initialize() {
+ // ----------------------------
+ createDocumentTypes();
+ createSimulationContextTypes();
+ createKnowledgeElementTypes();
+ }
+
+ // ==============================================================================================================================
+ // Private member function
+ // ==============================================================================================================================
+
+ private void loadCustomization(File config) {
+ // --------------------------------------------
+ try {
+ DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
+
+ org.w3c.dom.Document conf = dBuilder.parse(config.getPath());
+ HashMap<String, Node> children = XDOM.getNamedChildNodes(conf
+ .getDocumentElement());
+
+ // Repository tag initializing the reprop attribute
+ Node child = children.get("database");
+ HashMap<String, Node> datag = XDOM.getNamedChildNodes(child);
+
+ String disk = datag.get("repository").getAttributes().getNamedItem(
+ "disk").getNodeValue();
+ if (!disk.endsWith("/"))
+ disk = disk + "/";
+ logger.info("Database root set to " + disk);
+ reprop.setProperty("repository", disk);
+
+ // Formats tag initializing the reference pattern and date attributes
+ child = children.get("formats");
+ datag = XDOM.getNamedChildNodes(child);
+
+ NamedNodeMap natr = datag.get("references").getAttributes();
+ pattern = natr.getNamedItem("study").getNodeValue();
+
+ natr = datag.get("files").getAttributes();
+ naming = FileNaming.valueOf(natr.getNamedItem("name")
+ .getNodeValue());
+
+ natr = datag.get("versions").getAttributes();
+ versioning = natr.getNamedItem("pattern").getNodeValue();
+
+ // Activities tag initializing the steps and rex attributes
+ child = children.get("activities");
+ NodeList nlist = child.getChildNodes();
+ Vector<NamedNodeMap> flist = new Vector<NamedNodeMap>();
+ Vector<String> resultype = new Vector<String>();
+ Vector<NamedNodeMap> clist = new Vector<NamedNodeMap>();
+
+ int snum = 1; // Base number of steps
+ for (int i = 0; i < nlist.getLength(); i++) {
+ child = nlist.item(i);
+ if (child.getNodeName().equals("scenario")) {
+ NodeList slist = child.getChildNodes();
+ for (int j = 0; j < slist.getLength(); j++) {
+ child = slist.item(j);
+ if (!child.getNodeName().equals("step"))
+ continue;
+ HashMap<String, Node> tags = XDOM
+ .getNamedChildNodes(child);
+
+ natr = tags.get("storage").getAttributes();
+ ProjectSettingsService.Step step = new ProjectSettingsService.Step(
+ snum, Scenario.class, natr.getNamedItem("path")
+ .getNodeValue());
+
+ // Keeping flow and classification information for eventual later use
+ natr = tags.get("flow").getAttributes();
+ flist.add(natr);
+ child = natr.getNamedItem("result");
+ if (child != null)
+ resultype.add(child.getNodeValue());
+
+ child = tags.get("classification");
+ if (child != null)
+ clist.add(child.getAttributes());
+ else
+ clist.add(null);
+
+ if (natr.getNamedItem("contents").getNodeValue()
+ .equals("knowledge")) {
+ // TODO In a given scenario, only one step must contain knowledges
+ step.contents.add(KnowledgeElement.class);
+ } else {
+ step.contents.add(Document.class);
+ }
+ steps.add(step);
+ snum += 1;
+ }
+ } else {
+ if (!child.getNodeName().equals("step"))
+ continue;
+ HashMap<String, Node> tags = XDOM.getNamedChildNodes(child);
+
+ natr = tags.get("storage").getAttributes(); // Mandatory information
+ ProjectSettingsService.Step step = new ProjectSettingsService.Step(
+ snum, Study.class, natr.getNamedItem("path")
+ .getNodeValue());
+
+ // Keeping flow and classification information for eventual later use
+ natr = tags.get("flow").getAttributes();
+ flist.add(natr);
+ child = natr.getNamedItem("result");
+ if (child != null)
+ resultype.add(child.getNodeValue());
+
+ child = tags.get("classification"); // Optional information
+ if (child != null)
+ clist.add(child.getAttributes());
+ else
+ clist.add(null);
+
+ if (natr.getNamedItem("contents").getNodeValue().equals(
+ "knowledge")) {
+ // TODO Error: knowledges must be attached to scenarios
+ } else {
+ step.contents.add(Document.class);
+ }
+ steps.add(step);
+ snum += 1;
+ }
+ }
+ // Validations tag
+ child = children.get("validations");
+ concycles = new Vector<ProjectSettingsValidationCycle>();
+ datag = XDOM.getNamedChildNodes(child);
+
+ String[] step = { "review", "approval", "acceptance" };
+ resultype.add("default");
+ for (Iterator<String> i = resultype.iterator(); i.hasNext();) {
+ Actor[] actor = { null, null, null };
+ String name = i.next();
+ child = datag.get(name);
+ if (child == null)
+ continue; // Document type not subject of any validation
+ natr = child.getAttributes();
+ for (int j = 0; j < step.length; j++) {
+ child = natr.getNamedItem(step[j]);
+ if (child == null)
+ continue; // Validation step not required
+ actor[j] = Actor.valueOf(child.getNodeValue());
+ }
+ concycles.add(new ProjectSettingsValidationCycle(name, actor));
+ }
+ concycles.add(new ProjectSettingsValidationCycle()); // Adds the built-in validation cycle
+
+ if (getDatabase().getMe().isInitialized())
+ return; // No need to load object type definitions as they are already stored
+
+ // Documents tag
+ child = children.get("documents");
+ nlist = child.getChildNodes();
+
+ flows = flist; // Kept for later use in document type definition
+ sclass = clist; // Kept for later use in simulation context type definition
+ mapuse = new LinkedHashMap<String, String>();
+ for (int i = 0; i < nlist.getLength(); i++) {
+ child = nlist.item(i);
+ if (!child.getNodeName().equals("article"))
+ continue;
+
+ natr = child.getAttributes();
+ String type = natr.getNamedItem("type").getNodeValue();
+ String uses = null;
+ child = natr.getNamedItem("uses");
+ if (child != null)
+ uses = child.getNodeValue();
+ mapuse.put(type, uses); // Must be added to the map even if no (null) uses
+ }
+ // Simulation Contexts tag
+ child = children.get("contexts");
+ nlist = child.getChildNodes();
+
+ context = new Vector<String>();
+ for (int i = 0; i < nlist.getLength(); i++) {
+ child = nlist.item(i);
+ if (!child.getNodeName().equals("article"))
+ continue;
+
+ context.add(child.getAttributes().getNamedItem("type")
+ .getNodeValue());
+ }
+ // Knowledge Elements tag
+ child = children.get("knowledges");
+ nlist = child.getChildNodes();
+
+ kname = new Vector<String>();
+ for (int i = 0; i < nlist.getLength(); i++) {
+ child = nlist.item(i);
+ if (!child.getNodeName().equals("article"))
+ continue;
+
+ kname.add(child.getAttributes().getNamedItem("type")
+ .getNodeValue());
+ }
+ } catch (Exception error) {
+ logger.info("Error in customization", error);
+ }
+ }
+
+ private void createDocumentTypes() {
+ // -----------------------------------
+ DocumentType.Properties tprop = new DocumentType.Properties();
+ HashMap<String, Vector<ProjectSettingsService.Step>> mapsteps = new HashMap<String, Vector<ProjectSettingsService.Step>>();
+ HashMap<String, ProjectSettingsService.Step> mapresult = new HashMap<String, ProjectSettingsService.Step>();
+ HashMap<String, DocumentType> maptype = new HashMap<String, DocumentType>();
+
+ Vector<ProjectSettingsService.Step> slist = null; // List of Steps to which each document type is valid
+ int snum = 0; // Step number
+ String type = null;
+ String uses = null;
+ for (Iterator<NamedNodeMap> i = flows.iterator(); i.hasNext(); snum++) {
+ NamedNodeMap flow = i.next();
+ ProjectSettingsService.Step step = steps.get(snum);
+ String[] contents = flow.getNamedItem("contents").getNodeValue()
+ .split(",");
+ for (int j = 0; j < contents.length; j++) {
+ type = contents[j];
+ if (!mapuse.containsKey(type)) {
+ logger.warn("Undefined \"" + type + "\" document type.");
+ continue;
+ }
+ slist = mapsteps.get(type);
+ if (slist == null)
+ slist = new Vector<ProjectSettingsService.Step>();
+ slist.add(step);
+ mapsteps.put(type, slist);
+ }
+ Node result = flow.getNamedItem("result");
+ if (result != null)
+ mapresult.put(result.getNodeValue(), step);
+ }
+ try {
+ DocumentType tdoc = null;
+ Set<String> tset = mapuse.keySet();
+ ProjectSettingsService.Step step;
+ for (Iterator<String> i = tset.iterator(); i.hasNext();) {
+ type = i.next();
+ slist = mapsteps.get(type);
+ uses = mapuse.get(type);
+ step = mapresult.get(type);
+
+ tprop.clear();
+ tprop.setName(type).setStep(
+ slist.toArray(new ProjectSettingsService.Step[slist
+ .size()]));
+ if (uses != null) {
+ tdoc = maptype.get(uses);
+ if (tdoc == null)
+ logger
+ .warn("Undefined \"" + uses
+ + "\" document type.");
+ else
+ tprop.setUses(tdoc);
+ }
+ if (step != null)
+ tprop.setResult(step);
+
+ tprop.disableCheck();
+ tdoc = Document.createType(tprop); // Creation of Document Types
+ tdoc.approve();
+ maptype.put(type, tdoc);
+ }
+ } catch (Exception error) {
+ logger.warn("Error creating document types, reason:", error); // Should not happen
+ }
+ }
+
+ private void createKnowledgeElementTypes() {
+ // -------------------------------------------
+ try {
+ KnowledgeElementType ktype = KnowledgeElement.createType("usecase"); // Internal reserved knowledge element type
+ ktype.reserve();
+ for (Iterator<String> i = kname.iterator(); i.hasNext();) {
+ String type = i.next();
+
+ ktype = KnowledgeElement.createType(type); // Knowledge Elements Types defined in the configuration
+ ktype.approve();
+ }
+ } catch (Exception error) {
+ logger.warn("Error creating knowledge types, reason:", error); // Should not happen
+ }
+ }
+
+ private void createSimulationContextTypes() {
+ // --------------------------------------------
+ HashMap<String, ProjectSettingsService.Step> mapstep = new HashMap<String, ProjectSettingsService.Step>();
+ int snum = 0;
+ for (Iterator<NamedNodeMap> i = sclass.iterator(); i.hasNext(); snum++) {
+ NamedNodeMap clatr = i.next();
+ if (clatr == null)
+ continue;
+
+ String[] clist = clatr.getNamedItem("context").getNodeValue()
+ .split(",");
+ for (int j = 0; j < clist.length; j++) {
+ mapstep.put(clist[j], steps.get(snum));
+ }
+ }
+ try {
+ SimulationContextType tctex = null;
+ for (Iterator<String> i = context.iterator(); i.hasNext();) {
+ String type = i.next();
+ if (!mapstep.containsKey(type)) {
+ logger
+ .warn("Could not find \""
+ + type
+ + "\" classification. Simulation Context type ignored.");
+ continue;
+ }
+ tctex = getSimulationContextService().createType(type,
+ mapstep.get(type)); // Creation of Simulation Context Types
+ tctex.approve();
+ }
+ } catch (Exception error) {
+ logger.warn("Error creating context types, reason:", error); // Should not happen
+ }
+ }
-/**
- * Return the validation cycles of result documents defined in the workflow, ordered by study activities
- * and ending by the default validation cycle, if defined.
- *
- * @return the validation cycles of the workflow
- */
- public static List<ProjectSettingsValidationCycle> getAllValidationCycles () {
-// -------------------------------------------------------------
- return my.concycles;
- }
-
- public FileNaming getFileNamingScheme () {
-// -----------------------------------------------
- return naming;
- }
-
- public static ProjectSettingsValidationCycle getNewValidationCycle () {
-// ------------------------------------------------------
- return new ProjectSettingsValidationCycle();
- }
-
- public String getReferencePattern () {
- return pattern;
- }
-
- public String getRevisionPattern () {
-// ------------------------------------------
- return versioning;
- }
-
- public static ProjectSettingsService.Step getStep (int number) {
-// ---------------------------------------
- for (int i=0; i<my.steps.size(); i++) {
- ProjectSettingsService.Step step = my.steps.get(i);
- if (step.number == number) return step;
- }
- return null;
- }
-
- public List<ProjectSettingsService.Step> getStepsOf (Class<? extends ProjectElement> level) {
-// ---------------------------------------------------------------------------
- Vector<ProjectSettingsService.Step> result = new Vector<ProjectSettingsService.Step>();
-
- for (int i=0; i<steps.size(); i++) {
- ProjectSettingsService.Step step = steps.get(i);
- if (step.appliesTo(level)) result.add(step);
- }
- return result;
- }
-
-// ==============================================================================================================================
-// Protected member function
-// ==============================================================================================================================
-
- public void initialize () {
-// ----------------------------
- createDocumentTypes();
- createSimulationContextTypes();
- createKnowledgeElementTypes();
- }
-
-// ==============================================================================================================================
-// Private member function
-// ==============================================================================================================================
-
- private void loadCustomization (File config) {
-// --------------------------------------------
- try {
- DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
-
- org.w3c.dom.Document conf = dBuilder.parse(config.getPath());
- HashMap<String, Node> children = XDOM.getNamedChildNodes(conf.getDocumentElement());
-
-// Repository tag initializing the reprop attribute
- Node child = children.get("database");
- HashMap<String, Node> datag = XDOM.getNamedChildNodes(child);
-
- String disk = datag.get("repository").getAttributes().getNamedItem("disk").getNodeValue();
- if (!disk.endsWith("/")) disk = disk + "/";
- logger.info("Database root set to " + disk);
- reprop.setProperty("repository", disk);
-
-// Formats tag initializing the reference pattern and date attributes
- child = children.get("formats");
- datag = XDOM.getNamedChildNodes(child);
-
- NamedNodeMap natr = datag.get("references").getAttributes();
- pattern = natr.getNamedItem("study").getNodeValue();
-
- natr = datag.get("files").getAttributes();
- naming = FileNaming.valueOf(natr.getNamedItem("name").getNodeValue());
-
- natr = datag.get("versions").getAttributes();
- versioning = natr.getNamedItem("pattern").getNodeValue();
-
-// Activities tag initializing the steps and rex attributes
- child = children.get("activities");
- NodeList nlist = child.getChildNodes();
- Vector<NamedNodeMap> flist = new Vector<NamedNodeMap>();
- Vector<String> resultype = new Vector<String>();
- Vector<NamedNodeMap> clist = new Vector<NamedNodeMap>();
-
- int snum = 1; // Base number of steps
- for (int i=0; i<nlist.getLength(); i++) {
- child = nlist.item(i);
- if (child.getNodeName().equals("scenario")) {
- NodeList slist = child.getChildNodes();
- for (int j=0; j<slist.getLength(); j++) {
- child = slist.item(j);
- if (!child.getNodeName().equals("step")) continue;
- HashMap<String, Node> tags = XDOM.getNamedChildNodes(child);
-
- natr = tags.get("storage").getAttributes();
- ProjectSettingsService.Step step = new ProjectSettingsService.Step(snum, Scenario.class, natr.getNamedItem("path").getNodeValue());
-
-// Keeping flow and classification information for eventual later use
- natr = tags.get("flow").getAttributes();
- flist.add(natr);
- child = natr.getNamedItem("result");
- if (child != null) resultype.add(child.getNodeValue());
-
- child = tags.get("classification");
- if (child != null) clist.add( child.getAttributes() );
- else clist.add( null );
-
- if (natr.getNamedItem("contents").getNodeValue().equals("knowledge")) {
-//TODO In a given scenario, only one step must contain knowledges
- step.contents.add(KnowledgeElement.class);
- } else {
- step.contents.add(Document.class);
- }
- steps.add(step);
- snum += 1;
- }
- } else {
- if (!child.getNodeName().equals("step")) continue;
- HashMap<String, Node> tags = XDOM.getNamedChildNodes(child);
-
- natr = tags.get("storage").getAttributes(); // Mandatory information
- ProjectSettingsService.Step step = new ProjectSettingsService.Step(snum, Study.class, natr.getNamedItem("path").getNodeValue());
-
-// Keeping flow and classification information for eventual later use
- natr = tags.get("flow").getAttributes();
- flist.add(natr);
- child = natr.getNamedItem("result");
- if (child != null) resultype.add(child.getNodeValue());
-
- child = tags.get("classification"); // Optional information
- if (child != null) clist.add( child.getAttributes() );
- else clist.add( null );
-
- if (natr.getNamedItem("contents").getNodeValue().equals("knowledge")) {
-//TODO Error: knowledges must be attached to scenarios
- } else {
- step.contents.add(Document.class);
- }
- steps.add(step);
- snum += 1;
- }
- }
-// Validations tag
- child = children.get("validations");
- concycles = new Vector<ProjectSettingsValidationCycle>();
- datag = XDOM.getNamedChildNodes(child);
-
- String[] step = { "review", "approval", "acceptance" };
- resultype.add("default");
- for (Iterator<String> i=resultype.iterator(); i.hasNext(); ) {
- Actor[] actor = { null, null, null };
- String name = i.next();
- child = datag.get(name);
- if (child == null) continue; // Document type not subject of any validation
- natr = child.getAttributes();
- for (int j=0; j<step.length; j++) {
- child = natr.getNamedItem(step[j]);
- if (child == null) continue; // Validation step not required
- actor[j] = Actor.valueOf(child.getNodeValue());
- }
- concycles.add( new ProjectSettingsValidationCycle(name, actor) );
- }
- concycles.add( new ProjectSettingsValidationCycle() ); // Adds the built-in validation cycle
-
- if (getDatabase().getMe().isInitialized()) return; // No need to load object type definitions as they are already stored
-
-// Documents tag
- child = children.get("documents");
- nlist = child.getChildNodes();
-
- flows = flist; // Kept for later use in document type definition
- sclass = clist; // Kept for later use in simulation context type definition
- mapuse = new LinkedHashMap<String,String>();
- for (int i=0; i<nlist.getLength(); i++) {
- child = nlist.item(i);
- if (!child.getNodeName().equals("article")) continue;
-
- natr = child.getAttributes();
- String type = natr.getNamedItem("type").getNodeValue();
- String uses = null;
- child = natr.getNamedItem("uses");
- if (child != null) uses = child.getNodeValue();
- mapuse.put(type, uses); // Must be added to the map even if no (null) uses
- }
-// Simulation Contexts tag
- child = children.get("contexts");
- nlist = child.getChildNodes();
-
- context = new Vector<String>();
- for (int i=0; i<nlist.getLength(); i++) {
- child = nlist.item(i);
- if (!child.getNodeName().equals("article")) continue;
-
- context.add(child.getAttributes().getNamedItem("type").getNodeValue());
- }
-// Knowledge Elements tag
- child = children.get("knowledges");
- nlist = child.getChildNodes();
-
- kname = new Vector<String>();
- for (int i=0; i<nlist.getLength(); i++) {
- child = nlist.item(i);
- if (!child.getNodeName().equals("article")) continue;
-
- kname.add(child.getAttributes().getNamedItem("type").getNodeValue());
- }
- }
- catch (Exception error) {
- logger.info("Error in customization", error);
- }
- }
-
- private void createDocumentTypes () {
-// -----------------------------------
- DocumentType.Properties tprop = new DocumentType.Properties();
- HashMap<String,Vector<ProjectSettingsService.Step>> mapsteps = new HashMap<String,Vector<ProjectSettingsService.Step>>();
- HashMap<String,ProjectSettingsService.Step> mapresult = new HashMap<String,ProjectSettingsService.Step>();
- HashMap<String,DocumentType> maptype = new HashMap<String,DocumentType>();
-
- Vector<ProjectSettingsService.Step> slist = null; // List of Steps to which each document type is valid
- int snum = 0; // Step number
- String type = null;
- String uses = null;
- for (Iterator<NamedNodeMap> i=flows.iterator(); i.hasNext(); snum++) {
- NamedNodeMap flow = i.next();
- ProjectSettingsService.Step step = steps.get(snum);
- String[] contents = flow.getNamedItem("contents").getNodeValue().split(",");
- for (int j=0; j<contents.length; j++) {
- type = contents[j];
- if (!mapuse.containsKey(type)) {
- logger.warn("Undefined \"" + type + "\" document type.");
- continue;
- } slist = mapsteps.get(type);
- if (slist == null) slist = new Vector<ProjectSettingsService.Step>();
- slist.add(step);
- mapsteps.put(type, slist);
- }
- Node result = flow.getNamedItem("result");
- if (result != null) mapresult.put(result.getNodeValue(), step);
- }
- try {
- DocumentType tdoc = null;
- Set<String> tset = mapuse.keySet();
- ProjectSettingsService.Step step;
- for (Iterator<String> i=tset.iterator(); i.hasNext(); ) {
- type = i.next();
- slist = mapsteps.get(type);
- uses = mapuse.get(type);
- step = mapresult.get(type);
-
- tprop.clear();
- tprop.setName(type).setStep(slist.toArray(new ProjectSettingsService.Step[slist.size()]));
- if (uses != null) {
- tdoc = maptype.get(uses);
- if (tdoc == null) logger.warn("Undefined \"" + uses + "\" document type.");
- else tprop.setUses(tdoc);
- }
- if (step != null) tprop.setResult(step);
-
- tprop.disableCheck();
- tdoc = Document.createType(tprop); // Creation of Document Types
- tdoc.approve();
- maptype.put(type, tdoc);
- }
- } catch (Exception error) {
- logger.warn("Error creating document types, reason:", error); // Should not happen
- }
- }
-
- private void createKnowledgeElementTypes () {
-// -------------------------------------------
- try {
- KnowledgeElementType ktype = KnowledgeElement.createType("usecase"); // Internal reserved knowledge element type
- ktype.reserve();
- for (Iterator<String> i=kname.iterator(); i.hasNext(); ) {
- String type = i.next();
-
- ktype = KnowledgeElement.createType(type); // Knowledge Elements Types defined in the configuration
- ktype.approve();
- }
- } catch (Exception error) {
- logger.warn("Error creating knowledge types, reason:", error); // Should not happen
- }
- }
-
- private void createSimulationContextTypes () {
-// --------------------------------------------
- HashMap<String,ProjectSettingsService.Step> mapstep = new HashMap<String,ProjectSettingsService.Step>();
- int snum = 0;
- for (Iterator<NamedNodeMap> i=sclass.iterator(); i.hasNext(); snum++) {
- NamedNodeMap clatr = i.next();
- if (clatr == null) continue;
-
- String[] clist = clatr.getNamedItem("context").getNodeValue().split(",");
- for (int j=0; j<clist.length; j++) {
- mapstep.put(clist[j], steps.get(snum));
- }
- }
- try {
- SimulationContextType tctex = null;
- for (Iterator<String> i=context.iterator(); i.hasNext(); ) {
- String type = i.next();
- if (!mapstep.containsKey(type)) {
- logger.warn("Could not find \"" + type + "\" classification. Simulation Context type ignored.");
- continue;
- }
- tctex = SimulationContext.createType(type, mapstep.get(type)); // Creation of Simulation Context Types
- tctex.approve();
- }
- } catch (Exception error) {
- logger.warn("Error creating context types, reason:", error); // Should not happen
- }
- }
/**
* Get the database.
+ *
* @return the database
*/
public Database getDatabase() {
return _database;
}
+
/**
* Set the database.
- * @param database the database to set
+ *
+ * @param database
+ * the database to set
*/
public void setDatabase(Database database) {
_database = database;
}
+
+ /**
+ * Get the simulationContextService.
+ *
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ *
+ * @param simulationContextService
+ * the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
+ }
}
\ No newline at end of file
class="org.splat.service.DocumentServiceImpl">
<property name="projectSettings" ref="projectSettings" />
<property name="studyService" ref="studyService" />
+ <property name="documentDAO" ref="documentDAO" />
</bean>
<bean id="knowledgeElementService"
<bean id="stepService" class="org.splat.service.StepServiceImpl">
<property name="indexService" ref="indexService" />
<property name="documentService" ref="documentService" />
+ <property name="simulationContextService"
+ ref="simulationContextService" />
+ </bean>
+
+ <bean id="simulationContextService"
+ class="org.splat.service.SimulationContextServiceImpl">
+ <property name="simulationContextDAO"
+ ref="simulationContextDAO" />
+ <property name="simulationContextTypeDAO"
+ ref="simulationContextTypeDAO" />
</bean>
<bean id="studyService"
ref="projectElementService" />
<property name="projectSettings" ref="projectSettings" />
<property name="scenarioService" ref="scenarioService" />
- <property name="stepService" ref="stepService" />
+ <property name="stepService" ref="stepService" />
+ <property name="studyDAO" ref="studyDAO" />
</bean>
</beans>
\ No newline at end of file
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+<!-- Generated by Siman Generator on Tue Oct 16 14:37:09 MSD 2012 -->
<bean id="textAttributeDAO" parent="genericDAO"
class="org.splat.dal.dao.kernel.TextAttributeDAOImpl">
<bean id="projectSettings"
class="org.splat.service.technical.ProjectSettingsServiceImpl">
- <property name="database" ref="database" />
+ <property name="database" ref="database" />
+ <property name="simulationContextService" ref="simulationContextService" />
</bean>
<bean id="indexService"
import org.splat.dal.bo.kernel.User;
import org.splat.service.PublicationService;
import org.splat.service.ScenarioService;
+import org.splat.service.SimulationContextService;
import org.splat.service.StepService;
+import org.splat.service.technical.RepositoryService;
import org.splat.simer.Action;
import org.splat.simer.OpenStudy;
import org.splat.dal.bo.som.ConvertsRelation;
public class SaveDocumentAction extends Action {
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = -3364960833373200115L;
+
+ /**
+ * Current open study.
+ */
private OpenStudy mystudy = null;
private int doctype = 0;
private String filename = null;
private ProgressState state = null;
private List<Document> defuses = null;
private String summary = null; // Summary of changes in the new version
+ /**
+ * Injected scenario service.
+ */
private ScenarioService _scenarioService;
+ /**
+ * Injected publication service.
+ */
private PublicationService _publicationService;
+ /**
+ * Injected step service.
+ */
private StepService _stepService;
-
- private static final long serialVersionUID = -3364960833373200115L;
+ /**
+ * Injected repository service.
+ */
+ private RepositoryService _repositoryService;
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
// ==============================================================================================================================
// Action methods
DocumentType type = Document.selectType(doctype);
// File updir = Database.getDownloadDirectory(user);
// File upfile = new File(updir.getPath() + "/" + filename);
- String upath = Database.getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file between users
+ String upath = getRepositoryService().getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file
+ // between users
File upfile = new File(upath + filename);
String[] table = filename.split("\\x2E");
String format = table[table.length - 1];
connex.flush();
Document.Properties dprop = new Document.Properties();
- Publication credoc = getStepService().createDocument(step, dprop.setName(docname)
- .setType(type).setFormat(format).setAuthor(user));
+ Publication credoc = getStepService().createDocument(
+ step,
+ dprop.setName(docname).setType(type).setFormat(format)
+ .setAuthor(user));
// Writing the uploaded file into the created document
File target = credoc.getSourceFile().asFile();
if (target.exists())
// 2. Addition of simulation contexts
if (type.equals("model")) { // Set the characteristics of the mesh
SimulationContext.Properties cprop = new SimulationContext.Properties();
- SimulationContextType ctype = SimulationContext
+ SimulationContextType ctype = getSimulationContextService()
.selectType("model");
- SimulationContext context = Database.selectSimulationContext(
- ctype, "Éléments finis");
+ SimulationContext context = getSimulationContextService()
+ .selectSimulationContext(ctype, "Éléments finis");
if (context == null) {
getStepService().addSimulationContext(step,
cprop.setType(ctype).setValue("Éléments finis"));
} else {
getStepService().addSimulationContext(step, context);
}
- ctype = SimulationContext.selectType("element");
- context = Database.selectSimulationContext(ctype, "Surfacique");
+ ctype = getSimulationContextService().selectType("element");
+ context = getSimulationContextService()
+ .selectSimulationContext(ctype, "Surfacique");
if (context == null) {
getStepService().addSimulationContext(step,
cprop.setType(ctype).setValue("Surfacique"));
} else {
getStepService().addSimulationContext(step, context);
}
- ctype = SimulationContext.selectType("shape");
- context = Database.selectSimulationContext(ctype, "Triangles");
+ ctype = getSimulationContextService().selectType("shape");
+ context = getSimulationContextService()
+ .selectSimulationContext(ctype, "Triangles");
if (context == null) {
getStepService().addSimulationContext(step,
cprop.setType(ctype).setValue("Triangles"));
Step step = mystudy.getSelectedStep();
// File updir = Database.getDownloadDirectory(user);
// File upfile = new File(updir.getPath() + "/" + filename);
- String upath = Database.getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file between users
+ String upath = getRepositoryService().getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file
+ // between users
File upfile = new File(upath + filename);
String[] table = filename.split("\\x2E");
String format = table[table.length - 1];
if (summary.length() > 0)
dprop.setDescription(summary);
- Publication next = getStepService().versionDocument(step, current, dprop);
+ Publication next = getStepService().versionDocument(step, current,
+ dprop);
// Writing the uploaded file into the created document
File target = next.getSourceFile().asFile();
defuses.addAll(usedoc);
}
}
+
+ /**
+ * Get the repositoryService.
+ *
+ * @return the repositoryService
+ */
+ public RepositoryService getRepositoryService() {
+ return _repositoryService;
+ }
+
+ /**
+ * Set the repositoryService.
+ *
+ * @param repositoryService
+ * the repositoryService to set
+ */
+ public void setRepositoryService(RepositoryService repositoryService) {
+ _repositoryService = repositoryService;
+ }
+
+ /**
+ * Get the simulationContextService.
+ *
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ *
+ * @param simulationContextService
+ * the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
+ }
}
\ No newline at end of file
private OpenStudy _openStudy;
private OpenKnowledge _openKnowledge;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = -895295026709526501L;
+ /**
+ * Action logger.
+ */
protected static final Logger logger = Logger.getLogger(Action.class);
public class DocumentTypeComparator implements Comparator<DocumentType> {
private Properties jndprops = null; // JNDI context for launching converters
private static ApplicationSettings my = null; // Singleton instance
+ /**
+ * Application settings logger.
+ */
protected final static Logger logger = Logger.getLogger(ApplicationSettings.class);
+ /**
+ * Injected project settings service.
+ */
private ProjectSettingsService _projectSettingsService;
/**
private String password = null;
private String backmenu = null;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 6095471616361606231L;
private class Handler implements CallbackHandler {
public class Converter implements MessageListener {
+ /**
+ * Converter logger.
+ */
+ final static Logger logger = Logger.getLogger(Converter.class);
+
private String type; // Type of document to be converted (e.g. geometry, model)
private String from; // Source format (e.g. py, sldprt)
private String to; // Target format (e.g. brep)
private String exec; // Command line launching the actual converter
private String fname; // Absolute path of the source file to be converted
- final static Logger logger = Logger.getLogger(Converter.class);
-
// ==============================================================================================================================
// Constructor
// ==============================================================================================================================
protected String selection = null; // User activity selection
protected String action = null;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 3003902258668626946L;
protected enum Execute { popup, develop, reduce, reduceall }
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.ConvertsRelation;
import org.splat.service.PublicationService;
+import org.splat.service.technical.RepositoryService;
import org.splat.som.Step;
-
+/**
+ * Document modification action.
+ */
public class EditDocumentAction extends DisplayStudyStepAction {
- private String index = null;
- private String title = null;
- private String filename = null;
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 4573036736137033679L;
+
+ private String index = null;
+ private String title = null;
+ private String filename = null;
+ /**
+ * Injected publication service.
+ */
private PublicationService _publicationService;
+ /**
+ * Injected repository service.
+ */
+ private RepositoryService _repositoryService;
- private static final long serialVersionUID = 4573036736137033679L;
+ /**
+ * Operations enumeration.
+ */
+ private enum Execute {
+ renameDocument, accept, promote, demote, review, invalidate, approve, disapprove
+ };
+
+ // ==============================================================================================================================
+ // Action methods
+ // ==============================================================================================================================
+
+ /**
+ * Open a study.
+ *
+ * @return SUCCESS
+ */
+ public String doInitialize() {
+ mystudy = getOpenStudy();
+ return SUCCESS;
+ }
+
+ public String doSetDocument() {
+ // ------------------------------
+ Session connex = Database.getSession();
+ Transaction transax = connex.beginTransaction();
+ try {
+ mystudy = getOpenStudy();
+
+ Execute todo = Execute.valueOf(action);
+ Step step = mystudy.getSelectedStep();
+ Publication doc = step.getDocument(Integer.valueOf(index));
+
+ if (todo == Execute.renameDocument) {
+ doc.rename(title);
+ // Useless to update the document presentation
+ } else if (todo == Execute.accept) {
+ doc.actualize();
+ mystudy.update(doc);
+ } else if (todo == Execute.promote) {
+ getPublicationService().promote(doc,
+ Calendar.getInstance().getTime());
+ mystudy.update(doc);
+ } else if (todo == Execute.demote) {
+ getPublicationService().demote(doc);
+ mystudy.update(doc);
+ } else if (todo == Execute.review) {
+ getPublicationService().review(doc,
+ Calendar.getInstance().getTime());
+ mystudy.update(doc);
+ } else if (todo == Execute.invalidate) {
+ getPublicationService().invalidate(doc);
+ mystudy.update(doc);
+ } else if (todo == Execute.approve) {
+ getPublicationService().approve(doc,
+ Calendar.getInstance().getTime());
+ 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();
+ try {
+ // Getting user inputs
+ mystudy = getOpenStudy();
+ User user = getConnectedUser();
+ Step step = mystudy.getSelectedStep();
+ File updir = getRepositoryService().getDownloadDirectory(user);
+ File upfile = new File(updir.getPath() + "/" + filename);
+ String[] parse = filename.split("\\x2E");
+
+ Publication edited = step.getDocument(Integer.valueOf(index));
+ ConvertsRelation export = edited.attach(parse[parse.length - 1]);
+
+ if (logger.isInfoEnabled())
+ logger.info("Moving \"" + upfile.getName() + "\" to \""
+ + updir.getPath() + "\".");
+ upfile.renameTo(export.getTo().asFile());
+
+ mystudy.update(edited);
+ transax.commit();
+ return SUCCESS;
+ } catch (Exception error) {
+ logger.error("Reason:", error);
+ return ERROR;
+ }
+ }
+
+ public String doDeleteDocument() {
+ // ---------------------------------
+ Session connex = Database.getSession();
+ Transaction transax = connex.beginTransaction();
+ try {
+ mystudy = getOpenStudy();
+
+ Step step = mystudy.getSelectedStep();
+ Publication doctag = step.getDocument(Integer.valueOf(index));
+
+ step.removeDocument(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;
+ }
+ }
+
+ // ==============================================================================================================================
+ // Getters and setters
+ // ==============================================================================================================================
+
+ public void setDocumentTitle(String title) {
+ // -------------------------------------------
+ this.title = title;
+ }
+
+ public void setFileName(String filename) {
+ // -----------------------------------------
+ this.filename = filename;
+ }
+
+ public void setIndex(String index) {
+ // -----------------------------------
+ this.index = index;
+ }
- private enum Execute { renameDocument, accept, promote, demote, review, invalidate, approve, disapprove };
-
-// ==============================================================================================================================
-// Action methods
-// ==============================================================================================================================
-
- public String doInitialize () {
-// -----------------------------
-// Session connex = Database.getSession();
-// Transaction transax = connex.beginTransaction();
-
- mystudy = getOpenStudy();
-
-// transax.commit();
- return SUCCESS;
- }
-
- public String doSetDocument () {
-// ------------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
- try {
- mystudy = getOpenStudy();
-
- Execute todo = Execute.valueOf(action);
- Step step = mystudy.getSelectedStep();
- Publication doc = step.getDocument(Integer.valueOf(index));
-
- if (todo == Execute.renameDocument) {
- doc.rename(title);
-// Useless to update the document presentation
- } else
- if (todo == Execute.accept) {
- doc.actualize();
- mystudy.update(doc);
- } else
- if (todo == Execute.promote) {
- getPublicationService().promote(doc, Calendar.getInstance().getTime());
- mystudy.update(doc);
- } else
- if (todo == Execute.demote) {
- getPublicationService().demote(doc);
- mystudy.update(doc);
- } else
- if (todo == Execute.review) {
- getPublicationService().review(doc, Calendar.getInstance().getTime());
- mystudy.update(doc);
- } else
- if (todo == Execute.invalidate) {
- getPublicationService().invalidate(doc);
- mystudy.update(doc);
- } else
- if (todo == Execute.approve) {
- getPublicationService().approve(doc, Calendar.getInstance().getTime());
- 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();
- try {
-// Getting user inputs
- mystudy = getOpenStudy();
- User user = getConnectedUser();
- Step step = mystudy.getSelectedStep();
- File updir = Database.getDownloadDirectory(user);
- File upfile = new File(updir.getPath() + "/" + filename);
- String[] parse = filename.split("\\x2E");
-
- Publication edited = step.getDocument(Integer.valueOf(index));
- ConvertsRelation export = edited.attach(parse[parse.length-1]);
-
- if (logger.isInfoEnabled()) logger.info("Moving \"" + upfile.getName() + "\" to \"" + updir.getPath() + "\".");
- upfile.renameTo(export.getTo().asFile());
-
- mystudy.update(edited);
- transax.commit();
- return SUCCESS;
- }
- catch (Exception error) {
- logger.error("Reason:", error);
- return ERROR;
- }
- }
-
- public String doDeleteDocument () {
-// ---------------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
- try {
- mystudy = getOpenStudy();
-
- Step step = mystudy.getSelectedStep();
- Publication doctag = step.getDocument(Integer.valueOf(index));
-
- step.removeDocument(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;
- }
- }
-
-// ==============================================================================================================================
-// Getters and setters
-// ==============================================================================================================================
-
- public void setDocumentTitle (String title) {
-// -------------------------------------------
- this.title = title;
- }
- public void setFileName (String filename) {
-// -----------------------------------------
- this.filename = filename;
- }
- public void setIndex (String index) {
-// -----------------------------------
- this.index = index;
- }
/**
* Get the publicationService.
*
public void setPublicationService(PublicationService publicationService) {
_publicationService = publicationService;
}
+
+ /**
+ * Get the repositoryService.
+ *
+ * @return the repositoryService
+ */
+ public RepositoryService getRepositoryService() {
+ return _repositoryService;
+ }
+
+ /**
+ * Set the repositoryService.
+ *
+ * @param repositoryService
+ * the repositoryService to set
+ */
+ public void setRepositoryService(RepositoryService repositoryService) {
+ _repositoryService = repositoryService;
+ }
}
\ No newline at end of file
private ScenarioService _scenarioService;
private KnowledgeElementService _knowledgeElementService;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 4636919137087687068L;
// ==============================================================================================================================
private ScenarioService _scenarioService;
private ProjectElementService _projectElementService;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 4964740932426016171L;
// ==============================================================================================================================
import org.splat.dal.bo.som.ProjectElement;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.service.SimulationContextService;
import org.splat.service.StepService;
import org.splat.service.StudyService;
import org.splat.som.Step;
private String newtype = null; // Context type, if newed
private SimulationContextType type = null; // Corresponding context type object
private String value = null; // Context value
+ /**
+ * Injected study service.
+ */
private StudyService _studyService;
+ /**
+ * Injected step service.
+ */
private StepService _stepService;
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
/**
* Get the stepService.
return "create";
SimulationContext.Properties cprop = new SimulationContext.Properties();
- type = SimulationContext.selectType(typid);
+ type = getSimulationContextService().selectType(typid);
newtype = type.getName();
contype = getInvolvedContexts();
- contelm = Database.selectSimulationContextsWhere(cprop
- .setType(type));
+ contelm = getSimulationContextService()
+ .selectSimulationContextsWhere(cprop.setType(type));
return "set";
} finally {
SimulationContext.Properties cprop = new SimulationContext.Properties();
SimulationContext contex = null;
- type = SimulationContext.createType(newtype, step.getStep());
+ type = getSimulationContextService().createType(newtype,
+ step.getStep());
cprop.setType(type).setValue(value);
if (owner instanceof Study)
contex = getStudyService().addProjectContext(((Study) owner),
|| (input.length == 2 && input[1].equals(" "))) {
// Setting an existing simulation context identified by value (input = rid," ")
int valid = Integer.valueOf(input[0]);
- contex = Database.selectSimulationContext(valid);
+ contex = getSimulationContextService().selectSimulationContext(
+ valid);
if (owner instanceof Study)
getStudyService()
.addProjectContext(((Study) owner), contex);
// Setting a new simulation context value (input = 0,"new context value")
int typid = Integer.valueOf(selectype);
SimulationContext.Properties cprop = new SimulationContext.Properties();
- cprop.setType(SimulationContext.selectType(typid)).setValue(
- input[1].trim());
+ cprop.setType(getSimulationContextService().selectType(typid))
+ .setValue(input[1].trim());
if (owner instanceof Study)
contex = getStudyService().addProjectContext(
((Study) owner), cprop); // Re-indexes knowledges and the study
// ----------------------------------------------------------
SimulationContextType.Properties sprop = new SimulationContextType.Properties()
.setStep(mystudy.getSelectedStep().getStep());
- List<SimulationContextType> contype = SimulationContext
+ List<SimulationContextType> contype = getSimulationContextService()
.selectTypesWhere(sprop);
if (!contype.isEmpty()) {
public void setStudyService(StudyService studyService) {
_studyService = studyService;
}
+
+ /**
+ * Get the simulationContextService.
+ *
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ *
+ * @param simulationContextService
+ * the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
+ }
}
\ No newline at end of file
public class EditStudyAction extends DisplayStudyStepAction {
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = -4865668290514118396L;
private enum Execute { publish, promote }
import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.ProgressState;
+import org.splat.service.DocumentService;
import org.splat.service.PublicationService;
import org.splat.service.StepService;
import org.splat.service.technical.ProjectSettingsService;
+import org.splat.service.technical.RepositoryService;
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.DocumentType;
import org.splat.som.Revision;
public class ImportDocumentAction extends UploadBaseNextAction {
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 2587822564883588556L;
+
private List<DocumentType> doctypes = null;
private long doctype = 0;
private String docref = null; // Reference extracted from the imported file, if exist
private String docver = ""; // Version number extracted from the imported file, if exist
private String date = ""; // Date extracted from the imported file, if exist
+ /**
+ * Injected project settings service.
+ */
private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected publication service.
+ */
private PublicationService _publicationService;
+ /**
+ * Injected step service.
+ */
private StepService _stepService;
+ /**
+ * Injected document service.
+ */
+ private DocumentService _documentService;
- private static final long serialVersionUID = 2587822564883588556L;
+ /**
+ * Injected repository service.
+ */
+ private RepositoryService _repositoryService;
// ==============================================================================================================================
// Action methods
// ==============================================================================================================================
+ /**
+ * Initialize the operation.
+ * @return SUCCESS in success, otherwise - ERROR
+ */
public String doInitialize() {
// -----------------------------
Session connex = Database.getSession();
Transaction transax = connex.beginTransaction();
User user = getConnectedUser();
- File updir = Database.getDownloadDirectory(user);
+ File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
String[] table = filename.split("\\x2E");
String filext = table[table.length - 1].toLowerCase();
break;
}
if (fileref != null) {
- Document slot = Database.selectDocument(fileref,
+ Document slot = getDocumentService().selectDocument(fileref,
new Revision().toString());
if (slot == null) {
setErrorCode("reference.undefined");
return SUCCESS;
}
+ /**
+ * Perform import of a document.
+ * @return SUCCESS if ok, "cancel" - if canceled, ERROR - if error
+ */
public String doImport() {
// -------------------------
if (action == ToDo.cancel)
User user = getConnectedUser();
Step step = mystudy.getSelectedStep();
DocumentType type = Document.selectType((int)doctype);
- File updir = Database.getDownloadDirectory(user);
+ File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
String[] table = filename.split("\\x2E");
public void setStepService(StepService stepService) {
_stepService = stepService;
}
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Get the repositoryService.
+ * @return the repositoryService
+ */
+ public RepositoryService getRepositoryService() {
+ return _repositoryService;
+ }
+
+ /**
+ * Set the repositoryService.
+ * @param repositoryService the repositoryService to set
+ */
+ public void setRepositoryService(RepositoryService repositoryService) {
+ _repositoryService = repositoryService;
+ }
}
\ No newline at end of file
private String menuname;
private String selection;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 5904292225286579036L;
// ==============================================================================================================================
private StudyService _studyService;
private ProjectElementService _projectElementService;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = -5586724442986956861L;
protected enum ToDo { cancel, save };
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
import org.splat.dal.bo.som.Study;
+import org.splat.service.SimulationContextService;
import org.splat.service.StudyService;
public class NewStudyAction extends Action {
private String context = null;
private static int number = 0;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 693943641800113782L;
-
/**
- * The Study service.
+ * The injected Study service.
*/
private StudyService _studyService;
+ private SimulationContextService _simulationContextService;
// ==============================================================================================================================
// Action methods
// ==============================================================================================================================
- //Fill the values of the drop-down list.
- public String doInitialize () {
-
- //get the list of the simulation contexts of the study
- contelm = _studyService.getSimulationContextList();
-
- //set the default name of the new study
- ResourceBundle locale = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale());
- title = locale.getString("label.study") + " " + String.valueOf(number + 1);
-
- return SUCCESS;
- }
+ // Fill the values of the drop-down list.
+ public String doInitialize() {
+
+ // get the list of the simulation contexts of the study
+ contelm = getSimulationContextService().getSimulationContextList();
+
+ // set the default name of the new study
+ ResourceBundle locale = ResourceBundle.getBundle("labels",
+ ApplicationSettings.getCurrentLocale());
+ title = locale.getString("label.study") + " "
+ + String.valueOf(number + 1);
+
+ return SUCCESS;
+ }
public String doCreate() throws Exception {
// -------------------------
sprop.disableCheck();
} catch (Exception error) {
SimulationContext.Properties cprop = new SimulationContext.Properties();
- SimulationContextType product = SimulationContext
+ SimulationContextType product = getSimulationContextService()
.selectType("product");
- contelm = Database.selectSimulationContextsWhere(cprop
- .setType(product));
+ contelm = getSimulationContextService()
+ .selectSimulationContextsWhere(cprop.setType(product));
transax.commit();
return INPUT; // Title empty, simply wait for input without error message
}
// Addition of the entered project context
if (valid == 0) { // Input of new project context
SimulationContext.Properties cprop = new SimulationContext.Properties();
- cprop.setType(SimulationContext.selectType("product"))
+ cprop.setType(
+ getSimulationContextService().selectType("product"))
.setValue(value);
getStudyService().addProjectContext(study, cprop);
} else { // Selection of existing project context
- SimulationContext context = Database
+ SimulationContext context = getSimulationContextService()
.selectSimulationContext(valid);
getStudyService().addProjectContext(study, context);
}
public void setStudyService(StudyService studyService) {
_studyService = studyService;
}
+
+ /**
+ * Get the simulationContextService.
+ *
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ *
+ * @param simulationContextService
+ * the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
+ }
}
\ No newline at end of file
public class NotYetImplementedAction extends Action {
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 3131921588316476454L;
// ==============================================================================================================================
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.ProgressState;
import org.splat.service.ProjectElementService;
-import org.splat.service.PublicationService;
import org.splat.service.ScenarioService;
import org.splat.service.StepService;
-import org.splat.service.technical.ProjectSettingsService;
+import org.splat.service.technical.RepositoryService;
import org.splat.dal.bo.som.Publication;
import org.splat.som.Revision;
import org.splat.dal.bo.som.Scenario;
public class OpenStudy extends OpenObject implements OpenStudyServices {
+ /**
+ * Serial version ID.
+ */
+ protected final static Logger logger = org.splat.simer.Action.logger;
+
private Study mystudy;
private StudyRights urightstudy; // User rights on the open study
private StepRights urightstep; // User rights on the selected step
private String credate;
private String lasdate;
private Publication selecdoc;
+ /**
+ * Injected project element service.
+ */
private ProjectElementService _projectElementService;
+ /**
+ * Injected scenario service.
+ */
private ScenarioService _scenarioService;
+ /**
+ * Injected step service.
+ */
private StepService _stepService;
- protected final static Logger logger = org.splat.simer.Action.logger;
-
+ /**
+ * Injected repository service.
+ */
+ private RepositoryService _repositoryService;
// ==============================================================================================================================
// Constructor
// ==============================================================================================================================
+ /**
+ * Open the given study in the current http session.
+ * @param user the current user
+ * @param study the study to open
+ * @return this open study object
+ */
public OpenStudy open (User user, Study study) {
// -----------------------------------------
ResourceBundle custom = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
public URL newTemplateBasedDocument (String typename, User author) {
// ------------------------------------------------------------------
String filename = typename + ".xml"; // Only XML templates are writeable
- File template = new File(Database.getTemplatePath() + filename);
+ File template = new File(getRepositoryService().getTemplatePath() + filename);
if (!template.exists()) return null;
Session connex = Database.getSession();
Transaction transax = connex.beginTransaction();
try {
- File udir = Database.getDownloadDirectory(author);
+ File udir = getRepositoryService().getDownloadDirectory(author);
File credoc = new File(udir.getPath() + "/" + filename);
// Creation of the meta-document
public void setStepService(StepService stepService) {
_stepService = stepService;
}
+
+ /**
+ * Get the repositoryService.
+ * @return the repositoryService
+ */
+ public RepositoryService getRepositoryService() {
+ return _repositoryService;
+ }
+
+ /**
+ * Set the repositoryService.
+ * @param repositoryService the repositoryService to set
+ */
+ public void setRepositoryService(RepositoryService repositoryService) {
+ _repositoryService = repositoryService;
+ }
}
\ No newline at end of file
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.technical.ProjectSettingsService;
import org.splat.service.dto.Proxy;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
-
public abstract class SearchBaseAction extends Action {
- protected String ctype = null; // Context type index, when selected
- protected String cvalue = null; // Context value index, when selected
- protected String cindex = ""; // Context index, when removed
- protected String author = null;
- protected List<Name> manager = null;
- protected SimulationContextType newtype; // Context type to be valued
- protected List<SimulationContext> newvalue; // Context value to be selected
- protected List<SimulationContextType> critext; // Addable context types
- protected List<SimulationContext> context; // Current contexts search criteria
- protected List<Proxy> result;
-
- private static final long serialVersionUID = 7863055790228544510L;
-
- enum UserAction { refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext }
-
-// ==============================================================================================================================
-// Action methods
-// ==============================================================================================================================
-
- public String doSubmitForm () {
-// -----------------------------
-// Identification of the user action
- UserAction action = UserAction.refreshResult;
- if (ctype != null && Integer.valueOf(ctype) > 0) action = UserAction.selectContextType;
- else if (cvalue != null && Integer.valueOf(cvalue) > 0) action = UserAction.selectContextValue;
- else if (cindex.length() > 0) {
- int index = Integer.valueOf(cindex);
- if (index > 0) action = UserAction.removeContext;
- else if (index < 0) action = UserAction.cancelSelect;
- }
-// Execution of the user action
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
- String done;
- try {
- saveFilter(); // Also reinitializes the form, if needed
-
- if (action == UserAction.selectContextType) {
- done = doSelectContextType();
- } else
- if (action == UserAction.selectContextValue) {
- done = doAddContext();
- } else
- if (action == UserAction.removeContext) {
- done = doRemoveContext();
- } else
- if (action == UserAction.cancelSelect) {
- done = doCancel();
- }
- else { // UserAction.refreshResult
- done = doSearch();
- setContextTypeOptions(getInvolvedContexts()); // Done in other do functions, when required
- }
- setCandidates();
- transax.commit();
- return done;
- }
- catch (Exception error) {
-// No need to roll back the transaction as it is read only
- logger.error("Reason: ", error);
- return ERROR;
- }
- }
-
- @SuppressWarnings("unchecked")
- protected String doSelectContextType () {
-// ---------------------------------------
- SimulationContext.Properties sprop = new SimulationContext.Properties();
-
- newtype = SimulationContext.selectType(Integer.valueOf(ctype));
- newvalue = Database.selectSimulationContextsWhere(sprop.setType(newtype));
- if (cindex.length() > 0 && Integer.valueOf(cindex) == 0)
- getSession().remove("search.result");
- else
- result = (List<Proxy>)getSession().get("search.result"); // We keep the previous result search, if valid
- return "selectype";
- }
-
- protected String doAddContext () {
-// --------------------------------
- SimulationContext selected = Database.selectSimulationContext(Integer.valueOf(cvalue));
-
- context.add(selected);
- setContextTypeOptions(getInvolvedContexts()); // Sets critext
- getSession().remove("search.result"); // The current result is obsolete
- return "refresh";
- }
-
- protected String doRemoveContext () {
-// -----------------------------------
- int index = Integer.valueOf(cindex);
- for (Iterator<SimulationContext> selected=context.iterator(); selected.hasNext();) {
- if (selected.next().getIndex() == index) {
- selected.remove();
- break;
- }
- }
- setContextTypeOptions(getInvolvedContexts()); // Sets critext
- getSession().remove("search.result"); // The current result is obsolete
- return "refresh";
- }
-
- @SuppressWarnings("unchecked")
- protected String doCancel () {
-// ----------------------------
- result = (List<Proxy>)getSession().get("search.result"); // Current result search
- setContextTypeOptions(getInvolvedContexts()); // Sets critext
- return "refresh";
- }
-
-// ==============================================================================================================================
-// Getters
-// ==============================================================================================================================
-
- public String getAuthor () {
-// --------------------------
- return author;
- }
- public List<Name> getCandidates () {
-// ----------------------------------
- return manager;
- }
- public List<SimulationContextType> getContextTypeOptions () {
-// -----------------------------------------------------------
- return critext;
- }
- public List<SimulationContext> getContextValueOptions () {
-// --------------------------------------------------------
- return newvalue;
- }
- public SimulationContextType getSelectedContextType () {
-// ------------------------------------------------------
- return newtype;
- }
- public List<SimulationContext> getSimulationContexts () {
-// -------------------------------------------------------
- return context;
- }
- public List<Proxy> getResult () {
-// -------------------------------
- return result;
- }
-
-// ==============================================================================================================================
-// Setters
-// ==============================================================================================================================
-
- public void setAuthor (String index) {
-// ------------------------------------
- this.author = index;
- }
- public void setContextType (String type) {
-// ----------------------------------------
- this.ctype = type;
- }
- public void setContextValue (String value) {
-// ------------------------------------------
- this.cvalue = value;
- }
- public void setContextIndex (String value) {
-// ------------------------------------------
- this.cindex = value;
- }
-
- protected void setCandidates () {
-// -------------------------------
- manager = new Vector<Name>();
- List<User> users = UserDirectory.selectAllUsers();
- User me = getConnectedUser(); // May be null
- for (Iterator<User> i=users.iterator(); i.hasNext(); ) {
- User next = i.next();
- ApplicationRights he = new ApplicationRights(next);
- if (he.canCreateStudy()) {
- if (next.equals(me)) manager.add(0, new ValidationFacade.ByManager(me));
- else manager.add(next);
- }
- }
- }
-
- protected void setContextTypeOptions (List<SimulationContextType> critext) {
-// --------------------------------------------------------------------------
- for (Iterator<SimulationContext> i=context.iterator(); i.hasNext();) {
- critext.remove(i.next().getType()); // Already used context type
- }
-// Ordering by alphabetical order of localized context types
- SimulationContextType[] types = critext.toArray( new SimulationContextType[critext.size()] );
- ContextTypeComparator compare = new ContextTypeComparator();
- ProjectSettingsService.Step step = types[0].getAttachedStep();
- int from = 0;
- int to = 0;
- while (to < types.length-1) {
- to += 1;
- if (types[to].isAttachedTo(step)) continue;
-
- if (to > from+1) Arrays.sort(types, from, to, compare);
- from = to;
- step = types[to].getAttachedStep();
- }
- if (to > from) Arrays.sort(types, from, to+1, compare);
- this.critext = Arrays.asList(types);
- }
-
-// ==============================================================================================================================
-// Abstract services
-// ==============================================================================================================================
-
- protected abstract String doSearch () throws InvalidPropertyException;
- protected abstract List<SimulationContextType> getInvolvedContexts ();
- protected abstract void loadFilter ();
- protected abstract void saveFilter ();
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 7863055790228544510L;
+
+ protected String ctype = null; // Context type index, when selected
+ protected String cvalue = null; // Context value index, when selected
+ protected String cindex = ""; // Context index, when removed
+ protected String author = null;
+ protected List<Name> manager = null;
+ protected SimulationContextType newtype; // Context type to be valued
+ protected List<SimulationContext> newvalue; // Context value to be selected
+ protected List<SimulationContextType> critext; // Addable context types
+ protected List<SimulationContext> context; // Current contexts search criteria
+ protected List<Proxy> result;
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
+
+ enum UserAction {
+ refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext
+ }
+
+ // ==============================================================================================================================
+ // Action methods
+ // ==============================================================================================================================
+
+ public String doSubmitForm() {
+ // -----------------------------
+ // Identification of the user action
+ UserAction action = UserAction.refreshResult;
+ if (ctype != null && Integer.valueOf(ctype) > 0)
+ action = UserAction.selectContextType;
+ else if (cvalue != null && Integer.valueOf(cvalue) > 0)
+ action = UserAction.selectContextValue;
+ else if (cindex.length() > 0) {
+ int index = Integer.valueOf(cindex);
+ if (index > 0)
+ action = UserAction.removeContext;
+ else if (index < 0)
+ action = UserAction.cancelSelect;
+ }
+ // Execution of the user action
+ Session connex = Database.getSession();
+ Transaction transax = connex.beginTransaction();
+ String done;
+ try {
+ saveFilter(); // Also reinitializes the form, if needed
+
+ if (action == UserAction.selectContextType) {
+ done = doSelectContextType();
+ } else if (action == UserAction.selectContextValue) {
+ done = doAddContext();
+ } else if (action == UserAction.removeContext) {
+ done = doRemoveContext();
+ } else if (action == UserAction.cancelSelect) {
+ done = doCancel();
+ } else { // UserAction.refreshResult
+ done = doSearch();
+ setContextTypeOptions(getInvolvedContexts()); // Done in other do functions, when required
+ }
+ setCandidates();
+ transax.commit();
+ return done;
+ } catch (Exception error) {
+ // No need to roll back the transaction as it is read only
+ logger.error("Reason: ", error);
+ return ERROR;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected String doSelectContextType() {
+ // ---------------------------------------
+ SimulationContext.Properties sprop = new SimulationContext.Properties();
+
+ newtype = getSimulationContextService().selectType(Integer.valueOf(ctype));
+ newvalue = getSimulationContextService().selectSimulationContextsWhere(
+ sprop.setType(newtype));
+ if (cindex.length() > 0 && Integer.valueOf(cindex) == 0)
+ getSession().remove("search.result");
+ else
+ result = (List<Proxy>) getSession().get("search.result"); // We keep the previous result search, if valid
+ return "selectype";
+ }
+
+ protected String doAddContext() {
+ // --------------------------------
+ SimulationContext selected = getSimulationContextService()
+ .selectSimulationContext(Integer.valueOf(cvalue));
+
+ context.add(selected);
+ setContextTypeOptions(getInvolvedContexts()); // Sets critext
+ getSession().remove("search.result"); // The current result is obsolete
+ return "refresh";
+ }
+
+ protected String doRemoveContext() {
+ // -----------------------------------
+ int index = Integer.valueOf(cindex);
+ for (Iterator<SimulationContext> selected = context.iterator(); selected
+ .hasNext();) {
+ if (selected.next().getIndex() == index) {
+ selected.remove();
+ break;
+ }
+ }
+ setContextTypeOptions(getInvolvedContexts()); // Sets critext
+ getSession().remove("search.result"); // The current result is obsolete
+ return "refresh";
+ }
+
+ @SuppressWarnings("unchecked")
+ protected String doCancel() {
+ // ----------------------------
+ result = (List<Proxy>) getSession().get("search.result"); // Current result search
+ setContextTypeOptions(getInvolvedContexts()); // Sets critext
+ return "refresh";
+ }
+
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
+
+ public String getAuthor() {
+ // --------------------------
+ return author;
+ }
+
+ public List<Name> getCandidates() {
+ // ----------------------------------
+ return manager;
+ }
+
+ public List<SimulationContextType> getContextTypeOptions() {
+ // -----------------------------------------------------------
+ return critext;
+ }
+
+ public List<SimulationContext> getContextValueOptions() {
+ // --------------------------------------------------------
+ return newvalue;
+ }
+
+ public SimulationContextType getSelectedContextType() {
+ // ------------------------------------------------------
+ return newtype;
+ }
+
+ public List<SimulationContext> getSimulationContexts() {
+ // -------------------------------------------------------
+ return context;
+ }
+
+ public List<Proxy> getResult() {
+ // -------------------------------
+ return result;
+ }
+
+ // ==============================================================================================================================
+ // Setters
+ // ==============================================================================================================================
+
+ public void setAuthor(String index) {
+ // ------------------------------------
+ this.author = index;
+ }
+
+ public void setContextType(String type) {
+ // ----------------------------------------
+ this.ctype = type;
+ }
+
+ public void setContextValue(String value) {
+ // ------------------------------------------
+ this.cvalue = value;
+ }
+
+ public void setContextIndex(String value) {
+ // ------------------------------------------
+ this.cindex = value;
+ }
+
+ protected void setCandidates() {
+ // -------------------------------
+ manager = new Vector<Name>();
+ List<User> users = UserDirectory.selectAllUsers();
+ User me = getConnectedUser(); // May be null
+ for (Iterator<User> i = users.iterator(); i.hasNext();) {
+ User next = i.next();
+ ApplicationRights he = new ApplicationRights(next);
+ if (he.canCreateStudy()) {
+ if (next.equals(me))
+ manager.add(0, new ValidationFacade.ByManager(me));
+ else
+ manager.add(next);
+ }
+ }
+ }
+
+ protected void setContextTypeOptions(List<SimulationContextType> critext) {
+ // --------------------------------------------------------------------------
+ for (Iterator<SimulationContext> i = context.iterator(); i.hasNext();) {
+ critext.remove(i.next().getType()); // Already used context type
+ }
+ // Ordering by alphabetical order of localized context types
+ SimulationContextType[] types = critext
+ .toArray(new SimulationContextType[critext.size()]);
+ ContextTypeComparator compare = new ContextTypeComparator();
+ ProjectSettingsService.Step step = types[0].getAttachedStep();
+ int from = 0;
+ int to = 0;
+ while (to < types.length - 1) {
+ to += 1;
+ if (types[to].isAttachedTo(step))
+ continue;
+
+ if (to > from + 1)
+ Arrays.sort(types, from, to, compare);
+ from = to;
+ step = types[to].getAttachedStep();
+ }
+ if (to > from)
+ Arrays.sort(types, from, to + 1, compare);
+ this.critext = Arrays.asList(types);
+ }
+
+ // ==============================================================================================================================
+ // Abstract services
+ // ==============================================================================================================================
+
+ protected abstract String doSearch() throws InvalidPropertyException;
+
+ protected abstract List<SimulationContextType> getInvolvedContexts();
+
+ protected abstract void loadFilter();
+
+ protected abstract void saveFilter();
+
+ /**
+ * Get the simulationContextService.
+ *
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ *
+ * @param simulationContextService
+ * the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
+ }
}
\ No newline at end of file
public class SearchDocumentAction extends Action {
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 4347921635793712836L;
// ==============================================================================================================================
import org.splat.dal.bo.kernel.User;
import org.splat.kernel.UserDirectory;
import org.splat.service.SearchService;
+import org.splat.service.SimulationContextService;
import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.KnowledgeElementType;
private String words = null; // Full text search words
private List<KnowledgeElementType> types; // Available knowledge types filter (initialized below)
private SearchService _searchService;
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = -3104321907432838476L;
// ==============================================================================================================================
protected List<SimulationContextType> getInvolvedContexts () {
// ------------------------------------------------------------
- return SimulationContext.selectAllTypes();
+ return getSimulationContextService().selectAllTypes();
}
@SuppressWarnings("unchecked")
public void setSearchService(SearchService searchService) {
_searchService = searchService;
}
+
+ /**
+ * Get the simulationContextService.
+ *
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ *
+ * @param simulationContextService
+ * the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
+ }
}
\ No newline at end of file
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.technical.ProjectSettingsService;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
private String words = null; // Full text search words
private SearchService _searchService;
private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = -1910481357051393077L;
enum UserAction { refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext }
List<ProjectSettingsService.Step> steps = getProjectSettings().getStepsOf(Study.class);
ProjectSettingsService.Step[] number = steps.toArray(new ProjectSettingsService.Step[steps.size()]);
- return SimulationContext.selectTypesOf(number);
+ return getSimulationContextService().selectTypesOf(number);
}
@SuppressWarnings("unchecked")
ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
+
+ /**
+ * Get the simulationContextService.
+ *
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ *
+ * @param simulationContextService
+ * the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
+ }
}
\ No newline at end of file
private ProjectSettingsService _projectSettingsService;
private ApplicationSettings _ApplicationSettings;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 5875058140682652964L;
// ==============================================================================================================================
private int approver;
private StudyService _studyService;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 4210696018741092900L;
private enum Save { title, contributor, cycle }
import java.io.File;
import org.splat.kernel.Do;
+import org.splat.service.technical.RepositoryService;
import org.splat.dal.dao.som.Database;
private ToDo action; // Action to do
private String next = null; // Action to which the uploaded file is passed
private String index = null; // Depending on the next action, document index to which the action applies
+ /**
+ * Injected repository service.
+ */
+ private RepositoryService _repositoryService;
private static final long serialVersionUID = 6003880772275115923L;
// -------------------------
if (action == ToDo.cancel) return "cancel";
try {
- File udir = Database.getDownloadDirectory(getConnectedUser());
+ File udir = getRepositoryService().getDownloadDirectory(getConnectedUser());
String path = udir.getPath() + "/" + uploadFileName;
File file = new File(path);
// ----------------------------------------------
this.uploadMimeType = mime;
}
+
+ /**
+ * Get the repositoryService.
+ * @return the repositoryService
+ */
+ public RepositoryService getRepositoryService() {
+ return _repositoryService;
+ }
+
+ /**
+ * Set the repositoryService.
+ * @param repositoryService the repositoryService to set
+ */
+ public void setRepositoryService(RepositoryService repositoryService) {
+ _repositoryService = repositoryService;
+ }
}
\ No newline at end of file
protected String docuses = null;
protected ToDo action = null;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = -6925961099244461039L;
protected enum ToDo { cancel, save };
import org.splat.service.PublicationService;
import org.splat.service.StepService;
import org.splat.service.technical.ProjectSettingsService;
+import org.splat.service.technical.RepositoryService;
import org.splat.dal.bo.som.Publication;
import org.splat.som.Revision;
import org.splat.som.Step;
private ProjectSettingsService _projectSettingsService;
private PublicationService _publicationService;
private StepService _stepService;
+ /**
+ * Injected repository service.
+ */
+ private RepositoryService _repositoryService;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = -5702264003232132168L;
// ==============================================================================================================================
Session connex = Database.getSession();
Transaction transax = connex.beginTransaction();
User user = getConnectedUser();
- File updir = Database.getDownloadDirectory(user);
+ File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
mystudy = getOpenStudy();
mystudy = getOpenStudy();
User user = getConnectedUser();
Step step = mystudy.getSelectedStep();
- File updir = Database.getDownloadDirectory(user);
+ File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
// Versioning of the document
public void setStepService(StepService stepService) {
_stepService = stepService;
}
+
+ /**
+ * Get the repositoryService.
+ * @return the repositoryService
+ */
+ public RepositoryService getRepositoryService() {
+ return _repositoryService;
+ }
+
+ /**
+ * Set the repositoryService.
+ * @param repositoryService the repositoryService to set
+ */
+ public void setRepositoryService(RepositoryService repositoryService) {
+ _repositoryService = repositoryService;
+ }
}
\ No newline at end of file
public class DatabaseIndexingAction extends Action {
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 4194268823457749655L;
+
private List<ImportedStudy> newstudies;
private String indices;
private SearchService _searchService;
private ImportedStudy _importedStudy;
private StudyService _studyService;
- private static final long serialVersionUID = 4194268823457749655L;
-
// ==============================================================================================================================
// Action methods
// ==============================================================================================================================
import org.hibernate.Transaction;
import org.splat.dal.bo.kernel.User;
import org.splat.kernel.UserDirectory;
+import org.splat.service.technical.RepositoryService;
import org.splat.simer.UploadBaseNextAction;
import org.splat.dal.dao.som.Database;
public class ImportUserAction extends UploadBaseNextAction {
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 1516715800624817965L;
+
private List<User> users;
private Set<User> newsers;
-
- private static final long serialVersionUID = 1516715800624817965L;
+ /**
+ * Injected repository service.
+ */
+ private RepositoryService _repositoryService;
// ==============================================================================================================================
// Action methods
Transaction transax = connex.beginTransaction();
try {
User user = getConnectedUser(); // The database administrator
- File updir = Database.getDownloadDirectory(user);
+ File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
newsers = UserDirectory.importUsers(upfile);
// --------------------------------
return newsers.contains(user);
}
+
+ /**
+ * Get the repositoryService.
+ * @return the repositoryService
+ */
+ public RepositoryService getRepositoryService() {
+ return _repositoryService;
+ }
+
+ /**
+ * Set the repositoryService.
+ * @param repositoryService the repositoryService to set
+ */
+ public void setRepositoryService(RepositoryService repositoryService) {
+ _repositoryService = repositoryService;
+ }
}
\ No newline at end of file
public class KnowledgeElementAction extends Action {
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 2416672950671183384L;
// ==============================================================================================================================
import org.splat.dal.bo.som.ProgressState;
import org.splat.service.KnowledgeElementService;
import org.splat.service.SearchService;
+import org.splat.service.SimulationContextService;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.service.dto.Proxy;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
import org.splat.dal.bo.som.Study;
-
+/**
+ * Action for operations on simulation contexts.
+ */
public class SimulationContextAction extends Action {
- private List<SimulationContextFacade> tocheck; // Simulation contexts to be approved
- private int selection; // Index of the selected simulation context presented in the approval form
- private SimulationContext edition; // Corresponding simulation context object
- private ProjectSettingsService.Step step; // Study step to which the selected simulation context is attached
- private Set<ProjectElementFacade> owner; // Study scenarios indexed by this simulation context
- private List<LocalizedContextTypes> existype; // Existing approved simulation context types ordered by localized names
- private List<SimulationContextType> exisname; // Existing approved simulation context types ordered by internal codes
- private List<SimulationContext> existing; // Existing simulation contexts of selected type
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 7083323229359094699L;
+
+ private List<SimulationContextFacade> tocheck; // Simulation contexts to be approved
+ private int selection; // Index of the selected simulation context presented in the approval form
+ private SimulationContext edition; // Corresponding simulation context object
+ private ProjectSettingsService.Step step; // Study step to which the selected simulation context is attached
+ private Set<ProjectElementFacade> owner; // Study scenarios indexed by this simulation context
+ private List<LocalizedContextTypes> existype; // Existing approved simulation context types ordered by localized names
+ private List<SimulationContextType> exisname; // Existing approved simulation context types ordered by internal codes
+ private List<SimulationContext> existing; // Existing simulation contexts of selected type
+ /**
+ * Injected search service.
+ */
private SearchService _searchService;
+ /**
+ * Injected project settings service.
+ */
private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected knowledge element service.
+ */
private KnowledgeElementService _knowledgeElementService;
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
- private static final long serialVersionUID = 7083323229359094699L;
-
- private class ContextNameComparator implements Comparator<SimulationContextType> {
-// ---------------------------------------------------------------------------------
- public int compare(SimulationContextType t1, SimulationContextType t2)
- {
- String name1 = t1.getName();
- String name2 = t2.getName();
-
- return name1.compareToIgnoreCase(name2);
- }
- }
-
- public class LocalizedContextTypes {
-// ----------------------------------
- private Locale locale;
- private List<String> sortype; // Existing approved simulation context types ordered by localized names
-
- public LocalizedContextTypes (List<SimulationContextType> types, Locale lang)
- {
- ResourceBundle bundle = ResourceBundle.getBundle("som", lang);
- SimulationContextType[] tosort = types.toArray( new SimulationContextType[types.size()] );
- String[] name = new String[types.size()];
-
- for (int i=0; i<name.length; i++) name[i] = bundle.getString("type.context." + tosort[i].getName());
- Arrays.sort(name);
- sortype = Arrays.asList(name);
- locale = lang;
- }
- public String getLocale ()
- {
- return locale.toString();
- }
- public List<String> getTypeNames ()
- {
- return sortype;
- }
- public boolean isCurrent ()
- {
- return (locale.equals(ApplicationSettings.getCurrentLocale()));
- }
- }
-
-// ==============================================================================================================================
-// Action methods
-// ==============================================================================================================================
-
- public String doInitialize () {
-// -----------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
- try {
- SimulationContext.Properties cprop = new SimulationContext.Properties();
- List<SimulationContext> context = Database.selectSimulationContextsWhere(cprop.setState(ProgressState.inCHECK));
-
- tocheck = new Vector<SimulationContextFacade>(context.size());
- for (Iterator<SimulationContext> i=context.iterator(); i.hasNext(); ) {
- tocheck.add( new SimulationContextFacade(i.next(), getProjectSettings().getAllSteps()) );
- }
- selection = 0;
- edition = null;
- owner = null;
-
- transax.commit();
- return SUCCESS;
- }
- catch (Exception error) {
- logger.error("Reason:", error);
- return ERROR; // No need to roll-back the transaction as it is read-only
- }
- }
-
- public String doSelect () {
-// -------------------------
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
- try {
- SimulationContext.Properties cprop = new SimulationContext.Properties();
- List<SimulationContext> context = Database.selectSimulationContextsWhere(cprop.setState(ProgressState.inCHECK));
- List<SimulationContext> selected = new ArrayList<SimulationContext>(1);
-
- tocheck = new Vector<SimulationContextFacade>(context.size());
- for (Iterator<SimulationContext> i=context.iterator(); i.hasNext(); ) {
- SimulationContext next = i.next();
- if (next.getIndex() == selection) {
- edition = next;
- selected.add(edition);
- }
- tocheck.add( new SimulationContextFacade(next, getProjectSettings().getAllSteps()) );
- }
- KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
- List<Proxy> kelm = getSearchService().selectKnowledgeElementsWhere(kprop.setSimulationContexts(selected).setState(ProgressState.inWORK));
-
- step = edition.getType().getAttachedStep();
- owner = new HashSet<ProjectElementFacade>();
- for (Iterator<Proxy> i=kelm.iterator(); i.hasNext(); ) {
- KnowledgeElement next = getKnowledgeElementService().selectKnowledgeElement(i.next().getIndex());
- ProjectElementFacade facade;
- if (step.appliesTo(Study.class)) facade = new ProjectElementFacade(next.getOwnerScenario().getOwnerStudy(), step);
- else facade = new ProjectElementFacade(next.getOwnerScenario(), step);
- owner.add(facade);
- }
- SimulationContextType.Properties sprop = new SimulationContextType.Properties();
- List<SimulationContextType> types = SimulationContext.selectTypesWhere(sprop.setState(ProgressState.APPROVED));
- Locale[] support = ApplicationSettings.getSupportedLocales();
-
-// Sort localized type names
- existype = new ArrayList<LocalizedContextTypes>(support.length);
- for (int i=0; i<support.length; i++) {
- existype.add( new LocalizedContextTypes(types, support[i]) );
- }
- SimulationContextType[] names = types.toArray( new SimulationContextType[types.size()] );
-
- Arrays.sort(names, new ContextNameComparator() );
- exisname = Arrays.asList(names);
-
- existing = Database.selectSimulationContextsWhere(cprop.setType(edition.getType()).setState(ProgressState.APPROVED));
-
- transax.commit();
- return SUCCESS;
- }
- catch (Exception error) {
- logger.error("Reason:", error);
- return ERROR; // No need to roll-back the transaction as it is read-only
- }
- }
-
-// ==============================================================================================================================
-// Getters and setters
-// ==============================================================================================================================
-
- /**
- * @return
+ /**
+ * Context name comparator.
*/
- public SearchService getSearchService() {
- // TODO Auto-generated method stub
- return _searchService;
+ private class ContextNameComparator implements
+ Comparator<SimulationContextType> {
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(SimulationContextType t1, SimulationContextType t2) {
+ String name1 = t1.getName();
+ String name2 = t2.getName();
+
+ return name1.compareToIgnoreCase(name2);
+ }
}
- public void setSearchService(SearchService searchService) {
- _searchService = searchService;
+ public class LocalizedContextTypes {
+ // ----------------------------------
+ private Locale locale;
+ private List<String> sortype; // Existing approved simulation context types ordered by localized names
+
+ public LocalizedContextTypes(List<SimulationContextType> types,
+ Locale lang) {
+ ResourceBundle bundle = ResourceBundle.getBundle("som", lang);
+ SimulationContextType[] tosort = types
+ .toArray(new SimulationContextType[types.size()]);
+ String[] name = new String[types.size()];
+
+ for (int i = 0; i < name.length; i++)
+ name[i] = bundle.getString("type.context."
+ + tosort[i].getName());
+ Arrays.sort(name);
+ sortype = Arrays.asList(name);
+ locale = lang;
+ }
+
+ public String getLocale() {
+ return locale.toString();
+ }
+
+ public List<String> getTypeNames() {
+ return sortype;
+ }
+
+ public boolean isCurrent() {
+ return (locale.equals(ApplicationSettings.getCurrentLocale()));
+ }
+ }
+
+ // ==============================================================================================================================
+ // Action methods
+ // ==============================================================================================================================
+
+ public String doInitialize() {
+ // -----------------------------
+ Session connex = Database.getSession();
+ Transaction transax = connex.beginTransaction();
+ try {
+ SimulationContext.Properties cprop = new SimulationContext.Properties();
+ List<SimulationContext> context = getSimulationContextService()
+ .selectSimulationContextsWhere(
+ cprop.setState(ProgressState.inCHECK));
+
+ tocheck = new Vector<SimulationContextFacade>(context.size());
+ for (Iterator<SimulationContext> i = context.iterator(); i
+ .hasNext();) {
+ tocheck.add(new SimulationContextFacade(i.next(),
+ getProjectSettings().getAllSteps()));
+ }
+ selection = 0;
+ edition = null;
+ owner = null;
+
+ transax.commit();
+ return SUCCESS;
+ } catch (Exception error) {
+ logger.error("Reason:", error);
+ return ERROR; // No need to roll-back the transaction as it is read-only
+ }
+ }
+
+ public String doSelect() {
+ // -------------------------
+ Session connex = Database.getSession();
+ Transaction transax = connex.beginTransaction();
+ try {
+ SimulationContext.Properties cprop = new SimulationContext.Properties();
+ List<SimulationContext> context = getSimulationContextService()
+ .selectSimulationContextsWhere(
+ cprop.setState(ProgressState.inCHECK));
+ List<SimulationContext> selected = new ArrayList<SimulationContext>(
+ 1);
+
+ tocheck = new Vector<SimulationContextFacade>(context.size());
+ for (Iterator<SimulationContext> i = context.iterator(); i
+ .hasNext();) {
+ SimulationContext next = i.next();
+ if (next.getIndex() == selection) {
+ edition = next;
+ selected.add(edition);
+ }
+ tocheck.add(new SimulationContextFacade(next,
+ getProjectSettings().getAllSteps()));
+ }
+ KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
+ List<Proxy> kelm = getSearchService().selectKnowledgeElementsWhere(
+ kprop.setSimulationContexts(selected).setState(
+ ProgressState.inWORK));
+
+ step = edition.getType().getAttachedStep();
+ owner = new HashSet<ProjectElementFacade>();
+ for (Iterator<Proxy> i = kelm.iterator(); i.hasNext();) {
+ KnowledgeElement next = getKnowledgeElementService()
+ .selectKnowledgeElement(i.next().getIndex());
+ ProjectElementFacade facade;
+ if (step.appliesTo(Study.class))
+ facade = new ProjectElementFacade(next.getOwnerScenario()
+ .getOwnerStudy(), step);
+ else
+ facade = new ProjectElementFacade(next.getOwnerScenario(),
+ step);
+ owner.add(facade);
+ }
+ SimulationContextType.Properties sprop = new SimulationContextType.Properties();
+ List<SimulationContextType> types = getSimulationContextService()
+ .selectTypesWhere(sprop.setState(ProgressState.APPROVED));
+ Locale[] support = ApplicationSettings.getSupportedLocales();
+
+ // Sort localized type names
+ existype = new ArrayList<LocalizedContextTypes>(support.length);
+ for (int i = 0; i < support.length; i++) {
+ existype.add(new LocalizedContextTypes(types, support[i]));
+ }
+ SimulationContextType[] names = types
+ .toArray(new SimulationContextType[types.size()]);
+
+ Arrays.sort(names, new ContextNameComparator());
+ exisname = Arrays.asList(names);
+
+ existing = getSimulationContextService()
+ .selectSimulationContextsWhere(
+ cprop.setType(edition.getType()).setState(
+ ProgressState.APPROVED));
+
+ transax.commit();
+ return SUCCESS;
+ } catch (Exception error) {
+ logger.error("Reason:", error);
+ return ERROR; // No need to roll-back the transaction as it is read-only
+ }
+ }
+
+ // ==============================================================================================================================
+ // Getters and setters
+ // ==============================================================================================================================
+
+ public List<ProjectSettingsService.Step> getAllStudySteps() {
+ // -----------------------------------------------------
+ return getProjectSettings().getAllSteps();
}
- public List<ProjectSettingsService.Step> getAllStudySteps () {
-// -----------------------------------------------------
- return getProjectSettings().getAllSteps();
- }
- /**
- * Get project settings.
+ /**
+ * Get project settings.
+ *
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
/**
* Set project settings service.
- * @param projectSettingsService project settings service
+ *
+ * @param projectSettingsService
+ * project settings service
*/
- public void setProjectSettings(
- ProjectSettingsService projectSettingsService) {
+ public void setProjectSettings(ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
- public ProjectSettingsService.Step getAttachedStep () {
-// ----------------------------------------------
- return step;
- }
- public List<SimulationContextFacade> getContextsToBeApproved () {
-// ---------------------------------------------------------------
- return tocheck;
- }
- public SimulationContext getEdited () {
-// -------------------------------------
- return edition;
- }
- public List<SimulationContext> getExistingContexts () {
-// -----------------------------------------------------
- return existing;
- }
- public List<SimulationContextType> getExistingNames () {
-// ------------------------------------------------------
- return exisname;
- }
- public List<LocalizedContextTypes> getSupportedLocales () {
-// ---------------------------------------------------------
- return existype;
- }
- public Set<ProjectElementFacade> getIndexedElements () {
-// ------------------------------------------------------
- return owner;
- }
- public int getSelection () {
-// --------------------------
- return selection;
- }
-
- public void setSelection (String index) {
-// ---------------------------------------
- selection = Integer.valueOf(index);
- }
+ public ProjectSettingsService.Step getAttachedStep() {
+ // ----------------------------------------------
+ return step;
+ }
+
+ public List<SimulationContextFacade> getContextsToBeApproved() {
+ // ---------------------------------------------------------------
+ return tocheck;
+ }
+
+ public SimulationContext getEdited() {
+ // -------------------------------------
+ return edition;
+ }
+
+ public List<SimulationContext> getExistingContexts() {
+ // -----------------------------------------------------
+ return existing;
+ }
+
+ public List<SimulationContextType> getExistingNames() {
+ // ------------------------------------------------------
+ return exisname;
+ }
+
+ public List<LocalizedContextTypes> getSupportedLocales() {
+ // ---------------------------------------------------------
+ return existype;
+ }
+
+ public Set<ProjectElementFacade> getIndexedElements() {
+ // ------------------------------------------------------
+ return owner;
+ }
+
+ public int getSelection() {
+ // --------------------------
+ return selection;
+ }
+
+ public void setSelection(String index) {
+ // ---------------------------------------
+ selection = Integer.valueOf(index);
+ }
/**
* Get the knowledgeElementService.
+ *
* @return the knowledgeElementService
*/
public KnowledgeElementService getKnowledgeElementService() {
/**
* Set the knowledgeElementService.
- * @param knowledgeElementService the knowledgeElementService to set
+ *
+ * @param knowledgeElementService
+ * the knowledgeElementService to set
*/
public void setKnowledgeElementService(
KnowledgeElementService knowledgeElementService) {
_knowledgeElementService = knowledgeElementService;
}
+
+ /**
+ * Get the simulationContextService.
+ *
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ *
+ * @param simulationContextService
+ * the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
+ }
+
+ /**
+ * Get the searchService.
+ * @return the searchService
+ */
+ public SearchService getSearchService() {
+ return _searchService;
+ }
+
+ /**
+ * Set the searchService.
+ * @param searchService the searchService to set
+ */
+ public void setSearchService(SearchService searchService) {
+ _searchService = searchService;
+ }
}
\ No newline at end of file
private String myurl;
private boolean selected = false;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = -3505572710372809913L;
// ==============================================================================================================================
protected static class Group extends MenuItem {
// ---------------------------------------------
private boolean open = false;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 8319750643667219000L;
protected Group (String label) { super(label); }
}
protected static class SubItem extends MenuItem {
// -----------------------------------------------
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = -4793172296421132566L;
protected SubItem (String label) { super(label); }
protected HashMap<String,String> disabled; // Actions of disabled item
protected String selection;
+ /**
+ * Serial version ID.
+ */
private static final long serialVersionUID = 1851786085512439549L;
// ==============================================================================================================================
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
-
- <context:property-placeholder
- location="classpath:siman.properties,classpath:jdbc.properties"
- ignore-unresolvable="true" />
- <!-- configuration i18n -->
- <bean id="i18nUtils"
- class="org.splat.i18n.I18nUtils">
+ <context:property-placeholder
+ location="classpath:siman.properties,classpath:jdbc.properties"
+ ignore-unresolvable="true" />
+
+ <!-- configuration i18n -->
+ <bean id="i18nUtils" class="org.splat.i18n.I18nUtils">
<property name="resourceBundleMessageSource"
ref="messageSource" />
</bean>
</list>
</property>
</bean>
- <!-- ref 'baseMessageSource' into Siman-common\src\spring\globalContext.xml -->
+ <!-- ref 'baseMessageSource' into Siman-common\src\spring\globalContext.xml -->
<!-- property name="parentMessageSource" ref="baseMessageSource"/-->
-
- <bean id="applicationSettings"
+
+ <bean id="applicationSettings"
class="org.splat.simer.ApplicationSettings">
<property name="projectSettings" ref="projectSettings" />
</bean>
<property name="publicationService" ref="publicationService" />
<property name="scenarioService" ref="scenarioService" />
<property name="stepService" ref="stepService" />
+ <property name="repositoryService" ref="repositoryService" />
</bean>
<bean id="openKnowledge" class="org.splat.simer.OpenKnowledge"
<property name="openKnowledge" ref="openKnowledge" />
</bean>
- <!--========= Inherited from baseAction =========-->
-
- <bean id="newStudyAction" class="org.splat.simer.NewStudyAction"
- parent="baseAction" scope="prototype">
- <property name="studyService" ref="studyService" />
- </bean>
+ <!--========= Inherited from baseAction =========-->
+
+ <bean id="newStudyAction" class="org.splat.simer.NewStudyAction"
+ parent="baseAction" scope="prototype">
+ <property name="simulationContextService"
+ ref="simulationContextService" />
+ <property name="studyService" ref="studyService" />
+ </bean>
<bean id="displayStudyStepAction"
class="org.splat.simer.DisplayStudyStepAction" parent="baseAction"
<property name="studyService" ref="studyService" />
</bean>
- <!--========= Inherited from displayStudyStepAction =========-->
-
+ <!--========= Inherited from displayStudyStepAction =========-->
+
<bean id="studyPropertiesAction"
class="org.splat.simer.StudyPropertiesAction" scope="prototype"
parent="displayStudyStepAction">
class="org.splat.simer.EditSimulationContextAction" scope="prototype"
parent="displayStudyStepAction">
<property name="stepService" ref="stepService" />
+ <property name="simulationContextService"
+ ref="simulationContextService" />
</bean>
<bean id="editDocumentAction"
class="org.splat.simer.EditDocumentAction" scope="prototype"
parent="displayStudyStepAction">
<property name="publicationService" ref="publicationService" />
+ <property name="repositoryService" ref="repositoryService" />
</bean>
<bean id="editKnowledgeElementAction"
<property name="scenarioService" ref="scenarioService" />
</bean>
- <!-- End of Inherited from displayStudyStepAction -->
-
+ <!-- End of Inherited from displayStudyStepAction -->
+
<bean id="startAction" class="org.splat.simer.StartAction"
scope="prototype">
<property name="applicationSettings" ref="applicationSettings" />
class="org.splat.simer.SearchStudyAction" scope="prototype">
<property name="projectSettings" ref="projectSettings" />
<property name="searchService" ref="searchService" />
+ <property name="simulationContextService"
+ ref="simulationContextService" />
</bean>
<bean id="searchKnowledgeAction"
class="org.splat.simer.SearchKnowledgeAction" scope="prototype">
<property name="searchService" ref="searchService" />
+ <property name="simulationContextService"
+ ref="simulationContextService" />
</bean>
<bean id="searchDocumentAction"
<bean id="uploadAction" class="org.splat.simer.UploadAction"
scope="prototype">
+ <property name="repositoryService" ref="repositoryService" />
</bean>
<bean id="importDocumentAction"
<property name="stepService" ref="stepService" />
<property name="projectSettings" ref="projectSettings" />
<property name="publicationService" ref="publicationService" />
+ <property name="repositoryService" ref="repositoryService" />
</bean>
<bean id="versionDocumentAction"
<property name="projectSettings" ref="projectSettings" />
<property name="publicationService" ref="publicationService" />
<property name="stepService" ref="stepService" />
+ <property name="repositoryService" ref="repositoryService" />
</bean>
<bean id="databaseIndexingAction"
<bean id="importUserAction"
class="org.splat.simer.admin.ImportUserAction" scope="prototype">
+ <property name="repositoryService" ref="repositoryService" />
</bean>
<bean id="simulationContextAction"
ref="knowledgeElementService" />
<property name="searchService" ref="searchService" />
<property name="projectSettings" ref="projectSettings" />
+ <property name="simulationContextService"
+ ref="simulationContextService" />
</bean>
<bean id="knowledgeElementAction"
<bean id="saveDocumentAction"
class="org.splat.module.SaveDocumentAction" scope="prototype">
<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" />
</bean>
</beans>