Salome HOME
Refactoring continues: UserService is created instead of UserDirectory. Database...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / StudyServiceImpl.java
index d120b69444d1675dd5fd47b31d17216fb495dfd8..b9cd50e7269971c9be4d47152530775acdcccec9 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Company         EURIWARE
+ * Company         OPEN CASCADE
  * Application     SIMAN
  * File            Id: 
  * Creation date   02.10.2012
 package org.splat.service;
 
 import java.io.IOException;
+import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
+import java.util.Collections;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import org.hibernate.criterion.Restrictions;
 import org.splat.dal.bo.kernel.Relation;
@@ -27,7 +30,6 @@ import org.splat.dal.bo.som.Document;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.IDBuilder;
 import org.splat.dal.bo.som.KnowledgeElement;
-import org.splat.dal.bo.som.KnowledgeElementType;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.bo.som.Publication;
 import org.splat.dal.bo.som.Scenario;
@@ -35,8 +37,10 @@ import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.ValidationCycle;
 import org.splat.dal.bo.som.ValidationCycleRelation;
+import org.splat.dal.bo.som.ValidationStep;
 import org.splat.dal.bo.som.Visibility;
 import org.splat.dal.bo.som.Study.Properties;
+import org.splat.dal.bo.som.ValidationCycle.Actor;
 import org.splat.dal.dao.som.IDBuilderDAO;
 import org.splat.dal.dao.som.ScenarioDAO;
 import org.splat.dal.dao.som.StudyDAO;
@@ -44,10 +48,10 @@ import org.splat.dal.dao.som.ValidationCycleDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
-import org.splat.kernel.UserDirectory;
 import org.splat.log.AppLogger;
 import org.splat.service.technical.IndexService;
 import org.splat.service.technical.ProjectSettingsService;
