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 public List<ScenarioDTO> getStudyScenarios(final Long studyId);
47 * Copy content of a source study into the given study up to the given step.
52 * the source scenario id
54 * the final source step number
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
66 * if document file creation is failed
67 * @throws NotApplicableException
68 * if document state is not applicable
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;
77 * Get lists of scenario steps, documents and files for building siman-salome.conf file.
81 * @return list of step DTOs
83 List<StepDTO> getScenarioInfo(long scenarioId);
86 * Assign context to the study.
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
101 public void assignStudyContext(final Long studyId, final String ctxType,
102 final String ctxValue) throws MissedPropertyException,
103 InvalidPropertyException, MultiplyDefinedException;
106 * Create a new study.
113 * study product simulation context value
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
124 long createStudy(final String username, final String title,
125 final String productName, final String description)
126 throws InvalidPropertyException, MissedPropertyException,
127 MultiplyDefinedException;
130 * Create a new study with one scenario and "product" simulation context.
133 * the study properties
135 * the scenario properties
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
146 Study createStudy(Study.Properties sprop, Scenario.Properties oprop,
147 SimulationContext.Properties cprop) throws MissedPropertyException,
148 InvalidPropertyException, MultiplyDefinedException;
151 * Add a new scenario to the study.
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
165 Scenario addScenario(Study aStudy, Scenario.Properties sprop)
166 throws MissedPropertyException, InvalidPropertyException,
167 MultiplyDefinedException;
170 * Add a new knowledge element to the scenario.
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
184 KnowledgeElement addKnowledgeElement(Scenario aScenario,
185 KnowledgeElement.Properties kprop) throws MissedPropertyException,
186 InvalidPropertyException, MultiplyDefinedException;
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.
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>
196 * <b>NOTE:</b> Only the first attached file is processed for each document. <br/>All new documents/versions are created in inWORK
202 * the id of the user who modified documents
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
218 void checkin(final long scenId, final long userId,
219 final List<StepDTO> scInfo) throws InvalidPropertyException,
220 MissedPropertyException, MultiplyDefinedException,
221 MismatchException, IOException, NotApplicableException;
224 * Check in the scenario.
227 * the id of the scenario to check in
228 * @throws InvalidPropertyException
229 * if the scenario is not found in the database
231 public void checkin(final long scenarioId) throws InvalidPropertyException;
234 * Check out the scenario.
237 * the scenario to check out
240 * @return true if check out operation succeeded
242 boolean checkout(Scenario aScenario, User user);
245 * Mark the given scenario as checked out by the given user.
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
256 public void checkout(final long scenarioId, final long userId)
257 throws InvalidPropertyException, NotApplicableException;
260 * Copy contents from other scenario up to its given step into the given scenario.
263 * the target scenario
265 * the last processed step of the source scenario
267 void copyContentsUpTo(Scenario scenario, Step lastep);
270 * Check if the scenario is empty, i.d. no one of its steps doesn't contain any knowledge elements or documents.
273 * the scenario to check
274 * @return true if the scenario is empty
276 boolean isEmpty(Scenario scenario);
279 * Remove a knowledge element from a scenario.
284 * the knowledge element to remove
285 * @return true if removal succeeded
287 boolean removeKnowledgeElement(Scenario scenario, KnowledgeElement kelm);
290 * Rename the scenario.
293 * the scenario with a new title.
295 void renameScenario(final Scenario scenario);
298 * Remove the scenario.
300 * @param scenarioId -
301 * the id of the scenario to remove.
303 void removeScenario(final long scenarioId);