*
* @see org.splat.service.DocumentService#generateDocumentId(org.splat.dal.bo.som.Document, org.splat.dal.bo.som.Document.Properties)
*/
+ @Transactional
public void generateDocumentId(Document aDoc, Properties dprop) {
Study owner = null;
if (dprop.getOwner() instanceof Study)
package org.splat.service;
import java.util.List;
+import java.util.Vector;
+import org.splat.dal.bo.som.ProgressState;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
import org.splat.kernel.InvalidPropertyException;
+import org.splat.service.dto.SimulationContextFacade;
import org.splat.service.technical.ProjectSettingsService;
/**
*/
public interface SimulationContextService {
+ /**
+ * Get simulation contexts which are currently in the given state.
+ *
+ * @param aState
+ * the progress state to filter contexts
+ * @return the list of found contexts as a vector of SimulationContextFacade
+ * @throws InvalidPropertyException
+ * if the given state is invalid
+ */
+ public Vector<SimulationContextFacade> getSimulationContextsInState(
+ ProgressState aState) throws InvalidPropertyException;
+
/**
* Get simulation context by its id.
*
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.
*
*/
List<SimulationContext> getSimulationContextList();
- /**
- * Approve the simulation context type.
- *
- * @param simCtxType
- * the type to approve
- * @return true if approval succeeded
- */
- public boolean approve(SimulationContextType simCtxType);
-
/**
* @param simCtxType
* @return
package org.splat.service;
+import java.util.Iterator;
import java.util.List;
+import java.util.Vector;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import org.splat.dal.dao.som.SimulationContextTypeDAO;
import org.splat.kernel.InvalidPropertyException;
import org.splat.log.AppLogger;
+import org.splat.service.dto.SimulationContextFacade;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.service.technical.ProjectSettingsServiceImpl;
import org.springframework.transaction.annotation.Transactional;
* Injected simulation context type DAO.
*/
private SimulationContextTypeDAO _simulationContextTypeDAO;
+ /**
+ * Injected project settings service.
+ */
+ private ProjectSettingsService _projectSettingsService;
+
+ /**
+ * Get simulation contexts which are currently in the given state.
+ *
+ * @param aState
+ * the progress state to filter contexts
+ * @return the list of found contexts as a vector of SimulationContextFacade
+ * @throws InvalidPropertyException
+ * if the given state is invalid
+ */
+ @Transactional(readOnly=true)
+ public Vector<SimulationContextFacade> getSimulationContextsInState(
+ ProgressState aState) throws InvalidPropertyException {
+ SimulationContext.Properties cprop = new SimulationContext.Properties();
+ List<SimulationContext> context = selectSimulationContextsWhere(cprop
+ .setState(aState));
+
+ Vector<SimulationContextFacade> result = new Vector<SimulationContextFacade>(
+ context.size());
+ for (Iterator<SimulationContext> i = context.iterator(); i.hasNext();) {
+ result.add(new SimulationContextFacade(i.next(),
+ getProjectSettings().getAllSteps()));
+ }
+ return result;
+ }
/**
* {@inheritDoc}
// .append("'");
// separator = " and";
- aCondition = Restrictions.and(aCondition,
- Restrictions.eq("value", value));
+ aCondition = Restrictions.and(aCondition, Restrictions.eq("value",
+ value));
}
if (state != null) {
// query = query.append(separator).append(" state='").append(state)
// order = " order by type asc";
anOrder = Order.asc("type");
}
- aCondition = Restrictions.and(aCondition,
- Restrictions.eq("state", state));
+ aCondition = Restrictions.and(aCondition, Restrictions.eq("state",
+ state));
}
// query.append(order);
// return (List<SimulationContext>) Database.getSession().createQuery(
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}
*
// query = query.append(" order by step asc");
Criterion aCondition = Restrictions.eq("step", step[0].getNumber());
for (int i = 1; i < step.length; i++) { // Useless to order as the result mixes localized and non localized types
- aCondition = Restrictions.or(aCondition,
- Restrictions.eq("step", step[i].getNumber()));
+ aCondition = Restrictions.or(aCondition, Restrictions.eq("step",
+ step[i].getNumber()));
}
return getSimulationContextTypeDAO().getFilteredList(aCondition,
Order.asc("step"));
anOrder = Order.desc("state"); // APPROVED (upper case A) is grater than inCHECK (lower case i)
}
if (state != null) {
- aCondition = Restrictions.and(aCondition,
- Restrictions.eq("state", state));
+ aCondition = Restrictions.and(aCondition, Restrictions.eq("state",
+ state));
if (step != null) {
if (state != ProgressState.APPROVED) {
anOrder = Order.asc("name");
return true;
}
- /**
- * Approve the simulation context type.
- *
- * @param simCtxType
- * the type to approve
- * @return true if approval succeeded
- */
- public boolean approve(SimulationContextType simCtxType) {
- if (simCtxType.getState() != ProgressState.inCHECK)
- return false;
- simCtxType.setState(ProgressState.APPROVED); // The type name is supposed being localized
- getSimulationContextTypeDAO().update(simCtxType);
- return true;
- }
-
/**
* @param simCtxType
* @return
SimulationContextTypeDAO simulationContextTypeDAO) {
_simulationContextTypeDAO = simulationContextTypeDAO;
}
+
+ /**
+ * Get project settings.
+ *
+ * @return Project settings service
+ */
+ private ProjectSettingsService getProjectSettings() {
+ return _projectSettingsService;
+ }
+
+ /**
+ * Set project settings service.
+ *
+ * @param projectSettingsService
+ * project settings service
+ */
+ public void setProjectSettings(ProjectSettingsService projectSettingsService) {
+ _projectSettingsService = projectSettingsService;
+ }
}
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 22.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service;
+
+import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.service.technical.ProjectSettingsService;
+
+/**
+ * Simulation context type service interface.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public interface SimulationContextTypeService {
+
+ /**
+ * 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;
+
+ /**
+ * Approve the simulation context type.
+ *
+ * @param simCtxType
+ * the type to approve
+ * @return true if approval succeeded
+ */
+ public boolean approve(SimulationContextType simCtxType);
+
+}
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 22.10.2012
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service;
+
+import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.dal.dao.som.SimulationContextTypeDAO;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.service.technical.ProjectSettingsService;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Simulation context type service implementation.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class SimulationContextTypeServiceImpl implements
+ SimulationContextTypeService {
+
+ /**
+ * Injected simulation context type DAO.
+ */
+ private SimulationContextTypeDAO _simulationContextTypeDAO;
+
+ /**
+ * {@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;
+ }
+
+ /**
+ * Approve the simulation context type.
+ *
+ * @param simCtxType
+ * the type to approve
+ * @return true if approval succeeded
+ */
+ public boolean approve(SimulationContextType simCtxType) {
+ if (simCtxType.getState() != ProgressState.inCHECK)
+ return false;
+ simCtxType.setState(ProgressState.APPROVED); // The type name is supposed being localized
+ getSimulationContextTypeDAO().update(simCtxType);
+ return true;
+ }
+
+ /**
+ * 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;
+ }
+
+}
--- /dev/null
+package org.splat.service.dto;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.splat.service.technical.ProjectSettingsService;
+import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.SimulationContext;
+import org.splat.dal.bo.som.SimulationContextType;
+
+public class SimulationContextFacade {
+
+ private SimulationContext my;
+ private String name;
+ private int at;
+ private ProgressState state;
+
+ // ==============================================================================================================================
+ // Constructor
+ // ==============================================================================================================================
+
+ public SimulationContextFacade(SimulationContext represented,
+ List<ProjectSettingsService.Step> steps) {
+ // --------------------------------------------------------------
+ SimulationContextType mytype;
+
+ my = represented;
+ mytype = my.getType();
+ for (Iterator<ProjectSettingsService.Step> i = steps.iterator(); i
+ .hasNext();) {
+ ProjectSettingsService.Step step = i.next();
+ if (!mytype.isAttachedTo(step))
+ continue;
+ at = step.getNumber(); // There is no direct service for getting the step number
+ break;
+ }
+ name = my.getType().getName();
+ if (mytype.isApproved()) {
+ state = ProgressState.inCHECK;
+ // RKV: TODO: Do translation in presentation layer by struts tools: name = ResourceBundle.getBundle("som",
+ // ApplicationSettings.getCurrentLocale()).getString("type.context." + name);
+ } else {
+ state = ProgressState.inDRAFT;
+ }
+ }
+
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
+
+ public String getEditIcon() {
+ // ----------------------------
+ StringBuffer result = new StringBuffer("icon.ed").append(state).append(
+ ".png");
+ return result.toString();
+ }
+
+ public String getIndex() {
+ // -------------------------
+ return String.valueOf(my.getIndex());
+ }
+
+ public int getStepNumber() {
+ // ---------------------------
+ return at;
+ }
+
+ public String getTypeName() {
+ // ----------------------------
+ return name;
+ }
+
+ public String getValue() {
+ // -------------------------
+ return my.getValue();
+ }
+}
\ No newline at end of file
import org.splat.manox.XDOM;
import org.splat.service.DocumentTypeService;
import org.splat.service.KnowledgeElementTypeService;
-import org.splat.service.SimulationContextService;
+import org.splat.service.SimulationContextTypeService;
public class ProjectSettingsServiceImpl implements ProjectSettingsService {
private static ProjectSettingsServiceImpl my = null; // Singleton instance
private Database _database;
/**
- * Injected simulation context service.
+ * Injected simulation context type service.
*/
- private SimulationContextService _simulationContextService;
+ private SimulationContextTypeService _simulationContextTypeService;
/**
* Injected knowledge element type service.
*/
+ "\" classification. Simulation Context type ignored.");
continue;
}
- tctex = getSimulationContextService().createType(type,
+ tctex = getSimulationContextTypeService().createType(type,
mapstep.get(type)); // Creation of Simulation Context Types
- getSimulationContextService().approve(tctex);
+ getSimulationContextTypeService().approve(tctex);
}
} catch (Exception error) {
logger.warn("Error creating context types, reason:", error); // Should not happen
}
/**
- * Get the simulationContextService.
+ * Get the simulationContextTypeService.
*
- * @return the simulationContextService
+ * @return the simulationContextTypeService
*/
- public SimulationContextService getSimulationContextService() {
- return _simulationContextService;
+ public SimulationContextTypeService getSimulationContextTypeService() {
+ return _simulationContextTypeService;
}
/**
- * Set the simulationContextService.
+ * Set the simulationContextTypeService.
*
- * @param simulationContextService
- * the simulationContextService to set
+ * @param simulationContextTypeService
+ * the simulationContextTypeService to set
*/
- public void setSimulationContextService(
- SimulationContextService simulationContextService) {
- _simulationContextService = simulationContextService;
+ public void setSimulationContextTypeService(
+ SimulationContextTypeService simulationContextTypeService) {
+ _simulationContextTypeService = simulationContextTypeService;
}
/**
<property name="projectElementDAO" ref="projectElementDAO" />
</bean>
- <bean id="simulationContextService"
- class="org.splat.service.SimulationContextServiceImpl">
- <property name="simulationContextDAO"
- ref="simulationContextDAO" />
- <property name="simulationContextTypeDAO"
- ref="simulationContextTypeDAO" />
- </bean>
+ <bean id="simulationContextService"
+ class="org.splat.service.SimulationContextServiceImpl">
+ <property name="simulationContextDAO"
+ ref="simulationContextDAO" />
+ <property name="simulationContextTypeDAO"
+ ref="simulationContextTypeDAO" />
+ </bean>
+
+ <bean id="simulationContextTypeService"
+ class="org.splat.service.SimulationContextTypeServiceImpl">
+ <property name="simulationContextTypeDAO"
+ ref="simulationContextTypeDAO" />
+ </bean>
<bean id="studyService"
class="org.splat.service.StudyServiceImpl">
<bean id="projectSettings"
class="org.splat.service.technical.ProjectSettingsServiceImpl">
<property name="database" ref="database" />
- <property name="simulationContextService"
- ref="simulationContextService" />
+ <property name="simulationContextTypeService"
+ ref="simulationContextTypeService" />
<property name="documentTypeService" ref="documentTypeService" />
<property name="knowledgeElementTypeService"
ref="knowledgeElementTypeService" />
import org.splat.dal.bo.som.ProgressState;
import org.splat.service.DocumentTypeService;
import org.splat.service.technical.ProjectSettingsService;
+import org.splat.simer.Converter;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.som.Step;
import org.splat.som.StudyRights;
import org.splat.service.SimulationContextService;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.service.dto.Proxy;
+import org.splat.service.dto.SimulationContextFacade;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
import org.splat.dal.bo.som.Study;
// Action methods
// ==============================================================================================================================
+ /**
+ * Initialize the simulation context list.
+ * @return SUCCESS if succeeded, otherwise - ERROR
+ */
public String doInitialize() {
- // -----------------------------
- Session connex = Database.getCurSession();
- 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()));
- }
+ tocheck = getSimulationContextService()
+ .getSimulationContextsInState(ProgressState.inCHECK);
selection = 0;
edition = null;
owner = null;
- transax.commit();
return SUCCESS;
} catch (Exception error) {
logger.error("Reason:", error);
kprop.setSimulationContexts(selected).setState(
ProgressState.inWORK));
- step = getSimulationContextService().getAttachedStep(edition.getType());
+ step = getSimulationContextService().getAttachedStep(
+ edition.getType());
owner = new HashSet<ProjectElementFacade>();
for (Iterator<Proxy> i = kelm.iterator(); i.hasNext();) {
KnowledgeElement next = getKnowledgeElementService()
}
SimulationContextType.Properties sprop = new SimulationContextType.Properties();
List<SimulationContextType> types = getSimulationContextService()
- .selectTypesWhere(sprop.setProgressState(ProgressState.APPROVED));
+ .selectTypesWhere(
+ sprop.setProgressState(ProgressState.APPROVED));
Locale[] support = ApplicationSettings.getSupportedLocales();
// Sort localized type names
/**
* Get the searchService.
+ *
* @return the searchService
*/
public SearchService getSearchService() {
/**
* Set the searchService.
- * @param searchService the searchService to set
+ *
+ * @param searchService
+ * the searchService to set
*/
public void setSearchService(SearchService searchService) {
_searchService = searchService;
+++ /dev/null
-package org.splat.simer.admin;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.splat.service.technical.ProjectSettingsService;
-import org.splat.simer.ApplicationSettings;
-import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.bo.som.SimulationContext;
-import org.splat.dal.bo.som.SimulationContextType;
-
-
-public class SimulationContextFacade {
-
- private SimulationContext my;
- private String name;
- private int at;
- private ProgressState state;
-
-// ==============================================================================================================================
-// Constructor
-// ==============================================================================================================================
-
- public SimulationContextFacade (SimulationContext represented, List<ProjectSettingsService.Step> steps) {
-// --------------------------------------------------------------
- SimulationContextType mytype;
-
- my = represented;
- mytype = my.getType();
- for (Iterator<ProjectSettingsService.Step> i=steps.iterator(); i.hasNext(); ) {
- ProjectSettingsService.Step step = i.next();
- if (!mytype.isAttachedTo(step)) continue;
- at = step.getNumber(); // There is no direct service for getting the step number
- break;
- }
- name = my.getType().getName();
- if (mytype.isApproved()) {
- state = ProgressState.inCHECK;
- name = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale()).getString("type.context." + name);
- } else {
- state = ProgressState.inDRAFT;
- }
- }
-
-// ==============================================================================================================================
-// Getters
-// ==============================================================================================================================
-
- public String getEditIcon () {
-// ----------------------------
- StringBuffer result = new StringBuffer("icon.ed").append(state).append(".png");
- return result.toString();
- }
- public String getIndex () {
-// -------------------------
- return String.valueOf(my.getIndex());
- }
- public int getStepNumber () {
-// ---------------------------
- return at;
- }
- public String getTypeName () {
-// ----------------------------
- return name;
- }
- public String getValue () {
-// -------------------------
- return my.getValue();
- }
-}
\ No newline at end of file