1 /*****************************************************************************
5 * Creation date 02.10.2012
6 * @author Author: Maria KRUCHININA
8 *****************************************************************************/
10 package org.splat.service;
12 import java.util.List;
14 import org.splat.dal.bo.kernel.User;
15 import org.splat.dal.bo.som.DocumentType;
16 import org.splat.dal.bo.som.SimulationContext;
17 import org.splat.dal.bo.som.Study;
18 import org.splat.dal.bo.som.ValidationCycle;
19 import org.splat.dal.bo.som.Study.Properties;
20 import org.splat.exception.IncompatibleDataException;
21 import org.splat.exception.InvalidParameterException;
22 import org.splat.kernel.InvalidPropertyException;
23 import org.splat.kernel.MismatchException;
24 import org.splat.kernel.MissedPropertyException;
25 import org.splat.kernel.MultiplyDefinedException;
26 import org.splat.service.dto.DocToCompareDTO;
27 import org.splat.service.dto.DocumentDTO;
28 import org.splat.service.dto.StudyFacadeDTO;
29 import org.splat.service.dto.UserDTO;
30 import org.splat.service.dto.StudyFacadeDTO.ScenarioDTO;
33 * This class defines all methods for creation, modification the study.
35 * @author Maria KRUCHININA
38 public interface StudyService {
41 * Check if the study can be promoted taking into account its documents states.
44 * the study to be checked
45 * @return true if states of study documents allows the operation
47 boolean canBePromoted(final Study study);
50 * Check if the study can be validated taking into account its documents states.
53 * the study to be checked
54 * @return true if states of study documents allows the operation
56 boolean canBeReviewed(final Study study);
59 * Check if the study can be approved taking into account its documents states.
62 * the study to be checked
63 * @return true if states of study documents allows the operation
65 boolean canBeApproved(final Study study);
68 * Get the study result document type.
72 * @return document type
74 DocumentType getStudyResultType(final Study aStudy);
77 * Increment total number of study documents including versions (docount) and update it in the study.
81 * @return incremented docount value
83 int generateLocalIndex(Study aStudy);
86 * Get study by its id.
90 * @return found study or null
92 Study selectStudy(long index);
100 void removeStudy(final Long index);
103 * Create a new study.
106 * properties of the new study
107 * @return the created study
108 * @throws MissedPropertyException
109 * if a mandatory property is missed
110 * @throws InvalidPropertyException
111 * if an invalid value is passed to a property
112 * @throws MultiplyDefinedException
113 * if some property is defined several times
115 Study createStudy(Study.Properties sprop) throws MissedPropertyException,
116 InvalidPropertyException, MultiplyDefinedException;
119 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
124 * the simulation context properties
125 * @return the added simulation context
126 * @throws MissedPropertyException
127 * if a mandatory property is missed
128 * @throws InvalidPropertyException
129 * if an invalid value is passed to a property
130 * @throws MultiplyDefinedException
131 * if some property occurs several times
133 SimulationContext addProjectContext(Study aStudy,
134 SimulationContext.Properties cprop) throws MissedPropertyException,
135 InvalidPropertyException, MultiplyDefinedException;
138 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
143 * the simulation context to add
144 * @return the added simulation context
146 SimulationContext addProjectContext(Study aStudy, SimulationContext context);
149 * Remove a simulation context from a study.
154 * the simulation context to remove
155 * @return true if removing succeeded
157 boolean removeProjectContext(Study aStudy, SimulationContext context);
160 * Demotes this study from In-Check or In-Draft to In-Work states.
164 * @return true if the demotion succeeded.
166 boolean demote(Study aStudy);
169 * Promotes this study from In-Work to In-Draft then In-Check and APPROVED <BR>
170 * states. This function takes into account statuses of final result<BR>
171 * documents of the study.
175 * @return true if the promotion succeeded.
177 boolean promote(Study aStudy);
180 * Add a contributor to the study.
186 * @return true if addition succeeded
188 boolean addContributor(Study aStudy, User user);
191 * Remove contributors from the study.
197 * @return true if removing succeeded
199 boolean removeContributor(Study aStudy, User... users);
202 * Set a validation cycle for documents of the given type in the given study.
209 * validation cycle properties
211 void setValidationCycle(Study aStudy, DocumentType type,
212 ValidationCycle.Properties vprop);
215 * Moves this study from the Private to the Public area of the repository.
219 * @return true if the move succeeded.
222 boolean moveToPublic(Study aStudy);
225 * Moves this study from the Public to the Private area of the repository.
229 * @return true if the move succeeded.
231 boolean moveToPrivate(Study aStudy);
237 * the study to update
239 * new properties of the study
240 * @return true if the study has been updated successfully
241 * @throws InvalidPropertyException
242 * if an invalid value is passed to a property
244 boolean update(Study aStudy, Properties sprop)
245 throws InvalidPropertyException;
248 * Initialize shortcuts of the study as its transient collections.
253 void loadWorkflow(Study aStudy);
256 * Returns the validation cycle of the given document type.
261 * the document type being subject of validation
262 * @return the validation cycle of the document, or null if not defined.
264 ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
267 * Checks if the given user participates to this study. The Study staff includes the author and contributors.
272 * the user to look for
273 * @return true if the given user is actor of this study.
274 * @see #getContributors()
276 boolean isStaffedBy(Study aStudy, User user);
279 * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
284 * the user to look for
285 * @return true if the given user is actor of this study.
288 boolean hasActor(Study aStudy, User user);
291 * Returns unmodifiable initialized transient list of contributors of this study.
295 * @return the unmodifiable not null transient list of contributors of this study
297 List<User> getContributors(Study aStudy);
300 * Mark this study as Reference. The study must previously be approved.
304 * @return true if succeeded
306 boolean markStudyAsReference(Study aStudy);
309 * Remove study as reference. This operation is inverse one to Mark as reference.
314 void removeStudyAsReference(Study aStudy);
317 * Get studies, scenarios and publications available for comparison. <br>
318 * <b> DocumentDto.id are actually filled in with Publication ids.</b>
321 * id of the user to to whom visible studies will be returned.
322 * @return list of {@link StudyFacadeDTO} containing lists of {@link ScenarioDTO} containing list of {@link DocumentDTO}, corresponding
323 * to to the publications available for comparison, with ids and titles filled in.
324 * @throws MismatchException
325 * if some configurations considering postprocessing step are invalid.
327 List<StudyFacadeDTO> getComparableStudies(final long userId)
328 throws MismatchException;
331 * Get the description attribute related to the study (there supposed to be the only one such attribute in the database).
335 * @return the description attribute value (null if does not exist)
336 * @throws InvalidParameterException
337 * if a study with such id does not exist in the database.
339 String getDescription(Long studyId) throws InvalidParameterException;
342 * Set the description attribute related to the study.
346 * @param descriptionText
347 * the description text
348 * @throws InvalidParameterException
349 * if some parameters are invalid.
351 void setDescription(Long studyId, String descriptionText)
352 throws InvalidParameterException;
355 * Remove a description attached to a study.
359 * @throws InvalidParameterException
360 * if no study with such Id has been found in the database.
361 * @return true if succeeded, false if study doesn't have a description.
363 boolean removeDescription(final Long studyId)
364 throws InvalidParameterException;
367 * Compare the studies and generate the file that contains the result chart.
370 * the list of dtos each contains information: StudyTitle, ScenarioTitle, PathToFile in vault.
372 * the name of the user who compare the results.
373 * @throws IncompatibleDataException
374 * if data is incompatible for "Compare the studies" functionality.
376 * @return path to result file in the vault.
378 String compare(List<DocToCompareDTO> docsList, final String userName)
379 throws IncompatibleDataException;
382 * Get readers of a given study.
386 * @return list of user DTO corresponding to the study readers.
387 * @throws InvalidParameterException
388 * if no study with such id has been found in the database.
390 List<UserDTO> getReaders(final long studyId)
391 throws InvalidParameterException;
394 * Add reader to a given study.
400 * @return true if the user has been added as a reader
401 * @throws InvalidParameterException
402 * if no study or user with such id has been found in the database.
404 boolean addReader(final long studyId, final long userId)
405 throws InvalidParameterException;
408 * Remove reader from a given study.
414 * @return true if the relation has been found and removed
415 * @throws InvalidParameterException
416 * if no study or user with such id has been found in the database.
418 boolean removeReader(final long studyId, final long userId)
419 throws InvalidParameterException;