Salome HOME
Satisfy some PMD rules.
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / StudyService.java
index 50595523194a58b0341c0e1633b57632ccb131b2..73d498da2e2bd6d533e8015b91e0ef70049cfcc3 100644 (file)
@@ -14,14 +14,21 @@ import java.util.List;
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.Publication;
-import org.splat.dal.bo.som.Scenario;
 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.Study.Properties;
+import org.splat.exception.IncompatibleDataException;
+import org.splat.exception.InvalidParameterException;
 import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MismatchException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
+import org.splat.service.dto.DocToCompareDTO;
+import org.splat.service.dto.DocumentDTO;
+import org.splat.service.dto.StudyFacadeDTO;
+import org.splat.service.dto.UserDTO;
+import org.splat.service.dto.StudyFacadeDTO.ScenarioDTO;
 
 /**
  * This class defines all methods for creation, modification the study.
@@ -38,7 +45,7 @@ public interface StudyService {
         *            the study
         * @return incremented docount value
         */
-       public int generateLocalIndex(Study aStudy);
+       int generateLocalIndex(Study aStudy);
 
        /**
         * Get study by its id.
@@ -47,7 +54,15 @@ public interface StudyService {
         *            the study id
         * @return found study or null
         */
-       public Study selectStudy(long index);
+       Study selectStudy(long index);
+
+       /**
+        * Delete the study.
+        * 
+        * @param index
+        *            the study id
+        */
+       void removeStudy(final Long index);
 
        /**
         * Create a new study.
@@ -58,13 +73,12 @@ public interface StudyService {
         * @throws MissedPropertyException
         *             if a mandatory property is missed
         * @throws InvalidPropertyException
-        *             if some property doesn't exist
+        *             if an invalid value is passed to a property
         * @throws MultiplyDefinedException
         *             if some property is defined several times
         */
-       public Study createStudy(Study.Properties sprop)
-                       throws MissedPropertyException, InvalidPropertyException,
-                       MultiplyDefinedException;
+       Study createStudy(Study.Properties sprop) throws MissedPropertyException,
+                       InvalidPropertyException, MultiplyDefinedException;
 
        /**
         * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
@@ -77,11 +91,11 @@ public interface StudyService {
         * @throws MissedPropertyException
         *             if a mandatory property is missed
         * @throws InvalidPropertyException
-        *             if some property doesn't exist
+        *             if an invalid value is passed to a property
         * @throws MultiplyDefinedException
         *             if some property occurs several times
         */
