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.ValidationCycle;
21 import org.splat.dal.bo.som.Study.Properties;
22 import org.splat.exception.IncompatibleDataException;
23 import org.splat.exception.InvalidParameterException;
24 import org.splat.kernel.InvalidPropertyException;
25 import org.splat.kernel.MismatchException;
26 import org.splat.kernel.MissedPropertyException;
27 import org.splat.kernel.MultiplyDefinedException;
28 import org.splat.service.dto.DocToCompareDTO;
29 import org.splat.service.dto.DocumentDTO;
30 import org.splat.service.dto.StudyFacadeDTO;
31 import org.splat.service.dto.UserDTO;
32 import org.splat.service.dto.StudyFacadeDTO.ScenarioDTO;
35 * This class defines all methods for creation, modification the study.
37 * @author Maria KRUCHININA
40 public interface StudyService {
43 * Increment total number of study documents including versions (docount) and update it in the study.
47 * @return incremented docount value
49 int generateLocalIndex(Study aStudy);
52 * Get study by its id.
56 * @return found study or null
58 Study selectStudy(long index);
66 public void removeStudy(final Long index);
72 * properties of the new study
73 * @return the created study
74 * @throws MissedPropertyException
75 * if a mandatory property is missed
76 * @throws InvalidPropertyException
77 * if an invalid value is passed to a property
78 * @throws MultiplyDefinedException
79 * if some property is defined several times
81 Study createStudy(Study.Properties sprop) throws MissedPropertyException,
82 InvalidPropertyException, MultiplyDefinedException;
85 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
90 * the simulation context properties
91 * @return the added simulation context
92 * @throws MissedPropertyException
93 * if a mandatory property is missed
94 * @throws InvalidPropertyException
95 * if an invalid value is passed to a property
96 * @throws MultiplyDefinedException
97 * if some property occurs several times
99 SimulationContext addProjectContext(Study aStudy,
100 SimulationContext.Properties cprop) throws MissedPropertyException,
101 InvalidPropertyException, MultiplyDefinedException;
104 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
109 * the simulation context to add
110 * @return the added simulation context
112 SimulationContext addProjectContext(Study aStudy, SimulationContext context);
115 * Remove a simulation context from a study.
120 * the simulation context to remove
121 * @return true if removing succeeded
123 boolean removeProjectContext(Study aStudy, SimulationContext context);
126 * Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
127 * document of the study.
130 * the study to demote
131 * @return true if the demotion succeeded.
133 boolean demote(Study aStudy);
136 * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
137 * final result document of the study.
140 * the study to promote
141 * @return true if the promotion succeeded.
143 boolean promote(Study aStudy);
146 * Add a contributor to the study.
152 * @return true if addition succeeded
154 boolean addContributor(Study aStudy, User user);
157 * Remove contributors from the study.
163 * @return true if removing succeeded
165 boolean removeContributor(Study aStudy, User... users);
168 * Set a validation cycle for documents of the given type in the given study.
175 * validation cycle properties
177 void setValidationCycle(Study aStudy, DocumentType type,
178 ValidationCycle.Properties vprop);
181 * Moves this study from the Private to the Public area of the repository.
185 * @return true if the move succeeded.
188 boolean moveToPublic(Study aStudy);
191 * Moves this study from the Public to the Private area of the repository.
195 * @return true if the move succeeded.
197 boolean moveToPrivate(Study aStudy);
200 * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
201 * previously be approved.
205 * @return true if the move succeeded.
206 * @see #moveToPublic()
208 * @see Publication#approve(Date)
210 boolean moveToReference(Study aStudy);
216 * the study to update
218 * new properties of the study
219 * @return true if the study has been updated successfully
220 * @throws InvalidPropertyException
221 * if an invalid value is passed to a property
223 boolean update(Study aStudy, Properties sprop)
224 throws InvalidPropertyException;
227 * Initialize shortcuts of the study as its transient collections.
232 void loadWorkflow(Study aStudy);
235 * Returns the validation cycle of the given document type.
240 * the document type being subject of validation
241 * @return the validation cycle of the document, or null if not defined.
243 ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
246 * Checks if the given user participates to this study. The Study staff includes the author and contributors.
251 * the user to look for
252 * @return true if the given user is actor of this study.
253 * @see #getContributors()
255 boolean isStaffedBy(Study aStudy, User user);
258 * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
263 * the user to look for
264 * @return true if the given user is actor of this study.
267 boolean hasActor(Study aStudy, User user);
270 * Returns unmodifiable initialized transient list of contributors of this study.
274 * @return the unmodifiable not null transient list of contributors of this study
276 List<User> getContributors(Study aStudy);
279 * Mark study as reference.
284 void markStudyAsReference(Study aStudy);
287 * Remove study as reference. This operation is inverse one to Mark as reference.
292 void removeStudyAsReference(Study aStudy);
295 * Get studies, scenarios and publications available for comparison.
296 * <br><b> DocumentDto.id are actually filled in with Publication ids.</b>
297 * @param userId id of the user to to whom visible studies will be returned.
298 * @return list of {@link StudyFacadeDTO} containing lists of {@link ScenarioDTO} containing list of
299 * {@link DocumentDTO}, corresponding to to the publications available for comparison,
300 * with ids and titles filled in.
301 * @throws MismatchException if some configurations considering postprocessing step are invalid.
303 List<StudyFacadeDTO> getComparableStudies(final long userId) throws MismatchException;
306 * Get the description attribute related to the study (there supposed to be the only one such attribute in the database).
310 * @return the description attribute value (null if does not exist)
311 * @throws InvalidParameterException
312 * if a study with such id does not exist in the database.
314 String getDescription(Long studyId) throws InvalidParameterException;
317 * Set the description attribute related to the study.
321 * @param descriptionText
322 * the description text
323 * @throws InvalidParameterException
324 * if some parameters are invalid.
326 void setDescription(Long studyId, String descriptionText)
327 throws InvalidParameterException;
330 * Remove a description attached to a study.
334 * @throws InvalidParameterException
335 * if no study with such Id has been found in the database.
336 * @return true if succeeded, false if study doesn't have a description.
338 boolean removeDescription(final Long studyId)
339 throws InvalidParameterException;
342 * Compare the studies and generate the file that contains the result chart.
345 * the list of dtos each contains information: StudyTitle, ScenarioTitle, PathToFile in vault.
347 * the name of the user who compare the results.
348 * @throws IncompatibleDataException
349 * if data is incompatible for "Compare the studies" functionality.
351 * @return path to result file in the vault.
353 String compare(List<DocToCompareDTO> docsList, final String userName)
354 throws IncompatibleDataException;
357 * Get readers of a given study.
358 * @param studyId the study id.
359 * @return list of user DTO corresponding to the study readers.
360 * @throws InvalidParameterException if no study with such id has been found in the database.
362 List<UserDTO> getReaders(final long studyId) throws InvalidParameterException;
365 * Add reader to a given study.
366 * @param studyId the study id.
367 * @param userId the user id.
368 * @return true if the user has been added as a reader
369 * @throws InvalidParameterException if no study or user with such id has been found in the database.
371 boolean addReader(final long studyId, final long userId) throws InvalidParameterException;
374 * Remove reader from a given study.
375 * @param studyId the study id.
376 * @param userId the user id.
377 * @return true if the relation has been found and removed
378 * @throws InvalidParameterException if no study or user with such id has been found in the database.
380 boolean removeReader(final long studyId, final long userId) throws InvalidParameterException;