Salome HOME
VPV fix for the following case:
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / ScenarioService.java
1 /*****************************************************************************
2  * Company         OPEN CASCADE
3  * Application     SIMAN
4  * File            $Id$ 
5  * Creation date   06.10.2012
6  * @author         $Author$
7  * @version        $Revision$
8  *****************************************************************************/
9
10 package org.splat.service;
11
12 import java.io.IOException;
13 import java.util.List;
14
15 import org.splat.dal.bo.kernel.User;
16 import org.splat.dal.bo.som.KnowledgeElement;
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.exception.InvalidParameterException;
21 import org.splat.kernel.InvalidPropertyException;
22 import org.splat.kernel.MismatchException;
23 import org.splat.kernel.MissedPropertyException;
24 import org.splat.kernel.MultiplyDefinedException;
25 import org.splat.kernel.NotApplicableException;
26 import org.splat.service.dto.ScenarioDTO;
27 import org.splat.service.dto.StepDTO;
28 import org.splat.som.Step;
29
30 /**
31  * Scenario service interface.
32  * 
33  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
34  */
35 public interface ScenarioService {
36
37         /**
38          * Get a list of scenarios of a study with the given id.
39          * 
40          * @param studyId
41          *            the study id
42          * @return list of scenario DTOs
43          */
44         public List<ScenarioDTO> getStudyScenarios(final Long studyId);
45
46         /**
47          * Copy content of a source study into the given study up to the given step.
48          * 
49          * @param fromStudyId
50          *            the source study id
51          * @param fromScenId
52          *            the source scenario id
53          * @param finalStepNum
54          *            the final source step number
55          * @param toStudyId
56          *            the target study
57          * @throws InvalidParameterException
58          *             if study, scenario or step is not found
59          * @throws MissedPropertyException
60          *             if document creation is failed
61          * @throws InvalidPropertyException
62          *             if document creation is failed
63          * @throws MultiplyDefinedException
64          *             if document creation is failed
65          * @throws IOException
66          *             if document file creation is failed
67          * @throws NotApplicableException
68          *             if document state is not applicable
69          */
70         public void copyStudyContent(final long fromStudyId, final long fromScenId,
71                         final int finalStepNum, final long toStudyId)
72                         throws InvalidParameterException, MissedPropertyException,
73                         InvalidPropertyException, MultiplyDefinedException,
74                         NotApplicableException, IOException;
75
76         /**
77          * Get lists of scenario steps, documents and files for building siman-salome.conf file.
78          * 
79          * @param scenarioId
80          *            scenario id
81          * @return list of step DTOs
82          */
83         List<StepDTO> getScenarioInfo(long scenarioId);
84
85         /**
86          * Assign context to the study.
87          * 
88          * @param studyId
89          *            study id
90          * @param ctxType
91          *            context type name
92          * @param ctxValue
93          *            context value
94          * @throws InvalidPropertyException
95          *             if an invalid value is passed to a property
96          * @throws MissedPropertyException
97          *             if a mandatory property is missed
98          * @throws MultiplyDefinedException
99          *             if some property is defined several times
100          */
101         public void assignStudyContext(final Long studyId, final String ctxType,
102                         final String ctxValue) throws MissedPropertyException,
103                         InvalidPropertyException, MultiplyDefinedException;
104
105         /**
106          * Create a new study.
107          * 
108          * @param username
109          *            user login
110          * @param title
111          *            study title
112          * @param productName
113          *            study product simulation context value
114          * @param description
115          *            study summary
116          * @return the created study id
117          * @throws InvalidPropertyException
118          *             if an invalid value is passed to a property
119          * @throws MissedPropertyException
120          *             if a mandatory property is missed
121          * @throws MultiplyDefinedException
122          *             if some property is defined several times
123          */
124         long createStudy(final String username, final String title,
125                         final String productName, final String description)
126                         throws InvalidPropertyException, MissedPropertyException,
127                         MultiplyDefinedException;
128
129         /**
130          * Create a new study with one scenario and "product" simulation context.
131          * 
132          * @param sprop
133          *            the study properties
134          * @param oprop
135          *            the scenario properties
136          * @param cprop
137          *            the "product" simulation context properties
138          * @return the created study
139          * @throws MissedPropertyException
140          *             if a mandatory property is missed
141          * @throws InvalidPropertyException
142          *             if a property is invalid
143          * @throws MultiplyDefinedException
144          *             if some property occurs several times
145          */
146         Study createStudy(Study.Properties sprop, Scenario.Properties oprop,
147                         SimulationContext.Properties cprop) throws MissedPropertyException,
148                         InvalidPropertyException, MultiplyDefinedException;
149
150         /**
151          * Add a new scenario to the study.
152          * 
153          * @param aStudy
154          *            the study
155          * @param sprop
156          *            scenario properties
157          * @return the added scenario
158          * @throws MissedPropertyException
159          *             if a mandatory property is missed
160          * @throws InvalidPropertyException
161          *             if an invalid value is passed to a property
162          * @throws MultiplyDefinedException
163          *             if some property occurs several times
164          */
165         Scenario addScenario(Study aStudy, Scenario.Properties sprop)
166                         throws MissedPropertyException, InvalidPropertyException,
167                         MultiplyDefinedException;
168
169         /**
170          * Add a new knowledge element to the scenario.
171          * 
172          * @param aScenario
173          *            the scenario
174          * @param kprop
175          *            knowledge element properties
176          * @return the created knowledge element
177          * @throws MissedPropertyException
178          *             if a mandatory property is missed
179          * @throws InvalidPropertyException
180          *             if an invalid value is passed to a property
181          * @throws MultiplyDefinedException
182          *             if some property is defined several times
183          */
184         KnowledgeElement addKnowledgeElement(Scenario aScenario,
185                         KnowledgeElement.Properties kprop) throws MissedPropertyException,
186                         InvalidPropertyException, MultiplyDefinedException;
187
188         /**
189          * Check-in the scenario after SALOME session. If a document to be checked in already exists then create a new version of it. Otherwise
190          * create a new document of the appropriate step result type.
191          * <ul>
192          * <li>For each new created document version we copy Uses relations from the previous document version. If used document has been also
193          * versioned during this check-in operation then refer to its new version.</li>
194          * <li>For each new document create uses relation to the last versions of results of a previous step.</li>
195          * </ul>
196          * <b>NOTE:</b> Only the first attached file is processed for each document. <br/>All new documents/versions are created in inWORK
197          * state.
198          * 
199          * @param scenId
200          *            the scenario id
201          * @param userId
202          *            the id of the user who modified documents
203          * @param scInfo
204          *            the list of scenario steps DTO
205          * @throws InvalidPropertyException
206          *             if the scenario hasn't some of given steps or documents
207          * @throws IOException
208          *             if a file can't be moved into the vault
209          * @throws MismatchException
210          *             if version creation in some of steps is failed
211          * @throws MissedPropertyException
212          *             if some mandatory property is missed when new document or new document version is created
213          * @throws MultiplyDefinedException
214          *             if some property is defined several times when new document or new document version is created
215          * @throws NotApplicableException
216          *             if failed saving of a new publication with a given state
217          */
218         void checkin(final long scenId, final long userId,
219                         final List<StepDTO> scInfo) throws InvalidPropertyException,
220                         MissedPropertyException, MultiplyDefinedException,
221                         MismatchException, IOException, NotApplicableException;
222
223         /**
224          * Check in the scenario.
225          * 
226          * @param scenarioId
227          *            the id of the scenario to check in
228          * @throws InvalidPropertyException
229          *             if the scenario is not found in the database
230          */
231         public void checkin(final long scenarioId) throws InvalidPropertyException;
232
233         /**
234          * Check out the scenario.
235          * 
236          * @param aScenario
237          *            the scenario to check out
238          * @param user
239          *            the current user
240          * @return true if check out operation succeeded
241          */
242         boolean checkout(Scenario aScenario, User user);
243
244         /**
245          * Mark the given scenario as checked out by the given user.
246          * 
247          * @param scenarioId
248          *            the scenario id
249          * @param userId
250          *            the id of the user performing the check out
251          * @throws InvalidPropertyException
252          *             if the user or the scenario is not found in the database
253          * @throws NotApplicableException
254          *             if the given user can not check out the scenario
255          */
256         public void checkout(final long scenarioId, final long userId)
257                         throws InvalidPropertyException, NotApplicableException;
258
259         /**
260          * Copy contents from other scenario up to its given step into the given scenario.
261          * 
262          * @param scenario
263          *            the target scenario
264          * @param lastep
265          *            the last processed step of the source scenario
266          */
267         void copyContentsUpTo(Scenario scenario, Step lastep);
268
269         /**
270          * Check if the scenario is empty, i.d. no one of its steps doesn't contain any knowledge elements or documents.
271          * 
272          * @param scenario
273          *            the scenario to check
274          * @return true if the scenario is empty
275          */
276         boolean isEmpty(Scenario scenario);
277
278         /**
279          * Remove a knowledge element from a scenario.
280          * 
281          * @param scenario
282          *            the scenario
283          * @param kelm
284          *            the knowledge element to remove
285          * @return true if removal succeeded
286          */
287         boolean removeKnowledgeElement(Scenario scenario, KnowledgeElement kelm);
288
289         /**
290          * Rename the scenario.
291          * 
292          * @param scenario -
293          *            the scenario with a new title.
294          */
295         void renameScenario(final Scenario scenario);
296
297         /**
298          * Remove the scenario.
299          * 
300          * @param scenarioId -
301          *            the id of the scenario to remove.
302          */
303         void removeScenario(final long scenarioId);
304 }