1 /*****************************************************************************
5 * Creation date 02.10.2012
6 * @author Author: Maria KRUCHININA
8 *****************************************************************************/
10 package org.splat.service;
12 import java.util.Date;
13 import java.util.List;
15 import org.splat.dal.bo.kernel.User;
16 import org.splat.dal.bo.som.DocumentType;
17 import org.splat.dal.bo.som.Publication;
18 import org.splat.dal.bo.som.SimulationContext;
19 import org.splat.dal.bo.som.Study;
20 import org.splat.dal.bo.som.Study.Properties;
21 import org.splat.dal.bo.som.ValidationCycle;
22 import org.splat.exception.IncompatibleDataException;
23 import org.splat.exception.InvalidParameterException;
24 import org.splat.kernel.InvalidPropertyException;
25 import org.splat.kernel.MissedPropertyException;
26 import org.splat.kernel.MultiplyDefinedException;
27 import org.splat.service.dto.DocToCompareDTO;
30 * This class defines all methods for creation, modification the study.
32 * @author Maria KRUCHININA
35 public interface StudyService {
38 * Increment total number of study documents including versions (docount) and update it in the study.
42 * @return incremented docount value
44 int generateLocalIndex(Study aStudy);
47 * Get study by its id.
51 * @return found study or null
53 Study selectStudy(long index);
59 * properties of the new study
60 * @return the created study
61 * @throws MissedPropertyException
62 * if a mandatory property is missed
63 * @throws InvalidPropertyException
64 * if some property doesn't exist
65 * @throws MultiplyDefinedException
66 * if some property is defined several times
68 Study createStudy(Study.Properties sprop)
69 throws MissedPropertyException, InvalidPropertyException,
70 MultiplyDefinedException;
73 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
78 * the simulation context properties
79 * @return the added simulation context
80 * @throws MissedPropertyException
81 * if a mandatory property is missed
82 * @throws InvalidPropertyException
83 * if some property doesn't exist
84 * @throws MultiplyDefinedException
85 * if some property occurs several times
87 SimulationContext addProjectContext(Study aStudy,
88 SimulationContext.Properties cprop) throws MissedPropertyException,
89 InvalidPropertyException, MultiplyDefinedException;
92 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
97 * the simulation context to add
98 * @return the added simulation context
100 SimulationContext addProjectContext(Study aStudy,
101 SimulationContext context);
104 * Remove a simulation context from a study.
109 * the simulation context to remove
110 * @return true if removing succeeded
112 boolean removeProjectContext(Study aStudy, SimulationContext context);
115 * Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
116 * document of the study.
119 * the study to demote
120 * @return true if the demotion succeeded.
122 boolean demote(Study aStudy);
125 * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
126 * final result document of the study.
129 * the study to promote
130 * @return true if the promotion succeeded.
132 boolean promote(Study aStudy);
135 * Add a contributor to the study.
141 * @return true if addition succeeded
143 boolean addContributor(Study aStudy, User user);
146 * Remove contributors from the study.
152 * @return true if removing succeeded
154 boolean removeContributor(Study aStudy, User... users);
157 * Set a validation cycle for documents of the given type in the given study.
164 * validation cycle properties
166 void setValidationCycle(Study aStudy, DocumentType type,
167 ValidationCycle.Properties vprop);
170 * Moves this study from the Private to the Public area of the repository.
174 * @return true if the move succeeded.
177 boolean moveToPublic(Study aStudy);
180 * Moves this study from the Public to the Private area of the repository.
184 * @return true if the move succeeded.
186 boolean moveToPrivate(Study aStudy);
189 * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
190 * previously be approved.
194 * @return true if the move succeeded.
195 * @see #moveToPublic()
197 * @see Publication#approve(Date)
199 boolean moveToReference(Study aStudy);
205 * the study to update
207 * new properties of the study
208 * @return true if the study has been updated successfully
209 * @throws InvalidPropertyException
210 * if some property doesn't exist
212 boolean update(Study aStudy, Properties sprop)
213 throws InvalidPropertyException;
216 * Initialize shortcuts of the study as its transient collections.
221 void loadWorkflow(Study aStudy);
224 * Returns the validation cycle of the given document type.
229 * the document type being subject of validation
230 * @return the validation cycle of the document, or null if not defined.
232 ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
235 * Checks if the given user participates to this study. The Study staff includes the author and contributors.
240 * the user to look for
241 * @return true if the given user is actor of this study.
242 * @see #getContributors()
244 boolean isStaffedBy(Study aStudy, User user);
247 * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
252 * the user to look for
253 * @return true if the given user is actor of this study.
256 boolean hasActor(Study aStudy, User user);
259 * Returns unmodifiable initialized transient list of contributors of this study.
263 * @return the unmodifiable not null transient list of contributors of this study
265 List<User> getContributors(Study aStudy);
268 * Mark study as reference.
270 * @param aStudy - the Study
272 void markStudyAsReference(Study aStudy);
275 * Remove study as reference.
276 * This operation is inverse one to Mark as reference.
278 * @param aStudy - the Study
280 void removeStudyAsReference(Study aStudy);
283 * Get the description attribute related to the study
284 * (there supposed to be the only one such attribute in the database).
285 * @param studyId the study id
286 * @return the description attribute value (null if does not exist)
287 * @throws InvalidParameterException if a study with such id does not exist in the database.
289 String getDescription(Long studyId) throws InvalidParameterException;
292 * Set the description attribute related to the study.
293 * @param studyId the study id
294 * @param descriptionText the description text
295 * @throws InvalidParameterException if some parameters are invalid.
297 void setDescription(Long studyId, String descriptionText) throws InvalidParameterException;
300 * Remove a description attached to a study.
302 * @param studyId the study id
303 * @throws InvalidParameterException
304 * if no study with such Id has been found in the database.
305 * @return true if succeeded, false if study doesn't have a description.
307 boolean removeDescription(final Long studyId) throws InvalidParameterException;
310 * Compare the studies and generate the file that contains the result chart.
311 * @param docsList the list of dtos each contains information:
312 * StudyTitle, ScenarioTitle, PathToFile in vault.
313 * @param userName the name of the user who compare the results.
314 * @throws IncompatibleDataException
315 * if data is incompatible for "Compare the studies" functionality.
317 * @return path to result file in the vault.
319 String compare (List<DocToCompareDTO> docsList, final String userName) throws IncompatibleDataException;