1 /*****************************************************************************
5 * Creation date 06.10.2012
8 *****************************************************************************/
10 package org.splat.service;
13 import java.io.FileNotFoundException;
14 import java.io.IOException;
15 import java.text.ParseException;
16 import java.util.Date;
17 import java.util.List;
19 import org.splat.dal.bo.kernel.User;
20 import org.splat.dal.bo.som.ConvertsRelation;
21 import org.splat.dal.bo.som.Document;
22 import org.splat.dal.bo.som.DocumentType;
23 import org.splat.dal.bo.som.ProgressState;
24 import org.splat.dal.bo.som.ProjectElement;
25 import org.splat.dal.bo.som.Publication;
26 import org.splat.dal.bo.som.Study;
27 import org.splat.dal.bo.som.Timestamp;
28 import org.splat.exception.IncompatibleDataException;
29 import org.splat.exception.InvalidParameterException;
30 import org.splat.kernel.InvalidPropertyException;
31 import org.splat.kernel.MismatchException;
32 import org.splat.kernel.MissedPropertyException;
33 import org.splat.kernel.MultiplyDefinedException;
34 import org.splat.kernel.NotApplicableException;
35 import org.splat.service.dto.DocToCompareDTO;
36 import org.splat.som.DocumentRights;
37 import org.splat.som.Revision;
38 import org.splat.som.Step;
41 * Publication service interface.
43 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
45 public interface PublicationService {
48 * Copy the publication to the given project element.
51 * the publication to copy
53 * the target project element
54 * @return the created copy of the publication
56 Publication copy(Publication aPublication, ProjectElement publisher);
58 public Publication createDoc(final long ownerId, final Step step,
59 final long documentTypeId, final long userId, final String fname,
60 final String doctitle, final ProgressState docstate,
61 final String reference, final String version, final Date docDate,
62 final List<Long> docuses) throws MissedPropertyException,
63 InvalidPropertyException, MultiplyDefinedException, IOException,
64 NotApplicableException, InterruptedException, ParseException;
67 * Create a new version of the document.
70 * the study step where the document is published
74 * the new version file name
78 * new document version string, empty for external documents
82 * the new state of the document
84 * the new modification date
86 * the array of documents ids used by the versioned document
88 * the array of impacted documents ids
89 * @throws MissedPropertyException
90 * if some mandatory property is missed
91 * @throws InvalidPropertyException
92 * if some property has invalid value
93 * @throws MultiplyDefinedException
94 * if some property occurs several times
96 * if file moving is failed
97 * @throws MismatchException
98 * if step number in properties doesn't match to the given step
99 * @throws NotApplicableException
100 * if publication's document is undefined
101 * @throws InterruptedException
102 * by Thread.sleep if interrupted
104 void versionDocument(Step step, User user, String filename, long docIndex,
105 String docver, String summary, ProgressState state, Date date,
106 String[] docuses, long[] docusedby) throws MissedPropertyException,
107 InvalidPropertyException, MultiplyDefinedException, IOException,
108 MismatchException, NotApplicableException, InterruptedException;
111 * Returns the study Step into which the document version referenced by this publication has been published.
113 * @param aPublication
114 * the document publication
117 Step getInvolvedStep(Publication aPublication);
120 * Promotes the document referenced by this publication from In-Check to Approved state, if not out-dated, and attaches the
121 * corresponding time-stamp to the document.<br/> If the promoted document is the final result of the owner study, the study is itself
122 * is promoted as well.<br/> <br/> Limitation: the way this promotion is propagated to the study supposes that the study has only ONE
123 * final result document.
125 * @param aPublication
126 * the document publication
128 * the date of approval
129 * @return true if the approval succeeded
130 * @see #getProgressState()
131 * @see DocumentRights#canApprove()
132 * @see DocumentType#isStudyResult()
133 * @see Study#getApproverOf(Publication)
135 Timestamp approve(Publication aPublication, Date adate);
138 * Demotes the document referenced by this publication to In-Work state, and removes the Promoter of the document, if exist.<br/> The
139 * In-Draft state is skipped (direct demotion to In-Work) if the validation cycle of the document does not include the review step.<br/>
140 * If the demoted document is the final result of the owner study, the study is itself is demoted as well.<br/> <br/> Limitation: the
141 * way this demotion is propagated to the study supposes that the study has only ONE final result document.
143 * @param aPublication
144 * the document publication
145 * @return true if the demotion succeeded
146 * @see #getProgressState()
147 * @see DocumentRights#canDemote()
148 * @see DocumentType#isStudyResult()
150 boolean demote(Publication aPublication);
153 * Undo the review operation by demoting the document referenced by this publication from In-Check to In-Draft state and removing the
154 * Reviewer.<br/> If the demoted document is the final result of the owner study, the study is itself is demoted as well.<br/> <br/>
155 * Limitation: the way this demotion is propagated to the study supposes that the study has only ONE final result document.
157 * @param aPublication
158 * the document publication
159 * @return true if the demotion succeeded
160 * @see #getProgressState()
162 * @see DocumentRights#canInvalidate()
163 * @see DocumentType#isStudyResult()
165 boolean invalidate(Publication aPublication);
168 * Promotes the document referenced by this publication from In-Work to In-Draft or In-Check state, if not out-dated, and attaches the
169 * corresponding time-stamp to the document.<br/> The In-Draft state is skipped (direct promotion to In-Check) if the validation cycle
170 * of the document does not include the review step.<br/> Also, if the promoted document is the final result of the owner study, the
171 * study is itself promoted as well.<br/> This operation can be undo-ed by demote().<br/> <br/> Limitation: the way this promotion is
172 * propagated to the study supposes that the study has only ONE final result document.
174 * @param aPublication
175 * the document publication
177 * the date of promotion
178 * @return true if the promotion succeeded
179 * @see #getProgressState()
181 * @see DocumentRights#canPromote()
182 * @see DocumentType#isStudyResult()
184 Timestamp promote(Publication aPublication, Date pdate);
187 * Promotes the document referenced by this publication from In-Draft to In-Check state, if not out-dated, and attaches the
188 * corresponding time-stamp to the document.<br/> If the promoted document is the final result of the owner study, the study is itself
189 * is promoted as well.<br/> This operation can be undo-ed by invalidate().<br/> <br/> Limitation: the way this promotion is
190 * propagated to the study supposes that the study has only ONE final result document.
192 * @param aPublication
193 * the document publication
196 * @return true if the review succeeded
197 * @see #getProgressState()
199 * @see DocumentRights#canReview()
200 * @see DocumentType#isStudyResult()
201 * @see Study#getReviewerOf(Publication)
203 Timestamp review(Publication aPublication, Date rdate);
206 * Publishes the document referenced by this publication into the owner Project Element under the given state, the revision number of
207 * the document being automatically set accordingly. If the given state is In-Draft and the document is final result of the owner study,
208 * this automatically promotes the study to In-Draft. The old publication is removed from the scenario.
210 * @param aPublication
211 * the document publication
213 * the required progress state
214 * @throws FileNotFoundException
215 * If the referenced document is empty
216 * @throws NotApplicableException
217 * If the referenced document is undefined
219 void saveAs(Publication aPublication, ProgressState state)
220 throws FileNotFoundException, NotApplicableException;
223 * Publishes the document referenced by this publication into the owner Project Element under the given revision number.<br/> The state
224 * of the referenced document is supposed being automatically set according to the given revision number, but, due to the versioning
225 * scheme, as it is not possible to differentiate In-Work and In-Draft states, this function has been deprecated (it is currently used
226 * only for the need of integration of Microsoft Office which anyway has to be redesigned). <br/> Note: in the context of branch
227 * versioning, the given revision may be modified by an update of the branch name. The old publication is removed from the scenario.
229 * @param aPublication
230 * the document publication
232 * the required revision number
233 * @throws FileNotFoundException
234 * If the referenced document is empty
235 * @throws NotApplicableException
236 * If the referenced document is undefined
240 void saveAs(Publication aPublication, Revision newvers)
241 throws FileNotFoundException, NotApplicableException;
244 * Rename the published document.
246 * @param aPublication
247 * the publication of the document
249 * the new document title
250 * @throws InvalidPropertyException
251 * if the new title is empty
253 void rename(Publication aPublication, String title)
254 throws InvalidPropertyException;
257 * Replace the document source file. The document status must be inWORK or <BR>
258 * EXTERN to be able to replace the source file.
261 * document publication
266 * @return true if succeeded otherwise return false
267 * @throws IncompatibleDataException
268 * if the document status is not valid for replacing
270 boolean replace(final Publication pub, final File newFile,
271 final Date modifTime) throws IncompatibleDataException;
274 * Create "Converts" relation for the given document publication and format.
276 * @param aPublication
277 * the document publication
280 * @return the created "Converts" relation
282 ConvertsRelation attach(Publication aPublication, String format);
285 * Create "Converts" relation for the given document publication, format and description.
287 * @param aPublication
288 * the document publication
292 * the description of the relation
293 * @return the created "Converts" relation
295 ConvertsRelation attach(Publication aPublication, String format,
299 * Searches for a document which is connected by chain of versioning operations with the given
300 * and belongs to a publication from given project element.
301 * If the given document is the last version, it will be returned.
302 * @param doc the document
303 * @param owner the project element
304 * @return the document if found, null otherwise
306 Document getLastVersion(final Document doc, final ProjectElement owner);
309 * Undo the out-date operation.
311 * @param aPublication
313 * @return true if the acceptance succeeds
315 * @see DocumentRights#canAccept()
317 boolean actualize(Publication aPublication);
320 * Out-dates this publication and recursively all publications using this one. Typically, a publication is out-dated when modifying a
321 * document to which it depends.
323 * @param aPublication
326 * @see #getProgressState()
329 void outdate(Publication aPublication);
332 * Get DocToCompareDTO by publication id.
334 * @param publicationId
336 * @return DocToCompareDTO
337 * @throws InvalidParameterException
338 * if there is no document with such id.
340 DocToCompareDTO getDocToCompareDTO(long publicationId)
341 throws InvalidParameterException;