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.Publication;
17 import org.splat.dal.bo.som.SimulationContext;
18 import org.splat.dal.bo.som.Study;
19 import org.splat.dal.bo.som.Study.Properties;
20 import org.splat.dal.bo.som.ValidationCycle;
21 import org.splat.exception.InvalidParameterException;
22 import org.splat.kernel.InvalidPropertyException;
23 import org.splat.kernel.MissedPropertyException;
24 import org.splat.kernel.MultiplyDefinedException;
27 * This class defines all methods for creation, modification the study.
29 * @author Maria KRUCHININA
32 public interface StudyService {
35 * Increment total number of study documents including versions (docount) and update it in the study.
39 * @return incremented docount value
41 int generateLocalIndex(Study aStudy);
44 * Get study by its id.
48 * @return found study or null
50 Study selectStudy(long index);
56 * properties of the new study
57 * @return the created study
58 * @throws MissedPropertyException
59 * if a mandatory property is missed
60 * @throws InvalidPropertyException
61 * if some property doesn't exist
62 * @throws MultiplyDefinedException
63 * if some property is defined several times
65 Study createStudy(Study.Properties sprop)
66 throws MissedPropertyException, InvalidPropertyException,
67 MultiplyDefinedException;
70 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
75 * the simulation context properties
76 * @return the added simulation context
77 * @throws MissedPropertyException
78 * if a mandatory property is missed
79 * @throws InvalidPropertyException
80 * if some property doesn't exist
81 * @throws MultiplyDefinedException
82 * if some property occurs several times
84 SimulationContext addProjectContext(Study aStudy,
85 SimulationContext.Properties cprop) throws MissedPropertyException,
86 InvalidPropertyException, MultiplyDefinedException;
89 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
94 * the simulation context to add
95 * @return the added simulation context
97 SimulationContext addProjectContext(Study aStudy,
98 SimulationContext context);
101 * Remove a simulation context from a study.
106 * the simulation context to remove
107 * @return true if removing succeeded
109 boolean removeProjectContext(Study aStudy, SimulationContext context);
112 * Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
113 * document of the study.
116 * the study to demote
117 * @return true if the demotion succeeded.
119 boolean demote(Study aStudy);
122 * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
123 * final result document of the study.
126 * the study to promote
127 * @return true if the promotion succeeded.
129 boolean promote(Study aStudy);
132 * Add a contributor to the study.
138 * @return true if addition succeeded
140 boolean addContributor(Study aStudy, User user);
143 * Remove contributors from the study.
149 * @return true if removing succeeded
151 boolean removeContributor(Study aStudy, User... users);
154 * Set a validation cycle for documents of the given type in the given study.
161 * validation cycle properties
163 void setValidationCycle(Study aStudy, DocumentType type,
164 ValidationCycle.Properties vprop);
167 * Moves this study from the Private to the Public area of the repository.
171 * @return true if the move succeeded.
174 boolean moveToPublic(Study aStudy);
177 * Moves this study from the Public to the Private area of the repository.
181 * @return true if the move succeeded.
183 boolean moveToPrivate(Study aStudy);
186 * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
187 * previously be approved.
191 * @return true if the move succeeded.
192 * @see #moveToPublic()
194 * @see Publication#approve(Date)
196 boolean moveToReference(Study aStudy);
202 * the study to update
204 * new properties of the study
205 * @return true if the study has been updated successfully
206 * @throws InvalidPropertyException
207 * if some property doesn't exist
209 boolean update(Study aStudy, Properties sprop)
210 throws InvalidPropertyException;
213 * Initialize shortcuts of the study as its transient collections.
218 void loadWorkflow(Study aStudy);
221 * Returns the validation cycle of the given document type.
226 * the document type being subject of validation
227 * @return the validation cycle of the document, or null if not defined.
229 ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
232 * Checks if the given user participates to this study. The Study staff includes the author and contributors.
237 * the user to look for
238 * @return true if the given user is actor of this study.
239 * @see #getContributors()
241 boolean isStaffedBy(Study aStudy, User user);
244 * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
249 * the user to look for
250 * @return true if the given user is actor of this study.
253 boolean hasActor(Study aStudy, User user);
256 * Returns unmodifiable initialized transient list of contributors of this study.
260 * @return the unmodifiable not null transient list of contributors of this study
262 List<User> getContributors(Study aStudy);
265 * Mark study as reference.
267 * @param aStudy - the Study
269 void markStudyAsReference(Study aStudy);
272 * Remove study as reference.
273 * This operation is inverse one to Mark as reference.
275 * @param aStudy - the Study
277 void removeStudyAsReference(Study aStudy);
280 * Get the description attribute related to the study
281 * (there supposed to be the only one such attribute in the database).
282 * @param studyId the study id
283 * @return the description attribute value (null if does not exist)
284 * @throws InvalidParameterException if a study with such id does not exist in the database.
286 String getDescription(Long studyId) throws InvalidParameterException;
289 * Set the description attribute related to the study.
290 * @param studyId the study id
291 * @param descriptionText the description text
292 * @throws InvalidParameterException if some parameters are invalid.
294 void setDescription(Long studyId, String descriptionText) throws InvalidParameterException;