/*****************************************************************************
* Company EURIWARE
* Application SIMAN
- * File $Id$
- * Creation date 06.10.2012
- * @author $Author$
- * @version $Revision$
+ * File Id:
+ * Creation date 02.10.2012
+ * @author Author: Maria KRUCHININA
+ * @version Revision:
*****************************************************************************/
package org.splat.service;
import org.apache.log4j.Logger;
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.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
import org.splat.kernel.UserDirectory;
+import org.splat.log.AppLogger;
import org.splat.service.technical.IndexService;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.som.Revision;
/**
- * @author RKV
- *
+ * This class defines all methods for creation, modification the study.
+ * @author Maria KRUCHININA
+ *
*/
public class StudyServiceImpl implements StudyService {
- public final static Logger logger = Logger.getLogger(org.splat.service.StudyServiceImpl.class);
+ /**
+ * logger for the service.
+ */
+ public final static AppLogger logger = AppLogger.getLogger(StudyServiceImpl.class);
private IndexService _indexService;
private ProjectSettingsService _projectSettingsService;
private ProjectElementService _projectElementService;
+
+ /**
+ * Get the simulation context list for displaying drop-down list values populating
+ * on the "Create new study" screen.
+ * {@inheritDoc}
+ * @see org.splat.service.StudyService#getSimulationContextList()
+ */
+ 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;
+ }
+
+ public Study selectStudy(int index) {
+ // -------------------------------------------
+ StringBuffer query = new StringBuffer("from Study where rid='").append(
+ index).append("'");
+ Study result = (Study) Database.getSession().createQuery(
+ query.toString()).uniqueResult();
+
+ result.loadWorkflow();
+ return result;
+ }
+
+ public Study selectStudy(String refid) {
+ // ----------------------------------------------
+ StringBuffer query = new StringBuffer("from Study where sid='").append(
+ refid).append("'");
+ Study result = (Study) Database.getSession().createQuery(
+ query.toString()).uniqueResult();
+
+ result.loadWorkflow();
+ return result;
+ }
public Study createStudy(Study.Properties sprop)
throws MissedPropertyException, InvalidPropertyException,
return added;
}
- /**
- * @return
- */
- public StepService getStepService() {
- return _stepService;
- }
-
- public void setStepService(StepService stepService) {
- _stepService = stepService;
- }
-
public SimulationContext addProjectContext(Study aStudy,
SimulationContext context) {
// ----------------------------------------------------------------------
public int generateLocalIndex(Study aStudy) {
aStudy.setLastLocalIndex(aStudy.getLastLocalIndex() + 1);
- Database.getSession().update(this);
+ Database.getSession().update(aStudy);
return aStudy.getLastLocalIndex();
}
aStudy.getScenariiList().add(
aStudy.getScenariiList().indexOf(previous) + 1, scenario);
}
- session.update(this); // No need to update the Lucene index
+ session.update(aStudy); // No need to update the Lucene index
session.save(scenario); // Must be done after updating this study because of the back reference to the study
if (sprop.getBaseStep() != null) {
// No need to update the Knowledge Element index as Knowledge Elements are not copied
ProjectElementService projectElementService) {
_projectElementService = projectElementService;
}
+
+ /**
+ * Get the stepService.
+ * @return the stepService
+ */
+ public StepService getStepService() {
+ return _stepService;
+ }
+
+ /**
+ * Set the stepService.
+ * @param stepService the stepService to set
+ */
+ public void setStepService(StepService stepService) {
+ _stepService = stepService;
+ }
}