+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.service.ScenarioService#getScenarioInfo(long)
+ */
+ @Transactional
+ public List<StepDTO> getScenarioInfo(final long scenarioId) {
+ List<StepDTO> res = new ArrayList<StepDTO>();
+ // Get the scenario from the database by id
+ Scenario scen = getScenarioDAO().get(scenarioId);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Scenario[" + scenarioId + "]: Number of publications: "
+ + scen.getDocums().size());
+ }
+ // Get activities of the scenario
+ Step[] steps = getProjectElementService().getSteps(scen);
+ StepDTO stepDTO;
+ DocumentDTO docDTO;
+ String docType, fileFormat;
+ String processing;
+ boolean doImport;
+ // For each activity create a step DTO and add it to the result list
+ for (Step step : steps) {
+ stepDTO = BeanHelper.copyBean(step.getStep(), StepDTO.class);
+ res.add(stepDTO);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Step[" + stepDTO.getNumber()
+ + "]: Number of documents: "
+ + step.getDocuments().size());
+ }
+ // For each publication of the activity create a document DTO.
+ // Each file is considered as a source file.
+ for (Publication tag : step.getDocuments()) {
+ docDTO = stepDTO.addDoc(tag.value().getIndex(), tag.value()
+ .getTitle());
+ char aState = tag.getIsnew();
+ docType = tag.value().getType().getName();
+ // For each file of the document create a file DTO
+ // Process source file of the document
+ fileFormat = tag.value().getFile().getFormat();
+ doImport = getProjectSettings().doImport(docType, fileFormat);
+ if (doImport && (!tag.isOutdated())) {
+ processing = "file-import";
+ } else {
+ processing = "file-download";
+ }
+ docDTO.addFile(tag.value().getFile().getRelativePath(), aState,
+ processing, false);
+ // Process all exported files
+ for (Relation rel : tag.value().getRelations(
+ ConvertsRelation.class)) {
+ File aFile = ((ConvertsRelation) rel).getTo();
+ fileFormat = aFile.getFormat();
+ doImport = getProjectSettings().doImport(docType,
+ fileFormat);
+ if (doImport && (!tag.isOutdated())) {
+ processing = "file-import";
+ } else {
+ processing = "file-download";
+ }
+ docDTO.addFile(aFile.getRelativePath(), aState, processing,
+ false);
+ }
+ }
+ }
+ return res;
+ }
+
+ /**
+ * 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(final Study.Properties sprop,
+ final Scenario.Properties oprop,
+ final 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}
+ *
+ * @see org.splat.service.ScenarioService#addKnowledgeElement(org.splat.dal.bo.som.Scenario,
+ * org.splat.dal.bo.som.KnowledgeElement.Properties)
+ */
+ @Transactional
+ public KnowledgeElement addKnowledgeElement(final Scenario aScenarioDTO,
+ final KnowledgeElement.Properties kprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException {
+ KnowledgeElement kelm = null;