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