-       public SimulationContext addProjectContext(Study aStudy,
+       SimulationContext addProjectContext(Study aStudy,
                        SimulationContext.Properties cprop) throws MissedPropertyException,
                        InvalidPropertyException, MultiplyDefinedException;
 
@@ -94,8 +108,7 @@ public interface StudyService {
         *            the simulation context to add
         * @return the added simulation context
         */
-       public SimulationContext addProjectContext(Study aStudy,
-                       SimulationContext context);
+       SimulationContext addProjectContext(Study aStudy, SimulationContext context);
 
        /**
         * Remove a simulation context from a study.
@@ -106,7 +119,7 @@ public interface StudyService {
         *            the simulation context to remove
         * @return true if removing succeeded
         */
-       public boolean removeProjectContext(Study aStudy, SimulationContext context);
+       boolean removeProjectContext(Study aStudy, SimulationContext context);
 
        /**
         * Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
@@ -116,7 +129,7 @@ public interface StudyService {
         *            the study to demote
         * @return true if the demotion succeeded.
         */
-       public boolean demote(Study aStudy);
+       boolean demote(Study aStudy);
 
        /**
         * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
@@ -126,7 +139,7 @@ public interface StudyService {
         *            the study to promote
         * @return true if the promotion succeeded.
         */
-       public boolean promote(Study aStudy);
+       boolean promote(Study aStudy);
 
        /**
         * Add a contributor to the study.
@@ -137,7 +150,7 @@ public interface StudyService {
         *            the contributor
         * @return true if addition succeeded
         */
-       public boolean addContributor(Study aStudy, User user);
+       boolean addContributor(Study aStudy, User user);
 
        /**
         * Remove contributors from the study.
@@ -148,7 +161,7 @@ public interface StudyService {
         *            contributor(s)
         * @return true if removing succeeded
         */
-       public boolean removeContributor(Study aStudy, User... users);
+       boolean removeContributor(Study aStudy, User... users);
 
        /**
         * Set a validation cycle for documents of the given type in the given study.
@@ -160,7 +173,7 @@ public interface StudyService {
         * @param vprop
         *            validation cycle properties
         */
-       public void setValidationCycle(Study aStudy, DocumentType type,
+       void setValidationCycle(Study aStudy, DocumentType type,
                        ValidationCycle.Properties vprop);
 
        /**
@@ -171,7 +184,16 @@ public interface StudyService {
         * @return true if the move succeeded.
         * @see #isPublic()
         */
-       public boolean moveToPublic(Study aStudy);
+       boolean moveToPublic(Study aStudy);
+
+       /**
+        * Moves this study from the Public to the Private area of the repository.
+        * 
+        * @param aStudy
+        *            the study to move
+        * @return true if the move succeeded.
+        */
+       boolean moveToPrivate(Study aStudy);
 
        /**
         * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
@@ -184,7 +206,7 @@ public interface StudyService {
         * @see #isPublic()
         * @see Publication#approve(Date)
         */
-       public boolean moveToReference(Study aStudy);
+       boolean moveToReference(Study aStudy);
 
        /**
         * Update a study.
@@ -195,9 +217,9 @@ public interface StudyService {
         *            new properties of the study
         * @return true if the study has been updated successfully
         * @throws InvalidPropertyException
-        *             if some property doesn't exist
+        *             if an invalid value is passed to a property
         */
-       public boolean update(Study aStudy, Properties sprop)
+       boolean update(Study aStudy, Properties sprop)
                        throws InvalidPropertyException;
 
        /**
@@ -206,7 +228,7 @@ public interface StudyService {
         * @param aStudy
         *            the study
         */
-       public void loadWorkflow(Study aStudy);
+       void loadWorkflow(Study aStudy);
 
        /**
         * Returns the validation cycle of the given document type.
@@ -217,7 +239,7 @@ public interface StudyService {
         *            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);
+       ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
 
        /**
         * Checks if the given user participates to this study. The Study staff includes the author and contributors.
@@ -229,7 +251,7 @@ public interface StudyService {
         * @return true if the given user is actor of this study.
         * @see #getContributors()
         */
-       public boolean isStaffedBy(Study aStudy, User user);
+       boolean isStaffedBy(Study aStudy, User user);
 
        /**
         * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
@@ -241,7 +263,7 @@ public interface StudyService {
         * @return true if the given user is actor of this study.
         * @see #getActors()
         */
-       public boolean hasActor(Study aStudy, User user);
+       boolean hasActor(Study aStudy, User user);
 
        /**
         * Returns unmodifiable initialized transient list of contributors of this study.
@@ -250,5 +272,109 @@ public interface StudyService {
         *            the study
         * @return the unmodifiable not null transient list of contributors of this study
         */
-       public List<User> getContributors(Study aStudy);
+       List<User> getContributors(Study aStudy);
+
+       /**
+        * Mark study as reference.
+        * 
+        * @param aStudy -
+        *            the Study
+        */
+       void markStudyAsReference(Study aStudy);
+
+       /**
+        * Remove study as reference. This operation is inverse one to Mark as reference.
+        * 
+        * @param aStudy -
+        *            the Study
+        */
+       void removeStudyAsReference(Study aStudy);
+
+       /**
+        * Get studies, scenarios and publications available for comparison.
+        * <br><b> DocumentDto.id are actually filled in with Publication ids.</b>
+        * @param userId id of the user to to whom visible studies will be returned.
+        * @return list of {@link StudyFacadeDTO} containing lists of {@link ScenarioDTO} containing list of 
+        *              {@link DocumentDTO}, corresponding to to the publications available for comparison,
+        *              with ids and titles filled in.
+        * @throws MismatchException if some configurations considering postprocessing step are invalid.
+        */
+       List<StudyFacadeDTO> getComparableStudies(final long userId) throws MismatchException;
+       
+       /**
+        * Get the description attribute related to the study (there supposed to be the only one such attribute in the database).
+        * 
+        * @param studyId
+        *            the study id
+        * @return the description attribute value (null if does not exist)
+        * @throws InvalidParameterException
+        *             if a study with such id does not exist in the database.
+        */
+       String getDescription(Long studyId) throws InvalidParameterException;
+
+       /**
+        * Set the description attribute related to the study.
+        * 
+        * @param studyId
+        *            the study id
+        * @param descriptionText
+        *            the description text
+        * @throws InvalidParameterException
+        *             if some parameters are invalid.
+        */
+       void setDescription(Long studyId, String descriptionText)
+                       throws InvalidParameterException;
+
+       /**
+        * Remove a description attached to a study.
+        * 
+        * @param studyId
+        *            the study id
+        * @throws InvalidParameterException
+        *             if no study with such Id has been found in the database.
+        * @return true if succeeded, false if study doesn't have a description.
+        */
+       boolean removeDescription(final Long studyId)
+                       throws InvalidParameterException;
+
+       /**
+        * Compare the studies and generate the file that contains the result chart.
+        * 
+        * @param docsList
+        *            the list of dtos each contains information: StudyTitle, ScenarioTitle, PathToFile in vault.
+        * @param userName
+        *            the name of the user who compare the results.
+        * @throws IncompatibleDataException
+        *             if data is incompatible for "Compare the studies" functionality.
+        * 
+        * @return path to result file in the vault.
+        */
+       String compare(List<DocToCompareDTO> docsList, final String userName)
+                       throws IncompatibleDataException;
+       
+       /**
+        * Get readers of a given study.
+        * @param studyId the study id.
+        * @return list of user DTO corresponding to the study readers.
+        * @throws InvalidParameterException if no study with such id has been found in the database.
+        */
+       List<UserDTO> getReaders(final long studyId) throws InvalidParameterException;
+       
+       /**
+        * Add reader to a given study.
+        * @param studyId the study id.
+        * @param userId the user id.
+        * @return true if the user has been added as a reader
+        * @throws InvalidParameterException if no study or user with such id has been found in the database.
+        */
+       boolean addReader(final long studyId, final long userId) throws InvalidParameterException;
+
+       /**
+        * Remove reader from a given study.
+        * @param studyId the study id.
+        * @param userId the user id.
+        * @return true if the relation has been found and removed
+        * @throws InvalidParameterException if no study or user with such id has been found in the database.
+        */
+       boolean removeReader(final long studyId, final long userId) throws InvalidParameterException;
 }