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.InvalidParameterException;
23 import org.splat.kernel.InvalidPropertyException;
24 import org.splat.kernel.MissedPropertyException;
25 import org.splat.kernel.MultiplyDefinedException;
28 * This class defines all methods for creation, modification the study.
30 * @author Maria KRUCHININA
33 public interface StudyService {
36 * Increment total number of study documents including versions (docount) and update it in the study.
40 * @return incremented docount value
42 int generateLocalIndex(Study aStudy);
45 * Get study by its id.
49 * @return found study or null
51 Study selectStudy(long index);
57 * properties of the new study
58 * @return the created study
59 * @throws MissedPropertyException
60 * if a mandatory property is missed
61 * @throws InvalidPropertyException
62 * if some property doesn't exist
63 * @throws MultiplyDefinedException
64 * if some property is defined several times
66 Study createStudy(Study.Properties sprop)
67 throws MissedPropertyException, InvalidPropertyException,
68 MultiplyDefinedException;
71 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
76 * the simulation context properties
77 * @return the added simulation context
78 * @throws MissedPropertyException
79 * if a mandatory property is missed
80 * @throws InvalidPropertyException
81 * if some property doesn't exist
82 * @throws MultiplyDefinedException
83 * if some property occurs several times
85 SimulationContext addProjectContext(Study aStudy,
86 SimulationContext.Properties cprop) throws MissedPropertyException,
87 InvalidPropertyException, MultiplyDefinedException;
90 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
95 * the simulation context to add
96 * @return the added simulation context
98 SimulationContext addProjectContext(Study aStudy,
99 SimulationContext context);
102 * Remove a simulation context from a study.
107 * the simulation context to remove
108 * @return true if removing succeeded
110 boolean removeProjectContext(Study aStudy, SimulationContext context);
113 * Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
114 * document of the study.
117 * the study to demote
118 * @return true if the demotion succeeded.
120 boolean demote(Study aStudy);
123 * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
124 * final result document of the study.
127 * the study to promote
128 * @return true if the promotion succeeded.
130 boolean promote(Study aStudy);
133 * Add a contributor to the study.
139 * @return true if addition succeeded
141 boolean addContributor(Study aStudy, User user);
144 * Remove contributors from the study.
150 * @return true if removing succeeded
152 boolean removeContributor(Study aStudy, User... users);
155 * Set a validation cycle for documents of the given type in the given study.
162 * validation cycle properties
164 void setValidationCycle(Study aStudy, DocumentType type,
165 ValidationCycle.Properties vprop);
168 * Moves this study from the Private to the Public area of the repository.
172 * @return true if the move succeeded.
175 boolean moveToPublic(Study aStudy);
178 * Moves this study from the Public to the Private area of the repository.
182 * @return true if the move succeeded.
184 boolean moveToPrivate(Study aStudy);
187 * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
188 * previously be approved.
192 * @return true if the move succeeded.
193 * @see #moveToPublic()
195 * @see Publication#approve(Date)
197 boolean moveToReference(Study aStudy);
203 * the study to update
205 * new properties of the study
206 * @return true if the study has been updated successfully
207 * @throws InvalidPropertyException
208 * if some property doesn't exist
210 boolean update(Study aStudy, Properties sprop)
211 throws InvalidPropertyException;
214 * Initialize shortcuts of the study as its transient collections.
219 void loadWorkflow(Study aStudy);
222 * Returns the validation cycle of the given document type.
227 * the document type being subject of validation
228 * @return the validation cycle of the document, or null if not defined.
230 ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
233 * Checks if the given user participates to this study. The Study staff includes the author and contributors.
238 * the user to look for
239 * @return true if the given user is actor of this study.
240 * @see #getContributors()
242 boolean isStaffedBy(Study aStudy, User user);
245 * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
250 * the user to look for
251 * @return true if the given user is actor of this study.
254 boolean hasActor(Study aStudy, User user);
257 * Returns unmodifiable initialized transient list of contributors of this study.
261 * @return the unmodifiable not null transient list of contributors of this study
263 List<User> getContributors(Study aStudy);
266 * Mark study as reference.
268 * @param aStudy - the Study
270 void markStudyAsReference(Study aStudy);
273 * Remove study as reference.
274 * This operation is inverse one to Mark as reference.
276 * @param aStudy - the Study
278 void removeStudyAsReference(Study aStudy);
281 * Get the description attribute related to the study
282 * (there supposed to be the only one such attribute in the database).
283 * @param studyId the study id
284 * @return the description attribute value (null if does not exist)
285 * @throws InvalidParameterException if a study with such id does not exist in the database.
287 String getDescription(Long studyId) throws InvalidParameterException;
290 * Set the description attribute related to the study.
291 * @param studyId the study id
292 * @param descriptionText the description text
293 * @throws InvalidParameterException if some parameters are invalid.
295 void setDescription(Long studyId, String descriptionText) throws InvalidParameterException;
298 * Remove a description attached to a study.
300 * @param studyId the study id
301 * @throws InvalidParameterException
302 * if no study with such Id has been found in the database.
303 * @return true if succeeded, false if study doesn't have a description.
305 boolean removeDescription(final Long studyId) throws InvalidParameterException;