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