1 /*****************************************************************************
5 * Creation date 06.10.2012
8 *****************************************************************************/
10 package org.splat.service;
12 import java.io.FileNotFoundException;
13 import java.io.IOException;
14 import java.text.ParseException;
15 import java.util.Date;
16 import java.util.List;
18 import org.splat.dal.bo.kernel.User;
19 import org.splat.dal.bo.som.ConvertsRelation;
20 import org.splat.dal.bo.som.DocumentType;
21 import org.splat.dal.bo.som.ProgressState;
22 import org.splat.dal.bo.som.ProjectElement;
23 import org.splat.dal.bo.som.Publication;
24 import org.splat.dal.bo.som.Study;
25 import org.splat.dal.bo.som.Timestamp;
26 import org.splat.exception.InvalidParameterException;
27 import org.splat.kernel.InvalidPropertyException;
28 import org.splat.kernel.MismatchException;
29 import org.splat.kernel.MissedPropertyException;
30 import org.splat.kernel.MultiplyDefinedException;
31 import org.splat.kernel.NotApplicableException;
32 import org.splat.service.dto.DocToCompareDTO;
33 import org.splat.som.DocumentRights;
34 import org.splat.som.Revision;
35 import org.splat.som.Step;
38 * Publication service interface.
40 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
42 public interface PublicationService {
45 * Copy the publication to the given project element.
48 * the publication to copy
50 * the target project element
51 * @return the created copy of the publication
53 Publication copy(Publication aPublication, ProjectElement publisher);
55 public Publication createDoc(final long ownerId, final Step step,
56 final long documentTypeId, final long userId, final String fname,
57 final String doctitle, final ProgressState docstate,
58 final String reference, final String version, final Date docDate,
59 final List<Long> docuses) throws MissedPropertyException,
60 InvalidPropertyException, MultiplyDefinedException, IOException,
61 NotApplicableException, InterruptedException, ParseException;
64 * Create a new version of the document.
67 * the study step where the document is published
71 * the new version file name
75 * new document version string, empty for external documents
79 * the new state of the document
81 * the new modification date
83 * the array of documents ids used by the versioned document
85 * the array of impacted documents ids
86 * @throws MissedPropertyException
87 * if some mandatory property is missed
88 * @throws InvalidPropertyException
89 * if some property has invalid value
90 * @throws MultiplyDefinedException
91 * if some property occurs several times
93 * if file moving is failed
94 * @throws MismatchException
95 * if step number in properties doesn't match to the given step
96 * @throws NotApplicableException
97 * if publication's document is undefined
98 * @throws InterruptedException
99 * by Thread.sleep if interrupted
101 void versionDocument(Step step, User user, String filename, long docIndex,
102 String docver, String summary, ProgressState state, Date date,
103 String[] docuses, long[] docusedby) throws MissedPropertyException,
104 InvalidPropertyException, MultiplyDefinedException, IOException,
105 MismatchException, NotApplicableException, InterruptedException;
108 * Returns the study Step into which the document version referenced by this publication has been published.
110 * @param aPublication
111 * the document publication
114 Step getInvolvedStep(Publication aPublication);
117 * Promotes the document referenced by this publication from In-Check to Approved state, if not out-dated, and attaches the
118 * corresponding time-stamp to the document.<br/> If the promoted document is the final result of the owner study, the study is itself
119 * is promoted as well.<br/> <br/> Limitation: the way this promotion is propagated to the study supposes that the study has only ONE
120 * final result document.
122 * @param aPublication
123 * the document publication
125 * the date of approval
126 * @return true if the approval succeeded
127 * @see #getProgressState()
128 * @see DocumentRights#canApprove()
129 * @see DocumentType#isStudyResult()
130 * @see Study#getApproverOf(Publication)
132 Timestamp approve(Publication aPublication, Date adate);
135 * Demotes the document referenced by this publication to In-Work state, and removes the Promoter of the document, if exist.<br/> The
136 * In-Draft state is skipped (direct demotion to In-Work) if the validation cycle of the document does not include the review step.<br/>
137 * If the demoted document is the final result of the owner study, the study is itself is demoted as well.<br/> <br/> Limitation: the
138 * way this demotion is propagated to the study supposes that the study has only ONE final result document.
140 * @param aPublication
141 * the document publication
142 * @return true if the demotion succeeded
143 * @see #getProgressState()
144 * @see DocumentRights#canDemote()
145 * @see DocumentType#isStudyResult()
147 boolean demote(Publication aPublication);
150 * Undo the review operation by demoting the document referenced by this publication from In-Check to In-Draft state and removing the
151 * Reviewer.<br/> If the demoted document is the final result of the owner study, the study is itself is demoted as well.<br/> <br/>
152 * Limitation: the way this demotion is propagated to the study supposes that the study has only ONE final result document.
154 * @param aPublication
155 * the document publication
156 * @return true if the demotion succeeded
157 * @see #getProgressState()
159 * @see DocumentRights#canInvalidate()
160 * @see DocumentType#isStudyResult()
162 boolean invalidate(Publication aPublication);
165 * Promotes the document referenced by this publication from In-Work to In-Draft or In-Check state, if not out-dated, and attaches the
166 * corresponding time-stamp to the document.<br/> The In-Draft state is skipped (direct promotion to In-Check) if the validation cycle
167 * of the document does not include the review step.<br/> Also, if the promoted document is the final result of the owner study, the
168 * study is itself promoted as well.<br/> This operation can be undo-ed by demote().<br/> <br/> Limitation: the way this promotion is
169 * propagated to the study supposes that the study has only ONE final result document.
171 * @param aPublication
172 * the document publication
174 * the date of promotion
175 * @return true if the promotion succeeded
176 * @see #getProgressState()
178 * @see DocumentRights#canPromote()
179 * @see DocumentType#isStudyResult()
181 Timestamp promote(Publication aPublication, Date pdate);
184 * Promotes the document referenced by this publication from In-Draft to In-Check state, if not out-dated, and attaches the
185 * corresponding time-stamp to the document.<br/> If the promoted document is the final result of the owner study, the study is itself
186 * is promoted as well.<br/> This operation can be undo-ed by invalidate().<br/> <br/> Limitation: the way this promotion is
187 * propagated to the study supposes that the study has only ONE final result document.
189 * @param aPublication
190 * the document publication
193 * @return true if the review succeeded
194 * @see #getProgressState()
196 * @see DocumentRights#canReview()
197 * @see DocumentType#isStudyResult()
198 * @see Study#getReviewerOf(Publication)
200 Timestamp review(Publication aPublication, Date rdate);
203 * Publishes the document referenced by this publication into the owner Project Element under the given state, the revision number of
204 * the document being automatically set accordingly. If the given state is In-Draft and the document is final result of the owner study,
205 * this automatically promotes the study to In-Draft. The old publication is removed from the scenario.
207 * @param aPublication
208 * the document publication
210 * the required progress state
211 * @throws FileNotFoundException
212 * If the referenced document is empty
213 * @throws NotApplicableException
214 * If the referenced document is undefined
216 void saveAs(Publication aPublication, ProgressState state)
217 throws FileNotFoundException, NotApplicableException;
220 * Publishes the document referenced by this publication into the owner Project Element under the given revision number.<br/> The state
221 * of the referenced document is supposed being automatically set according to the given revision number, but, due to the versioning
222 * scheme, as it is not possible to differentiate In-Work and In-Draft states, this function has been deprecated (it is currently used
223 * only for the need of integration of Microsoft Office which anyway has to be redesigned). <br/> Note: in the context of branch
224 * versioning, the given revision may be modified by an update of the branch name. The old publication is removed from the scenario.
226 * @param aPublication
227 * the document publication
229 * the required revision number
230 * @throws FileNotFoundException
231 * If the referenced document is empty
232 * @throws NotApplicableException
233 * If the referenced document is undefined
237 void saveAs(Publication aPublication, Revision newvers)
238 throws FileNotFoundException, NotApplicableException;
241 * Rename the published document.
243 * @param aPublication
244 * the publication of the document
246 * the new document title
247 * @throws InvalidPropertyException
248 * if the new title is empty
250 void rename(Publication aPublication, String title)
251 throws InvalidPropertyException;
254 * Create "Converts" relation for the given document publication and format.
256 * @param aPublication
257 * the document publication
260 * @return the created "Converts" relation
262 ConvertsRelation attach(Publication aPublication, String format);
265 * Create "Converts" relation for the given document publication, format and description.
267 * @param aPublication
268 * the document publication
272 * the description of the relation
273 * @return the created "Converts" relation
275 ConvertsRelation attach(Publication aPublication, String format,
279 * Undo the out-date operation.
281 * @param aPublication
283 * @return true if the acceptance succeeds
285 * @see DocumentRights#canAccept()
287 boolean actualize(Publication aPublication);
290 * Out-dates this publication and recursively all publications using this one. Typically, a publication is out-dated when modifying a
291 * document to which it depends.
293 * @param aPublication
296 * @see #getProgressState()
299 void outdate(Publication aPublication);
303 * Get DocToCompareDTO by publication id.
304 * @param publicationId publication id
305 * @return DocToCompareDTO
306 * @throws InvalidParameterException if there is no document with such id.
308 DocToCompareDTO getDocToCompareDTO(long publicationId) throws InvalidParameterException;