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.ValidationCycle;
20 import org.splat.dal.bo.som.Study.Properties;
21 import org.splat.kernel.InvalidPropertyException;
22 import org.splat.kernel.MissedPropertyException;
23 import org.splat.kernel.MultiplyDefinedException;
26 * This class defines all methods for creation, modification the study.
28 * @author Maria KRUCHININA
31 public interface StudyService {
34 * Increment total number of study documents including versions (docount) and update it in the study.
38 * @return incremented docount value
40 int generateLocalIndex(Study aStudy);
43 * Get study by its id.
47 * @return found study or null
49 Study selectStudy(long index);
55 * properties of the new study
56 * @return the created study
57 * @throws MissedPropertyException
58 * if a mandatory property is missed
59 * @throws InvalidPropertyException
60 * if some property doesn't exist
61 * @throws MultiplyDefinedException
62 * if some property is defined several times
64 Study createStudy(Study.Properties sprop)
65 throws MissedPropertyException, InvalidPropertyException,
66 MultiplyDefinedException;
69 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
74 * the simulation context properties
75 * @return the added simulation context
76 * @throws MissedPropertyException
77 * if a mandatory property is missed
78 * @throws InvalidPropertyException
79 * if some property doesn't exist
80 * @throws MultiplyDefinedException
81 * if some property occurs several times
83 SimulationContext addProjectContext(Study aStudy,
84 SimulationContext.Properties cprop) throws MissedPropertyException,
85 InvalidPropertyException, MultiplyDefinedException;
88 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
93 * the simulation context to add
94 * @return the added simulation context
96 SimulationContext addProjectContext(Study aStudy,
97 SimulationContext context);
100 * Remove a simulation context from a study.
105 * the simulation context to remove
106 * @return true if removing succeeded
108 boolean removeProjectContext(Study aStudy, SimulationContext context);
111 * Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
112 * document of the study.
115 * the study to demote
116 * @return true if the demotion succeeded.
118 boolean demote(Study aStudy);
121 * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
122 * final result document of the study.
125 * the study to promote
126 * @return true if the promotion succeeded.
128 boolean promote(Study aStudy);
131 * Add a contributor to the study.
137 * @return true if addition succeeded
139 boolean addContributor(Study aStudy, User user);
142 * Remove contributors from the study.
148 * @return true if removing succeeded
150 boolean removeContributor(Study aStudy, User... users);
153 * Set a validation cycle for documents of the given type in the given study.
160 * validation cycle properties
162 void setValidationCycle(Study aStudy, DocumentType type,
163 ValidationCycle.Properties vprop);
166 * Moves this study from the Private to the Public area of the repository.
170 * @return true if the move succeeded.
173 boolean moveToPublic(Study aStudy);
176 * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
177 * previously be approved.
181 * @return true if the move succeeded.
182 * @see #moveToPublic()
184 * @see Publication#approve(Date)
186 boolean moveToReference(Study aStudy);
192 * the study to update
194 * new properties of the study
195 * @return true if the study has been updated successfully
196 * @throws InvalidPropertyException
197 * if some property doesn't exist
199 boolean update(Study aStudy, Properties sprop)
200 throws InvalidPropertyException;
203 * Initialize shortcuts of the study as its transient collections.
208 void loadWorkflow(Study aStudy);
211 * Returns the validation cycle of the given document type.
216 * the document type being subject of validation
217 * @return the validation cycle of the document, or null if not defined.
219 ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
222 * Checks if the given user participates to this study. The Study staff includes the author and contributors.
227 * the user to look for
228 * @return true if the given user is actor of this study.
229 * @see #getContributors()
231 boolean isStaffedBy(Study aStudy, User user);
234 * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
239 * the user to look for
240 * @return true if the given user is actor of this study.
243 boolean hasActor(Study aStudy, User user);
246 * Returns unmodifiable initialized transient list of contributors of this study.
250 * @return the unmodifiable not null transient list of contributors of this study
252 List<User> getContributors(Study aStudy);