+import org.splat.service.technical.ProjectSettingsServiceImpl;
 import org.splat.som.Revision;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -75,11 +79,6 @@ public class StudyServiceImpl implements StudyService {
         */
        private StepService _stepService;
 
-       /**
-        * Injected scenario service.
-        */
-       private ScenarioService _scenarioService;
-
        /**
         * Injected project service.
         */
@@ -110,6 +109,16 @@ public class StudyServiceImpl implements StudyService {
         */
        private IDBuilderDAO _iDBuilderDAO;
 
+       /**
+        * Injected document type service.
+        */
+       private DocumentTypeService _documentTypeService;
+
+       /**
+        * Injected user service.
+        */
+       private UserService _userService;
+
        /**
         * {@inheritDoc}
         * 
@@ -118,7 +127,7 @@ public class StudyServiceImpl implements StudyService {
        @Transactional
        public Study selectStudy(long index) {
                Study result = getStudyDAO().get(index);
-               result.loadWorkflow();
+               loadWorkflow(result);
                return result;
        }
 
@@ -133,7 +142,7 @@ public class StudyServiceImpl implements StudyService {
        public Study selectStudy(String refid) {
                Study result = getStudyDAO().findByCriteria(
                                Restrictions.eq("sid", refid));
-               result.loadWorkflow();
+               loadWorkflow(result);
                return result;
        }
 
@@ -195,13 +204,13 @@ public class StudyServiceImpl implements StudyService {
         * @see org.splat.service.StudyService#addContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User)
         */
        public boolean addContributor(Study aStudy, User user) {
-               List<User> contributor = aStudy.getModifiableContributors(); // Initializes contributor
+               List<User> contributor = getModifiableContributors(aStudy); // Initializes contributor
                for (Iterator<User> i = contributor.iterator(); i.hasNext();) {
                        User present = i.next();
                        if (present.equals(user))
                                return false;
                }
-               boolean absent = aStudy.getModifiableActors().add(user); // User may already be a reviewer or an approver
+               boolean absent = getModifiableActors(aStudy).add(user); // User may already be a reviewer or an approver
 
                aStudy.addRelation(new ContributorRelation(aStudy, user));
                if (absent)
@@ -276,7 +285,7 @@ public class StudyServiceImpl implements StudyService {
         * @see org.splat.service.StudyService#removeContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User[])
         */
        public boolean removeContributor(Study aStudy, User... users) {
-               List<User> contributor = aStudy.getModifiableContributors(); // Initializes contributor
+               List<User> contributor = getModifiableContributors(aStudy); // Initializes contributor
                Boolean done = false;
                for (int i = 0; i < users.length; i++) {
                        User user = users[i];
@@ -317,26 +326,25 @@ public class StudyServiceImpl implements StudyService {
        @Transactional
        public void setValidationCycle(Study aStudy, DocumentType type,
                        ValidationCycle.Properties vprop) {
-               HashMap<String, ValidationCycle> validactor = aStudy
-                               .getValidationCycles();
+               Map<String, ValidationCycle> validactor = aStudy.getValidationCycles();
                if (validactor == null)
-                       aStudy.setShortCuts(); // Initializes validactor and actor
+                       setShortCuts(aStudy); // Initializes validactor and actor
 
                String cname = type.getName();
                ValidationCycle cycle = validactor.get(cname);
 
                if (cycle != null && cycle.isAssigned()) {
-                       cycle.resetActors(vprop);
+                       resetActors(cycle, vprop);
                } else
                        try {
                                cycle = new ValidationCycle(aStudy, vprop.setDocumentType(type));
 
-                               getValidationCycleDAO().create(cycle); //RKV
-                               
+                               getValidationCycleDAO().create(cycle); // RKV
+
                                ValidationCycleRelation link = cycle.getContext();
-//RKV:                         aStudy.addRelation(link);
-                               aStudy.getAllRelations().add(link); //RKV
-                               
+                               // RKV: aStudy.addRelation(link);
+                               aStudy.getAllRelations().add(link); // RKV
+
                                validactor.put(cname, link.getTo()); // Replaces the cycle if exists as default,
                        } catch (Exception error) {
                                logger.error("Unable to re-index Knowledge Elements, reason:",
@@ -377,46 +385,6 @@ public class StudyServiceImpl implements StudyService {
                return aStudy.getLastLocalIndex();
        }
 
-       /**
-        * {@inheritDoc}
-        * 
-        * @see org.splat.service.StudyService#addScenario(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.Scenario.Properties)
-        */
-       @Transactional
-       public Scenario addScenario(Study aStudy, Scenario.Properties sprop)
-                       throws MissedPropertyException, InvalidPropertyException,
-                       MultiplyDefinedException {
-               if (sprop.getManager() == null)
-                       sprop.setManager(aStudy.getAuthor());
-
-               Scenario scenario = new Scenario(sprop.setOwnerStudy(aStudy));
-               if (sprop.getBaseStep() != null)
-                       getScenarioService()
-                                       .copyContentsUpTo(scenario, sprop.getBaseStep());
-               Scenario previous = sprop.getInsertAfter();
-
-               if (previous == null) {
-                       aStudy.getScenariiList().add(scenario);
-               } else {
-                       aStudy.getScenariiList().add(
-                                       aStudy.getScenariiList().indexOf(previous) + 1, scenario);
-               }
-               getStudyDAO().update(aStudy); // No need to update the Lucene index
-               getScenarioDAO().create(scenario); // Must be done after updating this study because of the back reference to the study
-               if (sprop.getBaseStep() != null) {
-                       // No need to update the Knowledge Element index as Knowledge Elements are not copied
-                       scenario.refresh(); // Because saving the scenario changes the hashcode of copied Publications
-               }
-               KnowledgeElementType ucase = KnowledgeElement.selectType("usecase");
-               KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
-               User admin = UserDirectory.selectUser(1); // First user created when creating the database
-               kprop.setType(ucase).setTitle(aStudy.getTitle()).setValue(
-                               scenario.getTitle()).setAuthor(admin); // Internal Knowledge Element required by the validation process of
-               // knowledges
-               getScenarioService().addKnowledgeElement(scenario, kprop);
-               return scenario;
-       }
-
        /**
         * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
         * final result document of the study.
@@ -474,6 +442,7 @@ public class StudyServiceImpl implements StudyService {
                boolean isOk = false;
                try {
                        getStudyDAO().update(aStudy); // Update of relational base
+                       setShortCuts(aStudy); // RKV: initialize transient actors set
                        getIndex().update(aStudy); // Update of Lucene index
                        isOk = true;
                } catch (Exception error) {
@@ -498,10 +467,77 @@ public class StudyServiceImpl implements StudyService {
                        tool = new IDBuilder(aStudy.getDate());
                        getIDBuilderDAO().create(tool);
                }
-               aStudy.setReference(tool.buildReference(pattern, aStudy));
+               aStudy.setReference(buildReference(tool, pattern, aStudy));
                return true;
        }
 
+       /**
+        * Build reference for the study. The reference of the study is stored as a new reference pattern (IDBuilder).
+        * 
+        * @param aBuilder
+        *            the id builder
+        * @param study
+        *            the study
+        * @param pattern
+        *            the reference pattern
+        * @return true if reference building is succeded
+        */
+       @Transactional
+       public String buildReference(IDBuilder aBuilder, String pattern, Study study) {
+               char[] format = pattern.toCharArray();
+               char[] ref = new char[80]; // Better evaluate the length of the generated string
+               int next = aBuilder.getBase() + 1;
+
+               int count = 0;
+               for (int i = 0; i < format.length; i++) {
+
+                       // Insertion of attribute values
+                       if (format[i] == '%') {
+                               i += 1;
+
+                               if (format[i] == 'y') { // Insertion of year in format 2 (e.g. 09) or 4 (e.g. 2009) digits
+                                       int n = i;
+                                       while (format[i] == 'y') {
+                                               i += 1;
+                                               if (i == format.length)
+                                                       break;
+                                       }
+                                       SimpleDateFormat tostring = new SimpleDateFormat("yyyy");
+                                       String year = tostring.format(study.getDate());
+                                       year = year.substring(4 - (i - n), 4); // 4-(i-n) must be equal to either 0 or 2
+                                       for (int j = 0; j < year.length(); j++) {
+                                               ref[count] = year.charAt(j);
+                                               count += 1;
+                                       }
+                                       i -= 1; // Back to the last 'y' character
+                               } else if (format[i] == '0') { // Insertion of the index
+                                       int n = i;
+                                       while (format[i] == '0') {
+                                               i += 1;
+                                               if (i == format.length)
+                                                       break;
+                                       }
+                                       DecimalFormat tostring = new DecimalFormat(
+                                                       pattern.substring(n, i));
+                                       String number = tostring.format(next);
+                                       for (int j = 0; j < number.length(); j++) {
+                                               ref[count] = number.charAt(j);
+                                               count += 1;
+                                       }
+                                       i -= 1; // Back to the last '0' character
+                               }
+                               // Keep the character
+                       } else {
+                               ref[count] = format[i];
+                               count += 1;
+                       }
+               }
+               // Incrementation of the number of study
+               aBuilder.setBase(next);
+               getIDBuilderDAO().update(aBuilder);
+               return String.copyValueOf(ref, 0, count);
+       }
+
        /**
         * Find an id builder by date.
         * 
@@ -523,14 +559,14 @@ public class StudyServiceImpl implements StudyService {
         *            the study
         */
        private void resetActorsShortCut(Study aStudy) {
-               aStudy.getModifiableActors().clear();
+               getModifiableActors(aStudy).clear();
                // Get all actors involved in validation cycles
                for (Iterator<ValidationCycle> i = aStudy.getValidationCycles()
                                .values().iterator(); i.hasNext();) {
                        ValidationCycle cycle = i.next();
                        User[] user = cycle.getAllActors();
                        for (int j = 0; j < user.length; j++)
-                               aStudy.getModifiableActors().add(user[j]);
+                               getModifiableActors(aStudy).add(user[j]);
                }
                // Get all other actors
                for (Iterator<Relation> i = aStudy.getAllRelations().iterator(); i
@@ -539,7 +575,7 @@ public class StudyServiceImpl implements StudyService {
                        Class<?> kindof = link.getClass().getSuperclass();
                        if (!kindof.equals(ActorRelation.class))
                                continue;
-                       aStudy.getModifiableActors().add(((ActorRelation) link).getTo());
+                       getModifiableActors(aStudy).add(((ActorRelation) link).getTo());
                }
        }
 
@@ -586,6 +622,316 @@ public class StudyServiceImpl implements StudyService {
                return lucin;
        }
 
+       /**
+        * Create a new validation cycle for documents of the given study.
+        * 
+        * @param from
+        *            the study
+        * @param cycle
+        *            the cycle description
+        * @return the new validation cycle
+        */
+       protected ValidationCycle createValidationCycle(Study from,
+                       ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle) {
+               // -----------------------------------------------------------------------------
+               Actor[] actype = cycle.getActorTypes();
+               User.Properties uprop = new User.Properties();
+
+               ValidationCycle aValidationCycle = new ValidationCycle();
+               aValidationCycle.setDocumentType(getDocumentTypeService().selectType(
+                               cycle.getName())); // Null in case of default validation cycle
+               // context = new ValidationCycleRelation(from, this);
+               // RKV aValidationCycle.context = null; // Validation cycle defined in the workflow
+               for (int i = 0; i < actype.length; i++) {
+                       User actor = null;
+                       if (actype[i] != null)
+                               try {
+                                       if (actype[i] == Actor.manager) {
+                                               actor = from.getAuthor();
+                                       } else if (actype[i] == Actor.Nx1) {
+                                               List<User> manager = getUserService()
+                                                               .selectUsersWhere(uprop
+                                                                               .setOrganizationName("Nx1"));
+                                               if (manager.size() == 1)
+                                                       actor = manager.get(0);
+                                       } else if (actype[i] == Actor.Nx2) {
+                                               List<User> manager = getUserService()
+                                                               .selectUsersWhere(uprop
+                                                                               .setOrganizationName("Nx2"));
+                                               if (manager.size() == 1)
+                                                       actor = manager.get(0);
+                                       } else { /* Actor.customer */
+                                               actor = from.getAuthor();
+                                               // TODO: Get the customer of the study, if exists
+                                       }
+                               } catch (Exception e) { // Should not happen
+                                       actor = null;
+                               }
+                       if (i == 0)
+                               aValidationCycle.setReviewer(actor);
+                       else if (i == 1)
+                               aValidationCycle.setApprover(actor);
+                       else if (i == 2)
+                               aValidationCycle.setSignatory(actor);
+               }
+               return aValidationCycle;
+       }
+
+       /**
+        * Remove a validation step from the validation cycle.
+        * 
+        * @param aValidationCycle
+        *            the validation cycle
+        * @param step
+        *            the validation step to remove
+        */
+       @Transactional
+       protected void remove(ValidationCycle aValidationCycle, ValidationStep step) {
+               // ------------------------------------------
+               if (step == ValidationStep.REVIEW)
+                       aValidationCycle.setReviewer(null);
+               else if (step == ValidationStep.APPROVAL)
+                       aValidationCycle.setApprover(null);
+               else if (step == ValidationStep.ACCEPTANCE
+                               || step == ValidationStep.REFUSAL)
+                       aValidationCycle.setSignatory(null);
+               if (aValidationCycle.isSaved()) {
+                       getValidationCycleDAO().update(aValidationCycle);
+               }
+       }
+
+       /**
+        * Reset actors for the validation cycle.
+        * 
+        * @param aValidationCycle
+        *            the validation cycle to update
+        * @param vprop
+        *            new validation cycle properties containing new actors
+        */
+       @Transactional
+       public void resetActors(ValidationCycle aValidationCycle,
+                       ValidationCycle.Properties vprop) {
+               aValidationCycle.setPublisher(vprop.getPublisher()); // May be null
+               aValidationCycle.setReviewer(vprop.getReviewer()); // May be null
+               aValidationCycle.setApprover(vprop.getApprover()); // May be null
+               aValidationCycle.setSignatory(vprop.getSignatory()); // May be null
+               if (aValidationCycle.isSaved()) {
+                       getValidationCycleDAO().update(aValidationCycle);
+               }
+       }
+
+       /**
+        * Set actor for the given validation cycle and validation step.
+        * 
+        * @param aValidationCycle
+        *            the validation cycle
+        * @param step
+        *            the validation step
+        * @param actor
+        *            the actor to set
+        */
+       @Transactional
+       protected void setActor(ValidationCycle aValidationCycle,
+                       ValidationStep step, User actor) {
+               if (step == ValidationStep.PROMOTION) {
+                       aValidationCycle.setPublisher(actor);
+               } else if (step == ValidationStep.REVIEW) {
+                       aValidationCycle.setReviewer(actor);
+               } else if (step == ValidationStep.APPROVAL) {
+                       aValidationCycle.setApprover(actor);
+               } else if (step == ValidationStep.ACCEPTANCE
+                               || step == ValidationStep.REFUSAL) {
+                       aValidationCycle.setSignatory(actor);
+               }
+               if (aValidationCycle.isSaved()) {
+                       getValidationCycleDAO().update(aValidationCycle);
+               }
+       }
+
+       /**
+        * Returns all actors of this study other than the author, including contributors, reviewers and approvers.
+        * 
+        * @param aStudy
+        *            the study
+        * @return the actors of this study
+        * @see #hasActor(User)
+        */
+       public Set<User> getActors(Study aStudy) {
+               if (aStudy.getActor() == null)
+                       setShortCuts(aStudy);
+               return Collections.unmodifiableSet(aStudy.getActor());
+       }
+
+       /**
+        * Returns all actors of this study other than the author, including contributors, reviewers and approvers.
+        * 
+        * @param aStudy
+        *            the study
+        * @return the modifiable set of actors of this study
+        * @see #hasActor(User)
+        */
+       public Set<User> getModifiableActors(Study aStudy) {
+               if (aStudy.getActor() == null)
+                       setShortCuts(aStudy);
+               return aStudy.getActor();
+       }
+
+       /**
+        * Returns unmodifiable initialized transient list of contributors of this study.
+        * 
+        * @param aStudy
+        *            the study
+        * @return the unmodifiable not null transient list of contributors of this study
+        */
+       public List<User> getContributors(Study aStudy) {
+               if (aStudy.getContributor() == null)
+                       setShortCuts(aStudy);
+               return Collections.unmodifiableList(aStudy.getContributor()); // May be empty
+       }
+
+       /**
+        * Returns modifiable initialized transient list of contributors of this study.
+        * 
+        * @param aStudy
+        *            the study
+        * @return the modifiable not null transient list of contributors of this study
+        */
+       public List<User> getModifiableContributors(Study aStudy) {
+               if (aStudy.getContributor() == null)
+                       setShortCuts(aStudy);
+               return aStudy.getContributor(); // May be empty
+       }
+
+       /**
+        * Returns the validation cycle of the given document type.
+        * 
+        * @param aStudy
+        *            the study
+        * @param type
+        *            the document type being subject of validation
+        * @return the validation cycle of the document, or null if not defined.
+        */
+       public ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type) {
+               if (aStudy.getValidationCycles() == null)
+                       setShortCuts(aStudy);
+               ValidationCycle result = aStudy.getValidationCycles().get(
+                               type.getName());
+               if (result == null) {
+                       if (type.isStepResult())
+                               result = aStudy.getValidationCycles().get("default"); // "default" validation cycle defined in the configuration, if exist
+                       if (result == null)
+                               result = aStudy.getValidationCycles().get("built-in");
+               }
+               return result;
+       }
+
+       /**
+        * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
+        * 
+        * @param aStudy
+        *            the study
+        * @param user
+        *            the user to look for
+        * @return true if the given user is actor of this study.
+        * @see #getActors()
+        */
+       public boolean hasActor(Study aStudy, User user) {
+               if (user == null)
+                       return false;
+               for (Iterator<User> i = getActors(aStudy).iterator(); i.hasNext();) {
+                       User involved = i.next();
+                       if (involved.equals(user))
+                               return true;
+               }
+               return false;
+       }
+
+       /**
+        * Checks if the given user participates to this study. The Study staff includes the author and contributors.
+        * 
+        * @param aStudy
+        *            the study
+        * @param user
+        *            the user to look for
+        * @return true if the given user is actor of this study.
+        * @see #getContributors()
+        */
+       public boolean isStaffedBy(Study aStudy, User user) {
+               if (user == null)
+                       return false;
+               if (aStudy.getAuthor().equals(user))
+                       return true;
+               for (Iterator<User> i = getContributors(aStudy).iterator(); i.hasNext();) {
+                       if (i.next().equals(user))
+                               return true;
+               }
+               return false;
+       }
+
+       /**
+        * Initialize shortcuts of the study as its transient collections.
+        * 
+        * @param aStudy
+        *            the study
+        */
+       public void loadWorkflow(Study aStudy) {
+               setShortCuts(aStudy);
+       }
+
+       /**
+        * Initialize shortcuts of the study as its transient collections.
+        * 
+        * @param aStudy
+        *            the study
+        */
+       public void setShortCuts(Study aStudy) {
+               aStudy.getContributor().clear();
+               aStudy.getValidationCycles().clear();
+               aStudy.getActor().clear();
+
+               // Get the contributors
+               for (Iterator<Relation> i = aStudy.getRelations(
+                               ContributorRelation.class).iterator(); i.hasNext();) {
+                       ContributorRelation link = (ContributorRelation) i.next();
+                       aStudy.getContributor().add(link.getTo());
+               }
+               // Get the validation cycles specific to this study
+               for (Iterator<Relation> i = aStudy.getRelations(
+                               ValidationCycleRelation.class).iterator(); i.hasNext();) {
+                       ValidationCycleRelation link = (ValidationCycleRelation) i.next();
+                       aStudy.getValidationCycles().put(link.getDocumentType().getName(),
+                                       link.getTo()); // The associated document type is necessarily not null in this
+                       // context
+               }
+               // Get the validation cycles coming from the configured workflow and not overridden in this study
+               for (Iterator<ProjectSettingsServiceImpl.ProjectSettingsValidationCycle> i = ProjectSettingsServiceImpl
+                               .getAllValidationCycles().iterator(); i.hasNext();) {
+                       ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle = i
+                                       .next();
+                       String type = cycle.getName();
+                       if (!aStudy.getValidationCycles().containsKey(type))
+                               aStudy.getValidationCycles().put(type,
+                                               createValidationCycle(aStudy, cycle));
+               }
+               // Get all corresponding actors
+               for (Iterator<ValidationCycle> i = aStudy.getValidationCycles()
+                               .values().iterator(); i.hasNext();) {
+                       ValidationCycle cycle = i.next();
+                       User[] user = cycle.getAllActors();
+                       for (int j = 0; j < user.length; j++)
+                               aStudy.getActor().add(user[j]);
+               }
+               // Get all other actors
+               for (Iterator<Relation> i = aStudy.getAllRelations().iterator(); i
+                               .hasNext();) {
+                       Relation link = i.next();
+                       Class<?> kindof = link.getClass().getSuperclass();
+                       if (!kindof.equals(ActorRelation.class))
+                               continue;
+                       aStudy.getActor().add(((ActorRelation) link).getTo());
+               }
+       }
+
        /**
         * Get project settings.
         * 
@@ -701,25 +1047,6 @@ public class StudyServiceImpl implements StudyService {
                _iDBuilderDAO = builderDAO;
        }
 
-       /**
-        * Get the scenarioService.
-        * 
-        * @return the scenarioService
-        */
-       public ScenarioService getScenarioService() {
-               return _scenarioService;
-       }
-
-       /**
-        * Set the scenarioService.
-        * 
-        * @param scenarioService
-        *            the scenarioService to set
-        */
-       public void setScenarioService(ScenarioService scenarioService) {
-               _scenarioService = scenarioService;
-       }
-
        /**
         * Get the scenarioDAO.
         * 
@@ -741,6 +1068,7 @@ public class StudyServiceImpl implements StudyService {
 
        /**
         * Get the validationCycleDAO.
+        * 
         * @return the validationCycleDAO
         */
        public ValidationCycleDAO getValidationCycleDAO() {
@@ -749,9 +1077,46 @@ public class StudyServiceImpl implements StudyService {
 
        /**
         * Set the validationCycleDAO.
-        * @param validationCycleDAO the validationCycleDAO to set
+        * 
+        * @param validationCycleDAO
+        *            the validationCycleDAO to set
         */
        public void setValidationCycleDAO(ValidationCycleDAO validationCycleDAO) {
                _validationCycleDAO = validationCycleDAO;
        }
+
+       /**
+        * Get the documentTypeService.
+        * 
+        * @return the documentTypeService
+        */
+       public DocumentTypeService getDocumentTypeService() {
+               return _documentTypeService;
+       }
+
+       /**
+        * Set the documentTypeService.
+        * 
+        * @param documentTypeService
+        *            the documentTypeService to set
+        */
+       public void setDocumentTypeService(DocumentTypeService documentTypeService) {
+               _documentTypeService = documentTypeService;
+       }
+
+       /**
+        * Get the userService.
+        * @return the userService
+        */
+       public UserService getUserService() {
+               return _userService;
+       }
+
+       /**
+        * Set the userService.
+        * @param userService the userService to set
+        */
+       public void setUserService(UserService userService) {
+               _userService = userService;
+       }
 }