X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Workspace%2FSiman-Common%2Fsrc%2Forg%2Fsplat%2Fservice%2FStudyServiceImpl.java;h=0af12a2baf98965dc31336e154ba1ebaa28b9a80;hb=9a1c4c7c806a97eaa27baa9bb44257e91aca3117;hp=374c04317d8ef27faca3eda61eab6778488a4e4a;hpb=9fb332c9dc5e5e737eca71e88c2beb37429be389;p=tools%2Fsiman.git diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java index 374c043..0af12a2 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java @@ -1,10 +1,10 @@ /***************************************************************************** * 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; @@ -17,6 +17,7 @@ import java.util.List; 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; @@ -31,6 +32,7 @@ import org.splat.dal.bo.som.ProgressState; 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; @@ -41,17 +43,22 @@ import org.splat.kernel.InvalidPropertyException; import org.splat.kernel.MissedPropertyException; import org.splat.kernel.MultiplyDefinedException; import org.splat.kernel.UserDirectory; +import org.splat.log.AppLogger; import org.splat.service.technical.IndexService; import org.splat.service.technical.ProjectSettingsService; 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; @@ -62,6 +69,48 @@ public class StudyServiceImpl implements StudyService { 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 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 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, @@ -100,17 +149,6 @@ public class StudyServiceImpl implements StudyService { return added; } - /** - * @return - */ - public StepService getStepService() { - return _stepService; - } - - public void setStepService(StepService stepService) { - _stepService = stepService; - } - public SimulationContext addProjectContext(Study aStudy, SimulationContext context) { // ---------------------------------------------------------------------- @@ -292,7 +330,7 @@ public class StudyServiceImpl implements StudyService { public int generateLocalIndex(Study aStudy) { aStudy.setLastLocalIndex(aStudy.getLastLocalIndex() + 1); - Database.getSession().update(this); + Database.getSession().update(aStudy); return aStudy.getLastLocalIndex(); } @@ -320,7 +358,7 @@ public class StudyServiceImpl implements StudyService { 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 @@ -473,4 +511,20 @@ public class StudyServiceImpl implements StudyService { 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; + } }