1 /*****************************************************************************
5 * Creation date 06.10.2012
8 *****************************************************************************/
10 package org.splat.service;
12 import java.io.IOException;
13 import java.util.List;
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;
31 * Scenario service interface.
33 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
35 public interface ScenarioService {
38 * Get a list of scenarios of a study with the given id.
42 * @return list of scenario DTOs
44 List<ScenarioDTO> getStudyScenarios(final Long studyId);
47 * Get a new id to document arriver after check-out.
48 * Return two several values: -1 or ID of the existing document.
52 * @param activityNumber
53 * the number of activity
58 * @return new document id or -1 if same document do nor exist.
60 * @throws InvalidPropertyException if activityNumber is incorrect.
63 long getNewDocumentId(final long scenId,
64 final int activityNumber, final Long docId,
65 final String fileExt) throws InvalidPropertyException;
68 * Copy content of a source study into the given study up to the given step.
73 * the source scenario id
75 * the final source step number
78 * @throws InvalidParameterException
79 * if study, scenario or step is not found
80 * @throws MissedPropertyException
81 * if document creation is failed
82 * @throws InvalidPropertyException
83 * if document creation is failed
84 * @throws MultiplyDefinedException
85 * if document creation is failed
87 * if document file creation is failed
88 * @throws NotApplicableException
89 * if document state is not applicable
91 void copyStudyContent(final long fromStudyId, final long fromScenId,
92 final int finalStepNum, final long toStudyId)
93 throws InvalidParameterException, MissedPropertyException,
94 InvalidPropertyException, MultiplyDefinedException,
95 NotApplicableException, IOException;
98 * Get lists of scenario steps, documents and files for building siman-salome.conf file.
102 * @return list of step DTOs
104 List<StepDTO> getScenarioInfo(long scenarioId);
107 * Assign context to the study.
115 * @throws InvalidPropertyException
116 * if an invalid value is passed to a property
117 * @throws MissedPropertyException
118 * if a mandatory property is missed
119 * @throws MultiplyDefinedException
120 * if some property is defined several times
122 void assignStudyContext(final Long studyId, final String ctxType,
123 final String ctxValue) throws MissedPropertyException,
124 InvalidPropertyException, MultiplyDefinedException;
127 * Create a new study.
134 * study product simulation context value
137 * @return the created study id
138 * @throws InvalidPropertyException
139 * if an invalid value is passed to a property
140 * @throws MissedPropertyException
141 * if a mandatory property is missed
142 * @throws MultiplyDefinedException
143 * if some property is defined several times
145 long createStudy(final String username, final String title,
146 final String productName, final String description)
147 throws InvalidPropertyException,
148 MissedPropertyException,
149 MultiplyDefinedException;
152 * Create a new study with one scenario and "product"
153 * simulation context.
156 * the study properties
158 * the scenario properties
160 * the "product" simulation context properties
161 * @return the created study
162 * @throws MissedPropertyException
163 * if a mandatory property is missed
164 * @throws InvalidPropertyException
165 * if a property is invalid
166 * @throws MultiplyDefinedException
167 * if some property occurs several times
169 Study createStudy(Study.Properties sprop, Scenario.Properties oprop,
170 SimulationContext.Properties cprop) throws MissedPropertyException,
171 InvalidPropertyException, MultiplyDefinedException;
174 * Add a new scenario to the study.
179 * scenario properties
180 * @return the added scenario
181 * @throws MissedPropertyException
182 * if a mandatory property is missed
183 * @throws InvalidPropertyException
184 * if an invalid value is passed to a property
185 * @throws MultiplyDefinedException
186 * if some property occurs several times
188 Scenario addScenario(Study aStudy, Scenario.Properties sprop)
189 throws MissedPropertyException, InvalidPropertyException,
190 MultiplyDefinedException;
193 * Add a new knowledge element to the scenario.
198 * knowledge element properties
199 * @return the created knowledge element
200 * @throws MissedPropertyException
201 * if a mandatory property is missed
202 * @throws InvalidPropertyException
203 * if an invalid value is passed to a property
204 * @throws MultiplyDefinedException
205 * if some property is defined several times
207 KnowledgeElement addKnowledgeElement(Scenario aScenario,
208 KnowledgeElement.Properties kprop) throws MissedPropertyException,
209 InvalidPropertyException, MultiplyDefinedException;
212 * Check-in the scenario after SALOME session. If a document to be checked in already exists then create a new version of it. Otherwise
213 * create a new document of the appropriate step result type.
215 * <li>For each new created document version we copy Uses relations from the previous document version. If used document has been also
216 * versioned during this check-in operation then refer to its new version.</li>
217 * <li>For each new document create uses relation to the last versions of results of a previous step.</li>
219 * <b>NOTE:</b> Only the first attached file is processed for each document. <br/>All new documents/versions are created in inWORK
225 * the id of the user who modified documents
227 * the list of scenario steps DTO
228 * @throws InvalidPropertyException
229 * if the scenario hasn't some of given steps or documents
230 * @throws IOException
231 * if a file can't be moved into the vault
232 * @throws MismatchException
233 * if version creation in some of steps is failed
234 * @throws MissedPropertyException
235 * if some mandatory property is missed when new document or new document version is created
236 * @throws MultiplyDefinedException
237 * if some property is defined several times when new document or new document version is created
238 * @throws NotApplicableException
239 * if failed saving of a new publication with a given state
241 void checkin(final long scenId, final long userId,
242 final List<StepDTO> scInfo) throws InvalidPropertyException,
243 MissedPropertyException, MultiplyDefinedException,
244 MismatchException, IOException, NotApplicableException;
247 * Check in the scenario.
250 * the id of the scenario to check in
251 * @throws InvalidPropertyException
252 * if the scenario is not found in the database
254 void checkin(final long scenarioId) throws InvalidPropertyException;
257 * Check out the scenario.
260 * the scenario to check out
263 * @return true if check out operation succeeded
265 boolean checkout(Scenario aScenario, User user);
268 * Mark the given scenario as checked out by the given user.
273 * the id of the user performing the check out
274 * @throws InvalidPropertyException
275 * if the user or the scenario is not found in the database
276 * @throws NotApplicableException
277 * if the given user can not check out the scenario
279 void checkout(final long scenarioId, final long userId)
280 throws InvalidPropertyException, NotApplicableException;
283 * Copy contents from other scenario up to its given step into the given scenario.
286 * the target scenario
288 * the last processed step of the source scenario
290 void copyContentsUpTo(Scenario scenario, Step lastep);
293 * Check if the scenario is empty, i.d. no one of its steps doesn't contain any knowledge elements or documents.
296 * the scenario to check
297 * @return true if the scenario is empty
299 boolean isEmpty(Scenario scenario);
302 * Remove a knowledge element from a scenario.
307 * the knowledge element to remove
308 * @return true if removal succeeded
310 boolean removeKnowledgeElement(Scenario scenario, KnowledgeElement kelm);
313 * Rename the scenario.
316 * the scenario with a new title.
318 void renameScenario(final Scenario scenario);
321 * Remove the scenario.
323 * @param scenarioId -
324 * the id of the scenario to remove.
326 void removeScenario(final long scenarioId);