]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman-Common/src/org/splat/service/StudyService.java
Salome HOME
Publish the study functionality is improved, protect the study functionality is imple...
[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.Study.Properties;
20 import org.splat.dal.bo.som.ValidationCycle;
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 Private area of the repository.
177          * 
178          * @param aStudy
179          *            the study to move
180          * @return true if the move succeeded.
181          */
182         boolean moveToPrivate(Study aStudy);
183
184         /**
185          * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
186          * previously be approved.
187          * 
188          * @param aStudy
189          *            the study to move
190          * @return true if the move succeeded.
191          * @see #moveToPublic()
192          * @see #isPublic()
193          * @see Publication#approve(Date)
194          */
195         boolean moveToReference(Study aStudy);
196
197         /**
198          * Update a study.
199          * 
200          * @param aStudy
201          *            the study to update
202          * @param sprop
203          *            new properties of the study
204          * @return true if the study has been updated successfully
205          * @throws InvalidPropertyException
206          *             if some property doesn't exist
207          */
208         boolean update(Study aStudy, Properties sprop)
209                         throws InvalidPropertyException;
210
211         /**
212          * Initialize shortcuts of the study as its transient collections.
213          * 
214          * @param aStudy
215          *            the study
216          */
217         void loadWorkflow(Study aStudy);
218
219         /**
220          * Returns the validation cycle of the given document type.
221          * 
222          * @param aStudy
223          *            the study
224          * @param type
225          *            the document type being subject of validation
226          * @return the validation cycle of the document, or null if not defined.
227          */
228         ValidationCycle getValidationCycleOf(Study aStudy, DocumentType type);
229
230         /**
231          * Checks if the given user participates to this study. The Study staff includes the author and contributors.
232          * 
233          * @param aStudy
234          *            the study
235          * @param user
236          *            the user to look for
237          * @return true if the given user is actor of this study.
238          * @see #getContributors()
239          */
240         boolean isStaffedBy(Study aStudy, User user);
241
242         /**
243          * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
244          * 
245          * @param aStudy
246          *            the study
247          * @param user
248          *            the user to look for
249          * @return true if the given user is actor of this study.
250          * @see #getActors()
251          */
252         boolean hasActor(Study aStudy, User user);
253
254         /**
255          * Returns unmodifiable initialized transient list of contributors of this study.
256          * 
257          * @param aStudy
258          *            the study
259          * @return the unmodifiable not null transient list of contributors of this study
260          */
261         List<User> getContributors(Study aStudy);
262         
263         /**
264          * Mark study as reference.
265          * 
266          * @param aStudy - the Study
267          * @return true if operation is success
268          */
269         void markStudyAsReference(Study aStudy);
270         
271         /**
272          * Remove study as reference.
273          * This operation is inverse one to Mark as reference.
274          * 
275          * @param aStudy - the Study
276          * @return true if operation is success
277          */
278         void removeStudyAsReference(Study aStudy);
279 }