LCK-000001=Lock reference already exists for user {2}.
LCK-000002=Lock reference does not exists.
LCK-000003=Lock reference protected and can be only deleted or updated by user {2}.
-LCK-000004=Lock reference is timeout and could have been modified by user {2}.
\ No newline at end of file
+LCK-000004=Lock reference is timeout and could have been modified by user {2}.
+STD-000001="Unable to re-index the study #{1}, reason: {2}"
\ No newline at end of file
import org.splat.kernel.ObjectProperties;
/**
- * Base implementation of the API Design Pattern of objects which persistence is based on Hibernate.<br/>
- * This Design Pattern supports the following features:
+ * Base implementation of the API Design Pattern of objects which persistence is based on Hibernate.<br/> This Design Pattern supports the
+ * following features:
* <ul>
* <li>Flexible API for constructing objects from many variable arguments</li>
* <li>Impossible to leave persistent objects in inconsistent state, even temporarily, during their construction</li>
* <li>Same Object Oriented API for constructing and selecting objects from the database</li>
* <li>Centralized validity check of arguments</li>
* </ul>
- * The API is based on intermediate properties objects used for collecting arguments and checking their validity.
- * These properties objects are passed to persistent object constructors and database select functions for execution.
- * For example, as based on this Design Pattern, a User object could be created that way:
+ * The API is based on intermediate properties objects used for collecting arguments and checking their validity. These properties objects
+ * are passed to persistent object constructors and database select functions for execution. For example, as based on this Design Pattern, a
+ * User object could be created that way:
+ *
* <pre>
- * User.Properties args = new User.Properties();
- * User user = new User( args.setUsername("mypseudo").setMailAddress("me@provider.domain") );
+ * User.Properties args = new User.Properties();
+ * User user = new User(args.setUsername("mypseudo").setMailAddress(
+ * "me@provider.domain"));
* </pre>
- * Classes implementing this Design Pattern must inherit from Persistent and implement their Properties class as a nested
- * subclass of Persistent.Properties.<br/>
- * <br/>
- * Naturally, as usual with Hibernate, any class can be persistent (you don't need to inherit from Persistent for being
- * persistent). Inheriting from Persistent is only a matter of enabling the API supported by the above Design Pattern.
+ *
+ * Classes implementing this Design Pattern must inherit from Persistent and implement their Properties class as a nested subclass of
+ * Persistent.Properties.<br/> <br/> Naturally, as usual with Hibernate, any class can be persistent (you don't need to inherit from
+ * Persistent for being persistent). Inheriting from Persistent is only a matter of enabling the API supported by the above Design Pattern.
*
* @see ObjectProperties
* @see Persistent.Properties
- * @author Daniel Brunier-Coulin
+ * @author Daniel Brunier-Coulin
* @copyright OPEN CASCADE 2012
*/
-
public abstract class Persistent {
- private long rid; // Primary key of persistent objects
-
- protected abstract static class Properties implements ObjectProperties {
-// ----------------------------------------------------------------------
- private boolean tobechecked = true; // Property validity check flag
-
- public void disableCheck () {
- tobechecked = false;
- }
- public boolean mustBeChecked () {
- return tobechecked;
- }
- public void clear () {
- tobechecked = true;
- }
- }
-
-// ==============================================================================================================================
-// Constructors
-// ==============================================================================================================================
-/**
- * Database fetch constructor.
- */
- protected Persistent () {
-// -----------------------
- rid = 0; // Set when loading the object
- }
+ private long rid; // Primary key of persistent objects
+
+ protected abstract static class Properties implements ObjectProperties {
+ private long rid; // Primary key of persistent objects
+
+ private boolean tobechecked = true; // Property validity check flag
+
+ public void disableCheck() {
+ tobechecked = false;
+ }
+
+ public boolean mustBeChecked() {
+ return tobechecked;
+ }
+
+ public void clear() {
+ tobechecked = true;
+ }
+
+ /**
+ * Get the rid.
+ *
+ * @return the rid
+ */
+ public long getIndex() {
+ return rid;
+ }
+
+ /**
+ * Set the rid.
+ *
+ * @param rid
+ * the rid to set
+ */
+ public void setIndex(long rid) {
+ this.rid = rid;
+ }
+ }
-/**
- * Checks the mutual compatibility of arguments previously set in the given properties object, if the validity check is enabled.
- * As this validity depends on concrete classes, the check is delegated to subclasses of the given Persistent.Properties.
- */
- protected Persistent (ObjectProperties oprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
-// ---------------------------------------------
- if (oprop.mustBeChecked()) oprop.checkValidity(); // Throws one of the above exception if not valid
- rid = 0; // Set when saving the object
- }
-
-// ==============================================================================================================================
-// Public member functions
-// ==============================================================================================================================
-
- public boolean equals(Object entity) {
-// ------------------------------------
- if (entity == null) return false;
- if (entity.getClass().equals(this.getClass())) {
- Persistent object = (Persistent)entity;
- long he = object.getIndex(); // getIndex() is supposed fetching the index if not yet done
- long me = this.getIndex(); // getIndex() is supposed fetching the index if not yet done
- if (me*he != 0) return (he == me);
- if (me+he == 0) return (this == object);
- }
- return false;
- }
+ // ==============================================================================================================================
+ // Constructors
+ // ==============================================================================================================================
+ /**
+ * Database fetch constructor.
+ */
+ protected Persistent() {
+ // -----------------------
+ rid = 0; // Set when loading the object
+ }
-/**
- * Returns the Persistent ID of this object. The PID is set when saving this object. It is unique in the scope of the class
- * of this object only.
- *
- * @return the PID of this, or 0 if this is not saved.
- * @see isSaved()
- */
- public long getIndex () {
-// ----------------------
- return rid;
- }
+ /**
+ * Checks the mutual compatibility of arguments previously set in the given properties object, if the validity check is enabled. As this
+ * validity depends on concrete classes, the check is delegated to subclasses of the given Persistent.Properties.
+ */
+ protected Persistent(ObjectProperties oprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException {
+ // ---------------------------------------------
+ if (oprop.mustBeChecked())
+ oprop.checkValidity(); // Throws one of the above exception if not valid
+ rid = 0; // Set when saving the object
+ }
+
+ // ==============================================================================================================================
+ // Public member functions
+ // ==============================================================================================================================
+
+ public boolean equals(Object entity) {
+ // ------------------------------------
+ if (entity == null)
+ return false;
+ if (entity.getClass().equals(this.getClass())) {
+ Persistent object = (Persistent) entity;
+ long he = object.getIndex(); // getIndex() is supposed fetching the index if not yet done
+ long me = this.getIndex(); // getIndex() is supposed fetching the index if not yet done
+ if (me * he != 0)
+ return (he == me);
+ if (me + he == 0)
+ return (this == object);
+ }
+ return false;
+ }
+
+ /**
+ * Returns the Persistent ID of this object. The PID is set when saving this object. It is unique in the scope of the class of this
+ * object only.
+ *
+ * @return the PID of this, or 0 if this is not saved.
+ * @see isSaved()
+ */
+ public long getIndex() {
+ // ----------------------
+ return rid;
+ }
/**
* Set an id for the object.
- * @param anId id to set
+ *
+ * @param anId
+ * id to set
*/
public void setIndex(long anId) {
rid = anId;
}
-
- public int hashCode () {
-// ----------------------
- return toString().hashCode();
- }
-/**
- * Returns true if this object is saved.
- *
- * @return true if this is saved.
- * @see getIndex()
- */
- public boolean isSaved () {
-// -------------------------
- return (getIndex() != 0); // getIndex() is supposed fetching the index if not yet done
- }
+ public int hashCode() {
+ // ----------------------
+ return toString().hashCode();
+ }
-/**
- * Return a string representing uniquely this object.
- *
- * @return the unique string representation of this object.
- */
- public String toString () {
-// -------------------------
- long oid = getIndex(); // getIndex() is supposed fetching the index if not yet done
- if (oid == 0) oid = super.hashCode(); //WARNING: Must not call super.toString() as it goes back here (this.toString())
- return new StringBuffer("object ").append(getClass().getName()).append("@").append(oid).toString();
- }
+ /**
+ * Returns true if this object is saved.
+ *
+ * @return true if this is saved.
+ * @see getIndex()
+ */
+ public boolean isSaved() {
+ // -------------------------
+ return (getIndex() != 0); // getIndex() is supposed fetching the index if not yet done
+ }
-/**
- * Get the rid.
- * @return the rid
- */
-public long getRid() {
- return rid;
-}
+ /**
+ * Return a string representing uniquely this object.
+ *
+ * @return the unique string representation of this object.
+ */
+ public String toString() {
+ // -------------------------
+ long oid = getIndex(); // getIndex() is supposed fetching the index if not yet done
+ if (oid == 0)
+ oid = super.hashCode(); // WARNING: Must not call super.toString() as it goes back here (this.toString())
+ return new StringBuffer("object ").append(getClass().getName()).append(
+ "@").append(oid).toString();
+ }
-/**
- * Set the rid.
- * @param rid the rid to set
- */
-public void setRid(long rid) {
- this.rid = rid;
-}
+ /**
+ * 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
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.Scenario;
+import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.Study;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
*/
public interface ScenarioService {
+ /**
+ * Create a new study with one scenario and "product" simulation context.
+ *
+ * @param sprop
+ * the study properties
+ * @param oprop
+ * the scenario properties
+ * @param cprop
+ * the "product" simulation context properties
+ * @return the created study
+ * @throws MissedPropertyException
+ * if a mandatory property is missed
+ * @throws InvalidPropertyException
+ * if a property is invalid
+ * @throws MultiplyDefinedException
+ * if some property occurs several times
+ */
+ public Study createStudy(Study.Properties sprop, Scenario.Properties oprop,
+ SimulationContext.Properties cprop) throws MissedPropertyException,
+ InvalidPropertyException, MultiplyDefinedException;
+
/**
* Add a new scenario to the study.
*
*/
private KnowledgeElementTypeDAO _knowledgeElementTypeDAO;
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
+
/**
* Get the projectElementService.
*
_stepService = stepService;
}
+ /**
+ * Create a new study with one scenario and "product" simulation context.
+ *
+ * @param sprop
+ * the study properties
+ * @param oprop
+ * the scenario properties
+ * @param cprop
+ * the "product" simulation context properties
+ * @return the created study
+ * @throws MissedPropertyException
+ * if a mandatory property is missed
+ * @throws InvalidPropertyException
+ * if a property is invalid
+ * @throws MultiplyDefinedException
+ * if some property occurs several times
+ */
+ @Transactional
+ public Study createStudy(Study.Properties sprop, Scenario.Properties oprop,
+ SimulationContext.Properties cprop) throws MissedPropertyException,
+ InvalidPropertyException, MultiplyDefinedException {
+ Study study = getStudyService().createStudy(sprop);
+ addScenario(study, oprop);
+ if (cprop.getIndex() == 0) { // Input of new project context
+ cprop.setType(getSimulationContextService().selectType("product"))
+ .setValue(cprop.getValue());
+ getStudyService().addProjectContext(study, cprop);
+ } else { // Selection of existing project context
+ SimulationContext context = getSimulationContextService()
+ .selectSimulationContext(cprop.getIndex());
+ getStudyService().addProjectContext(study, context);
+ }
+ return study;
+ }
+
/**
* {@inheritDoc}
*
// Get the persistent scenario.
Scenario aScenario = getScenarioDAO().get(aScenarioId);
// Get persistent objects for creating a new knowledge.
- //TODO: Actions must use DTO instead of persistent objects.
+ // TODO: Actions must use DTO instead of persistent objects.
getUserDAO().merge(kprop.getAuthor());
getKnowledgeElementTypeDAO().merge(kprop.getType());
// Create a transient knowledge element related to the given scenario.
_knowledgeElementTypeDAO = knowledgeElementTypeDAO;
}
+ /**
+ * 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;
+ }
+
}
*
* @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext.Properties)
*/
+ @Transactional
public SimulationContext addProjectContext(Study aStudy,
SimulationContext.Properties cprop) throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException {
*
* @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext)
*/
+ @Transactional
public SimulationContext addProjectContext(Study aStudy,
SimulationContext context) {
SimulationContext added = getStepService().addSimulationContext(
setShortCuts(aStudy); // RKV: initialize transient actors set
getIndex().update(aStudy); // Update of Lucene index
isOk = true;
- } catch (Exception error) {
- logger.error("Unable to re-index the study '" + aStudy.getIndex()
- + "', reason:", error);
+ } catch (Exception e) {
+ logger.error("STD-000001", e, aStudy.getIndex(), e.getMessage());
}
return isOk;
}
if (i == format.length)
break;
}
- DecimalFormat tostring = new DecimalFormat(
- pattern.substring(n, i));
+ DecimalFormat tostring = new DecimalFormat(pattern
+ .substring(n, i));
String number = tostring.format(next);
for (int j = 0; j < number.length(); j++) {
ref[count] = number.charAt(j);
if (actype[i] == Actor.manager) {
actor = from.getAuthor();
} else if (actype[i] == Actor.Nx1) {
- List<User> manager = getUserService()
- .selectUsersWhere(uprop
- .setOrganizationName("Nx1"));
+ List<User> manager = getUserService().selectUsersWhere(
+ uprop.setOrganizationName("Nx1"));
if (manager.size() == 1)
actor = manager.get(0);
} else if (actype[i] == Actor.Nx2) {
- List<User> manager = getUserService()
- .selectUsersWhere(uprop
- .setOrganizationName("Nx2"));
+ List<User> manager = getUserService().selectUsersWhere(
+ uprop.setOrganizationName("Nx2"));
if (manager.size() == 1)
actor = manager.get(0);
} else { /* Actor.customer */
/**
* Get the userService.
+ *
* @return the userService
*/
public UserService getUserService() {
/**
* Set the userService.
- * @param userService the userService to set
+ *
+ * @param userService
+ * the userService to set
*/
public void setUserService(UserService userService) {
_userService = userService;
<property name="userDAO" ref="userDAO" />
<property name="knowledgeElementTypeDAO"
ref="knowledgeElementTypeDAO" />
+ <property name="simulationContextService"
+ ref="simulationContextService" />
</bean>
<bean id="searchService"
* Injected knowledge element type service.
*/
private KnowledgeElementTypeService _knowledgeElementTypeService;
-
+
/**
- * Value of the menu property.
- * It can be: none, create, open, study, knowledge, sysadmin, help.
+ * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
*/
private String _menuProperty;
*/
public String doInitialize() {
mystudy = getOpenStudy();
-
+
setMenuProperty("study");
initializationScreenContext(_menuProperty);
-
+
return SUCCESS;
}
* @return SUCCESS if operation succeeded, ERROR if Runtime exception, otherwise INPUT
*/
public String doSetKnowledge() {
-
+
setMenuProperty("study");
initializationScreenContext(_menuProperty);
-
+
try {
User user = getConnectedUser();
mystudy = getOpenStudy();
mystudy.remove(kelm);
getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of last removed document
-
+
setMenuProperty("study");
initializationScreenContext(_menuProperty);
/**
* Get the knowledgeElementTypeService.
+ *
* @return the knowledgeElementTypeService
*/
public KnowledgeElementTypeService getKnowledgeElementTypeService() {
/**
* Set the knowledgeElementTypeService.
- * @param knowledgeElementTypeService the knowledgeElementTypeService to set
+ *
+ * @param knowledgeElementTypeService
+ * the knowledgeElementTypeService to set
*/
public void setKnowledgeElementTypeService(
KnowledgeElementTypeService knowledgeElementTypeService) {
_knowledgeElementTypeService = knowledgeElementTypeService;
}
-
+
/**
* Get the menuProperty.
+ *
* @return the menuProperty
*/
public String getMenuProperty() {
/**
* Set the menuProperty.
- * @param menuProperty the menuProperty to set
+ *
+ * @param menuProperty
+ * the menuProperty to set
*/
public void setMenuProperty(String menuProperty) {
this._menuProperty = menuProperty;
import org.splat.service.SimulationContextService;
import org.splat.service.StudyService;
+/**
+ * Action for creation of a new study.
+ */
public class NewStudyAction extends Action {
- private String title = null;
- private List<SimulationContext> contelm = null;
- private String context = null;
-
- private static int number = 0;
/**
* Serial version ID.
*/
private static final long serialVersionUID = 693943641800113782L;
+ /**
+ * Sequential number of the new study for appending to its default title.
+ */
+ private static int number = 0;
+
+ /**
+ * Title of the new study.
+ */
+ private String title = null;
+ /**
+ * List of available project contexts for selection for the new study.
+ */
+ private List<SimulationContext> contelm = null;
+ /**
+ * Project context.
+ */
+ private String context = null;
/**
* The injected Study service.
*/
private StudyService _studyService;
+ /**
+ * Injected simulation context service.
+ */
private SimulationContextService _simulationContextService;
/**
* Injected scenario service.
*/
private ScenarioService _scenarioService;
-
+
/**
- * Value of the menu property.
- * It can be: none, create, open, study, knowledge, sysadmin, help.
+ * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
*/
private String _menuProperty;
// Action methods
// ==============================================================================================================================
- // Fill the values of the drop-down list.
+ /**
+ * Fill the values of the drop-down list, and initialize a menu.
+ *
+ * @return SUCCESS
+ */
public String doInitialize() {
// get the list of the simulation contexts of the study
ApplicationSettings.getCurrentLocale());
title = locale.getString("label.study") + " "
+ String.valueOf(number + 1);
-
+
setMenuProperty("create");
initializationScreenContext(_menuProperty);
return SUCCESS;
}
+ /**
+ * Create a new study.
+ *
+ * @return SUCCESS if the new study is created, INPUT if project context is not defined, ERROR if failed
+ * @throws Exception
+ * if properties of the new study are invalid
+ */
public String doCreate() throws Exception {
String[] input = context.split(",");
int valid = Integer.valueOf(input[0]);
Study.Properties sprop = new Study.Properties();
// Check arguments and creation of the study
- try {
- if (valid == -1)
- throw new Exception();
- if (valid == 0) {
- value = input[1].trim();
- if (value.length() == 0) {
-
- setMenuProperty("create");
- initializationScreenContext(_menuProperty);
-
- return INPUT; // No need to reinitialize the list of existing products
- }
- }
- sprop.setTitle(title).setManager(getConnectedUser());
- sprop.checkValidity();
- sprop.disableCheck();
- } catch (Exception error) {
+ if (valid == -1) {
SimulationContext.Properties cprop = new SimulationContext.Properties();
SimulationContextType product = getSimulationContextService()
.selectType("product");
contelm = getSimulationContextService()
.selectSimulationContextsWhere(cprop.setType(product));
-
- setMenuProperty("create");
- initializationScreenContext(_menuProperty);
-
return INPUT; // Title empty, simply wait for input without error message
}
+ if (valid == 0) {
+ value = input[1].trim();
+ if (value.length() == 0) {
+ setMenuProperty("create");
+ initializationScreenContext(_menuProperty);
+ return INPUT; // No need to reinitialize the list of existing products
+ }
+ }
+ sprop.setTitle(title).setManager(getConnectedUser());
+ sprop.checkValidity();
+ sprop.disableCheck();
try {
- Study study = getStudyService().createStudy(sprop);
-
// Addition of a default scenario
ResourceBundle locale = ResourceBundle.getBundle("labels",
ApplicationSettings.getCurrentLocale());
Scenario.Properties oprop = new Scenario.Properties();
oprop.setTitle(locale.getString("label.scenario") + " 1");
- getScenarioService().addScenario(study, oprop);
// Addition of the entered project context
+ SimulationContext.Properties cprop = new SimulationContext.Properties();
if (valid == 0) { // Input of new project context
- SimulationContext.Properties cprop = new SimulationContext.Properties();
cprop.setType(
getSimulationContextService().selectType("product"))
.setValue(value);
- getStudyService().addProjectContext(study, cprop);
} else { // Selection of existing project context
- SimulationContext context = getSimulationContextService()
- .selectSimulationContext(valid);
- getStudyService().addProjectContext(study, context);
+ cprop.setIndex(valid);
}
+ Study study = getScenarioService().createStudy(sprop, oprop, cprop);
// Update of the session
number += 1;
open(study); // Opens the study,
-
+
setMenuProperty("study");
initializationScreenContext(_menuProperty);
-
+
return SUCCESS;
} catch (Exception error) {
logger.error("Unable to save the study, reason:", error);
/**
* Get the scenarioService.
+ *
* @return the scenarioService
*/
public ScenarioService getScenarioService() {
/**
* Set the scenarioService.
- * @param scenarioService the scenarioService to set
+ *
+ * @param scenarioService
+ * the scenarioService to set
*/
public void setScenarioService(ScenarioService scenarioService) {
_scenarioService = scenarioService;
}
-
+
/**
* Get the menuProperty.
+ *
* @return the menuProperty
*/
public String getMenuProperty() {
/**
* Set the menuProperty.
- * @param menuProperty the menuProperty to set
+ *
+ * @param menuProperty
+ * the menuProperty to set
*/
public void setMenuProperty(String menuProperty) {
this._menuProperty = menuProperty;