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;
196 * Get a new id to document arriver after check-out.
197 * Return two several values: -1 or ID of the existing document.
201 * @param activityNumber
202 * the number of activity
207 * @return new document id or -1 if same document do nor exist.
208 * @throws InvalidPropertyException if activityNumber is incorrect.
212 public final long getNewDocumentId(final long scenId,
213 final int activityNumber, final Long docId,
214 final String fileExt) throws InvalidPropertyException {
216 Scenario aScenario = getScenarioDAO().get(scenId);
217 Step[] steps = getProjectElementService().getSteps(aScenario);
218 Step currentStep = null;
219 for (Step step : steps) {
220 if (step.getNumber() == activityNumber) {
225 if (currentStep == null) {
226 throw new InvalidPropertyException(
227 MessageKeyEnum.SCN_000001.toString(), activityNumber);
232 ProjectSettingsService.Step stepType = currentStep.getStep();
233 DocumentType documentType = _projectSettings
234 .getDefaultDocumentType(stepType, fileExt);
235 if (currentStep.getDocument(docId).value().getType()
236 .equals(documentType)) {
239 List<Publication> allDocs = currentStep.getAllDocuments();
240 for (Publication publication : allDocs) {
241 if (publication.value().getType().equals(documentType)
242 && publication.value().getIndex() > resId) {
243 resId = publication.value().getIndex();
252 * Get the projectElementService.
254 * @return the projectElementService
256 public ProjectElementService getProjectElementService() {
257 return _projectElementService;
261 * Set the projectElementService.
263 * @param projectElementService
264 * the projectElementService to set
266 public void setProjectElementService(
267 final ProjectElementService projectElementService) {
268 _projectElementService = projectElementService;
272 * Get the publicationService.
274 * @return the publicationService
276 public PublicationService getPublicationService() {
277 return _publicationService;
281 * Set the publicationService.
283 * @param publicationService
284 * the publicationService to set
286 public void setPublicationService(
287 final PublicationService publicationService) {
288 _publicationService = publicationService;
292 * Get the stepService.
294 * @return the stepService
296 public StepService getStepService() {
301 * Set the stepService.
304 * the stepService to set
306 public void setStepService(final StepService stepService) {
307 _stepService = stepService;
313 * @see org.splat.service.ScenarioService#getStudyScenarios(java.lang.Long)
316 @Transactional(readOnly = true)
317 public List<ScenarioDTO> getStudyScenarios(final Long studyId) {
318 DetachedCriteria query = DetachedCriteria
319 .forClass(Scenario.class, "scen")
320 .add(Restrictions.eq("owner.rid", studyId))
324 .add(Projections.property("scen.title"),
326 .add(Projections.property("scen.rid"), "index"))
327 .setResultTransformer(
328 Transformers.aliasToBean(ScenarioDTO.class));
329 return getScenarioDAO().getFilteredDTOList(query);
335 * @see org.splat.service.ScenarioService#copyStudyContent(long, long, int,
340 public void copyStudyContent(final long fromStudyId, final long fromScenId,
341 final int finalStepNum, final long toStudyId)
342 throws InvalidParameterException, MissedPropertyException,
343 InvalidPropertyException, MultiplyDefinedException,
344 NotApplicableException, IOException {
345 Study fromStudy = getStudyService().selectStudy(fromStudyId);
346 if (fromStudy == null) {
347 throw new InvalidParameterException(
348 MessageKeyEnum.STD_000002.toString(),
349 String.valueOf(fromStudyId));
351 Scenario fromScen = null;
352 for (Scenario scen : fromStudy.getScenariiList()) {
353 if (scen.getIndex() == fromScenId) {
359 Study toStudy = getStudyService().selectStudy(toStudyId);
360 if (toStudy == null) {
361 throw new InvalidParameterException(
362 MessageKeyEnum.STD_000002.toString(),
363 String.valueOf(toStudy));
366 // Check if the step is applied to a scenario and scenario is defined
368 && getStepsConfigService().stepInvolves(finalStepNum,
370 throw new InvalidParameterException(
371 MessageKeyEnum.SCN_000006.toString(),
372 String.valueOf(fromScenId));
375 // Copy validation cycles
376 copyValidationCycles(fromStudy, toStudy);
378 // Copy content of the study up to the given step
379 Map<Publication, Publication> oldToNewPub = new HashMap<Publication, Publication>();
380 copyDocs(fromStudy, toStudy, finalStepNum, oldToNewPub);
381 if (fromScen != null) {
382 copyDocs(fromScen, toStudy.getScenariiList().get(0), finalStepNum,
385 copyDependencies(fromStudy, finalStepNum, oldToNewPub);
386 if (fromScen != null) {
387 copyDependencies(fromScen, finalStepNum, oldToNewPub);
392 * Copy validation cycles from study to study.
397 * the destination study
399 private void copyValidationCycles(final Study fromStudy, final Study toStudy) {
400 for (ValidationCycle fromCycle : fromStudy.getValidationCycles()
402 if (fromCycle.isAssigned()) {
403 ValidationCycle cycle = fromCycle.clone(toStudy);
404 getValidationCycleDAO().create(cycle);
405 toStudy.addRelation(cycle.getContext());
406 toStudy.getValidationCycles().put(
407 cycle.getDocumentType().getName(), cycle); // Replaces
417 * Copy dependencies between documents from the given project element up to <BR>
418 * the given step according to the given map of old publications to new
422 * the source project element
423 * @param finalStepNum
424 * the final step for copy processing
426 * the old to new publications map
428 private void copyDependencies(final ProjectElement from,
429 final int finalStepNum,
430 final Map<Publication, Publication> oldToNewPub) {
431 // Copy dependencies between copied documents
432 for (Publication pub : from.getDocums()) {
433 // If the document in the step before the final one
434 if (pub.value().getStep() <= finalStepNum) {
435 Publication newPub = oldToNewPub.get(pub);
436 for (Publication used : pub.getRelations(UsesRelation.class)) {
437 newPub.addDependency(oldToNewPub.get(used));
444 * Copy documents with dependencies up to the given step.
447 * the source project element
449 * the destination project element
450 * @param finalStepNum
451 * the final step for copy process
452 * @param oldToNewPub2
453 * @throws MissedPropertyException
454 * if document creation is failed
455 * @throws InvalidPropertyException
456 * if document creation is failed
457 * @throws MultiplyDefinedException
458 * if document creation is failed
459 * @throws IOException
460 * if document file creation is failed
461 * @throws NotApplicableException
462 * if document state is not applicable
464 * the old to new publications map
467 private void copyDocs(final ProjectElement from, final ProjectElement to,
468 final int finalStepNum,
469 final Map<Publication, Publication> oldToNewPub)
470 throws MissedPropertyException, InvalidPropertyException,
471 MultiplyDefinedException, NotApplicableException, IOException {
472 Map<Integer, Step> steps = getProjectElementService().getStepsMap(to);
473 // Copy publications without old versions and relations to not copied
475 for (Publication pub : from.getDocums()) {
476 // If the document in the step before the final one
477 if (pub.value().getStep() <= finalStepNum) {
481 createDoc(pub.value(),
482 steps.get(pub.value().getStep())));
488 * Create a copy of the given document and publish it in the given step.
491 * the source document
493 * the destination step
494 * @return the created publication
495 * @throws MissedPropertyException
496 * if document creation is failed
497 * @throws InvalidPropertyException
498 * if document creation is failed
499 * @throws MultiplyDefinedException
500 * if document creation is failed
501 * @throws IOException
502 * if document file creation is failed
503 * @throws NotApplicableException
504 * if document state is not applicable
506 private Publication createDoc(final Document fromDoc, final Step step)
507 throws MissedPropertyException, InvalidPropertyException,
508 MultiplyDefinedException, IOException, NotApplicableException {
510 java.io.File srcFile = fromDoc.getSourceFile().asFile();
511 // Creation of the document
512 Document.Properties dprop = new Document.Properties()
513 .setName(fromDoc.getTitle()).setType(fromDoc.getType())
514 .setFormat(fromDoc.getFormat()).setAuthor(fromDoc.getAuthor());
516 java.io.File tmpDir = getRepositoryService().getDownloadDirectory(
517 step.getOwnerStudy().getAuthor());
519 // Remove local file index prefix to get original filename.
520 java.io.File upfile = new java.io.File(tmpDir.getPath()
522 + srcFile.getName().substring(
523 srcFile.getName().indexOf('_') + 1));
524 // Copy the source file into the temporary folder with original
526 copyFile(srcFile, upfile);
528 dprop.setLocalPath(upfile.getPath());
529 Publication addoc = getStepService().createDocument(step, dprop);
531 // Move the temporary file into the repository
532 moveFile(upfile, addoc.getSourceFile().asFile());
534 getPublicationService().saveAs(addoc, fromDoc.getProgressState());
536 // Copy attached files
537 for (Relation rel : fromDoc.getRelations(ConvertsRelation.class)) {
538 File attach = ((ConvertsRelation) rel).getTo();
539 ConvertsRelation export = getPublicationService().attach(addoc,
541 // Copy the source document attachment file to the new study vault
542 copyFile(attach.asFile(), export.getTo().asFile());
548 * Copy a file. Print info message.
554 * @throws IOException
557 private void copyFile(final java.io.File upfile, final java.io.File file)
559 if (LOG.isInfoEnabled()) {
560 LOG.info("Copy " + upfile.getAbsolutePath() + TO + file.getPath());
562 IOUtils.copy(upfile, file);
566 * Copy a file. Print info message.
572 * @return true if renamed otherwise return false
574 private boolean moveFile(final java.io.File upfile, final java.io.File file) {
575 if (LOG.isInfoEnabled()) {
576 LOG.info("Move " + upfile.getAbsolutePath() + TO + file.getPath());
578 file.delete(); // necessary on some platforms if the file exists.
579 return upfile.renameTo(file);
585 * @see org.splat.service.ScenarioService#getScenarioInfo(long)
587 @Transactional(readOnly = true)
588 public List<StepDTO> getScenarioInfo(final long scenarioId) {
589 List<StepDTO> res = new ArrayList<StepDTO>();
590 // Get the scenario from the database by id
591 Scenario scen = getScenarioDAO().get(scenarioId);
592 if (LOG.isDebugEnabled()) {
593 LOG.debug("Scenario[" + scenarioId + "]: Number of publications: "
594 + scen.getDocums().size());
596 // Get activities of the scenario
597 Step[] steps = getProjectElementService().getSteps(scen);
600 String docType, fileFormat;
603 // For each activity create a step DTO and add it to the result list
604 for (Step step : steps) {
605 stepDTO = BeanHelper.copyBean(step.getStep(), StepDTO.class);
607 if (LOG.isDebugEnabled()) {
608 LOG.debug("Step[" + stepDTO.getNumber()
609 + "]: Number of documents: "
610 + step.getDocuments().size());
612 // For each publication of the activity create a document DTO.
613 // Each file is considered as a source file.
614 for (Publication tag : step.getDocuments()) {
615 docDTO = stepDTO.addDoc(tag.value().getIndex(), tag.value()
617 char aState = tag.getIsnew();
618 docType = tag.value().getType().getName();
619 // For each file of the document create a file DTO
620 // Process source file of the document
621 fileFormat = tag.value().getFile().getFormat();
622 doImport = getProjectSettings().doImport(docType, fileFormat);
623 if (doImport && (!tag.isOutdated())) {
624 processing = "file-import";
626 processing = "file-download";
628 File aFile = tag.value().getFile();
629 docDTO.addFile(aFile.getIndex(), aFile.getRelativePath(),
630 aState, processing, false);
631 // Process all exported files
632 for (Relation rel : tag.value().getRelations(
633 ConvertsRelation.class)) {
634 aFile = ((ConvertsRelation) rel).getTo();
635 fileFormat = aFile.getFormat();
636 doImport = getProjectSettings().doImport(docType,
638 if (doImport && (!tag.isOutdated())) {
639 processing = "file-import";
641 processing = "file-download";
643 docDTO.addFile(aFile.getIndex(), aFile.getRelativePath(),
644 aState, processing, false);
654 * @see org.splat.service.ScenarioService#createStudy(java.lang.String,
655 * java.lang.String, java.lang.String, java.lang.String)
658 public long createStudy(final String username, final String title,
659 final String productName, final String description)
660 throws InvalidPropertyException, MissedPropertyException,
661 MultiplyDefinedException {
665 User author = getUserService().selectUser(username);
666 if (author == null) {
668 throw new InvalidPropertyException(
669 MessageKeyEnum.USR_000001.toString(), username);
672 // Set the study properties
673 Study.Properties sprop = new Study.Properties();
674 sprop.setTitle(title).setManager(author);
675 sprop.setDescription(description);
677 // Find the product simulation context
678 SimulationContextType productContextType = getSimulationContextService()
679 .selectType("product");
680 SimulationContext.Properties cprop = new SimulationContext.Properties();
681 cprop.setType(productContextType).setValue(productName);
682 SimulationContext productCtx = getSimulationContextService()
683 .selectSimulationContext(productContextType, productName);
684 if (productCtx != null) {
685 cprop.setIndex(productCtx.getIndex());
688 // Set a first scenario properties
689 Scenario.Properties oprop = new Scenario.Properties();
690 oprop.setTitle(I18nUtils.getMessageLocaleDefault("label.scenario")
693 Study study = createStudy(sprop, oprop, cprop);
694 id = study.getIndex();
700 * Create a new study with one scenario and "product" simulation context.
703 * the study properties
705 * the scenario properties
707 * the "product" simulation context properties
708 * @return the created study
709 * @throws MissedPropertyException
710 * if a mandatory property is missed
711 * @throws InvalidPropertyException
712 * if a property is invalid
713 * @throws MultiplyDefinedException
714 * if some property occurs several times
717 public Study createStudy(final Study.Properties sprop,
718 final Scenario.Properties oprop,
719 final SimulationContext.Properties cprop)
720 throws MissedPropertyException, InvalidPropertyException,
721 MultiplyDefinedException {
722 Study study = getStudyService().createStudy(sprop);
723 addScenario(study, oprop);
724 if (cprop.getIndex() == 0) { // Input of new project context
725 cprop.setType(getSimulationContextService().selectType("product"))
726 .setValue(cprop.getValue());
727 getStudyService().addProjectContext(study, cprop);
728 } else { // Selection of existing project context
729 SimulationContext context = getSimulationContextService()
730 .selectSimulationContext(cprop.getIndex());
731 getStudyService().addProjectContext(study, context);
739 * @see org.splat.service.ScenarioService#assignStudyContext(java.lang.Long,
740 * java.lang.String, java.lang.String)
743 public void assignStudyContext(final Long studyId, final String ctxType,
744 final String ctxValue) throws MissedPropertyException,
745 InvalidPropertyException, MultiplyDefinedException {
746 // Find the study by the given id
747 Study study = getStudyDAO().get(studyId);
749 throw new InvalidPropertyException(
750 MessageKeyEnum.STD_000002.toString(), studyId);
752 // Find the context type by its name
753 SimulationContextType celt = getSimulationContextService().selectType(
756 // Creation of a new context type
757 celt = getSimulationContextTypeService().createType(ctxType,
758 getProjectElementService().getFirstStep(study).getStep());
760 // Find the given context value of the given type
761 SimulationContext context = getSimulationContextService()
762 .selectSimulationContext(celt, ctxValue);
763 if (context == null) { // Input of a new project context
764 SimulationContext.Properties cprop = new SimulationContext.Properties();
765 cprop.setType(celt).setValue(ctxValue);
766 getStudyService().addProjectContext(study, cprop);
767 } else { // Selection of existing project context
768 getStudyService().addProjectContext(study, context);
775 * @see org.splat.service.ScenarioService#addKnowledgeElement(org.splat.dal.bo.som.Scenario,
776 * org.splat.dal.bo.som.KnowledgeElement.Properties)
779 public KnowledgeElement addKnowledgeElement(final Scenario aScenarioDTO,
780 final KnowledgeElement.Properties kprop)
781 throws MissedPropertyException, InvalidPropertyException,
782 MultiplyDefinedException {
783 KnowledgeElement kelm = null;
785 long aScenarioId = aScenarioDTO.getIndex();
786 if (LOG.isDebugEnabled()) {
787 LOG.debug("Add a knowledge element to the scenario #" + aScenarioId);
789 // Get the persistent scenario.
790 Scenario aScenario = getScenarioDAO().get(aScenarioId);
791 // Get persistent objects for creating a new knowledge.
792 // TODO: Actions must use DTO instead of persistent objects.
793 getUserDAO().merge(kprop.getAuthor());
794 getKnowledgeElementTypeDAO().merge(kprop.getType());
795 // Create a transient knowledge element related to the given scenario.
796 kelm = new KnowledgeElement(kprop.setOwnerScenario(aScenario));
797 // Save the new knowledge in the database.
798 getKnowledgeElementDAO().create(kelm);
799 // Update scenario transient data.
800 if (kelm.getType().equals("usecase")) {
801 aScenarioDTO.setUcase(kelm);
802 } else if (aScenarioDTO.getKnowledgeElementsList() != null) { // If
809 aScenarioDTO.getKnowledgeElementsList().add(kelm);
812 // Load the workflow for the parent study to take into account
813 // all study actors durng reindexing.
814 getStudyService().loadWorkflow(aScenario.getOwnerStudy());
816 // // Update the lucene index of knowledge elements.
817 // getIndexService().add(kelm);
818 if (LOG.isDebugEnabled()) {
819 LOG.debug("A knowledge element #" + kelm.getIndex()
820 + " is added to the scenario #" + aScenario.getIndex());
822 // } catch (IOException error) {
823 // LOG.error("Unable to index the knowedge element '"
824 // + kelm.getIndex() + "', reason:", error);
834 * @see org.splat.service.ScenarioService#checkin(long, long,
838 public void checkin(final long scenId, final long userId,
839 final List<StepDTO> scInfo) throws InvalidPropertyException,
840 MissedPropertyException, MultiplyDefinedException,
841 MismatchException, IOException, NotApplicableException {
842 // Get the scenario from the database by id
843 Scenario aScenario = getScenarioDAO().get(scenId);
844 // Get the user who perform this check-in operation
845 User aUser = getUserService().selectUser(userId);
846 // Get activities of the scenario
847 Step[] steps = getProjectElementService().getSteps(aScenario);
848 // Find result document types
849 List<DocumentType> resTypes = getDocumentTypeService()
850 .selectResultTypes();
852 // Keep newly created documents to create uses relations to results of a
854 // For each processed existing document keep its new version
855 Map<Document, Document> newVersion = new HashMap<Document, Document>();
856 // Created publications of new created versions of existing documents
857 List<Publication> newVers = new ArrayList<Publication>();
858 // The list of publications of new created documents not existing before
860 List<Publication> newDocs = new ArrayList<Publication>();
862 DocumentType resType;
863 Date aDate = new Date(); // The timestamp of the checkin operation
864 for (StepDTO stepDTO : scInfo) {
865 if (LOG.isDebugEnabled()) {
866 LOG.debug("Checkin the step:\n" + stepDTO);
868 if (stepDTO.getDocs().size() == 0) {
871 // Find a result document type of the step
875 if (resTypes.get(i).isResultOf(
876 getProjectSettings().getStep(stepDTO.getNumber()))) {
877 resType = resTypes.get(i);
880 } while ((resType == null) && (i < resTypes.size()));
882 // Find the appropriate scenario step
883 Step step = findStep(stepDTO, steps);
885 List<FileDTO> filesToBeAttached = new ArrayList<FileDTO>();
886 FileDTO fileToAttachTo = null; // all the rest documents will be
889 // The id is the same for all DocumentDTOs of a step
890 Long currentDocId = stepDTO.getDocs().get(0).getId();
891 if (currentDocId != null && currentDocId > 0) { // there is a result
894 String currentFormat = step.getDocument(currentDocId).value()
897 // Process each document of the step
898 for (DocumentDTO doc : stepDTO.getDocs()) {
899 for (FileDTO fileDTO : doc.getFiles()) {
901 String path = fileDTO.getPath();
903 .substring(path.lastIndexOf('.') + 1);
905 // If it has the same format as current doc (there can
906 // be just one such file)
907 // then this doc will be DocToAttachTo.
908 if (format != null && format.equals(currentFormat)) {
909 fileToAttachTo = fileDTO;
911 // Else, put it in the list of docs that will be
912 // attached to DocToAttachTo
913 filesToBeAttached.add(fileDTO);
918 // Process each document of the step
919 for (DocumentDTO doc : stepDTO.getDocs()) {
920 for (FileDTO fileDTO : doc.getFiles()) {
921 String path = doc.getFiles().get(0).getPath();
923 .substring(path.lastIndexOf('.') + 1);
925 ProjectSettingsService.Step stepType = step.getStep();
926 // If the default type for its format in the current
927 // step is the result type,
928 // then this doc will be DocToAttachTo.
929 DocumentType defaultDocType = _projectSettings
930 .getDefaultDocumentType(stepType, format);
931 if (defaultDocType != null
932 && defaultDocType.isResultOf(stepType)) {
933 // It is possible that there is not just one such
935 if (fileToAttachTo != null) {
936 filesToBeAttached.add(fileToAttachTo);
938 fileToAttachTo = fileDTO;
940 // Else, put it in the list of docs that will be
941 // attached to DocToAttachTo
942 filesToBeAttached.add(fileDTO);
947 // could not find any file with appropriate format
948 if (fileToAttachTo == null && !filesToBeAttached.isEmpty()) {
949 // All the rest documents will be attached to the first in
951 fileToAttachTo = filesToBeAttached.get(0);
952 filesToBeAttached.remove(0);
956 if (fileToAttachTo != null) { // true if the DocumentDTO list is not
959 // Process docToAttachTo
960 Publication pub = checkinDoc(step, fileToAttachTo,
961 currentDocId, aUser, resType, aDate, newVersion,
963 currentDocId = pub.value().getIndex();
967 for (FileDTO file : filesToBeAttached) {
968 checkinDoc(step, file, currentDocId, aUser, resType, aDate,
969 newVersion, newVers, newDocs);
973 // Set uses/used relations
974 updateRelationsAfterCheckin(aScenario, newVersion, newVers, newDocs);
976 // Mark the scenario as checked in
981 * Updated uses/used relations after checkin operation:<BR>
983 * <li>For each new version copy uses relations from the previous version.</li>
984 * <li>Outdate documents which depend from the previous version and were not
985 * checked in during this operation.</li>
986 * <li>For each new document create uses relation to the last versions of
987 * results of the previous step.</li>
991 * the checked in scenario
993 * the mapping of documents existed before the checkin to their
994 * new created versions
996 * the list of publications of new created versions of documents
997 * existed before the checkin
999 * the list of publications of new created documents not existed
1000 * before the checkin
1002 private void updateRelationsAfterCheckin(final Scenario aScenario,
1003 final Map<Document, Document> newVersion,
1004 final List<Publication> newVers, final List<Publication> newDocs) {
1005 // For each new version copy uses relations from the previous version.
1006 for (Publication newVer : newVers) {
1007 // For each Uses relation of the previous version
1008 Document prevDoc = newVer.value().getPreviousVersion();// prevVersion.get(newVer);
1009 if (LOG.isDebugEnabled()) {
1010 LOG.debug("Previous version for publication #"
1011 + newVer.getIndex() + " is found: " + prevDoc);
1013 List<Relation> usesRelations = prevDoc
1014 .getRelations(UsesRelation.class);
1015 for (Relation rel : usesRelations) {
1016 // If used document has been also versioned then refer to its
1018 Document usedDoc = ((UsesRelation) rel).getTo();
1019 if (newVersion.containsKey(usedDoc)) {
1020 usedDoc = newVersion.get(usedDoc);
1022 // Build the appropriate relation for the new version.
1023 newVer.addDependency(usedDoc);
1025 // Outdate documents which depend from the previous version and
1026 // were not checked in during this operation.
1027 // 1. Get all usedBy relations of the previous document version
1028 for (Relation rel : prevDoc.getRelations(UsedByRelation.class)) {
1029 Document using = ((UsedByRelation) rel).getTo();
1030 // Check that not checked in dependent documents became outdated
1031 Publication usingPub = aScenario.getPublication(using);
1032 if (usingPub != null) { // if the document using the old version
1033 // is still published
1034 usingPub.setIsnew('O');
1039 // For each new document create uses relation to the last versions of
1040 // results of the previous step.
1041 for (Publication newPub : newDocs) {
1042 // Find used document type according to the configuration.
1043 Set<DocumentType> usedTypes = newPub.value().getType()
1045 // Find documents of used type in the previous study step.
1046 for (Publication pub : aScenario.getDocums()) {
1047 if ((pub.getStep().getNumber() <= newPub.getStep().getNumber())
1048 && (!pub.isOutdated())
1049 && usedTypes.contains(pub.value().getType())
1050 && !newPub.equals(pub)) {
1051 // Create uses relation from the new document
1052 // to the found document in the previous step.
1053 newPub.addDependency(pub);
1060 * Pure checkin of the document without creation of uses/usedBy relations.
1061 * For an existing document a new version is created. New documents become
1062 * published in the given step of the appropriate scenario. The appropriate
1063 * uploaded file is attached to the created document and the document is
1064 * published in the scenario. The publication of the old version is removed
1065 * from the scenario.
1068 * the destination scenario step
1070 * the FilDTO to checkin
1072 * target document id
1074 * the user who performs checkin
1076 * the result document type of the given step
1078 * timestamp of the checkin operation
1080 * the mapping of existing documents to their new created
1083 * the list of publications of new created versions of existing
1086 * the list of publications of new created documents not existing
1087 * before the checkin
1088 * @return the newly created publication, if exists (the document has been
1089 * created or versioned), null otherwise (the doc has been attached
1091 * @throws InvalidPropertyException
1092 * if the scenario hasn't some of given steps or documents
1093 * @throws IOException
1094 * if a file can't be moved into the vault
1095 * @throws MismatchException
1096 * if version creation in some of steps is failed
1097 * @throws MissedPropertyException
1098 * if some mandatory property is missed when new document or new
1099 * document version is created
1100 * @throws MultiplyDefinedException
1101 * if some property is defined several times when new document
1102 * or new document version is created
1103 * @throws NotApplicableException
1104 * if failed saving of a new publication with a given state
1106 private Publication checkinDoc(final Step step, final FileDTO file,
1107 final long docId, final User aUser, final DocumentType resType,
1108 final Date aDate, final Map<Document, Document> newVersion,
1109 final List<Publication> newVers, final List<Publication> newDocs)
1110 throws InvalidPropertyException, MismatchException,
1111 MissedPropertyException, MultiplyDefinedException, IOException,
1112 NotApplicableException {
1113 Publication newPub = null;
1115 Document.Properties dprop = new Document.Properties();
1116 // NOTE: Process only the first attached file for each document
1117 dprop.setLocalPath(file.getPath());
1119 // Get document title as the file name
1120 java.io.File upfile = new java.io.File(file.getPath());
1121 String fileFormat = upfile.getName().substring(
1122 upfile.getName().lastIndexOf('.') + 1);
1124 // Attach the file via ConvertsRelation, create a new document or
1125 // create a new version of the document
1126 dprop.setAuthor(aUser).setDate(aDate).setFormat(fileFormat);
1127 String authorName = I18nUtils.getMessageLocaleDefault(aUser
1129 String summary = I18nUtils.getMessageLocaleDefault(
1130 MessageKeyEnum.DCT_000005.toString(), authorName);
1131 dprop.setDescription(summary);
1134 newPub = checkinExistingDoc(step, docId, dprop, fileFormat,
1135 upfile, newVersion, newVers);
1138 // Otherwise create a new document of the result type
1139 // If result type is not found try to get type by file extension
1140 if (resType == null) {
1141 dprop.setType(getProjectSettings().getDefaultDocumentType(
1142 step.getStep(), fileFormat));
1144 dprop.setType(resType);
1146 // New document title generation as <document type name>_N
1147 String docname = dprop.getType().getName();
1149 for (Publication scenPub : step.getOwner().getDocums()) {
1150 if (scenPub.value().getTitle().startsWith(docname)) {
1154 docname += "_" + i; // The generated new document title
1156 dprop.setName(docname);
1157 newPub = getStepService().createDocument(step, dprop);
1159 // Remember the new document
1160 newDocs.add(newPub);
1162 saveFile(newPub, step, upfile);
1169 * Check in existing document.
1172 * study step to check in
1174 * target document id
1176 * document properties
1178 * checked in file format
1180 * the file to check in
1182 * the map of created versions during this check in
1184 * the list of new versions created during this check in
1185 * @return the newly created publication, if exists (the document has been
1186 * versioned), null otherwise (the doc has been attached to the old
1188 * @throws InvalidPropertyException
1189 * if publication of the document is not found in the step
1190 * @throws MismatchException
1191 * if the found publication does not point to a document
1192 * @throws IOException
1193 * if can not move the file into the vault
1194 * @throws MultiplyDefinedException
1195 * thrown by versionDocument
1196 * @throws MissedPropertyException
1197 * thrown by versionDocument
1198 * @throws NotApplicableException
1199 * if failed saving of a new publication with a given state
1201 private Publication checkinExistingDoc(final Step step, final long docId,
1202 final Properties dprop, final String fileFormat,
1203 final java.io.File upfile,
1204 final Map<Document, Document> newVersion,
1205 final List<Publication> newVers) throws InvalidPropertyException,
1206 MismatchException, MissedPropertyException,
1207 MultiplyDefinedException, IOException, NotApplicableException {
1208 // If the document already exists then
1209 // Attach the file via ConvertsRelation if the extension of the
1210 // new file differs from the old one.
1211 // If file format (i.e. extension) is the same then create a new
1212 // version of the document.
1213 // Find the document publication
1214 // Publication pub = step.getDocument(doc.getId());
1215 Publication pub = step.getDocument(docId);
1216 Publication newPub = null;
1218 throw new InvalidPropertyException(
1219 MessageKeyEnum.SCN_000002.toString(), docId);
1221 if (pub.value() == null) {
1222 throw new MismatchException(MessageKeyEnum.SCN_000002.toString(),
1225 if (LOG.isDebugEnabled()) {
1226 LOG.debug("Old format: " + pub.value().getFormat()
1227 + " => New format: " + fileFormat);
1229 // If formats are same then create a new document version
1230 if (pub.value().getFormat() != null
1231 && pub.value().getFormat().equals(fileFormat)) {
1232 newPub = getStepService().versionDocument(step, pub, dprop);
1233 if (LOG.isDebugEnabled()) {
1234 LOG.debug("Created document type: "
1235 + newPub.value().getType().getName() + ", format: "
1236 + newPub.value().getFormat());
1238 // Remeber the link from the old document to the new document
1240 newVersion.put(pub.value(), newPub.value());
1241 // Remember the new version publication
1242 newVers.add(newPub);
1244 saveFile(newPub, step, upfile);
1246 } else { // If formats are different then attach the new file via
1248 File attach = pub.value().getAttachedFile(fileFormat);
1249 if (attach == null) {
1250 // If there is no attachment with this extension then attach the
1252 ConvertsRelation export = getPublicationService().attach(pub,
1254 moveFile(upfile, export.getTo().asFile());
1256 // If an attachment with this extension already exists then
1257 // replace it by the new one
1258 moveFile(upfile, attach.asFile());
1259 // Update attached file modification date
1260 attach.setDate(new Date());
1267 * Save the file in the vault and create its publication in the step.
1270 * the new publication to save
1272 * the study step to publish the document
1274 * the downloaded file
1275 * @throws IOException
1276 * if a file can't be moved into the vault
1277 * @throws NotApplicableException
1278 * if failed saving of a new publication with a given state
1280 private void saveFile(final Publication newPub, final Step step,
1281 final java.io.File upfile) throws IOException,
1282 NotApplicableException {
1283 // Attach the file to the created document
1284 java.io.File updir = newPub.getSourceFile().asFile();
1285 if (updir.exists()) {
1286 if (updir.delete()) {
1287 LOG.info(MessageKeyEnum.SCN_000003.toString(),
1288 updir.getAbsoluteFile(), step.getOwner().getIndex());
1290 throw new IOException(
1291 "Can't delete the existing destination file to move file from "
1292 + upfile.getAbsolutePath() + TO
1293 + updir.getAbsolutePath());
1296 if (moveFile(upfile, updir)) {
1297 // Save the new publication in the scenario.
1298 // The old publication is removed from the scenario here.
1299 getPublicationService().saveAs(newPub, ProgressState.inWORK); // May
1308 throw new IOException("Can't move file from "
1309 + upfile.getAbsolutePath() + TO + updir.getAbsolutePath());
1314 * Find appropriate step in the array of scenario steps according to the
1321 * @return appropriate scenario step
1322 * @throws InvalidPropertyException
1323 * if appropriate step is not found
1325 private Step findStep(final StepDTO stepDTO, final Step[] steps)
1326 throws InvalidPropertyException {
1330 if (steps[i].getNumber() == stepDTO.getNumber()) {
1334 } while ((step == null) && (i < steps.length));
1337 throw new InvalidPropertyException(
1338 MessageKeyEnum.SCN_000001.toString(), stepDTO.getNumber());
1346 * @see org.splat.service.ScenarioService#checkin(long)
1349 public void checkin(final long scenarioId) throws InvalidPropertyException {
1350 Scenario aScenario = getScenarioDAO().get(scenarioId);
1351 if (aScenario == null) {
1352 // Scenario not found
1353 throw new InvalidPropertyException(
1354 MessageKeyEnum.SCN_000006.toString(), scenarioId);
1360 * Mark the scenario as checked in.
1363 * the scenario to check in.
1365 private void checkin(final Scenario aScenario) {
1366 aScenario.setUser(null);
1367 aScenario.setLastModificationDate(Calendar.getInstance().getTime());
1368 // getScenarioDAO().update(aScenario);
1374 * @see org.splat.service.ScenarioService#checkout(org.splat.dal.bo.som.Scenario,
1375 * org.splat.dal.bo.kernel.User)
1377 public boolean checkout(final Scenario aScenario, final User user) {
1378 boolean res = getStudyService().isStaffedBy(aScenario.getOwnerStudy(),
1381 aScenario.setUser(user);
1382 aScenario.setLastModificationDate(Calendar.getInstance().getTime());
1383 // RKV: getScenarioDAO().update(aScenario);
1389 * Mark the given scenario as checked out by the given user.
1394 * the id of the user performing the check out
1395 * @throws InvalidPropertyException
1396 * if the user or the scenario is not found in the database
1397 * @throws NotApplicableException
1398 * if the given user can not check out the scenario
1401 public void checkout(final long scenarioId, final long userId)
1402 throws InvalidPropertyException, NotApplicableException {
1403 User aUser = getUserService().selectUser(userId);
1404 if (aUser == null) {
1406 throw new InvalidPropertyException(
1407 MessageKeyEnum.USR_000001.toString(), userId);
1409 Scenario aScenario = getScenarioDAO().get(scenarioId);
1410 if (aScenario == null) {
1411 // Scenario not found
1412 throw new InvalidPropertyException(
1413 MessageKeyEnum.SCN_000006.toString(), scenarioId);
1415 boolean res = getStudyService().isStaffedBy(aScenario.getOwnerStudy(),
1418 if (aScenario.isCheckedout()
1419 && (!aScenario.getUser().getUsername()
1420 .equals(aUser.getUsername()))) {
1421 throw new NotApplicableException(
1422 MessageKeyEnum.SCN_000008.toString(), scenarioId,
1423 aScenario.getUser().getUsername());
1425 aScenario.setUser(aUser);
1426 aScenario.setLastModificationDate(Calendar.getInstance().getTime());
1428 // User doesn't participate in the scenario
1429 throw new NotApplicableException(
1430 MessageKeyEnum.SCN_000007.toString(), aUser.getUsername(),
1438 * @see org.splat.service.ScenarioService#copyContentsUpTo(org.splat.dal.bo.som.Scenario,
1439 * org.splat.som.Step)
1441 public void copyContentsUpTo(final Scenario scenario, final Step lastep) {
1442 Scenario base = (Scenario) lastep.getOwner();
1443 Step[] from = getProjectElementService().getSteps(base);
1444 Step[] to = getProjectElementService().getSteps(scenario);
1445 for (int i = 0; i < from.length; i++) {
1446 Step step = from[i];
1447 if (step.getNumber() > lastep.getNumber()) {
1451 List<Publication> docs = step.getAllDocuments();
1452 for (Iterator<Publication> j = docs.iterator(); j.hasNext();) {
1453 Publication doc = getPublicationService().copy(j.next(),
1454 scenario); // Creation of a new reference to the
1456 // Database.getSession().save(doc); Publications MUST be saved
1457 // later through cascading when saving the scenario
1458 getStepService().add(to[i], doc);
1460 List<SimulationContext> ctex = step.getAllSimulationContexts();
1461 for (Iterator<SimulationContext> j = ctex.iterator(); j.hasNext();) {
1462 getStepService().addSimulationContext(to[i], j.next());
1470 * @see org.splat.service.ScenarioService#isEmpty(org.splat.dal.bo.som.Scenario)
1472 public boolean isEmpty(final Scenario scenario) {
1473 Step[] mystep = getProjectElementService().getSteps(scenario);
1474 boolean isEmp = true;
1475 for (int i = 0; i < mystep.length; i++) {
1476 if (mystep[i].isStarted()) {
1488 public boolean isFinished(final Scenario scenario) {
1489 Step[] mystep = getProjectElementService().getSteps(scenario);
1490 boolean notempty = false; // If this is empty, this is not finished
1491 for (int i = 0; i < mystep.length; i++) {
1492 if (!mystep[i].isStarted()) {
1495 if (!mystep[i].isFinished()) {
1506 * @see org.splat.service.StudyService#addScenario(org.splat.dal.bo.som.Study,
1507 * org.splat.dal.bo.som.Scenario.Properties)
1510 public Scenario addScenario(final Study aStudy,
1511 final Scenario.Properties sprop) throws MissedPropertyException,
1512 InvalidPropertyException, MultiplyDefinedException {
1513 if (sprop.getManager() == null) {
1514 sprop.setManager(aStudy.getAuthor());
1517 Scenario scenario = new Scenario(sprop.setOwnerStudy(aStudy));
1518 if (sprop.getBaseStep() != null) {
1519 copyContentsUpTo(scenario, sprop.getBaseStep());
1521 Scenario previous = sprop.getInsertAfter();
1523 if (previous == null) {
1524 aStudy.getScenariiList().add(scenario);
1526 aStudy.getScenariiList().add(
1527 aStudy.getScenariiList().indexOf(previous) + 1, scenario);
1529 getStudyDAO().update(aStudy); // No need to update the Lucene index
1530 getScenarioDAO().create(scenario); // Must be done after updating this
1531 // study because of the back
1532 // reference to the study
1533 if (sprop.getBaseStep() != null) {
1534 // No need to update the Knowledge Element index as Knowledge
1535 // Elements are not copied
1536 getProjectElementService().refresh(scenario); // Because saving the
1539 // copied Publications
1541 KnowledgeElementType ucase = getKnowledgeElementTypeService()
1542 .selectType("usecase");
1543 KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
1544 // TODO: Get appropriate user by its role: UserService.getAdmin();
1545 // User admin = getUserService().selectUser(1); // First user created
1546 // when creating the database
1547 Role adminRole = getRoleDAO().getFilteredList(
1548 Restrictions.like("role", "%sysadmin%")).get(0);
1549 User admin = getUserDAO().getFilteredList(
1550 Restrictions.eq("role", adminRole), Order.asc("rid")).get(0); // First
1556 kprop.setType(ucase).setTitle(aStudy.getTitle())
1557 .setValue(scenario.getTitle()).setAuthor(admin); // Internal
1565 addKnowledgeElement(scenario, kprop);
1570 * Remove a knowledge element from a scenario.
1575 * the knowledge element to remove
1576 * @return true if removal succeeded
1579 public boolean removeKnowledgeElement(final Scenario scenario,
1580 final KnowledgeElement kelm) {
1581 KnowledgeElement torem = scenario.getKnowledgeElement(kelm.getIndex());
1582 boolean isOk = (torem != null);
1584 isOk = scenario.getKnowledgeElements().remove(torem);
1586 getScenarioDAO().merge(scenario);
1587 // Update of my transient data
1588 // RKV: These transient data are not used indeed.
1589 // RKV: List<KnowledgeElement> kelms =
1590 // scenario.getKnowledgeByType().get(
1591 // RKV: kelm.getType().getIndex());
1592 // RKV: kelms.remove(torem);
1593 if (scenario.getKnowledgeElementsList() != null) {
1594 scenario.getKnowledgeElementsList().remove(torem);
1596 // TODO: If the owner study is not private, remove the knowledge
1597 // from the Lucene index
1607 * @see org.splat.service.ScenarioService#renameScenario(java.lang.String)
1610 public void renameScenario(final Scenario scenario) {
1611 getScenarioDAO().merge(scenario);
1617 * @see org.splat.service.ScenarioService#removeScenario(long)
1620 public void removeScenario(final long scenarioId) {
1621 Scenario scenario = getScenarioDAO().get(scenarioId);
1622 Study study = scenario.getOwnerStudy();
1624 if (scenario != null && study != null) {
1625 getScenarioDAO().delete(scenario);
1627 // Collect all documents which are published in another scenario
1628 // or are previous versions of documents published in another
1630 Set<Document> untouched = new HashSet<Document>();
1632 List<Scenario> otherScenarios = study.getScenariiList();
1633 otherScenarios.remove(scenario);
1635 for (Scenario otherScenario : otherScenarios) {
1636 for (Publication publication : otherScenario.getDocums()) {
1637 for (Document document = publication.value(); document != null; document = document
1638 .getPreviousVersion()) {
1639 untouched.add(document);
1644 // Collect all documents which are published in this scenario
1645 // or are previous versions of documents published in this scenario
1646 Set<Document> toRemove = new HashSet<Document>();
1647 for (Publication publication : scenario.getDocums()) {
1648 for (Document document = publication.value(); document != null; document = document
1649 .getPreviousVersion()) {
1650 toRemove.add(document);
1654 toRemove.removeAll(untouched);
1656 // Delete all necessary documents
1657 for (Document document : toRemove) {
1658 _documentDAO.delete(document);
1664 * Get the knowledgeElementDAO.
1666 * @return the knowledgeElementDAO
1668 public KnowledgeElementDAO getKnowledgeElementDAO() {
1669 return _knowledgeElementDAO;
1673 * Set the knowledgeElementDAO.
1675 * @param knowledgeElementDAO
1676 * the knowledgeElementDAO to set
1678 public void setKnowledgeElementDAO(
1679 final KnowledgeElementDAO knowledgeElementDAO) {
1680 _knowledgeElementDAO = knowledgeElementDAO;
1684 * Get the indexService.
1686 * @return the indexService
1688 public IndexService getIndexService() {
1689 return _indexService;
1693 * Set the indexService.
1695 * @param indexService
1696 * the indexService to set
1698 public void setIndexService(final IndexService indexService) {
1699 _indexService = indexService;
1703 * Get the scenarioDAO.
1705 * @return the scenarioDAO
1707 public ScenarioDAO getScenarioDAO() {
1708 return _scenarioDAO;
1712 * Set the scenarioDAO.
1714 * @param scenarioDAO
1715 * the scenarioDAO to set
1717 public void setScenarioDAO(final ScenarioDAO scenarioDAO) {
1718 _scenarioDAO = scenarioDAO;
1724 * @return the studyDAO
1726 public StudyDAO getStudyDAO() {
1734 * the studyDAO to set
1736 public void setStudyDAO(final StudyDAO studyDAO) {
1737 _studyDAO = studyDAO;
1741 * Get the knowledgeElementTypeService.
1743 * @return the knowledgeElementTypeService
1745 public KnowledgeElementTypeService getKnowledgeElementTypeService() {
1746 return _knowledgeElementTypeService;
1750 * Set the knowledgeElementTypeService.
1752 * @param knowledgeElementTypeService
1753 * the knowledgeElementTypeService to set
1755 public void setKnowledgeElementTypeService(
1756 final KnowledgeElementTypeService knowledgeElementTypeService) {
1757 _knowledgeElementTypeService = knowledgeElementTypeService;
1761 * Get the studyService.
1763 * @return the studyService
1765 public StudyService getStudyService() {
1766 return _studyService;
1770 * Set the studyService.
1772 * @param studyService
1773 * the studyService to set
1775 public void setStudyService(final StudyService studyService) {
1776 _studyService = studyService;
1780 * Get the userService.
1782 * @return the userService
1784 public UserService getUserService() {
1785 return _userService;
1789 * Set the userService.
1791 * @param userService
1792 * the userService to set
1794 public void setUserService(final UserService userService) {
1795 _userService = userService;
1801 * @return the userDAO
1803 public UserDAO getUserDAO() {
1811 * the userDAO to set
1813 public void setUserDAO(final UserDAO userDAO) {
1818 * Get the knowledgeElementTypeDAO.
1820 * @return the knowledgeElementTypeDAO
1822 public KnowledgeElementTypeDAO getKnowledgeElementTypeDAO() {
1823 return _knowledgeElementTypeDAO;
1827 * Set the knowledgeElementTypeDAO.
1829 * @param knowledgeElementTypeDAO
1830 * the knowledgeElementTypeDAO to set
1832 public void setKnowledgeElementTypeDAO(
1833 final KnowledgeElementTypeDAO knowledgeElementTypeDAO) {
1834 _knowledgeElementTypeDAO = knowledgeElementTypeDAO;
1838 * Get the documentDAO.
1840 * @return the documentDAO
1842 public DocumentDAO getDocumentDAO() {
1843 return _documentDAO;
1847 * Set the documentDAO.
1849 * @param documentDAO
1850 * the documentDAO to set
1852 public void setDocumentDAO(final DocumentDAO documentDAO) {
1853 _documentDAO = documentDAO;
1857 * Get the simulationContextService.
1859 * @return the simulationContextService
1861 public SimulationContextService getSimulationContextService() {
1862 return _simulationContextService;
1866 * Set the simulationContextService.
1868 * @param simulationContextService
1869 * the simulationContextService to set
1871 public void setSimulationContextService(
1872 final SimulationContextService simulationContextService) {
1873 _simulationContextService = simulationContextService;
1877 * Get project settings.
1879 * @return Project settings service
1881 private ProjectSettingsService getProjectSettings() {
1882 return _projectSettings;
1886 * Set project settings service.
1888 * @param projectSettingsService
1889 * project settings service
1891 public void setProjectSettings(
1892 final ProjectSettingsService projectSettingsService) {
1893 _projectSettings = projectSettingsService;
1897 * Get the documentTypeService.
1899 * @return the documentTypeService
1901 public DocumentTypeService getDocumentTypeService() {
1902 return _documentTypeService;
1906 * Set the documentTypeService.
1908 * @param documentTypeService
1909 * the documentTypeService to set
1911 public void setDocumentTypeService(
1912 final DocumentTypeService documentTypeService) {
1913 _documentTypeService = documentTypeService;
1919 * @return the roleDAO
1921 public RoleDAO getRoleDAO() {
1929 * the roleDAO to set
1931 public void setRoleDAO(final RoleDAO roleDAO) {
1936 * Get the simulationContextTypeService.
1938 * @return the simulationContextTypeService
1940 public SimulationContextTypeService getSimulationContextTypeService() {
1941 return _simulationContextTypeService;
1945 * Set the simulationContextTypeService.
1947 * @param simulationContextTypeService
1948 * the simulationContextTypeService to set
1950 public void setSimulationContextTypeService(
1951 final SimulationContextTypeService simulationContextTypeService) {
1952 _simulationContextTypeService = simulationContextTypeService;
1956 * Get the validationCycleDAO.
1958 * @return the validationCycleDAO
1960 public ValidationCycleDAO getValidationCycleDAO() {
1961 return _validationCycleDAO;
1965 * Set the validationCycleDAO.
1967 * @param validationCycleDAO
1968 * the validationCycleDAO to set
1970 public void setValidationCycleDAO(
1971 final ValidationCycleDAO validationCycleDAO) {
1972 _validationCycleDAO = validationCycleDAO;
1978 * @return steps config service
1980 private StepsConfigService getStepsConfigService() {
1981 return _stepsConfigService;
1985 * Set steps config service.
1987 * @param stepsConfigService
1988 * steps config service
1990 public void setStepsConfigService(
1991 final StepsConfigService stepsConfigService) {
1992 _stepsConfigService = stepsConfigService;
1996 * Get the repositoryService.
1998 * @return the repositoryService
2000 public RepositoryService getRepositoryService() {
2001 return _repositoryService;
2005 * Set the repositoryService.
2007 * @param repositoryService
2008 * the repositoryService to set
2010 public void setRepositoryService(final RepositoryService repositoryService) {
2011 _repositoryService = repositoryService;