Salome HOME
Modifications done to respect PMD rules. Versioning a document is fixed. Validation...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / DocumentService.java
index 952f52954354777c0bb9fdf0d95ceeae2c9f1987..1c65b18edfbeb93d4a427961c8cfb00c58178fc4 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Company         EURIWARE
+ * Company         OPEN CASCADE
  * Application     SIMAN
  * File            $Id$ 
  * Creation date   06.10.2012
@@ -9,21 +9,37 @@
 
 package org.splat.service;
 
+import org.splat.dal.bo.som.ConvertsRelation;
 import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.ProjectElement;
+import org.splat.dal.bo.som.Study;
+import org.splat.dal.bo.som.Timestamp;
 import org.splat.dal.bo.som.Document.Properties;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.NotApplicableException;
+import org.splat.som.Revision;
 import org.splat.som.Step;
 
 /**
  * Document service interface.
  * 
- * @author RKV
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  * 
  */
 public interface DocumentService {
 
+       /**
+        * Get document by its path.
+        * 
+        * @param path
+        *            the document path
+        * @return the document if found or null
+        */
+       Document getDocumentByPath(String path);
+
        /**
         * Defines this document.
         * 
@@ -40,7 +56,7 @@ public interface DocumentService {
         * @see Step#createDocument(Properties)
         * @see #isUndefined()
         */
-       public void initialize(Document aDoc, Properties dprop)
+       void initialize(Document aDoc, Properties dprop)
                        throws MissedPropertyException, InvalidPropertyException,
                        NotApplicableException;
 
@@ -51,7 +67,7 @@ public interface DocumentService {
         *            document id
         * @return found document
         */
-       public Document selectDocument(long index);
+       Document selectDocument(long index);
 
        /**
         * Find a document by its reference and version.
@@ -62,7 +78,7 @@ public interface DocumentService {
         *            document version
         * @return found document
         */
-       public Document selectDocument(String refid, String version);
+       Document selectDocument(String refid, String version);
 
        /**
         * Generate document reference.
@@ -72,12 +88,156 @@ public interface DocumentService {
         * @param dprop
         *            document properties (owner project element is used)
         */
-       public void generateDocumentId(Document aDoc, Properties dprop);
-       
+       void generateDocumentId(Document aDoc, Properties dprop);
+
        /**
         * Get a directory where the document file is saved.
-        * @param aDoc the document
+        * 
+        * @param aDoc
+        *            the document
         * @return a directory
         */
-       public java.io.File getSaveDirectory(Document aDoc);
+       java.io.File getSaveDirectory(Document aDoc);
+
+       /**
+        * Extract title and reference properties from the given file.
+        * 
+        * @param file
+        *            the file to parse
+        * @return the extracted properties
+        */
+       Properties extractProperties(java.io.File file);
+
+       /**
+        * Create "Converts" relation for the given document and the given format.
+        * 
+        * @param aDoc
+        *            the document
+        * @param format
+        *            the format
+        * @return the created "Converts" relation
+        */
+       ConvertsRelation attach(Document aDoc, String format);
+
+       /**
+        * Create "Converts" relation for the given document, format and description.
+        * 
+        * @param aDoc
+        *            the document
+        * @param format
+        *            the format
+        * @param description
+        *            the description of the relation
+        * @return the created "Converts" relation
+        */
+       ConvertsRelation attach(Document aDoc, String format,
+                       String description);
+
+       /**
+        * Build a reference (document id) for the given document in the given study basing on the given original document.
+        * 
+        * @param aDoc
+        *            the document to set set the new reference to
+        * @param scope
+        *            the study
+        * @param lineage
+        *            the original document
+        * @return true if the new reference is set
+        */
+       boolean buildReferenceFrom(Document aDoc, ProjectElement scope,
+                       Document lineage);
+
+       /**
+        * Build a reference (document id) for the given document in the given study.
+        * 
+        * @param aDoc
+        *            the document to set set the new reference to
+        * @param scope
+        *            the study
+        * @return true if the new reference is set
+        */
+       boolean buildReferenceFrom(Document aDoc, Study scope);
+
+       /**
+        * Demote a document.
+        * 
+        * @param aDoc
+        *            the document to demote
+        * @return true if demoting succeeded
+        */
+       boolean demote(Document aDoc);
+
+       /**
+        * Promote a document.
+        * 
+        * @param aDoc
+        *            the document to promote
+        * @param stamp
+        *            the timestamp of the promotion
+        * @return true if promotion succeeded
+        */
+       boolean promote(Document aDoc, Timestamp stamp);
+
+       /**
+        * Increments the reference count of this document following its publication in a Study step.
+        * 
+        * @param aDoc
+        *            the document to hold
+        * @see #release()
+        */
+       void hold(Document aDoc);
+
+       /**
+        * Decrements the reference count of this document following the removal of a Publication from a Study step.
+        * 
+        * @param aDoc
+        *            the document to release
+        * @see #hold()
+        */
+       void release(Document aDoc);
+
+       /**
+        * Rename a document.
+        * 
+        * @param aDoc
+        *            the document to rename
+        * @param title
+        *            the new document title
+        * @throws InvalidPropertyException
+        *             if the new title is empty
+        */
+       void rename(Document aDoc, String title)
+                       throws InvalidPropertyException;
+
+       /**
+        * Update a version of the given document.
+        * 
+        * @param aDoc
+        *            the document
+        * @param newvers
+        *            the new version
+        */
+       void updateAs(Document aDoc, Revision newvers);
+
+       /**
+        * Update a state of the given document.
+        * 
+        * @param aDoc
+        *            the document
+        * @param state
+        *            the new state
+        */
+       void updateAs(Document aDoc, ProgressState state);
+
+       /**
+        * 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
+        * the study.
+        * 
+        * @param aType
+        *            the document type
+        * @return true if documents of this type are result of a study.
+        * @see #isStepResult()
+        * @see #isResultOf(org.splat.service.technical.ProjectSettingsServiceImpl.Step)
+        */
+       boolean isStudyResult(DocumentType aType);
 }