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.MissedPropertyException;
26 import org.splat.kernel.MultiplyDefinedException;
27 import org.splat.service.dto.DocToCompareDTO;
30 * This class defines all methods for creation, modification the study.
32 * @author Maria KRUCHININA
35 public interface StudyService {
38 * Increment total number of study documents including versions (docount) and update it in the study.
42 * @return incremented docount value
44 int generateLocalIndex(Study aStudy);
47 * Get study by its id.
51 * @return found study or null
53 Study selectStudy(long index);
61 public void removeStudy(final long index);
67 * properties of the new study
68 * @return the created study
69 * @throws MissedPropertyException
70 * if a mandatory property is missed
71 * @throws InvalidPropertyException
72 * if an invalid value is passed to a property
73 * @throws MultiplyDefinedException
74 * if some property is defined several times
76 Study createStudy(Study.Properties sprop) throws MissedPropertyException,
77 InvalidPropertyException, MultiplyDefinedException;
80 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
85 * the simulation context properties
86 * @return the added simulation context
87 * @throws MissedPropertyException
88 * if a mandatory property is missed
89 * @throws InvalidPropertyException
90 * if an invalid value is passed to a property
91 * @throws MultiplyDefinedException
92 * if some property occurs several times
94 SimulationContext addProjectContext(Study aStudy,
95 SimulationContext.Properties cprop) throws MissedPropertyException,
96 InvalidPropertyException, MultiplyDefinedException;
99 * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
104 * the simulation context to add
105 * @return the added simulation context
107 SimulationContext addProjectContext(Study aStudy, SimulationContext context);
110 * Remove a simulation context from a study.
115 * the simulation context to remove
116 * @return true if removing succeeded
118 boolean removeProjectContext(Study aStudy, SimulationContext context);
121 * Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
122 * document of the study.
125 * the study to demote
126 * @return true if the demotion succeeded.
128 boolean demote(Study aStudy);
131 * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
132 * final result document of the study.
135 * the study to promote
136 * @return true if the promotion succeeded.
138 boolean promote(Study aStudy);
141 * Add a contributor to the study.
147 * @return true if addition succeeded
149 boolean addContributor(Study aStudy, User user);
152 * Remove contributors from the study.
158 * @return true if removing succeeded
160 boolean removeContributor(Study aStudy, User... users);
163 * Set a validation cycle for documents of the given type in the given study.
170 * validation cycle properties
172 void setValidationCycle(Study aStudy, DocumentType type,
173 ValidationCycle.Properties vprop);
176 * Moves this study from the Private to the Public area of the repository.
180 * @return true if the move succeeded.
183 boolean moveToPublic(Study aStudy);
186 * Moves this study from the Public to the Private area of the repository.
190 * @return true if the move succeeded.
192 boolean moveToPrivate(Study aStudy);
195 * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
196 * previously be approved.
200 * @return true if the move succeeded.
201 * @see #moveToPublic()
203 * @see Publication#approve(Date)
205 boolean moveToReference(Study aStudy);
211 * the study to update
213 * new properties of the study
214 * @return true if the study has been updated successfully
215 * @throws InvalidPropertyException
216 * if an invalid value is passed to a property
218 boolean update(Study aStudy, Properties sprop)
219 throws InvalidPropertyException;
222 * Initialize shortcuts of the study as its transient collections.
227 void loadWorkflow(Study aStudy);
230 * Returns the validation cycle of the given document type.
235 * the document type being subject of validation
236 * @return the validation cycle of the document, or null if not defined.
238 ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
241 * Checks if the given user participates to this study. The Study staff includes the author and contributors.
246 * the user to look for
247 * @return true if the given user is actor of this study.
248 * @see #getContributors()
250 boolean isStaffedBy(Study aStudy, User user);
253 * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
258 * the user to look for
259 * @return true if the given user is actor of this study.
262 boolean hasActor(Study aStudy, User user);
265 * Returns unmodifiable initialized transient list of contributors of this study.
269 * @return the unmodifiable not null transient list of contributors of this study
271 List<User> getContributors(Study aStudy);
274 * Mark study as reference.
279 void markStudyAsReference(Study aStudy);
282 * Remove study as reference. This operation is inverse one to Mark as reference.
287 void removeStudyAsReference(Study aStudy);
290 * Get the description attribute related to the study (there supposed to be the only one such attribute in the database).
294 * @return the description attribute value (null if does not exist)
295 * @throws InvalidParameterException
296 * if a study with such id does not exist in the database.
298 String getDescription(Long studyId) throws InvalidParameterException;
301 * Set the description attribute related to the study.
305 * @param descriptionText
306 * the description text
307 * @throws InvalidParameterException
308 * if some parameters are invalid.
310 void setDescription(Long studyId, String descriptionText)
311 throws InvalidParameterException;
314 * Remove a description attached to a study.
318 * @throws InvalidParameterException
319 * if no study with such Id has been found in the database.
320 * @return true if succeeded, false if study doesn't have a description.
322 boolean removeDescription(final Long studyId)
323 throws InvalidParameterException;
326 * Compare the studies and generate the file that contains the result chart.
329 * the list of dtos each contains information: StudyTitle, ScenarioTitle, PathToFile in vault.
331 * the name of the user who compare the results.
332 * @throws IncompatibleDataException
333 * if data is incompatible for "Compare the studies" functionality.
335 * @return path to result file in the vault.
337 String compare(List<DocToCompareDTO> docsList, final String userName)
338 throws IncompatibleDataException;