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