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.som.Document;
16 import org.splat.dal.bo.som.DocumentType;
17 import org.splat.dal.bo.som.Publication;
18 import org.splat.dal.bo.som.SimulationContext;
19 import org.splat.exception.DocumentIsUsedException;
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.StepCommentDTO;
27 import org.splat.som.Step;
30 * Step service interface.
32 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
34 public interface StepService {
37 * Create a new document published in the given study step.
40 * the target study step
42 * properties of the new document
43 * @return the created publication of the new document
44 * @throws MissedPropertyException
45 * if a mandatory property is missed
46 * @throws InvalidPropertyException
47 * if some property doesn't exist
48 * @throws MultiplyDefinedException
49 * if some property is defined several times
51 * if a file system error occurs
53 Publication createDocument(Step aStep, Document.Properties dprop)
54 throws MissedPropertyException, InvalidPropertyException,
55 MultiplyDefinedException, IOException;
58 * Publish an existing document in the given study step.
61 * the target study step
63 * new properties of the document
64 * @return the created publication of the document
65 * @throws MissedPropertyException
66 * if a mandatory property is missed
67 * @throws InvalidPropertyException
68 * if some property doesn't exist
69 * @throws NotApplicableException
70 * if the document is undefined
72 Publication assignDocument(Step aStep, Document.Properties dprop)
73 throws MissedPropertyException, InvalidPropertyException,
74 NotApplicableException;
77 * Create a new version of a document in the given study step.
82 * the base document published version
84 * properties of the new version
85 * @return the new version publication
86 * @throws MissedPropertyException
87 * if a mandatory property is missed
88 * @throws InvalidPropertyException
89 * if some property doesn't exist
90 * @throws MultiplyDefinedException
91 * if some property is defined several times
93 * if a file system error occurs
94 * @throws MismatchException
95 * if the document is not applicable to the given study step
97 Publication versionDocument(Step aStep, Publication base,
98 Document.Properties dprop) throws MissedPropertyException,
99 InvalidPropertyException, MultiplyDefinedException, IOException,
103 * Add simulation context to the study step.
108 * properties of the simulation context to add
109 * @return the added simulation context
110 * @throws MissedPropertyException
111 * if a mandatory property is missed
112 * @throws InvalidPropertyException
113 * if some property doesn't exist
114 * @throws MultiplyDefinedException
115 * if some property is defined several times
117 SimulationContext addSimulationContext(Step aStep,
118 SimulationContext.Properties dprop) throws MissedPropertyException,
119 InvalidPropertyException, MultiplyDefinedException;
122 * Add simulation context to the study step.
127 * the simulation context to add
128 * @return the added simulation context
130 SimulationContext addSimulationContext(Step firstStep,
131 SimulationContext context);
134 * Remove a simulation context from the study step.
139 * the simulation context to remove
140 * @return true if removal succeeded
142 boolean removeSimulationContext(Step aStep, SimulationContext context);
145 * Add a document publication to the given step.
148 * the target study step
150 * the document publication to add
151 * @return true if publication succeeded
153 boolean add(Step aStep, Publication newdoc);
156 * Remove a document publication from the given step.
161 * the document publication to remove
162 * @return true if removing of the publication succeeded
164 boolean remove(Step aStep, Publication oldoc);
167 * Remove a document from the given step and from the database if it is no more used.
173 * @return true if removing of the document succeeded
174 * @throws DocumentIsUsedException
175 * if the document is used by other documents
177 boolean removeDocument(Step aStep, long docId)
178 throws DocumentIsUsedException;
181 * Get document types which are applicable for the given study step (activity).
185 * @return the list of document types
187 List<DocumentType> getValidDocumentTypes(Step aStep);
191 * Add a comment to study step specified in DTO.
192 * The 'id' field must be null, new primary key will be placed there if succeeded.
193 * User is identified by userId, userName is not necessary.
196 * data to be placed in the comment attribute
197 * @throws InvalidParameterException
198 * if some parameter is invalid
200 void addStepComment(final StepCommentDTO comment) throws InvalidParameterException;
203 * Retrieves from the database all the comments related to the given step.
207 * @return list of StepCommentDTO's with properties 'id', 'text', 'user', 'date' filled in.
209 * @throws InvalidParameterException
210 * if the owner of the step is not found in the database.
212 List<StepCommentDTO> getStepComments(final Step step) throws InvalidParameterException;
215 * Removes the comment with given id from the database.
219 * @throws InvalidParameterException
220 * if the comment is not found in the database.
222 void removeStepComment(final long commentId) throws InvalidParameterException;
226 * Checks if a given comment was made by a given user.
227 * @param commentId the comment id
228 * @param userId the user id
229 * @return if the comment was made by the user
230 * @throws InvalidParameterException if the comment with such id does not exist.
232 boolean isCommentMadeByUser(final long commentId, final long userId) throws InvalidParameterException;
236 * Edit value and title of a comment.
237 * If value or title is null - no changes will be applied to this field.
238 * @param commentId the comment id
239 * @param newValue the new comment value
240 * @param newTitle the new comment title
241 * @throws InvalidParameterException if the comment with such id does not exist.
243 void editStepComment(final long commentId, final String newValue, final String newTitle)
244 throws InvalidParameterException;