1 /*****************************************************************************
5 * Creation date 06.10.2012
8 *****************************************************************************/
10 package org.splat.service;
12 import java.io.IOException;
13 import java.util.ArrayList;
14 import java.util.Calendar;
15 import java.util.Date;
16 import java.util.HashMap;
17 import java.util.HashSet;
18 import java.util.Iterator;
19 import java.util.List;
23 import org.hibernate.criterion.DetachedCriteria;
24 import org.hibernate.criterion.Order;
25 import org.hibernate.criterion.Projections;
26 import org.hibernate.criterion.Restrictions;
27 import org.hibernate.transform.Transformers;
28 import org.splat.common.properties.MessageKeyEnum;
29 import org.splat.dal.bo.kernel.Relation;
30 import org.splat.dal.bo.kernel.Role;
31 import org.splat.dal.bo.kernel.User;
32 import org.splat.dal.bo.som.ConvertsRelation;
33 import org.splat.dal.bo.som.Document;
34 import org.splat.dal.bo.som.DocumentType;
35 import org.splat.dal.bo.som.File;
36 import org.splat.dal.bo.som.KnowledgeElement;
37 import org.splat.dal.bo.som.KnowledgeElementType;
38 import org.splat.dal.bo.som.ProgressState;
39 import org.splat.dal.bo.som.ProjectElement;
40 import org.splat.dal.bo.som.Publication;
41 import org.splat.dal.bo.som.Scenario;
42 import org.splat.dal.bo.som.SimulationContext;
43 import org.splat.dal.bo.som.SimulationContextType;
44 import org.splat.dal.bo.som.Study;
45 import org.splat.dal.bo.som.UsedByRelation;
46 import org.splat.dal.bo.som.UsesRelation;
47 import org.splat.dal.bo.som.ValidationCycle;
48 import org.splat.dal.bo.som.Document.Properties;
49 import org.splat.dal.dao.kernel.RoleDAO;
50 import org.splat.dal.dao.kernel.UserDAO;
51 import org.splat.dal.dao.som.DocumentDAO;
52 import org.splat.dal.dao.som.KnowledgeElementDAO;
53 import org.splat.dal.dao.som.KnowledgeElementTypeDAO;
54 import org.splat.dal.dao.som.ScenarioDAO;
55 import org.splat.dal.dao.som.StudyDAO;
56 import org.splat.dal.dao.som.ValidationCycleDAO;
57 import org.splat.exception.InvalidParameterException;
58 import org.splat.i18n.I18nUtils;
59 import org.splat.kernel.InvalidPropertyException;
60 import org.splat.kernel.MismatchException;
61 import org.splat.kernel.MissedPropertyException;
62 import org.splat.kernel.MultiplyDefinedException;
63 import org.splat.kernel.NotApplicableException;
64 import org.splat.log.AppLogger;
65 import org.splat.service.dto.DocumentDTO;
66 import org.splat.service.dto.FileDTO;
67 import org.splat.service.dto.ScenarioDTO;
68 import org.splat.service.dto.StepDTO;
69 import org.splat.service.technical.IndexService;
70 import org.splat.service.technical.ProjectSettingsService;
71 import org.splat.service.technical.RepositoryService;
72 import org.splat.service.technical.StepsConfigService;
73 import org.splat.som.Step;
74 import org.splat.util.BeanHelper;
75 import org.splat.util.IOUtils;
76 import org.springframework.transaction.annotation.Transactional;
79 * Scenario service implementation.
81 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
83 public class ScenarioServiceImpl implements ScenarioService {
86 * The logger for the service.
88 public final static AppLogger LOG = AppLogger
89 .getLogger(ScenarioServiceImpl.class);
94 private static final String TO = " to ";
96 * Injected index service.
98 private IndexService _indexService;
100 * Injected step service.
102 private StepService _stepService;
104 * Injected study service.
106 private StudyService _studyService;
108 * Injected publication service.
110 private PublicationService _publicationService;
112 * Injected project element service.
114 private ProjectElementService _projectElementService;
116 * Injected knowledge element DAO.
118 private KnowledgeElementDAO _knowledgeElementDAO;
120 * Injected scenario DAO.
122 private ScenarioDAO _scenarioDAO;
125 * Injected study DAO.
127 private StudyDAO _studyDAO;
130 * Injected knowledge element service.
132 private KnowledgeElementTypeService _knowledgeElementTypeService;
135 * Injected user service.
137 private UserService _userService;
142 private UserDAO _userDAO;
147 private RoleDAO _roleDAO;
150 * Injected knowledge element type DAO.
152 private KnowledgeElementTypeDAO _knowledgeElementTypeDAO;
155 * Injected document DAO.
157 private DocumentDAO _documentDAO;
160 * Injected simulation context service.
162 private SimulationContextService _simulationContextService;
165 * Injected simulation context type service.
167 private SimulationContextTypeService _simulationContextTypeService;
170 * Injected project service.
172 private ProjectSettingsService _projectSettings;
175 * Injected document type service.
177 private DocumentTypeService _documentTypeService;
180 * Injected validation cycle DAO.
182 private ValidationCycleDAO _validationCycleDAO;
185 * Injected project settings service.
187 private StepsConfigService _stepsConfigService;
190 * Injected repository service.
192 private RepositoryService _repositoryService;
195 * Get the projectElementService.
197 * @return the projectElementService
199 public ProjectElementService getProjectElementService() {
200 return _projectElementService;
204 * Set the projectElementService.
206 * @param projectElementService
207 * the projectElementService to set
209 public void setProjectElementService(
210 final ProjectElementService projectElementService) {
211 _projectElementService = projectElementService;
215 * Get the publicationService.
217 * @return the publicationService
219 public PublicationService getPublicationService() {
220 return _publicationService;
224 * Set the publicationService.
226 * @param publicationService
227 * the publicationService to set
229 public void setPublicationService(
230 final PublicationService publicationService) {
231 _publicationService = publicationService;
235 * Get the stepService.
237 * @return the stepService
239 public StepService getStepService() {
244 * Set the stepService.
247 * the stepService to set
249 public void setStepService(final StepService stepService) {
250 _stepService = stepService;
256 * @see org.splat.service.ScenarioService#getStudyScenarios(java.lang.Long)
259 @Transactional(readOnly = true)
260 public List<ScenarioDTO> getStudyScenarios(final Long studyId) {
261 DetachedCriteria query = DetachedCriteria
262 .forClass(Scenario.class, "scen")
263 .add(Restrictions.eq("owner.rid", studyId))
265 Projections.projectionList().add(
266 Projections.property("scen.title"), "title")
267 .add(Projections.property("scen.rid"), "index"))
268 .setResultTransformer(
269 Transformers.aliasToBean(ScenarioDTO.class));
270 return getScenarioDAO().getFilteredDTOList(query);
276 * @see org.splat.service.ScenarioService#copyStudyContent(long, long, int, long)
280 public void copyStudyContent(final long fromStudyId, final long fromScenId,
281 final int finalStepNum, final long toStudyId)
282 throws InvalidParameterException, MissedPropertyException,
283 InvalidPropertyException, MultiplyDefinedException,
284 NotApplicableException, IOException {
285 Study fromStudy = getStudyService().selectStudy(fromStudyId);
286 if (fromStudy == null) {
287 throw new InvalidParameterException(MessageKeyEnum.STD_000002
288 .toString(), String.valueOf(fromStudyId));
290 Scenario fromScen = null;
291 for (Scenario scen : fromStudy.getScenariiList()) {
292 if (scen.getIndex() == fromScenId) {
298 Study toStudy = getStudyService().selectStudy(toStudyId);
299 if (toStudy == null) {
300 throw new InvalidParameterException(MessageKeyEnum.STD_000002
301 .toString(), String.valueOf(toStudy));
304 // Check if the step is applied to a scenario and scenario is defined
306 && getStepsConfigService().stepInvolves(finalStepNum,
308 throw new InvalidParameterException(MessageKeyEnum.SCN_000006
309 .toString(), String.valueOf(fromScenId));
312 // Copy validation cycles
313 copyValidationCycles(fromStudy, toStudy);
315 // Copy content of the study up to the given step
316 Map<Publication, Publication> oldToNewPub = new HashMap<Publication, Publication>();
317 copyDocs(fromStudy, toStudy, finalStepNum, oldToNewPub);
318 if (fromScen != null) {
319 copyDocs(fromScen, toStudy.getScenariiList().get(0), finalStepNum,
322 copyDependencies(fromStudy, finalStepNum, oldToNewPub);
323 if (fromScen != null) {
324 copyDependencies(fromScen, finalStepNum, oldToNewPub);
329 * Copy validation cycles from study to study.
334 * the destination study
336 private void copyValidationCycles(final Study fromStudy, final Study toStudy) {
337 for (ValidationCycle fromCycle : fromStudy.getValidationCycles()
339 if (fromCycle.isAssigned()) {
340 ValidationCycle cycle = fromCycle.clone(toStudy);
341 getValidationCycleDAO().create(cycle);
342 toStudy.addRelation(cycle.getContext());
343 toStudy.getValidationCycles().put(
344 cycle.getDocumentType().getName(), cycle); // Replaces the cycle if exists as default,
350 * Copy dependencies between documents from the given project element up to <BR>
351 * the given step according to the given map of old publications to new publications.
354 * the source project element
355 * @param finalStepNum
356 * the final step for copy processing
358 * the old to new publications map
360 private void copyDependencies(final ProjectElement from,
361 final int finalStepNum,
362 final Map<Publication, Publication> oldToNewPub) {
363 // Copy dependencies between copied documents
364 for (Publication pub : from.getDocums()) {
365 // If the document in the step before the final one
366 if (pub.value().getStep() <= finalStepNum) {
367 Publication newPub = oldToNewPub.get(pub);
368 for (Publication used : pub.getRelations(UsesRelation.class)) {
369 newPub.addDependency(oldToNewPub.get(used));
376 * Copy documents with dependencies up to the given step.
379 * the source project element
381 * the destination project element
382 * @param finalStepNum
383 * the final step for copy process
384 * @param oldToNewPub2
385 * @throws MissedPropertyException
386 * if document creation is failed
387 * @throws InvalidPropertyException
388 * if document creation is failed
389 * @throws MultiplyDefinedException
390 * if document creation is failed
391 * @throws IOException
392 * if document file creation is failed
393 * @throws NotApplicableException
394 * if document state is not applicable
396 * the old to new publications map
399 private void copyDocs(final ProjectElement from, final ProjectElement to,
400 final int finalStepNum,
401 final Map<Publication, Publication> oldToNewPub)
402 throws MissedPropertyException, InvalidPropertyException,
403 MultiplyDefinedException, NotApplicableException, IOException {
404 Map<Integer, Step> steps = getProjectElementService().getStepsMap(to);
405 // Copy publications without old versions and relations to not copied steps documents
406 for (Publication pub : from.getDocums()) {
407 // If the document in the step before the final one
408 if (pub.value().getStep() <= finalStepNum) {
410 oldToNewPub.put(pub, createDoc(pub.value(), steps.get(pub
411 .value().getStep())));
417 * Create a copy of the given document and publish it in the given step.
420 * the source document
422 * the destination step
423 * @return the created publication
424 * @throws MissedPropertyException
425 * if document creation is failed
426 * @throws InvalidPropertyException
427 * if document creation is failed
428 * @throws MultiplyDefinedException
429 * if document creation is failed
430 * @throws IOException
431 * if document file creation is failed
432 * @throws NotApplicableException
433 * if document state is not applicable
435 private Publication createDoc(final Document fromDoc, final Step step)
436 throws MissedPropertyException, InvalidPropertyException,
437 MultiplyDefinedException, IOException, NotApplicableException {
439 java.io.File srcFile = fromDoc.getSourceFile().asFile();
440 // Creation of the document
441 Document.Properties dprop = new Document.Properties().setName(
442 fromDoc.getTitle()).setType(fromDoc.getType()).setFormat(
443 fromDoc.getFormat()).setAuthor(fromDoc.getAuthor());
445 java.io.File tmpDir = getRepositoryService().getDownloadDirectory(
446 step.getOwnerStudy().getAuthor());
448 // Remove local file index prefix to get original filename.
449 java.io.File upfile = new java.io.File(tmpDir.getPath()
451 + srcFile.getName().substring(
452 srcFile.getName().indexOf('_') + 1));
453 // Copy the source file into the temporary folder with original filename.
454 copyFile(srcFile, upfile);
456 dprop.setLocalPath(upfile.getPath());
457 Publication addoc = getStepService().createDocument(step, dprop);
459 // Move the temporary file into the repository
460 moveFile(upfile, addoc.getSourceFile().asFile());
462 getPublicationService().saveAs(addoc, fromDoc.getProgressState());
464 // Copy attached files
465 for (Relation rel : fromDoc.getRelations(ConvertsRelation.class)) {
466 File attach = ((ConvertsRelation) rel).getTo();
467 ConvertsRelation export = getPublicationService().attach(addoc,
469 // Copy the source document attachment file to the new study vault
470 copyFile(attach.asFile(), export.getTo().asFile());
476 * Copy a file. Print info message.
482 * @throws IOException
485 private void copyFile(final java.io.File upfile, final java.io.File file)
487 if (LOG.isInfoEnabled()) {
488 LOG.info("Copy " + upfile.getAbsolutePath() + TO + file.getPath());
490 IOUtils.copy(upfile, file);
494 * Copy a file. Print info message.
500 * @return true if renamed otherwise return false
502 private boolean moveFile(final java.io.File upfile, final java.io.File file) {
503 if (LOG.isInfoEnabled()) {
504 LOG.info("Move " + upfile.getAbsolutePath() + TO + file.getPath());
506 file.delete(); // necessary on some platforms if the file exists.
507 return upfile.renameTo(file);
513 * @see org.splat.service.ScenarioService#getScenarioInfo(long)
515 @Transactional(readOnly = true)
516 public List<StepDTO> getScenarioInfo(final long scenarioId) {
517 List<StepDTO> res = new ArrayList<StepDTO>();
518 // Get the scenario from the database by id
519 Scenario scen = getScenarioDAO().get(scenarioId);
520 if (LOG.isDebugEnabled()) {
521 LOG.debug("Scenario[" + scenarioId + "]: Number of publications: "
522 + scen.getDocums().size());
524 // Get activities of the scenario
525 Step[] steps = getProjectElementService().getSteps(scen);
528 String docType, fileFormat;
531 // For each activity create a step DTO and add it to the result list
532 for (Step step : steps) {
533 stepDTO = BeanHelper.copyBean(step.getStep(), StepDTO.class);
535 if (LOG.isDebugEnabled()) {
536 LOG.debug("Step[" + stepDTO.getNumber()
537 + "]: Number of documents: "
538 + step.getDocuments().size());
540 // For each publication of the activity create a document DTO.
541 // Each file is considered as a source file.
542 for (Publication tag : step.getDocuments()) {
543 docDTO = stepDTO.addDoc(tag.value().getIndex(), tag.value()
545 char aState = tag.getIsnew();
546 docType = tag.value().getType().getName();
547 // For each file of the document create a file DTO
548 // Process source file of the document
549 fileFormat = tag.value().getFile().getFormat();
550 doImport = getProjectSettings().doImport(docType, fileFormat);
551 if (doImport && (!tag.isOutdated())) {
552 processing = "file-import";
554 processing = "file-download";
556 File aFile = tag.value().getFile();
557 docDTO.addFile(aFile.getIndex(), aFile.getRelativePath(),
558 aState, processing, false);
559 // Process all exported files
560 for (Relation rel : tag.value().getRelations(
561 ConvertsRelation.class)) {
562 aFile = ((ConvertsRelation) rel).getTo();
563 fileFormat = aFile.getFormat();
564 doImport = getProjectSettings().doImport(docType,
566 if (doImport && (!tag.isOutdated())) {
567 processing = "file-import";
569 processing = "file-download";
571 docDTO.addFile(aFile.getIndex(), aFile.getRelativePath(),
572 aState, processing, false);
582 * @see org.splat.service.ScenarioService#createStudy(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
585 public long createStudy(final String username, final String title,
586 final String productName, final String description)
587 throws InvalidPropertyException, MissedPropertyException,
588 MultiplyDefinedException {
592 User author = getUserService().selectUser(username);
593 if (author == null) {
595 throw new InvalidPropertyException(MessageKeyEnum.USR_000001
596 .toString(), username);
599 // Set the study properties
600 Study.Properties sprop = new Study.Properties();
601 sprop.setTitle(title).setManager(author);
602 sprop.setDescription(description);
604 // Find the product simulation context
605 SimulationContextType productContextType = getSimulationContextService()
606 .selectType("product");
607 SimulationContext.Properties cprop = new SimulationContext.Properties();
608 cprop.setType(productContextType).setValue(productName);
609 SimulationContext productCtx = getSimulationContextService()
610 .selectSimulationContext(productContextType, productName);
611 if (productCtx != null) {
612 cprop.setIndex(productCtx.getIndex());
615 // Set a first scenario properties
616 Scenario.Properties oprop = new Scenario.Properties();
617 oprop.setTitle(I18nUtils.getMessageLocaleDefault("label.scenario")
620 Study study = createStudy(sprop, oprop, cprop);
621 id = study.getIndex();
627 * Create a new study with one scenario and "product" simulation context.
630 * the study properties
632 * the scenario properties
634 * the "product" simulation context properties
635 * @return the created study
636 * @throws MissedPropertyException
637 * if a mandatory property is missed
638 * @throws InvalidPropertyException
639 * if a property is invalid
640 * @throws MultiplyDefinedException
641 * if some property occurs several times
644 public Study createStudy(final Study.Properties sprop,
645 final Scenario.Properties oprop,
646 final SimulationContext.Properties cprop)
647 throws MissedPropertyException, InvalidPropertyException,
648 MultiplyDefinedException {
649 Study study = getStudyService().createStudy(sprop);
650 addScenario(study, oprop);
651 if (cprop.getIndex() == 0) { // Input of new project context
652 cprop.setType(getSimulationContextService().selectType("product"))
653 .setValue(cprop.getValue());
654 getStudyService().addProjectContext(study, cprop);
655 } else { // Selection of existing project context
656 SimulationContext context = getSimulationContextService()
657 .selectSimulationContext(cprop.getIndex());
658 getStudyService().addProjectContext(study, context);
666 * @see org.splat.service.ScenarioService#assignStudyContext(java.lang.Long, java.lang.String, java.lang.String)
669 public void assignStudyContext(final Long studyId, final String ctxType,
670 final String ctxValue) throws MissedPropertyException,
671 InvalidPropertyException, MultiplyDefinedException {
672 // Find the study by the given id
673 Study study = getStudyDAO().get(studyId);
675 throw new InvalidPropertyException(MessageKeyEnum.STD_000002
676 .toString(), studyId);
678 // Find the context type by its name
679 SimulationContextType celt = getSimulationContextService().selectType(
682 // Creation of a new context type
683 celt = getSimulationContextTypeService().createType(ctxType,
684 getProjectElementService().getFirstStep(study).getStep());
686 // Find the given context value of the given type
687 SimulationContext context = getSimulationContextService()
688 .selectSimulationContext(celt, ctxValue);
689 if (context == null) { // Input of a new project context
690 SimulationContext.Properties cprop = new SimulationContext.Properties();
691 cprop.setType(celt).setValue(ctxValue);
692 getStudyService().addProjectContext(study, cprop);
693 } else { // Selection of existing project context
694 getStudyService().addProjectContext(study, context);
701 * @see org.splat.service.ScenarioService#addKnowledgeElement(org.splat.dal.bo.som.Scenario,
702 * org.splat.dal.bo.som.KnowledgeElement.Properties)
705 public KnowledgeElement addKnowledgeElement(final Scenario aScenarioDTO,
706 final KnowledgeElement.Properties kprop)
707 throws MissedPropertyException, InvalidPropertyException,
708 MultiplyDefinedException {
709 KnowledgeElement kelm = null;
711 long aScenarioId = aScenarioDTO.getIndex();
712 if (LOG.isDebugEnabled()) {
714 .debug("Add a knowledge element to the scenario #"
717 // Get the persistent scenario.
718 Scenario aScenario = getScenarioDAO().get(aScenarioId);
719 // Get persistent objects for creating a new knowledge.
720 // TODO: Actions must use DTO instead of persistent objects.
721 getUserDAO().merge(kprop.getAuthor());
722 getKnowledgeElementTypeDAO().merge(kprop.getType());
723 // Create a transient knowledge element related to the given scenario.
724 kelm = new KnowledgeElement(kprop.setOwnerScenario(aScenario));
725 // Save the new knowledge in the database.
726 getKnowledgeElementDAO().create(kelm);
727 // Update scenario transient data.
728 if (kelm.getType().equals("usecase")) {
729 aScenarioDTO.setUcase(kelm);
730 } else if (aScenarioDTO.getKnowledgeElementsList() != null) { // If null, knowl will be initialized when needed
731 aScenarioDTO.getKnowledgeElementsList().add(kelm);
734 // Load the workflow for the parent study to take into account
735 // all study actors durng reindexing.
736 getStudyService().loadWorkflow(aScenario.getOwnerStudy());
738 // // Update the lucene index of knowledge elements.
739 // getIndexService().add(kelm);
740 if (LOG.isDebugEnabled()) {
741 LOG.debug("A knowledge element #" + kelm.getIndex()
742 + " is added to the scenario #" + aScenario.getIndex());
744 // } catch (IOException error) {
745 // LOG.error("Unable to index the knowedge element '"
746 // + kelm.getIndex() + "', reason:", error);
756 * @see org.splat.service.ScenarioService#checkin(long, long, java.util.List)
759 public void checkin(final long scenId, final long userId,
760 final List<StepDTO> scInfo) throws InvalidPropertyException,
761 MissedPropertyException, MultiplyDefinedException,
762 MismatchException, IOException, NotApplicableException {
763 // Get the scenario from the database by id
764 Scenario aScenario = getScenarioDAO().get(scenId);
765 // Get the user who perform this check-in operation
766 User aUser = getUserService().selectUser(userId);
767 // Get activities of the scenario
768 Step[] steps = getProjectElementService().getSteps(aScenario);
769 // Find result document types
770 List<DocumentType> resTypes = getDocumentTypeService()
771 .selectResultTypes();
773 // Keep newly created documents to create uses relations to results of a previous step.
774 // For each processed existing document keep its new version
775 Map<Document, Document> newVersion = new HashMap<Document, Document>();
776 // Created publications of new created versions of existing documents
777 List<Publication> newVers = new ArrayList<Publication>();
778 // The list of publications of new created documents not existing before the checkin
779 List<Publication> newDocs = new ArrayList<Publication>();
781 DocumentType resType;
782 Date aDate = new Date(); // The timestamp of the checkin operation
783 for (StepDTO stepDTO : scInfo) {
784 if (LOG.isDebugEnabled()) {
785 LOG.debug("Checkin the step:\n" + stepDTO);
787 if (stepDTO.getDocs().size() == 0) {
790 // Find a result document type of the step
794 if (resTypes.get(i).isResultOf(
795 getProjectSettings().getStep(stepDTO.getNumber()))) {
796 resType = resTypes.get(i);
799 } while ((resType == null) && (i < resTypes.size()));
801 // Find the appropriate scenario step
802 Step step = findStep(stepDTO, steps);
804 List<FileDTO> filesToBeAttached = new ArrayList<FileDTO>();
805 FileDTO fileToAttachTo = null; //all the rest documents will be attached to it
807 //The id is the same for all DocumentDTOs of a step
808 Long currentDocId = stepDTO.getDocs().get(0).getId();
809 if(currentDocId != null && currentDocId > 0) { //there is a result document in the step
810 String currentFormat = step.getDocument(currentDocId).value().getFormat();
812 // Process each document of the step
813 for (DocumentDTO doc : stepDTO.getDocs()) {
814 for (FileDTO fileDTO : doc.getFiles()) {
816 String path = fileDTO.getPath();
817 String format = path.substring(path.lastIndexOf('.') + 1);
819 // If it has the same format as current doc (there can be just one such file)
820 // then this doc will be DocToAttachTo.
821 if (format != null && format.equals(currentFormat)) {
822 fileToAttachTo = fileDTO;
824 // Else, put it in the list of docs that will be attached to DocToAttachTo
825 filesToBeAttached.add(fileDTO);
830 // Process each document of the step
831 for (DocumentDTO doc : stepDTO.getDocs()) {
832 for (FileDTO fileDTO : doc.getFiles()) {
833 String path = doc.getFiles().get(0).getPath();
834 String format = path.substring(path.lastIndexOf('.') + 1);
836 ProjectSettingsService.Step stepType = step.getStep();
837 // If the default type for its format in the current step is the result type,
838 // then this doc will be DocToAttachTo.
839 DocumentType defaultDocType = _projectSettings.getDefaultDocumentType(stepType, format);
840 if (defaultDocType != null && defaultDocType.isResultOf(stepType)) {
841 //It is possible that there is not just one such doc
842 if(fileToAttachTo != null){
843 filesToBeAttached.add(fileToAttachTo);
845 fileToAttachTo = fileDTO;
847 // Else, put it in the list of docs that will be attached to DocToAttachTo
848 filesToBeAttached.add(fileDTO);
853 //could not find any file with appropriate format
854 if (fileToAttachTo == null && !filesToBeAttached.isEmpty()) {
855 //All the rest documents will be attached to the first in the list
856 fileToAttachTo = filesToBeAttached.get(0);
857 filesToBeAttached.remove(0);
861 if (fileToAttachTo != null) { // true if the DocumentDTO list is not empty
863 //Process docToAttachTo
864 Publication pub = checkinDoc(step, fileToAttachTo, currentDocId,
865 aUser, resType, aDate,
866 newVersion, newVers, newDocs);
867 currentDocId = pub.value().getIndex();
871 for (FileDTO file : filesToBeAttached) {
872 checkinDoc(step, file, currentDocId, aUser, resType, aDate, newVersion,
877 // Set uses/used relations
878 updateRelationsAfterCheckin(aScenario, newVersion, newVers, newDocs);
880 // Mark the scenario as checked in
885 * Updated uses/used relations after checkin operation:<BR>
887 * <li>For each new version copy uses relations from the previous version.</li>
888 * <li>Outdate documents which depend from the previous version and were not checked in during this operation.</li>
889 * <li>For each new document create uses relation to the last versions of results of the previous step.</li>
893 * the checked in scenario
895 * the mapping of documents existed before the checkin to their new created versions
897 * the list of publications of new created versions of documents existed before the checkin
899 * the list of publications of new created documents not existed before the checkin
901 private void updateRelationsAfterCheckin(final Scenario aScenario,
902 final Map<Document, Document> newVersion,
903 final List<Publication> newVers, final List<Publication> newDocs) {
904 // For each new version copy uses relations from the previous version.
905 for (Publication newVer : newVers) {
906 // For each Uses relation of the previous version
907 Document prevDoc = newVer.value().getPreviousVersion();// prevVersion.get(newVer);
908 if (LOG.isDebugEnabled()) {
909 LOG.debug("Previous version for publication #"
910 + newVer.getIndex() + " is found: " + prevDoc);
912 List<Relation> usesRelations = prevDoc
913 .getRelations(UsesRelation.class);
914 for (Relation rel : usesRelations) {
915 // If used document has been also versioned then refer to its new version.
916 Document usedDoc = ((UsesRelation) rel).getTo();
917 if (newVersion.containsKey(usedDoc)) {
918 usedDoc = newVersion.get(usedDoc);
920 // Build the appropriate relation for the new version.
921 newVer.addDependency(usedDoc);
923 // Outdate documents which depend from the previous version and
924 // were not checked in during this operation.
925 // 1. Get all usedBy relations of the previous document version
926 for (Relation rel : prevDoc.getRelations(UsedByRelation.class)) {
927 Document using = ((UsedByRelation) rel).getTo();
928 // Check that not checked in dependent documents became outdated
929 Publication usingPub = aScenario.getPublication(using);
930 if (usingPub != null) { // if the document using the old version is still published
931 usingPub.setIsnew('O');
936 // For each new document create uses relation to the last versions of
937 // results of the previous step.
938 for (Publication newPub : newDocs) {
939 // Find used document type according to the configuration.
940 Set<DocumentType> usedTypes = newPub.value().getType()
942 // Find documents of used type in the previous study step.
943 for (Publication pub : aScenario.getDocums()) {
944 if ((pub.getStep().getNumber() <= newPub.getStep().getNumber())
945 && (!pub.isOutdated())
946 && usedTypes.contains(pub.value().getType())
947 && !newPub.equals(pub)) {
948 // Create uses relation from the new document
949 // to the found document in the previous step.
950 newPub.addDependency(pub);
957 * Pure checkin of the document without creation of uses/usedBy relations. For an existing document a new version is created. New
958 * documents become published in the given step of the appropriate scenario. The appropriate uploaded file is attached to the created
959 * document and the document is published in the scenario. The publication of the old version is removed from the scenario.
962 * the destination scenario step
964 * the FilDTO to checkin
968 * the user who performs checkin
970 * the result document type of the given step
972 * timestamp of the checkin operation
974 * the mapping of existing documents to their new created versions
976 * the list of publications of new created versions of existing documents
978 * the list of publications of new created documents not existing before the checkin
980 * the newly created publication, if exists (the document has been created or versioned),
981 * null otherwise (the doc has been attached to the old one)
982 * @throws InvalidPropertyException
983 * if the scenario hasn't some of given steps or documents
984 * @throws IOException
985 * if a file can't be moved into the vault
986 * @throws MismatchException
987 * if version creation in some of steps is failed
988 * @throws MissedPropertyException
989 * if some mandatory property is missed when new document or new document version is created
990 * @throws MultiplyDefinedException
991 * if some property is defined several times when new document or new document version is created
992 * @throws NotApplicableException
993 * if failed saving of a new publication with a given state
995 private Publication checkinDoc(final Step step, final FileDTO file,
996 final long docId, final User aUser, final DocumentType resType,
997 final Date aDate, final Map<Document, Document> newVersion,
998 final List<Publication> newVers, final List<Publication> newDocs)
999 throws InvalidPropertyException, MismatchException,
1000 MissedPropertyException, MultiplyDefinedException, IOException,
1001 NotApplicableException {
1002 Publication newPub = null;
1004 Document.Properties dprop = new Document.Properties();
1005 // NOTE: Process only the first attached file for each document
1006 dprop.setLocalPath(file.getPath());
1008 // Get document title as the file name
1009 java.io.File upfile = new java.io.File(file.getPath());
1010 String fileFormat = upfile.getName().substring(
1011 upfile.getName().lastIndexOf('.') + 1);
1013 // Attach the file via ConvertsRelation, create a new document or
1014 // create a new version of the document
1015 dprop.setAuthor(aUser).setDate(aDate).setFormat(fileFormat);
1016 String authorName = I18nUtils.getMessageLocaleDefault(aUser
1018 String summary = I18nUtils.getMessageLocaleDefault(
1019 MessageKeyEnum.DCT_000005.toString(), authorName);
1020 dprop.setDescription(summary);
1023 newPub = checkinExistingDoc(step, docId, dprop, fileFormat, upfile,
1024 newVersion, newVers);
1027 // Otherwise create a new document of the result type
1028 // If result type is not found try to get type by file extension
1029 if (resType == null) {
1030 dprop.setType(getProjectSettings().getDefaultDocumentType(
1031 step.getStep(), fileFormat));
1033 dprop.setType(resType);
1035 // New document title generation as <document type name>_N
1036 String docname = dprop.getType().getName();
1038 for (Publication scenPub : step.getOwner().getDocums()) {
1039 if (scenPub.value().getTitle().startsWith(docname)) {
1043 docname += "_" + i; // The generated new document title
1045 dprop.setName(docname);
1046 newPub = getStepService().createDocument(step,
1049 // Remember the new document
1050 newDocs.add(newPub);
1052 saveFile(newPub, step, upfile);
1059 * Check in existing document.
1062 * study step to check in
1064 * target document id
1066 * document properties
1068 * checked in file format
1070 * the file to check in
1072 * the map of created versions during this check in
1074 * the list of new versions created during this check in
1076 * the newly created publication, if exists (the document has been versioned),
1077 * null otherwise (the doc has been attached to the old one)
1078 * @throws InvalidPropertyException
1079 * if publication of the document is not found in the step
1080 * @throws MismatchException
1081 * if the found publication does not point to a document
1082 * @throws IOException
1083 * if can not move the file into the vault
1084 * @throws MultiplyDefinedException
1085 * thrown by versionDocument
1086 * @throws MissedPropertyException
1087 * thrown by versionDocument
1088 * @throws NotApplicableException
1089 * if failed saving of a new publication with a given state
1091 private Publication checkinExistingDoc(final Step step, final long docId,
1092 final Properties dprop, final String fileFormat,
1093 final java.io.File upfile,
1094 final Map<Document, Document> newVersion,
1095 final List<Publication> newVers) throws InvalidPropertyException,
1096 MismatchException, MissedPropertyException,
1097 MultiplyDefinedException, IOException, NotApplicableException {
1098 // If the document already exists then
1099 // Attach the file via ConvertsRelation if the extension of the
1100 // new file differs from the old one.
1101 // If file format (i.e. extension) is the same then create a new
1102 // version of the document.
1103 // Find the document publication
1104 //Publication pub = step.getDocument(doc.getId());
1105 Publication pub = step.getDocument(docId);
1106 Publication newPub = null;
1108 throw new InvalidPropertyException(MessageKeyEnum.SCN_000002
1109 .toString(), docId);
1111 if (pub.value() == null) {
1112 throw new MismatchException(MessageKeyEnum.SCN_000002.toString(),
1115 if (LOG.isDebugEnabled()) {
1116 LOG.debug("Old format: " + pub.value().getFormat()
1117 + " => New format: " + fileFormat);
1119 // If formats are same then create a new document version
1120 if (pub.value().getFormat() != null
1121 && pub.value().getFormat().equals(fileFormat)) {
1122 newPub = getStepService().versionDocument(step, pub,
1124 if (LOG.isDebugEnabled()) {
1125 LOG.debug("Created document type: "
1126 + newPub.value().getType().getName() + ", format: "
1127 + newPub.value().getFormat());
1129 // Remeber the link from the old document to the new document version
1130 newVersion.put(pub.value(), newPub.value());
1131 // Remember the new version publication
1132 newVers.add(newPub);
1134 saveFile(newPub, step, upfile);
1136 } else { // If formats are different then attach the new file via ConvertsRelation
1137 File attach = pub.value().getAttachedFile(fileFormat);
1138 if (attach == null) {
1139 // If there is no attachment with this extension then attach the new one
1140 ConvertsRelation export = getPublicationService().attach(pub,
1142 moveFile(upfile, export.getTo().asFile());
1144 // If an attachment with this extension already exists then
1145 // replace it by the new one
1146 moveFile(upfile, attach.asFile());
1147 // Update attached file modification date
1148 attach.setDate(new Date());
1155 * Save the file in the vault and create its publication in the step.
1158 * the new publication to save
1160 * the study step to publish the document
1162 * the downloaded file
1163 * @throws IOException
1164 * if a file can't be moved into the vault
1165 * @throws NotApplicableException
1166 * if failed saving of a new publication with a given state
1168 private void saveFile(final Publication newPub, final Step step,
1169 final java.io.File upfile) throws IOException,
1170 NotApplicableException {
1171 // Attach the file to the created document
1172 java.io.File updir = newPub.getSourceFile().asFile();
1173 if (updir.exists()) {
1174 if (updir.delete()) {
1175 LOG.info(MessageKeyEnum.SCN_000003.toString(), updir
1176 .getAbsoluteFile(), step.getOwner().getIndex());
1178 throw new IOException(
1179 "Can't delete the existing destination file to move file from "
1180 + upfile.getAbsolutePath() + TO
1181 + updir.getAbsolutePath());
1184 if (moveFile(upfile, updir)) {
1185 // Save the new publication in the scenario.
1186 // The old publication is removed from the scenario here.
1187 getPublicationService().saveAs(newPub, ProgressState.inWORK); // May throw FileNotFound if rename was not done
1189 throw new IOException("Can't move file from "
1190 + upfile.getAbsolutePath() + TO + updir.getAbsolutePath());
1195 * Find appropriate step in the array of scenario steps according to the given step DTO.
1201 * @return appropriate scenario step
1202 * @throws InvalidPropertyException
1203 * if appropriate step is not found
1205 private Step findStep(final StepDTO stepDTO, final Step[] steps)
1206 throws InvalidPropertyException {
1210 if (steps[i].getNumber() == stepDTO.getNumber()) {
1214 } while ((step == null) && (i < steps.length));
1217 throw new InvalidPropertyException(MessageKeyEnum.SCN_000001
1218 .toString(), stepDTO.getNumber());
1226 * @see org.splat.service.ScenarioService#checkin(long)
1229 public void checkin(final long scenarioId) throws InvalidPropertyException {
1230 Scenario aScenario = getScenarioDAO().get(scenarioId);
1231 if (aScenario == null) {
1232 // Scenario not found
1233 throw new InvalidPropertyException(MessageKeyEnum.SCN_000006
1234 .toString(), scenarioId);
1240 * Mark the scenario as checked in.
1243 * the scenario to check in.
1245 private void checkin(final Scenario aScenario) {
1246 aScenario.setUser(null);
1247 aScenario.setLastModificationDate(Calendar.getInstance().getTime());
1248 // getScenarioDAO().update(aScenario);
1254 * @see org.splat.service.ScenarioService#checkout(org.splat.dal.bo.som.Scenario, org.splat.dal.bo.kernel.User)
1256 public boolean checkout(final Scenario aScenario, final User user) {
1257 boolean res = getStudyService().isStaffedBy(aScenario.getOwnerStudy(),
1260 aScenario.setUser(user);
1261 aScenario.setLastModificationDate(Calendar.getInstance().getTime());
1262 // RKV: getScenarioDAO().update(aScenario);
1268 * Mark the given scenario as checked out by the given user.
1273 * the id of the user performing the check out
1274 * @throws InvalidPropertyException
1275 * if the user or the scenario is not found in the database
1276 * @throws NotApplicableException
1277 * if the given user can not check out the scenario
1280 public void checkout(final long scenarioId, final long userId)
1281 throws InvalidPropertyException, NotApplicableException {
1282 User aUser = getUserService().selectUser(userId);
1283 if (aUser == null) {
1285 throw new InvalidPropertyException(MessageKeyEnum.USR_000001
1286 .toString(), userId);
1288 Scenario aScenario = getScenarioDAO().get(scenarioId);
1289 if (aScenario == null) {
1290 // Scenario not found
1291 throw new InvalidPropertyException(MessageKeyEnum.SCN_000006
1292 .toString(), scenarioId);
1294 boolean res = getStudyService().isStaffedBy(aScenario.getOwnerStudy(),
1297 if (aScenario.isCheckedout()
1298 && (!aScenario.getUser().getUsername().equals(
1299 aUser.getUsername()))) {
1300 throw new NotApplicableException(MessageKeyEnum.SCN_000008
1301 .toString(), scenarioId, aScenario.getUser()
1304 aScenario.setUser(aUser);
1305 aScenario.setLastModificationDate(Calendar.getInstance().getTime());
1307 // User doesn't participate in the scenario
1308 throw new NotApplicableException(MessageKeyEnum.SCN_000007
1309 .toString(), aUser.getUsername(), scenarioId);
1316 * @see org.splat.service.ScenarioService#copyContentsUpTo(org.splat.dal.bo.som.Scenario, org.splat.som.Step)
1318 public void copyContentsUpTo(final Scenario scenario, final Step lastep) {
1319 Scenario base = (Scenario) lastep.getOwner();
1320 Step[] from = getProjectElementService().getSteps(base);
1321 Step[] to = getProjectElementService().getSteps(scenario);
1322 for (int i = 0; i < from.length; i++) {
1323 Step step = from[i];
1324 if (step.getNumber() > lastep.getNumber()) {
1328 List<Publication> docs = step.getAllDocuments();
1329 for (Iterator<Publication> j = docs.iterator(); j.hasNext();) {
1330 Publication doc = getPublicationService().copy(j.next(),
1331 scenario); // Creation of a new reference to the document
1332 // Database.getSession().save(doc); Publications MUST be saved later through cascading when saving the scenario
1333 getStepService().add(to[i], doc);
1335 List<SimulationContext> ctex = step.getAllSimulationContexts();
1336 for (Iterator<SimulationContext> j = ctex.iterator(); j.hasNext();) {
1337 getStepService().addSimulationContext(to[i], j.next());
1345 * @see org.splat.service.ScenarioService#isEmpty(org.splat.dal.bo.som.Scenario)
1347 public boolean isEmpty(final Scenario scenario) {
1348 Step[] mystep = getProjectElementService().getSteps(scenario);
1349 boolean isEmp = true;
1350 for (int i = 0; i < mystep.length; i++) {
1351 if (mystep[i].isStarted()) {
1363 public boolean isFinished(final Scenario scenario) {
1364 Step[] mystep = getProjectElementService().getSteps(scenario);
1365 boolean notempty = false; // If this is empty, this is not finished
1366 for (int i = 0; i < mystep.length; i++) {
1367 if (!mystep[i].isStarted()) {
1370 if (!mystep[i].isFinished()) {
1381 * @see org.splat.service.StudyService#addScenario(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.Scenario.Properties)
1384 public Scenario addScenario(final Study aStudy,
1385 final Scenario.Properties sprop) throws MissedPropertyException,
1386 InvalidPropertyException, MultiplyDefinedException {
1387 if (sprop.getManager() == null) {
1388 sprop.setManager(aStudy.getAuthor());
1391 Scenario scenario = new Scenario(sprop.setOwnerStudy(aStudy));
1392 if (sprop.getBaseStep() != null) {
1393 copyContentsUpTo(scenario, sprop.getBaseStep());
1395 Scenario previous = sprop.getInsertAfter();
1397 if (previous == null) {
1398 aStudy.getScenariiList().add(scenario);
1400 aStudy.getScenariiList().add(
1401 aStudy.getScenariiList().indexOf(previous) + 1, scenario);
1403 getStudyDAO().update(aStudy); // No need to update the Lucene index
1404 getScenarioDAO().create(scenario); // Must be done after updating this study because of the back reference to the study
1405 if (sprop.getBaseStep() != null) {
1406 // No need to update the Knowledge Element index as Knowledge Elements are not copied
1407 getProjectElementService().refresh(scenario); // Because saving the scenario changes the hashcode of copied Publications
1409 KnowledgeElementType ucase = getKnowledgeElementTypeService()
1410 .selectType("usecase");
1411 KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
1412 // TODO: Get appropriate user by its role: UserService.getAdmin();
1413 // User admin = getUserService().selectUser(1); // First user created when creating the database
1414 Role adminRole = getRoleDAO().getFilteredList(
1415 Restrictions.like("role", "%sysadmin%")).get(0);
1416 User admin = getUserDAO().getFilteredList(
1417 Restrictions.eq("role", adminRole), Order.asc("rid")).get(0); // First sysadmin in the database
1419 kprop.setType(ucase).setTitle(aStudy.getTitle()).setValue(
1420 scenario.getTitle()).setAuthor(admin); // Internal Knowledge Element required by the validation process of
1422 addKnowledgeElement(scenario, kprop);
1427 * Remove a knowledge element from a scenario.
1432 * the knowledge element to remove
1433 * @return true if removal succeeded
1436 public boolean removeKnowledgeElement(final Scenario scenario,
1437 final KnowledgeElement kelm) {
1438 KnowledgeElement torem = scenario.getKnowledgeElement(kelm.getIndex());
1439 boolean isOk = (torem != null);
1441 isOk = scenario.getKnowledgeElements().remove(torem);
1443 getScenarioDAO().merge(scenario);
1444 // Update of my transient data
1445 // RKV: These transient data are not used indeed.
1446 // RKV: List<KnowledgeElement> kelms = scenario.getKnowledgeByType().get(
1447 // RKV: kelm.getType().getIndex());
1448 // RKV: kelms.remove(torem);
1449 if (scenario.getKnowledgeElementsList() != null) {
1450 scenario.getKnowledgeElementsList().remove(torem);
1452 // TODO: If the owner study is not private, remove the knowledge from the Lucene index
1462 * @see org.splat.service.ScenarioService#renameScenario(java.lang.String)
1465 public void renameScenario(final Scenario scenario) {
1466 getScenarioDAO().merge(scenario);
1471 * @see org.splat.service.ScenarioService#removeScenario(long)
1474 public void removeScenario(final long scenarioId) {
1475 Scenario scenario = getScenarioDAO().get(scenarioId);
1476 Study study = scenario.getOwnerStudy();
1478 if (scenario != null && study != null) {
1479 getScenarioDAO().delete(scenario);
1481 // Collect all documents which are published in another scenario
1482 // or are previous versions of documents published in another scenario
1483 Set<Document> untouched = new HashSet<Document>();
1485 List<Scenario> otherScenarios = study.getScenariiList();
1486 otherScenarios.remove(scenario);
1488 for (Scenario otherScenario : otherScenarios) {
1489 for (Publication publication : otherScenario.getDocums()) {
1490 for (Document document = publication.value(); document != null;
1491 document = document.getPreviousVersion()) {
1492 untouched.add(document);
1497 // Collect all documents which are published in this scenario
1498 // or are previous versions of documents published in this scenario
1499 Set<Document> toRemove = new HashSet<Document>();
1500 for (Publication publication : scenario.getDocums()) {
1501 for (Document document = publication.value(); document != null;
1502 document = document.getPreviousVersion()) {
1503 toRemove.add(document);
1507 toRemove.removeAll(untouched);
1509 // Delete all necessary documents
1510 for (Document document : toRemove) {
1511 _documentDAO.delete(document);
1517 * Get the knowledgeElementDAO.
1519 * @return the knowledgeElementDAO
1521 public KnowledgeElementDAO getKnowledgeElementDAO() {
1522 return _knowledgeElementDAO;
1526 * Set the knowledgeElementDAO.
1528 * @param knowledgeElementDAO
1529 * the knowledgeElementDAO to set
1531 public void setKnowledgeElementDAO(
1532 final KnowledgeElementDAO knowledgeElementDAO) {
1533 _knowledgeElementDAO = knowledgeElementDAO;
1537 * Get the indexService.
1539 * @return the indexService
1541 public IndexService getIndexService() {
1542 return _indexService;
1546 * Set the indexService.
1548 * @param indexService
1549 * the indexService to set
1551 public void setIndexService(final IndexService indexService) {
1552 _indexService = indexService;
1556 * Get the scenarioDAO.
1558 * @return the scenarioDAO
1560 public ScenarioDAO getScenarioDAO() {
1561 return _scenarioDAO;
1565 * Set the scenarioDAO.
1567 * @param scenarioDAO
1568 * the scenarioDAO to set
1570 public void setScenarioDAO(final ScenarioDAO scenarioDAO) {
1571 _scenarioDAO = scenarioDAO;
1577 * @return the studyDAO
1579 public StudyDAO getStudyDAO() {
1587 * the studyDAO to set
1589 public void setStudyDAO(final StudyDAO studyDAO) {
1590 _studyDAO = studyDAO;
1594 * Get the knowledgeElementTypeService.
1596 * @return the knowledgeElementTypeService
1598 public KnowledgeElementTypeService getKnowledgeElementTypeService() {
1599 return _knowledgeElementTypeService;
1603 * Set the knowledgeElementTypeService.
1605 * @param knowledgeElementTypeService
1606 * the knowledgeElementTypeService to set
1608 public void setKnowledgeElementTypeService(
1609 final KnowledgeElementTypeService knowledgeElementTypeService) {
1610 _knowledgeElementTypeService = knowledgeElementTypeService;
1614 * Get the studyService.
1616 * @return the studyService
1618 public StudyService getStudyService() {
1619 return _studyService;
1623 * Set the studyService.
1625 * @param studyService
1626 * the studyService to set
1628 public void setStudyService(final StudyService studyService) {
1629 _studyService = studyService;
1633 * Get the userService.
1635 * @return the userService
1637 public UserService getUserService() {
1638 return _userService;
1642 * Set the userService.
1644 * @param userService
1645 * the userService to set
1647 public void setUserService(final UserService userService) {
1648 _userService = userService;
1654 * @return the userDAO
1656 public UserDAO getUserDAO() {
1664 * the userDAO to set
1666 public void setUserDAO(final UserDAO userDAO) {
1671 * Get the knowledgeElementTypeDAO.
1673 * @return the knowledgeElementTypeDAO
1675 public KnowledgeElementTypeDAO getKnowledgeElementTypeDAO() {
1676 return _knowledgeElementTypeDAO;
1680 * Set the knowledgeElementTypeDAO.
1682 * @param knowledgeElementTypeDAO
1683 * the knowledgeElementTypeDAO to set
1685 public void setKnowledgeElementTypeDAO(
1686 final KnowledgeElementTypeDAO knowledgeElementTypeDAO) {
1687 _knowledgeElementTypeDAO = knowledgeElementTypeDAO;
1691 * Get the documentDAO.
1692 * @return the documentDAO
1694 public DocumentDAO getDocumentDAO() {
1695 return _documentDAO;
1699 * Set the documentDAO.
1700 * @param documentDAO the documentDAO to set
1702 public void setDocumentDAO(final DocumentDAO documentDAO) {
1703 _documentDAO = documentDAO;
1707 * Get the simulationContextService.
1709 * @return the simulationContextService
1711 public SimulationContextService getSimulationContextService() {
1712 return _simulationContextService;
1716 * Set the simulationContextService.
1718 * @param simulationContextService
1719 * the simulationContextService to set
1721 public void setSimulationContextService(
1722 final SimulationContextService simulationContextService) {
1723 _simulationContextService = simulationContextService;
1727 * Get project settings.
1729 * @return Project settings service
1731 private ProjectSettingsService getProjectSettings() {
1732 return _projectSettings;
1736 * Set project settings service.
1738 * @param projectSettingsService
1739 * project settings service
1741 public void setProjectSettings(
1742 final ProjectSettingsService projectSettingsService) {
1743 _projectSettings = projectSettingsService;
1747 * Get the documentTypeService.
1749 * @return the documentTypeService
1751 public DocumentTypeService getDocumentTypeService() {
1752 return _documentTypeService;
1756 * Set the documentTypeService.
1758 * @param documentTypeService
1759 * the documentTypeService to set
1761 public void setDocumentTypeService(
1762 final DocumentTypeService documentTypeService) {
1763 _documentTypeService = documentTypeService;
1769 * @return the roleDAO
1771 public RoleDAO getRoleDAO() {
1779 * the roleDAO to set
1781 public void setRoleDAO(final RoleDAO roleDAO) {
1786 * Get the simulationContextTypeService.
1788 * @return the simulationContextTypeService
1790 public SimulationContextTypeService getSimulationContextTypeService() {
1791 return _simulationContextTypeService;
1795 * Set the simulationContextTypeService.
1797 * @param simulationContextTypeService
1798 * the simulationContextTypeService to set
1800 public void setSimulationContextTypeService(
1801 final SimulationContextTypeService simulationContextTypeService) {
1802 _simulationContextTypeService = simulationContextTypeService;
1806 * Get the validationCycleDAO.
1808 * @return the validationCycleDAO
1810 public ValidationCycleDAO getValidationCycleDAO() {
1811 return _validationCycleDAO;
1815 * Set the validationCycleDAO.
1817 * @param validationCycleDAO
1818 * the validationCycleDAO to set
1820 public void setValidationCycleDAO(
1821 final ValidationCycleDAO validationCycleDAO) {
1822 _validationCycleDAO = validationCycleDAO;
1828 * @return steps config service
1830 private StepsConfigService getStepsConfigService() {
1831 return _stepsConfigService;
1835 * Set steps config service.
1837 * @param stepsConfigService
1838 * steps config service
1840 public void setStepsConfigService(
1841 final StepsConfigService stepsConfigService) {
1842 _stepsConfigService = stepsConfigService;
1846 * Get the repositoryService.
1848 * @return the repositoryService
1850 public RepositoryService getRepositoryService() {
1851 return _repositoryService;
1855 * Set the repositoryService.
1857 * @param repositoryService
1858 * the repositoryService to set
1860 public void setRepositoryService(final RepositoryService repositoryService) {
1861 _repositoryService = repositoryService;