1 /*****************************************************************************
5 * Creation date 02.10.2012
6 * @author Author: Maria KRUCHININA
8 *****************************************************************************/
10 package org.splat.service;
12 import java.io.IOException;
13 import java.text.DecimalFormat;
14 import java.text.SimpleDateFormat;
15 import java.util.Calendar;
16 import java.util.Collections;
17 import java.util.Date;
18 import java.util.Iterator;
19 import java.util.List;
23 import org.hibernate.criterion.Restrictions;
24 import org.splat.dal.bo.kernel.Relation;
25 import org.splat.dal.bo.kernel.User;
26 import org.splat.dal.bo.som.ActorRelation;
27 import org.splat.dal.bo.som.ContributorRelation;
28 import org.splat.dal.bo.som.DescriptionAttribute;
29 import org.splat.dal.bo.som.DocumentType;
30 import org.splat.dal.bo.som.IDBuilder;
31 import org.splat.dal.bo.som.KnowledgeElement;
32 import org.splat.dal.bo.som.ProgressState;
33 import org.splat.dal.bo.som.Publication;
34 import org.splat.dal.bo.som.Scenario;
35 import org.splat.dal.bo.som.SimulationContext;
36 import org.splat.dal.bo.som.Study;
37 import org.splat.dal.bo.som.Study.Properties;
38 import org.splat.dal.bo.som.ValidationCycle;
39 import org.splat.dal.bo.som.ValidationCycle.Actor;
40 import org.splat.dal.bo.som.ValidationCycleRelation;
41 import org.splat.dal.bo.som.ValidationStep;
42 import org.splat.dal.bo.som.Visibility;
43 import org.splat.dal.dao.som.IDBuilderDAO;
44 import org.splat.dal.dao.som.ScenarioDAO;
45 import org.splat.dal.dao.som.StudyDAO;
46 import org.splat.dal.dao.som.ValidationCycleDAO;
47 import org.splat.kernel.InvalidPropertyException;
48 import org.splat.kernel.MissedPropertyException;
49 import org.splat.kernel.MultiplyDefinedException;
50 import org.splat.log.AppLogger;
51 import org.splat.service.technical.IndexService;
52 import org.splat.service.technical.ProjectSettingsService;
53 import org.splat.service.technical.ProjectSettingsServiceImpl;
54 import org.splat.som.Revision;
55 import org.springframework.transaction.annotation.Transactional;
58 * This class defines all methods for creation, modification the study.
60 * @author Maria KRUCHININA
63 public class StudyServiceImpl implements StudyService {
66 * logger for the service.
68 public final static AppLogger LOG = AppLogger
69 .getLogger(StudyServiceImpl.class);
72 * Injected index service.
74 private IndexService _indexService;
77 * Injected step service.
79 private StepService _stepService;
82 * Injected project service.
84 private ProjectSettingsService _projectSettingsService;
87 * Injected project element service.
89 private ProjectElementService _projectElementService;
94 private StudyDAO _studyDAO;
97 * Injected scenario DAO.
99 private ScenarioDAO _scenarioDAO;
102 * Injected validation cycle DAO.
104 private ValidationCycleDAO _validationCycleDAO;
107 * Injected IDBuilder DAO.
109 private IDBuilderDAO _iDBuilderDAO;
112 * Injected document type service.
114 private DocumentTypeService _documentTypeService;
117 * Injected user service.
119 private UserService _userService;
124 * @see org.splat.service.StudyService#selectStudy(long)
127 public Study selectStudy(final long index) {
128 Study result = getStudyDAO().get(index);
129 loadWorkflow(result);
134 * Get study by its reference.
137 * the study reference
138 * @return found study or null
140 @Transactional(readOnly = true)
141 public Study selectStudy(final String refid) {
142 Study result = getStudyDAO().findByCriteria(
143 Restrictions.eq("sid", refid));
144 loadWorkflow(result);
151 * @see org.splat.service.StudyService#createStudy(org.splat.dal.bo.som.Study.Properties)
154 public Study createStudy(final Study.Properties sprop)
155 throws MissedPropertyException, InvalidPropertyException,
156 MultiplyDefinedException {
157 sprop.setReference(getProjectSettings().getReferencePattern());
158 Study study = new Study(sprop);
160 buildReference(study);
161 getStudyDAO().create(study);
163 IndexService lucin = getIndex();
165 } catch (IOException error) {
166 LOG.error("Unable to index the study '" + study.getIndex()
167 + "', reason:", error);
168 // Continue and try to index later
176 * @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext.Properties)
179 public SimulationContext addProjectContext(final Study aStudy,
180 final SimulationContext.Properties cprop)
181 throws MissedPropertyException, InvalidPropertyException,
182 MultiplyDefinedException {
183 SimulationContext added = getStepService().addSimulationContext(
184 getProjectElementService().getFirstStep(aStudy), cprop);
192 * @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext)
195 public SimulationContext addProjectContext(final Study aStudy,
196 final SimulationContext context) {
197 SimulationContext added = getStepService().addSimulationContext(
198 getProjectElementService().getFirstStep(aStudy), context);
206 * @see org.splat.service.StudyService#addContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User)
208 public boolean addContributor(final Study aStudy, final User user) {
209 List<User> contributor = getModifiableContributors(aStudy); // Initializes contributor
210 for (Iterator<User> i = contributor.iterator(); i.hasNext();) {
211 User present = i.next();
212 if (present.equals(user)) {
216 boolean absent = getModifiableActors(aStudy).add(user); // User may already be a reviewer or an approver
218 aStudy.addRelation(new ContributorRelation(aStudy, user));
220 update(aStudy); // Else, useless to re-index the study
222 contributor.add(user);
227 * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
228 * previously be approved.
232 * @return true if the move succeeded.
233 * @see #moveToPublic()
235 * @see Publication#approve(Date)
237 public boolean moveToReference(final Study aStudy) {
238 if (aStudy.getProgressState() != ProgressState.APPROVED) {
241 if (aStudy.getVisibility() != Visibility.PUBLIC) {
245 aStudy.setVisibility(Visibility.REFERENCE);
246 if (update(aStudy)) {
247 return updateKnowledgeElementsIndex(aStudy); // If fails, the database roll-back is under responsibility of the caller
255 * @see org.splat.service.StudyService#update(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.Study.Properties)
257 public boolean update(final Study aStudy, final Properties sprop)
258 throws InvalidPropertyException {
259 if (sprop.getTitle() != null) {
260 aStudy.setTitle(sprop.getTitle());
262 if (sprop.getSummary() != null) {
263 aStudy.setAttribute(new DescriptionAttribute(aStudy, sprop
266 // TODO: To be completed
267 return update(aStudy);
271 * Check if the document is published in the study.
277 * @return true if the document is published in the study
279 /* private boolean publishes(final Study aStudy, final Document doc) {
280 if (!aStudy.publishes(doc)) {
281 Scenario[] scene = aStudy.getScenarii();
282 for (int i = 0; i < scene.length; i++) {
283 if (scene[i].publishes(doc)) {
294 * @see org.splat.service.StudyService#removeContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User[])
296 public boolean removeContributor(final Study aStudy, final User... users) {
297 List<User> contributor = getModifiableContributors(aStudy); // Initializes contributor
298 Boolean done = false;
299 for (int i = 0; i < users.length; i++) {
300 User user = users[i];
301 for (Iterator<User> j = contributor.iterator(); j.hasNext();) {
302 User present = j.next();
303 if (!present.equals(user)) {
307 aStudy.removeRelation(ContributorRelation.class, user);
308 j.remove(); // Updates the contributor shortcut
322 * @see org.splat.service.StudyService#removeProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext)
324 public boolean removeProjectContext(final Study aStudy,
325 final SimulationContext context) {
326 boolean done = getStepService().removeSimulationContext(
327 getProjectElementService().getFirstStep(aStudy), context);
335 * @see org.splat.service.StudyService#setValidationCycle(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.DocumentType,
336 * org.splat.dal.bo.som.ValidationCycle.Properties)
339 public void setValidationCycle(final Study aStudyDTO, final DocumentType type,
340 final ValidationCycle.Properties vprop) {
341 Map<String, ValidationCycle> validactor = aStudyDTO.getValidationCycles();
342 if (validactor == null) {
343 setShortCuts(aStudyDTO); // Initializes validactor and actor
346 Study aStudy = selectStudy(aStudyDTO.getIndex());
348 String cname = type.getName();
349 ValidationCycle cycle = validactor.get(cname);
351 if (cycle != null && cycle.isAssigned()) {
352 resetActors(cycle, vprop);
355 cycle = new ValidationCycle(aStudy, vprop.setDocumentType(type));
357 getValidationCycleDAO().create(cycle); // RKV
359 ValidationCycleRelation link = cycle.getContext();
360 aStudy.addRelation(link);
361 aStudyDTO.getAllRelations().add(link); // RKV
363 validactor.put(cname, link.getTo()); // Replaces the cycle if exists as default,
364 } catch (Exception error) {
365 LOG.error("Unable to re-index Knowledge Elements, reason:",
370 resetActorsShortCut(aStudyDTO);
371 update(aStudy); // Re-index the study, just in case
375 * Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
376 * document of the study.
380 * @return true if the demotion succeeded.
382 public boolean demote(final Study aStudy) {
383 if (aStudy.getProgressState() == ProgressState.inCHECK) {
384 aStudy.setProgressState(ProgressState.inDRAFT);
385 } else if (aStudy.getProgressState() == ProgressState.inDRAFT) {
386 aStudy.setProgressState(ProgressState.inWORK);
390 return update(aStudy);
396 * @see org.splat.service.StudyService#generateLocalIndex(org.splat.dal.bo.som.Study)
399 public int generateLocalIndex(final Study aStudy) {
400 aStudy.setLastLocalIndex(aStudy.getLastLocalIndex() + 1);
401 return aStudy.getLastLocalIndex();
405 * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
406 * final result document of the study.
410 * @return true if the demotion succeeded.
412 public boolean promote(final Study aStudy) {
413 if (aStudy.getProgressState() == ProgressState.inWORK) {
414 aStudy.setProgressState(ProgressState.inDRAFT);
415 } else if (aStudy.getProgressState() == ProgressState.inDRAFT) {
416 aStudy.setProgressState(ProgressState.inCHECK);
417 Revision myvers = new Revision(aStudy.getVersion());
418 if (myvers.isMinor()) {
419 aStudy.setVersion(myvers.incrementAs(aStudy.getProgressState())
422 } else if (aStudy.getProgressState() == ProgressState.inCHECK) {
423 aStudy.setProgressState(ProgressState.APPROVED);
428 return update(aStudy);
432 * Moves this study from the Private to the Public area of the repository.
436 * @return true if the move succeeded.
440 public boolean moveToPublic(final Study aStudy) {
441 boolean isOk = false;
442 if (aStudy.getVisibility() == Visibility.PRIVATE) {
443 aStudy.setVisibility(Visibility.PUBLIC);
444 if (update(aStudy)) {
445 isOk = updateKnowledgeElementsIndex(aStudy); // If fails, the database roll-back is under responsibility of the caller
452 * Moves this study from the Public to the Private area of the repository.
456 * @return true if the move succeeded.
459 public boolean moveToPrivate(final Study aStudy) {
460 boolean isOk = false;
461 if (aStudy.getVisibility() == Visibility.PUBLIC) {
462 aStudy.setVisibility(Visibility.PRIVATE);
463 if (update(aStudy)) {
464 isOk = updateKnowledgeElementsIndex(aStudy); // If fails, the database roll-back is under responsibility of the caller
471 * Update a study in the database.
474 * the study to update
475 * @return true if the study is updated successfully
478 private boolean update(final Study aStudy) {
479 boolean isOk = false;
481 getStudyDAO().merge(aStudy); // Update of relational base
482 setShortCuts(aStudy); // RKV: initialize transient actors set
483 getIndex().update(aStudy); // Update of Lucene index
485 } catch (Exception e) {
486 LOG.error("STD-000001", e, aStudy.getIndex(), e.getMessage());
492 * Build reference for the study. The reference of the study is stored as a new reference pattern (IDBuilder).
496 * @return true if reference building is succeded
499 private boolean buildReference(final Study aStudy) {
500 String pattern = aStudy.getReference(); // The study being supposed just created, its reference is the reference pattern
501 IDBuilder tool = selectIDBuilder(aStudy.getDate());
503 tool = new IDBuilder(aStudy.getDate());
504 getIDBuilderDAO().create(tool);
506 aStudy.setReference(buildReference(tool, pattern, aStudy));
511 * Build reference for the study. The reference of the study is stored as a new reference pattern (IDBuilder).
518 * the reference pattern
519 * @return true if reference building is succeded
522 public String buildReference(final IDBuilder aBuilder,
523 final String pattern, final Study study) {
524 char[] format = pattern.toCharArray();
525 char[] ref = new char[80]; // Better evaluate the length of the generated string
526 int next = aBuilder.getBase() + 1;
529 for (int i = 0; i < format.length; i++) {
531 // Insertion of attribute values
532 if (format[i] == '%') {
535 if (format[i] == 'y') { // Insertion of year in format 2 (e.g. 09) or 4 (e.g. 2009) digits
537 while (format[i] == 'y') {
539 if (i == format.length) {
543 SimpleDateFormat tostring = new SimpleDateFormat("yyyy"); //RKV: NOPMD: TODO: Use locale here?
544 String year = tostring.format(study.getDate());
545 year = year.substring(4 - (i - n), 4); // 4-(i-n) must be equal to either 0 or 2
546 for (int j = 0; j < year.length(); j++) {
547 ref[count] = year.charAt(j);
550 i -= 1; // Back to the last 'y' character
551 } else if (format[i] == '0') { // Insertion of the index
553 while (format[i] == '0') {
555 if (i == format.length) {
559 DecimalFormat tostring = new DecimalFormat(pattern
561 String number = tostring.format(next);
562 for (int j = 0; j < number.length(); j++) {
563 ref[count] = number.charAt(j);
566 i -= 1; // Back to the last '0' character
568 // Keep the character
570 ref[count] = format[i];
574 // Incrementation of the number of study
575 aBuilder.setBase(next);
576 getIDBuilderDAO().update(aBuilder);
577 return String.copyValueOf(ref, 0, count);
581 * Find an id builder by date.
585 * @return found id builder
587 private IDBuilder selectIDBuilder(final Date date) {
588 Calendar aDate = Calendar.getInstance();
590 return getIDBuilderDAO().findByCriteria(
591 Restrictions.eq("cycle", aDate.get(Calendar.YEAR)));
595 * Fill transient collection ModifiableActors of the study.
600 private void resetActorsShortCut(final Study aStudy) {
601 getModifiableActors(aStudy).clear();
602 // Get all actors involved in validation cycles
603 for (Iterator<ValidationCycle> i = aStudy.getValidationCycles()
604 .values().iterator(); i.hasNext();) {
605 ValidationCycle cycle = i.next();
606 User[] user = cycle.getAllActors();
607 for (int j = 0; j < user.length; j++) {
608 getModifiableActors(aStudy).add(user[j]);
611 // Get all other actors
612 for (Iterator<Relation> i = aStudy.getAllRelations().iterator(); i
614 Relation link = i.next();
615 Class<?> kindof = link.getClass().getSuperclass();
616 if (!kindof.equals(ActorRelation.class)) {
619 getModifiableActors(aStudy).add(((ActorRelation) link).getTo());
624 * Update lucene index for the study knowledge elements.
628 * @return true if reindexing succeeded
630 private boolean updateKnowledgeElementsIndex(final Study aStudy) {
631 boolean isOk = false;
633 IndexService lucin = getIndex();
635 for (Iterator<Scenario> i = aStudy.getScenariiList().iterator(); i
637 Scenario scene = i.next();
638 for (Iterator<KnowledgeElement> j = scene
639 .getAllKnowledgeElements().iterator(); j.hasNext();) {
640 KnowledgeElement kelm = j.next();
645 } catch (Exception error) {
646 LOG.error("Unable to re-index Knowledge Elements, reason:",
653 * Get lucene index service. Create a lucene index if it does not exist.
655 * @return index service
656 * @throws IOException
657 * if error occurs during lucene index creation
659 private IndexService getIndex() throws IOException {
660 IndexService lucin = getIndexService();
661 if (!lucin.exists()) {
662 lucin.create(); // Happens when re-indexing all studies
668 * Create a new validation cycle for documents of the given study.
673 * the cycle description
674 * @return the new validation cycle
676 protected ValidationCycle createValidationCycle(
678 final ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle) {
679 Actor[] actype = cycle.getActorTypes();
680 User.Properties uprop = new User.Properties();
682 ValidationCycle aValidationCycle = new ValidationCycle();
683 aValidationCycle.setDocumentType(getDocumentTypeService().selectType(
684 cycle.getName())); // Null in case of default validation cycle
685 // context = new ValidationCycleRelation(from, vprop);
686 // RKV aValidationCycle.context = null; // Validation cycle defined in the workflow
687 for (int i = 0; i < actype.length; i++) {
689 if (actype[i] != null) {
691 if (actype[i] == Actor.manager) {
692 actor = from.getAuthor();
693 } else if (actype[i] == Actor.Nx1) {
694 List<User> manager = getUserService().selectUsersWhere(
695 uprop.setOrganizationName("Nx1"));
696 if (manager.size() == 1) {
697 actor = manager.get(0);
699 } else if (actype[i] == Actor.Nx2) {
700 List<User> manager = getUserService().selectUsersWhere(
701 uprop.setOrganizationName("Nx2"));
702 if (manager.size() == 1) {
703 actor = manager.get(0);
705 } else { /* Actor.customer */
706 actor = from.getAuthor();
707 // TODO: Get the customer of the study, if exists
709 } catch (Exception e) { // Should not happen
714 aValidationCycle.setReviewer(actor);
716 aValidationCycle.setApprover(actor);
718 aValidationCycle.setSignatory(actor);
721 return aValidationCycle;
725 * Remove a validation step from the validation cycle.
727 * @param aValidationCycle
728 * the validation cycle
730 * the validation step to remove
733 protected void remove(final ValidationCycle aValidationCycle,
734 final ValidationStep step) {
735 if (step == ValidationStep.REVIEW) {
736 aValidationCycle.setReviewer(null);
737 } else if (step == ValidationStep.APPROVAL) {
738 aValidationCycle.setApprover(null);
739 } else if (step == ValidationStep.ACCEPTANCE
740 || step == ValidationStep.REFUSAL) {
741 aValidationCycle.setSignatory(null);
743 if (aValidationCycle.isSaved()) {
744 getValidationCycleDAO().update(aValidationCycle);
749 * Reset actors for the validation cycle.
751 * @param aValidationCycle
752 * the validation cycle to update
754 * new validation cycle properties containing new actors
757 public void resetActors(final ValidationCycle aValidationCycle,
758 final ValidationCycle.Properties vprop) {
759 aValidationCycle.setPublisher(vprop.getPublisher()); // May be null
760 aValidationCycle.setReviewer(vprop.getReviewer()); // May be null
761 aValidationCycle.setApprover(vprop.getApprover()); // May be null
762 aValidationCycle.setSignatory(vprop.getSignatory()); // May be null
763 if (aValidationCycle.isSaved()) {
764 getValidationCycleDAO().merge(aValidationCycle);
769 * Set actor for the given validation cycle and validation step.
771 * @param aValidationCycle
772 * the validation cycle
774 * the validation step
779 protected void setActor(final ValidationCycle aValidationCycle,
780 final ValidationStep step, final User actor) {
781 if (step == ValidationStep.PROMOTION) {
782 aValidationCycle.setPublisher(actor);
783 } else if (step == ValidationStep.REVIEW) {
784 aValidationCycle.setReviewer(actor);
785 } else if (step == ValidationStep.APPROVAL) {
786 aValidationCycle.setApprover(actor);
787 } else if (step == ValidationStep.ACCEPTANCE
788 || step == ValidationStep.REFUSAL) {
789 aValidationCycle.setSignatory(actor);
791 if (aValidationCycle.isSaved()) {
792 getValidationCycleDAO().update(aValidationCycle);
797 * Returns all actors of this study other than the author, including contributors, reviewers and approvers.
801 * @return the actors of this study
802 * @see #hasActor(User)
804 public Set<User> getActors(final Study aStudy) {
805 if (aStudy.getActor() == null) {
806 setShortCuts(aStudy);
808 return Collections.unmodifiableSet(aStudy.getActor());
812 * Returns all actors of this study other than the author, including contributors, reviewers and approvers.
816 * @return the modifiable set of actors of this study
817 * @see #hasActor(User)
819 public Set<User> getModifiableActors(final Study aStudy) {
820 if (aStudy.getActor() == null) {
821 setShortCuts(aStudy);
823 return aStudy.getActor();
827 * Returns unmodifiable initialized transient list of contributors of this study.
831 * @return the unmodifiable not null transient list of contributors of this study
833 public List<User> getContributors(final Study aStudy) {
834 if (aStudy.getContributor() == null) {
835 setShortCuts(aStudy);
837 return Collections.unmodifiableList(aStudy.getContributor()); // May be empty
841 * Returns modifiable initialized transient list of contributors of this study.
845 * @return the modifiable not null transient list of contributors of this study
847 public List<User> getModifiableContributors(final Study aStudy) {
848 if (aStudy.getContributor() == null) {
849 setShortCuts(aStudy);
851 return aStudy.getContributor(); // May be empty
855 * Returns the validation cycle of the given document type.
860 * the document type being subject of validation
861 * @return the validation cycle of the document, or null if not defined.
863 public ValidationCycle getValidationCycleOf(final Study aStudy,
864 final DocumentType type) {
865 if (aStudy.getValidationCycles() == null || aStudy.getValidationCycles().isEmpty()) {
866 setShortCuts(aStudy);
868 ValidationCycle result = aStudy.getValidationCycles().get(
870 if (result == null) {
871 if (type.isStepResult()) {
872 result = aStudy.getValidationCycles().get("default"); // "default" validation cycle defined in the configuration, if exist
874 if (result == null) {
875 result = aStudy.getValidationCycles().get("built-in");
882 * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
887 * the user to look for
888 * @return true if the given user is actor of this study.
891 public boolean hasActor(final Study aStudy, final User user) {
895 for (Iterator<User> i = getActors(aStudy).iterator(); i.hasNext();) {
896 User involved = i.next();
897 if (involved.equals(user)) {
905 * Checks if the given user participates to this study. The Study staff includes the author and contributors.
910 * the user to look for
911 * @return true if the given user is actor of this study.
912 * @see #getContributors()
914 public boolean isStaffedBy(final Study aStudy, final User user) {
918 if (aStudy == null) {
921 if (aStudy.getAuthor() == null) {
924 if (aStudy.getAuthor().equals(user)) {
927 for (Iterator<User> i = getContributors(aStudy).iterator(); i.hasNext();) {
928 if (i.next().equals(user)) {
936 * Initialize shortcuts of the study as its transient collections.
941 public void loadWorkflow(final Study aStudy) {
942 setShortCuts(aStudy);
946 * Initialize shortcuts of the study as its transient collections.
951 public void setShortCuts(final Study aStudy) {
952 aStudy.getContributor().clear();
953 aStudy.getValidationCycles().clear();
954 aStudy.getActor().clear();
956 // Get the contributors
957 for (Iterator<Relation> i = aStudy.getRelations(
958 ContributorRelation.class).iterator(); i.hasNext();) {
959 ContributorRelation link = (ContributorRelation) i.next();
960 aStudy.getContributor().add(link.getTo());
962 // Get the validation cycles specific to this study
963 for (Iterator<Relation> i = aStudy.getRelations(
964 ValidationCycleRelation.class).iterator(); i.hasNext();) {
965 ValidationCycleRelation link = (ValidationCycleRelation) i.next();
966 aStudy.getValidationCycles().put(link.getDocumentType().getName(),
967 link.getTo()); // The associated document type is necessarily not null in this
970 // Get the validation cycles coming from the configured workflow and not overridden in this study
971 for (Iterator<ProjectSettingsServiceImpl.ProjectSettingsValidationCycle> i = getProjectSettings()
972 .getAllValidationCycles().iterator(); i.hasNext();) {
973 ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle = i
975 String type = cycle.getName();
976 if (!aStudy.getValidationCycles().containsKey(type)) {
977 aStudy.getValidationCycles().put(type,
978 createValidationCycle(aStudy, cycle));
981 // Get all corresponding actors
982 for (Iterator<ValidationCycle> i = aStudy.getValidationCycles()
983 .values().iterator(); i.hasNext();) {
984 ValidationCycle cycle = i.next();
985 User[] user = cycle.getAllActors();
986 for (int j = 0; j < user.length; j++) {
987 aStudy.getActor().add(user[j]);
990 // Get all other actors
991 for (Iterator<Relation> i = aStudy.getAllRelations().iterator(); i
993 Relation link = i.next();
994 Class<?> kindof = link.getClass().getSuperclass();
995 if (!kindof.equals(ActorRelation.class)) {
998 aStudy.getActor().add(((ActorRelation) link).getTo());
1005 * @see org.splat.service.StudyService#markStudyAsReference(org.splat.dal.bo.som.Study)
1009 public void markStudyAsReference (final Study aStudy) {
1011 aStudy.setMarkreference(1);
1012 aStudy.setProgressState(ProgressState.TEMPLATE);
1013 getStudyDAO().merge(aStudy);
1019 * @see org.splat.service.StudyService#removeStudyAsReference(org.splat.dal.bo.som.Study)
1023 public void removeStudyAsReference(final Study aStudy) {
1025 aStudy.setMarkreference(0);
1026 aStudy.setProgressState(ProgressState.APPROVED);
1027 getStudyDAO().merge(aStudy);
1031 * Get project settings.
1033 * @return Project settings service
1035 private ProjectSettingsService getProjectSettings() {
1036 return _projectSettingsService;
1040 * Set project settings service.
1042 * @param projectSettingsService
1043 * project settings service
1045 public void setProjectSettings(
1046 final ProjectSettingsService projectSettingsService) {
1047 _projectSettingsService = projectSettingsService;
1051 * Get the projectElementService.
1053 * @return the projectElementService
1055 public ProjectElementService getProjectElementService() {
1056 return _projectElementService;
1060 * Set the projectElementService.
1062 * @param projectElementService
1063 * the projectElementService to set
1065 public void setProjectElementService(
1066 final ProjectElementService projectElementService) {
1067 _projectElementService = projectElementService;
1071 * Get the stepService.
1073 * @return the stepService
1075 public StepService getStepService() {
1076 return _stepService;
1080 * Set the stepService.
1082 * @param stepService
1083 * the stepService to set
1085 public void setStepService(final StepService stepService) {
1086 _stepService = stepService;
1090 * Get the indexService.
1092 * @return the indexService
1094 public IndexService getIndexService() {
1095 return _indexService;
1099 * Set the indexService.
1101 * @param indexService
1102 * the indexService to set
1104 public void setIndexService(final IndexService indexService) {
1105 _indexService = indexService;
1111 * @return the studyDAO
1113 public StudyDAO getStudyDAO() {
1121 * the studyDAO to set
1123 public void setStudyDAO(final StudyDAO studyDAO) {
1124 _studyDAO = studyDAO;
1128 * Get the iDBuilderDAO.
1130 * @return the iDBuilderDAO
1132 public IDBuilderDAO getIDBuilderDAO() {
1133 return _iDBuilderDAO;
1137 * Set the iDBuilderDAO.
1140 * the iDBuilderDAO to set
1142 public void setIDBuilderDAO(final IDBuilderDAO builderDAO) {
1143 _iDBuilderDAO = builderDAO;
1147 * Get the scenarioDAO.
1149 * @return the scenarioDAO
1151 public ScenarioDAO getScenarioDAO() {
1152 return _scenarioDAO;
1156 * Set the scenarioDAO.
1158 * @param scenarioDAO
1159 * the scenarioDAO to set
1161 public void setScenarioDAO(final ScenarioDAO scenarioDAO) {
1162 _scenarioDAO = scenarioDAO;
1166 * Get the validationCycleDAO.
1168 * @return the validationCycleDAO
1170 public ValidationCycleDAO getValidationCycleDAO() {
1171 return _validationCycleDAO;
1175 * Set the validationCycleDAO.
1177 * @param validationCycleDAO
1178 * the validationCycleDAO to set
1180 public void setValidationCycleDAO(
1181 final ValidationCycleDAO validationCycleDAO) {
1182 _validationCycleDAO = validationCycleDAO;
1186 * Get the documentTypeService.
1188 * @return the documentTypeService
1190 public DocumentTypeService getDocumentTypeService() {
1191 return _documentTypeService;
1195 * Set the documentTypeService.
1197 * @param documentTypeService
1198 * the documentTypeService to set
1200 public void setDocumentTypeService(
1201 final DocumentTypeService documentTypeService) {
1202 _documentTypeService = documentTypeService;
1206 * Get the userService.
1208 * @return the userService
1210 public UserService getUserService() {
1211 return _userService;
1215 * Set the userService.
1217 * @param userService
1218 * the userService to set
1220 public void setUserService(final UserService userService) {
1221 _userService = userService;