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