Salome HOME
Fix: document removing is fixed. Unit tests for StudyDAO and StepService.removeDocume...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / StepService.java
1 /*****************************************************************************
2  * Company         OPEN CASCADE
3  * Application     SIMAN
4  * File            $Id$ 
5  * Creation date   06.10.2012
6  * @author         $Author$
7  * @version        $Revision$
8  *****************************************************************************/
9
10 package org.splat.service;
11
12 import java.io.IOException;
13 import java.util.List;
14
15 import org.splat.dal.bo.som.Document;
16 import org.splat.dal.bo.som.DocumentType;
17 import org.splat.dal.bo.som.Publication;
18 import org.splat.dal.bo.som.SimulationContext;
19 import org.splat.kernel.InvalidPropertyException;
20 import org.splat.kernel.MismatchException;
21 import org.splat.kernel.MissedPropertyException;
22 import org.splat.kernel.MultiplyDefinedException;
23 import org.splat.kernel.NotApplicableException;
24 import org.splat.som.Step;
25
26 /**
27  * Step service interface.
28  * 
29  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
30  */
31 public interface StepService {
32
33         /**
34          * Create a new document published in the given study step.
35          * 
36          * @param aStep
37          *            the target study step
38          * @param dprop
39          *            properties of the new document
40          * @return the created publication of the new document
41          * @throws MissedPropertyException
42          *             if a mandatory property is missed
43          * @throws InvalidPropertyException
44          *             if some property doesn't exist
45          * @throws MultiplyDefinedException
46          *             if some property is defined several times
47          * @throws IOException
48          *             if a file system error occurs
49          */
50         Publication createDocument(Step aStep, Document.Properties dprop)
51                         throws MissedPropertyException, InvalidPropertyException,
52                         MultiplyDefinedException, IOException;
53
54         /**
55          * Publish an existing document in the given study step.
56          * 
57          * @param aStep
58          *            the target study step
59          * @param dprop
60          *            new properties of the document
61          * @return the created publication of the document
62          * @throws MissedPropertyException
63          *             if a mandatory property is missed
64          * @throws InvalidPropertyException
65          *             if some property doesn't exist
66          * @throws NotApplicableException
67          *             if the document is undefined
68          */
69         Publication assignDocument(Step aStep, Document.Properties dprop)
70                         throws MissedPropertyException, InvalidPropertyException,
71                         NotApplicableException;
72
73         /**
74          * Create a new version of a document in the given study step.
75          * 
76          * @param aStep
77          *            the study step
78          * @param base
79          *            the base document published version
80          * @param dprop
81          *            properties of the new version
82          * @return the new version publication
83          * @throws MissedPropertyException
84          *             if a mandatory property is missed
85          * @throws InvalidPropertyException
86          *             if some property doesn't exist
87          * @throws MultiplyDefinedException
88          *             if some property is defined several times
89          * @throws IOException
90          *             if a file system error occurs
91          * @throws MismatchException
92          *             if the document is not applicable to the given study step
93          */
94         Publication versionDocument(Step aStep, Publication base,
95                         Document.Properties dprop) throws MissedPropertyException,
96                         InvalidPropertyException, MultiplyDefinedException, IOException,
97                         MismatchException;
98
99         /**
100          * Add simulation context to the study step.
101          * 
102          * @param aStep
103          *            the study step
104          * @param dprop
105          *            properties of the simulation context to add
106          * @return the added simulation context
107          * @throws MissedPropertyException
108          *             if a mandatory property is missed
109          * @throws InvalidPropertyException
110          *             if some property doesn't exist
111          * @throws MultiplyDefinedException
112          *             if some property is defined several times
113          */
114         SimulationContext addSimulationContext(Step aStep,
115                         SimulationContext.Properties dprop) throws MissedPropertyException,
116                         InvalidPropertyException, MultiplyDefinedException;
117
118         /**
119          * Add simulation context to the study step.
120          * 
121          * @param firstStep
122          *            the study step
123          * @param context
124          *            the simulation context to add
125          * @return the added simulation context
126          */
127         SimulationContext addSimulationContext(Step firstStep,
128                         SimulationContext context);
129
130         /**
131          * Remove a simulation context from the study step.
132          * 
133          * @param aStep
134          *            the study step
135          * @param context
136          *            the simulation context to remove
137          * @return true if removal succeeded
138          */
139         boolean removeSimulationContext(Step aStep, SimulationContext context);
140
141         /**
142          * Add a document publication to the given step.
143          * 
144          * @param aStep
145          *            the target study step
146          * @param newdoc
147          *            the document publication to add
148          * @return true if publication succeeded
149          */
150         boolean add(Step aStep, Publication newdoc);
151
152         /**
153          * Remove a document publication from the given step.
154          * 
155          * @param aStep
156          *            the study step
157          * @param oldoc
158          *            the document publication to remove
159          * @return true if removing of the publication succeeded
160          */
161         boolean remove(Step aStep, Publication oldoc);
162
163         /**
164          * Remove a document from the given step and from the database if it is no more used.
165          * 
166          * @param aStep
167          *            the study step
168          * @param docId
169          *            the document id
170          * @return true if removing of the document succeeded
171          */
172         boolean removeDocument(Step aStep, long docId);
173
174         /**
175          * Get document types which are applicable for the given study step (activity).
176          * 
177          * @param aStep
178          *            the study step
179          * @return the list of document types
180          */
181         List<DocumentType> getValidDocumentTypes(Step aStep);
182 }