Salome HOME
Modifications done to respect PMD rules. Versioning a document is fixed. Validation...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / StudyService.java
1 /*****************************************************************************
2  * Company         OPEN CASCADE
3  * Application     SIMAN
4  * File            Id: 
5  * Creation date   02.10.2012
6  * @author         Author: Maria KRUCHININA
7  * @version        Revision: 
8  *****************************************************************************/
9
10 package org.splat.service;
11
12 import java.util.List;
13
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;
24
25 /**
26  * This class defines all methods for creation, modification the study.
27  * 
28  * @author Maria KRUCHININA
29  * 
30  */
31 public interface StudyService {
32
33         /**
34          * Increment total number of study documents including versions (docount) and update it in the study.
35          * 
36          * @param aStudy
37          *            the study
38          * @return incremented docount value
39          */
40         int generateLocalIndex(Study aStudy);
41
42         /**
43          * Get study by its id.
44          * 
45          * @param index
46          *            the study id
47          * @return found study or null
48          */
49         Study selectStudy(long index);
50
51         /**
52          * Create a new study.
53          * 
54          * @param sprop
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
63          */
64         Study createStudy(Study.Properties sprop)
65                         throws MissedPropertyException, InvalidPropertyException,
66                         MultiplyDefinedException;
67
68         /**
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.
70          * 
71          * @param aStudy
72          *            the study
73          * @param cprop
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
82          */
83         SimulationContext addProjectContext(Study aStudy,
84                         SimulationContext.Properties cprop) throws MissedPropertyException,
85                         InvalidPropertyException, MultiplyDefinedException;
86
87         /**
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.
89          * 
90          * @param aStudy
91          *            the study
92          * @param context
93          *            the simulation context to add
94          * @return the added simulation context
95          */
96         SimulationContext addProjectContext(Study aStudy,
97                         SimulationContext context);
98
99         /**
100          * Remove a simulation context from a study.
101          * 
102          * @param aStudy
103          *            the study
104          * @param context
105          *            the simulation context to remove
106          * @return true if removing succeeded
107          */
108         boolean removeProjectContext(Study aStudy, SimulationContext context);
109
110         /**
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.
113          * 
114          * @param aStudy
115          *            the study to demote
116          * @return true if the demotion succeeded.
117          */
118         boolean demote(Study aStudy);
119
120         /**
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.
123          * 
124          * @param aStudy
125          *            the study to promote
126          * @return true if the promotion succeeded.
127          */
128         boolean promote(Study aStudy);
129
130         /**
131          * Add a contributor to the study.
132          * 
133          * @param aStudy
134          *            the study
135          * @param user
136          *            the contributor
137          * @return true if addition succeeded
138          */
139         boolean addContributor(Study aStudy, User user);
140
141         /**
142          * Remove contributors from the study.
143          * 
144          * @param aStudy
145          *            the study
146          * @param users
147          *            contributor(s)
148          * @return true if removing succeeded
149          */
150         boolean removeContributor(Study aStudy, User... users);
151
152         /**
153          * Set a validation cycle for documents of the given type in the given study.
154          * 
155          * @param aStudy
156          *            the target study
157          * @param type
158          *            the document type
159          * @param vprop
160          *            validation cycle properties
161          */
162         void setValidationCycle(Study aStudy, DocumentType type,
163                         ValidationCycle.Properties vprop);
164
165         /**
166          * Moves this study from the Private to the Public area of the repository.
167          * 
168          * @param aStudy
169          *            the study to move
170          * @return true if the move succeeded.
171          * @see #isPublic()
172          */
173         boolean moveToPublic(Study aStudy);
174
175         /**
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.
178          * 
179          * @param aStudy
180          *            the study to move
181          * @return true if the move succeeded.
182          * @see #moveToPublic()
183          * @see #isPublic()
184          * @see Publication#approve(Date)
185          */
186         boolean moveToReference(Study aStudy);
187
188         /**
189          * Update a study.
190          * 
191          * @param aStudy
192          *            the study to update
193          * @param sprop
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
198          */
199         boolean update(Study aStudy, Properties sprop)
200                         throws InvalidPropertyException;
201
202         /**
203          * Initialize shortcuts of the study as its transient collections.
204          * 
205          * @param aStudy
206          *            the study
207          */
208         void loadWorkflow(Study aStudy);
209
210         /**
211          * Returns the validation cycle of the given document type.
212          * 
213          * @param aStudy
214          *            the study
215          * @param type
216          *            the document type being subject of validation
217          * @return the validation cycle of the document, or null if not defined.
218          */
219         ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
220
221         /**
222          * Checks if the given user participates to this study. The Study staff includes the author and contributors.
223          * 
224          * @param aStudy
225          *            the study
226          * @param user
227          *            the user to look for
228          * @return true if the given user is actor of this study.
229          * @see #getContributors()
230          */
231         boolean isStaffedBy(Study aStudy, User user);
232
233         /**
234          * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
235          * 
236          * @param aStudy
237          *            the study
238          * @param user
239          *            the user to look for
240          * @return true if the given user is actor of this study.
241          * @see #getActors()
242          */
243         boolean hasActor(Study aStudy, User user);
244
245         /**
246          * Returns unmodifiable initialized transient list of contributors of this study.
247          * 
248          * @param aStudy
249          *            the study
250          * @return the unmodifiable not null transient list of contributors of this study
251          */
252         List<User> getContributors(Study aStudy);
253 }