]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman-Common/src/org/splat/service/StudyService.java
Salome HOME
Database class usage is removed from StudyService.
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / StudyService.java
1 /*****************************************************************************
2  * Company         EURIWARE
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 org.splat.dal.bo.kernel.User;
13 import org.splat.dal.bo.som.DocumentType;
14 import org.splat.dal.bo.som.Publication;
15 import org.splat.dal.bo.som.Scenario;
16 import org.splat.dal.bo.som.SimulationContext;
17 import org.splat.dal.bo.som.Study;
18 import org.splat.dal.bo.som.ValidationCycle;
19 import org.splat.dal.bo.som.Study.Properties;
20 import org.splat.kernel.InvalidPropertyException;
21 import org.splat.kernel.MissedPropertyException;
22 import org.splat.kernel.MultiplyDefinedException;
23
24 /**
25  * This class defines all methods for creation, modification the study.
26  * 
27  * @author Maria KRUCHININA
28  * 
29  */
30 public interface StudyService {
31
32         /**
33          * Increment total number of study documents including versions (docount) and update it in the study.
34          * @param aStudy the study
35          * @return incremented docount value
36          */
37         public int generateLocalIndex(Study aStudy);
38
39         /**
40          * Get study by its id.
41          * 
42          * @param index
43          *            the study id
44          * @return found study or null
45          */
46         public Study selectStudy(long index);
47
48         /**
49          * Create a new study.
50          * 
51          * @param sprop
52          *            properties of the new study
53          * @return the created study
54          * @throws MissedPropertyException
55          *             if a mandatory property is missed
56          * @throws InvalidPropertyException
57          *             if some property doesn't exist
58          * @throws MultiplyDefinedException
59          *             if some property is defined several times
60          */
61         public Study createStudy(Study.Properties sprop)
62                         throws MissedPropertyException, InvalidPropertyException,
63                         MultiplyDefinedException;
64
65         /**
66          * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
67          * 
68          * @param aStudy
69          *            the study
70          * @param cprop
71          *            the simulation context properties
72          * @return the added simulation context
73          * @throws MissedPropertyException
74          *             if a mandatory property is missed
75          * @throws InvalidPropertyException
76          *             if some property doesn't exist
77          * @throws MultiplyDefinedException
78          *             if some property occurs several times
79          */
80         public SimulationContext addProjectContext(Study aStudy,
81                         SimulationContext.Properties cprop) throws MissedPropertyException,
82                         InvalidPropertyException, MultiplyDefinedException;
83
84         /**
85          * Add a simulation context to the first step of the study. If the context doesn't yet saved it is created in the database.
86          * 
87          * @param aStudy
88          *            the study
89          * @param context
90          *            the simulation context to add
91          * @return the added simulation context
92          */
93         public SimulationContext addProjectContext(Study aStudy,
94                         SimulationContext context);
95
96         /**
97          * Add a new scenario to the study.
98          * 
99          * @param aStudy
100          *            the study
101          * @param sprop
102          *            scenario properties
103          * @return the added scenario
104          * @throws MissedPropertyException
105          *             if a mandatory property is missed
106          * @throws InvalidPropertyException
107          *             if some property doesn't exist
108          * @throws MultiplyDefinedException
109          *             if some property occurs several times
110          */
111         public Scenario addScenario(Study aStudy, Scenario.Properties sprop)
112                         throws MissedPropertyException, InvalidPropertyException,
113                         MultiplyDefinedException;
114
115         /**
116          * Remove a simulation context from a study.
117          * @param aStudy the study
118          * @param context the simulation context to remove
119          * @return true if removing succeeded
120          */
121         public boolean removeProjectContext(Study aStudy, SimulationContext context);
122
123         /**
124          * Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
125          * document of the study.
126          * 
127          * @param aStudy
128          *            the study to demote
129          * @return true if the demotion succeeded.
130          */
131         public boolean demote(Study aStudy);
132
133         /**
134          * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
135          * final result document of the study.
136          * 
137          * @param aStudy
138          *            the study to promote
139          * @return true if the promotion succeeded.
140          */
141         public boolean promote(Study aStudy);
142
143         /**
144          * Add a contributor to the study.
145          * 
146          * @param aStudy
147          *            the study
148          * @param user
149          *            the contributor
150          * @return true if addition succeeded
151          */
152         public boolean addContributor(Study aStudy, User user);
153
154         /**
155          * Remove contributors from the study.
156          * 
157          * @param aStudy
158          *            the study
159          * @param users
160          *            contributor(s)
161          * @return true if removing succeeded
162          */
163         public boolean removeContributor(Study aStudy, User... users);
164
165         /**
166          * Set a validation cycle for documents of the given type in the given study.
167          * 
168          * @param aStudy
169          *            the target study
170          * @param type
171          *            the document type
172          * @param vprop
173          *            validation cycle properties
174          */
175         public void setValidationCycle(Study aStudy, DocumentType type,
176                         ValidationCycle.Properties vprop);
177
178         /**
179          * Moves this study from the Private to the Public area of the repository.
180          * 
181          * @param aStudy
182          *            the study to move
183          * @return true if the move succeeded.
184          * @see #isPublic()
185          */
186         public boolean moveToPublic(Study aStudy);
187
188         /**
189          * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
190          * previously be approved.
191          * 
192          * @param aStudy
193          *            the study to move
194          * @return true if the move succeeded.
195          * @see #moveToPublic()
196          * @see #isPublic()
197          * @see Publication#approve(Date)
198          */
199         public boolean moveToReference(Study aStudy);
200
201         /**
202          * Update a study.
203          * 
204          * @param aStudy
205          *            the study to update
206          * @param sprop
207          *            new properties of the study
208          * @return true if the study has been updated successfully
209          * @throws InvalidPropertyException
210          *             if some property doesn't exist
211          */
212         public boolean update(Study aStudy, Properties sprop)
213                         throws InvalidPropertyException;
214 }