1 /*****************************************************************************
5 * Creation date 06.10.2012
8 *****************************************************************************/
10 package org.splat.service;
12 import java.util.List;
14 import org.splat.dal.bo.som.ConvertsRelation;
15 import org.splat.dal.bo.som.Document;
16 import org.splat.dal.bo.som.DocumentType;
17 import org.splat.dal.bo.som.ProgressState;
18 import org.splat.dal.bo.som.ProjectElement;
19 import org.splat.dal.bo.som.Study;
20 import org.splat.dal.bo.som.Timestamp;
21 import org.splat.dal.bo.som.Document.Properties;
22 import org.splat.kernel.InvalidPropertyException;
23 import org.splat.kernel.MissedPropertyException;
24 import org.splat.kernel.MultiplyDefinedException;
25 import org.splat.kernel.NotApplicableException;
26 import org.splat.service.technical.ProjectSettingsService;
27 import org.splat.som.Revision;
28 import org.splat.som.Step;
29 import org.springframework.transaction.annotation.Transactional;
32 * Document service interface.
34 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
37 public interface DocumentService {
40 * Get document by its path.
44 * @return the document if found or null
46 public Document getDocumentByPath(String path);
49 * Defines this document.
52 * the document to define
54 * the properties of the document
55 * @throws MissedPropertyException
56 * if a mandatory property is missed
57 * @throws InvalidPropertyException
58 * if a property doesn't exist
59 * @throws NotApplicableException
60 * if the document is undefined
61 * @see Step#createDocument(Properties)
64 public void initialize(Document aDoc, Properties dprop)
65 throws MissedPropertyException, InvalidPropertyException,
66 NotApplicableException;
69 * Find a document by its id.
73 * @return found document
75 public Document selectDocument(long index);
78 * Find a document by its reference and version.
84 * @return found document
86 public Document selectDocument(String refid, String version);
89 * Generate document reference.
94 * document properties (owner project element is used)
96 public void generateDocumentId(Document aDoc, Properties dprop);
99 * Get a directory where the document file is saved.
103 * @return a directory
105 public java.io.File getSaveDirectory(Document aDoc);
108 * Extract title and reference properties from the given file.
112 * @return the extracted properties
114 public Properties extractProperties(java.io.File file);
117 * Create "Converts" relation for the given document and the given format.
123 * @return the created "Converts" relation
125 public ConvertsRelation attach(Document aDoc, String format);
128 * Create "Converts" relation for the given document, format and description.
135 * the description of the relation
136 * @return the created "Converts" relation
138 public ConvertsRelation attach(Document aDoc, String format,
142 * Build a reference (document id) for the given document in the given study basing on the given original document.
145 * the document to set set the new reference to
149 * the original document
150 * @return true if the new reference is set
152 public boolean buildReferenceFrom(Document aDoc, ProjectElement scope,
156 * Build a reference (document id) for the given document in the given study.
159 * the document to set set the new reference to
162 * @return true if the new reference is set
164 public boolean buildReferenceFrom(Document aDoc, Study scope);
170 * the document to demote
171 * @return true if demoting succeeded
173 public boolean demote(Document aDoc);
176 * Promote a document.
179 * the document to promote
181 * the timestamp of the promotion
182 * @return true if promotion succeeded
184 public boolean promote(Document aDoc, Timestamp stamp);
187 * Increments the reference count of this document following its publication in a Study step.
190 * the document to hold
193 public void hold(Document aDoc);
196 * Decrements the reference count of this document following the removal of a Publication from a Study step.
199 * the document to release
202 public void release(Document aDoc);
208 * the document to rename
210 * the new document title
211 * @throws InvalidPropertyException
212 * if the new title is empty
214 public void rename(Document aDoc, String title)
215 throws InvalidPropertyException;
218 * Update a version of the given document.
225 public void updateAs(Document aDoc, Revision newvers);
228 * Update a state of the given document.
235 public void updateAs(Document aDoc, ProgressState state);
238 * 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
243 * @return true if documents of this type are result of a study.
244 * @see #isStepResult()
245 * @see #isResultOf(org.splat.service.technical.ProjectSettingsServiceImpl.Step)
247 public boolean isStudyResult(DocumentType aType);