Salome HOME
Import document action is fixed: uses relations are created now in the same transacti...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / PublicationService.java
index a2eb497db5698c532ba1f01f097190aeb071ec9f..b3b4e4fbc1a156586dac7579a8f41809ca260ae8 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Company         EURIWARE
+ * Company         OPEN CASCADE
  * Application     SIMAN
  * File            $Id$ 
  * Creation date   06.10.2012
 package org.splat.service;
 
 import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.text.ParseException;
 import java.util.Date;
+import java.util.List;
 
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.ConvertsRelation;
 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.Publication;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.Timestamp;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MismatchException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
 import org.splat.kernel.NotApplicableException;
 import org.splat.som.DocumentRights;
 import org.splat.som.Revision;
@@ -39,7 +48,59 @@ public interface PublicationService {
         *            the target project element
         * @return the created copy of the publication
         */
-       public Publication copy(Publication aPublication, ProjectElement publisher);
+       Publication copy(Publication aPublication, ProjectElement publisher);
+
+       public Publication createDoc(final long ownerId, final Step step,
+                       final long documentTypeId, final long userId, final String fname,
+                       final String doctitle, final ProgressState docstate,
+                       final String reference, final String version, final Date docDate,
+                       final List<Long> docuses) throws MissedPropertyException,
+                       InvalidPropertyException, MultiplyDefinedException, IOException,
+                       NotApplicableException, InterruptedException, ParseException;
+       
+       /**
+        * Create a new version of the document.
+        * 
+        * @param step
+        *            the study step where the document is published
+        * @param user
+        *            the current user
+        * @param filename
+        *            the new version file name
+        * @param docIndex
+        *            the publication id
+        * @param docver
+        *            new document version string, empty for external documents
+        * @param summary
+        *            the version comment
+        * @param state
+        *            the new state of the document
+        * @param date
+        *            the new modification date
+        * @param docuses
+        *            the array of documents ids used by the versioned document
+        * @param docusedby
+        *            the array of impacted documents ids
+        * @throws MissedPropertyException
+        *             if some mandatory property is missed
+        * @throws InvalidPropertyException
+        *             if some property has invalid value
+        * @throws MultiplyDefinedException
+        *             if some property occurs several times
+        * @throws IOException
+        *             if file moving is failed
+        * @throws MismatchException
+        *             if step number in properties doesn't match to the given step
+        * @throws NotApplicableException
+        *             if publication's document is undefined
+        * @throws InterruptedException
+        *             by Thread.sleep if interrupted
+        */
+       void versionDocument(Step step, User user, String filename, long docIndex,
+                       String docver, String summary, ProgressState state, Date date,
+                       String[] docuses, long[] docusedby) throws MissedPropertyException,
+                       InvalidPropertyException, MultiplyDefinedException, IOException,
+                       MismatchException, NotApplicableException, InterruptedException;
 
        /**
         * Returns the study Step into which the document version referenced by this publication has been published.
@@ -48,7 +109,7 @@ public interface PublicationService {
         *            the document publication
         * @return study step
         */
-       public Step getInvolvedStep(Publication aPublication);
+       Step getInvolvedStep(Publication aPublication);
 
        /**
         * Promotes the document referenced by this publication from In-Check to Approved state, if not out-dated, and attaches the
@@ -66,7 +127,7 @@ public interface PublicationService {
         * @see DocumentType#isStudyResult()
         * @see Study#getApproverOf(Publication)
         */
-       public Timestamp approve(Publication aPublication, Date adate);
+       Timestamp approve(Publication aPublication, Date adate);
 
        /**
         * Demotes the document referenced by this publication to In-Work state, and removes the Promoter of the document, if exist.<br/> The
@@ -81,7 +142,7 @@ public interface PublicationService {
         * @see DocumentRights#canDemote()
         * @see DocumentType#isStudyResult()
         */
-       public boolean demote(Publication aPublication);
+       boolean demote(Publication aPublication);
 
        /**
         * Undo the review operation by demoting the document referenced by this publication from In-Check to In-Draft state and removing the
@@ -96,7 +157,7 @@ public interface PublicationService {
         * @see DocumentRights#canInvalidate()
         * @see DocumentType#isStudyResult()
         */
-       public boolean invalidate(Publication aPublication);
+       boolean invalidate(Publication aPublication);
 
        /**
         * Promotes the document referenced by this publication from In-Work to In-Draft or In-Check state, if not out-dated, and attaches the
@@ -115,7 +176,7 @@ public interface PublicationService {
         * @see DocumentRights#canPromote()
         * @see DocumentType#isStudyResult()
         */
-       public Timestamp promote(Publication aPublication, Date pdate);
+       Timestamp promote(Publication aPublication, Date pdate);
 
        /**
         * Promotes the document referenced by this publication from In-Draft to In-Check state, if not out-dated, and attaches the
@@ -134,12 +195,12 @@ public interface PublicationService {
         * @see DocumentType#isStudyResult()
         * @see Study#getReviewerOf(Publication)
         */
-       public Timestamp review(Publication aPublication, Date rdate);
+       Timestamp review(Publication aPublication, Date rdate);
 
        /**
         * Publishes the document referenced by this publication into the owner Project Element under the given state, the revision number of
         * the document being automatically set accordingly. If the given state is In-Draft and the document is final result of the owner study,
-        * this automatically promotes the study to In-Draft.
+        * this automatically promotes the study to In-Draft. The old publication is removed from the scenario.
         * 
         * @param aPublication
         *            the document publication
@@ -150,7 +211,7 @@ public interface PublicationService {
         * @throws NotApplicableException
         *             If the referenced document is undefined
         */
-       public void saveAs(Publication aPublication, ProgressState state)
+       void saveAs(Publication aPublication, ProgressState state)
                        throws FileNotFoundException, NotApplicableException;
 
        /**
@@ -158,7 +219,7 @@ public interface PublicationService {
         * of the referenced document is supposed being automatically set according to the given revision number, but, due to the versioning
         * scheme, as it is not possible to differentiate In-Work and In-Draft states, this function has been deprecated (it is currently used
         * only for the need of integration of Microsoft Office which anyway has to be redesigned). <br/> Note: in the context of branch
-        * versioning, the given revision may be modified by an update of the branch name.
+        * versioning, the given revision may be modified by an update of the branch name. The old publication is removed from the scenario.
         * 
         * @param aPublication
         *            the document publication
@@ -170,6 +231,68 @@ public interface PublicationService {
         *             If the referenced document is undefined
         * @deprecated
         */
-       public void saveAs(Publication aPublication, Revision newvers)
+       @Deprecated
+       void saveAs(Publication aPublication, Revision newvers)
                        throws FileNotFoundException, NotApplicableException;
+
+       /**
+        * Rename the published document.
+        * 
+        * @param aPublication
+        *            the publication of the document
+        * @param title
+        *            the new document title
+        * @throws InvalidPropertyException
+        *             if the new title is empty
+        */
+       void rename(Publication aPublication, String title)
+                       throws InvalidPropertyException;
+
+       /**
+        * Create "Converts" relation for the given document publication and format.
+        * 
+        * @param aPublication
+        *            the document publication
+        * @param format
+        *            the format
+        * @return the created "Converts" relation
+        */
+       ConvertsRelation attach(Publication aPublication, String format);
+
+       /**
+        * Create "Converts" relation for the given document publication, format and description.
+        * 
+        * @param aPublication
+        *            the document publication
+        * @param format
+        *            the format
+        * @param description
+        *            the description of the relation
+        * @return the created "Converts" relation
+        */
+       ConvertsRelation attach(Publication aPublication, String format,
+                       String description);
+
+       /**
+        * Undo the out-date operation.
+        * 
+        * @param aPublication
+        *            the publication
+        * @return true if the acceptance succeeds
+        * @see #outdate()
+        * @see DocumentRights#canAccept()
+        */
+       boolean actualize(Publication aPublication);
+
+       /**
+        * Out-dates this publication and recursively all publications using this one. Typically, a publication is out-dated when modifying a
+        * document to which it depends.
+        * 
+        * @param aPublication
+        *            the publication
+        * @see #isOutdated()
+        * @see #getProgressState()
+        * @see #actualize()
+        */
+       void outdate(Publication aPublication);
 }