1 /*****************************************************************************
5 * Creation date 06.10.2012
8 *****************************************************************************/
10 package org.splat.service;
12 import org.splat.dal.bo.som.ConvertsRelation;
13 import org.splat.dal.bo.som.Document;
14 import org.splat.dal.bo.som.DocumentType;
15 import org.splat.dal.bo.som.ProgressState;
16 import org.splat.dal.bo.som.ProjectElement;
17 import org.splat.dal.bo.som.Study;
18 import org.splat.dal.bo.som.Timestamp;
19 import org.splat.dal.bo.som.Document.Properties;
20 import org.splat.kernel.InvalidPropertyException;
21 import org.splat.kernel.MissedPropertyException;
22 import org.splat.kernel.NotApplicableException;
23 import org.splat.som.Revision;
24 import org.splat.som.Step;
27 * Document service interface.
29 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
32 public interface DocumentService {
35 * Get document by its path.
39 * @return the document if found or null
41 Document getDocumentByPath(String path);
44 * Defines this document.
47 * the document to define
49 * the properties of the document
50 * @throws MissedPropertyException
51 * if a mandatory property is missed
52 * @throws InvalidPropertyException
53 * if a property doesn't exist
54 * @throws NotApplicableException
55 * if the document is undefined
56 * @see Step#createDocument(Properties)
59 void initialize(Document aDoc, Properties dprop)
60 throws MissedPropertyException, InvalidPropertyException,
61 NotApplicableException;
64 * Find a document by its id.
68 * @return found document
70 Document selectDocument(long index);
73 * Find a document by its reference and version.
79 * @return found document
81 Document selectDocument(String refid, String version);
84 * Generate document reference.
89 * document properties (owner project element is used)
91 void generateDocumentId(Document aDoc, Properties dprop);
94 * Get a directory where the document file is saved.
100 java.io.File getSaveDirectory(Document aDoc);
103 * Extract title and reference properties from the given file.
107 * @return the extracted properties
109 Properties extractProperties(java.io.File file);
112 * Create "Converts" relation for the given document and the given format.
118 * @return the created "Converts" relation
120 ConvertsRelation attach(Document aDoc, String format);
123 * Create "Converts" relation for the given document, format and description.
130 * the description of the relation
131 * @return the created "Converts" relation
133 ConvertsRelation attach(Document aDoc, String format,
137 * Build a reference (document id) for the given document in the given study basing on the given original document.
140 * the document to set set the new reference to
144 * the original document
145 * @return true if the new reference is set
147 boolean buildReferenceFrom(Document aDoc, ProjectElement scope,
151 * Build a reference (document id) for the given document in the given study.
154 * the document to set set the new reference to
157 * @return true if the new reference is set
159 boolean buildReferenceFrom(Document aDoc, Study scope);
165 * the document to demote
166 * @return true if demoting succeeded
168 boolean demote(Document aDoc);
171 * Promote a document.
174 * the document to promote
176 * the timestamp of the promotion
177 * @return true if promotion succeeded
179 boolean promote(Document aDoc, Timestamp stamp);
182 * Increments the reference count of this document following its publication in a Study step.
185 * the document to hold
188 void hold(Document aDoc);
191 * Decrements the reference count of this document following the removal of a Publication from a Study step.
194 * the document to release
197 void release(Document aDoc);
203 * the document to rename
205 * the new document title
206 * @throws InvalidPropertyException
207 * if the new title is empty
209 void rename(Document aDoc, String title)
210 throws InvalidPropertyException;
213 * Update a version of the given document.
220 void updateAs(Document aDoc, Revision newvers);
223 * Update a state of the given document.
230 void updateAs(Document aDoc, ProgressState state);
233 * Checks if documents of this type are result of a study. A document is the result of a study when it is the result of the last step of
238 * @return true if documents of this type are result of a study.
239 * @see #isStepResult()
240 * @see #isResultOf(org.splat.service.technical.ProjectSettingsServiceImpl.Step)
242 boolean isStudyResult(DocumentType aType);