Salome HOME
ProjectSettings are now configured when the bean is created (without call to a struts...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / technical / ProjectSettingsService.java
1 /*****************************************************************************
2  * Company         OPEN CASCADE
3  * Application     SIMAN
4  * File            $Id$ 
5  * Creation date   05.10.2012
6  * @author         $Author$
7  * @version        $Revision$
8  *****************************************************************************/
9
10 package org.splat.service.technical;
11
12 import java.io.IOException;
13 import java.sql.SQLException;
14 import java.util.HashSet;
15 import java.util.List;
16 import java.util.Set;
17
18 import org.splat.dal.bo.som.DocumentType;
19 import org.splat.dal.bo.som.ProjectElement;
20 import org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming;
21 import org.splat.service.technical.ProjectSettingsServiceImpl.ProjectSettingsValidationCycle;
22
23 /**
24  * Project settings service interface.
25  */
26 public interface ProjectSettingsService {
27
28         /**
29          * Transient study step data.
30          */
31         class Step {
32                 /**
33                  * The sequential number of the step.
34                  */
35                 private int _number;
36                 /**
37                  * The step's key name.
38                  */
39                 private String _key;
40
41                 /**
42                  * The owner of the step: study or scenario.
43                  */
44                 private Class<? extends ProjectElement> _level;
45                 /**
46                  * Set of Document and/or Knowledge applicable on this step.
47                  */
48                 protected Set<Class<?>> _contents;
49                 /**
50                  * Data path for this step.
51                  */
52                 private String _path;
53                 /**
54                  * Executable module for this step.
55                  */
56                 private String _module;
57
58                 /**
59                  * Create a transient study step definition.
60                  * 
61                  * @param number
62                  *            the step sequential number
63                  * @param level
64                  *            the level (study or scenario) the step is applied to
65                  * @param path
66                  *            the step data path
67                  */
68                 Step(final int number, final Class<? extends ProjectElement> level,
69                                 final String path) {
70                         this.initialize(number, level, path);
71                 }
72
73                 /**
74                  * Create a transient study step definition.
75                  * 
76                  * @param number
77                  *            the step sequential number
78                  * @param level
79                  *            the level (study or scenario) the step is applied to
80                  * @param contents
81                  *            the set of applicable data types
82                  * @param path
83                  *            the step data path
84                  */
85                 @SuppressWarnings("unused")
86                 private Step(final int number,
87                                 final Class<? extends ProjectElement> level,
88                                 final Class<?> contents, final String path) {
89                         this.initialize(number, level, path);
90                         this._contents.add(contents);
91                 }
92
93                 /**
94                  * Initialize the study step.
95                  * 
96                  * @param number
97                  *            the step sequential number
98                  * @param level
99                  *            the level (study or scenario) the step is applied to
100                  * @param path
101                  *            the step data path
102                  */
103                 private void initialize(final int number,
104                                 final Class<? extends ProjectElement> level, final String path) {
105                         this._number = number;
106                         this._level = level;
107                         this._path = path + "/";
108                         this._contents = new HashSet<Class<?>>();
109                 }
110
111                 /**
112                  * Check if the step is applied to a study or a scenario level.
113                  * 
114                  * @param level
115                  *            the study or a scenario to check the step applicability
116                  * @return true if the step is applied to the given level
117                  */
118                 public boolean appliesTo(final Class<? extends ProjectElement> level) {
119                         return (level == this._level);
120                 }
121
122                 /**
123                  * Check if the step can contain documents or knowledges of the given type.
124                  * 
125                  * @param type
126                  *            the document type
127                  * @return true if the step can contain data of the given type
128                  */
129                 public boolean mayContain(final Class<?> type) {
130                         return _contents.contains(type);
131                 }
132
133                 /**
134                  * Get the sequential number of the step.
135                  * 
136                  * @return the sequential number of the step
137                  */
138                 public int getNumber() {
139                         return _number;
140                 }
141
142                 /**
143                  * Get data path for this step.
144                  * 
145                  * @return data path for this step
146                  */
147                 public String getPath() {
148                         return _path;
149                 }
150
151                 /**
152                  * Get the module.
153                  * 
154                  * @return the module
155                  */
156                 public String getModule() {
157                         return _module;
158                 }
159
160                 /**
161                  * Set the module.
162                  * 
163                  * @param module
164                  *            the module to set
165                  */
166                 public void setModule(final String module) {
167                         _module = module;
168                 }
169
170                 /**
171                  * Get the key.
172                  * 
173                  * @return the key
174                  */
175                 public String getKey() {
176                         return _key;
177                 }
178
179                 /**
180                  * Set the key.
181                  * 
182                  * @param key
183                  *            the key to set
184                  */
185                 public void setKey(final String key) {
186                         _key = key;
187                 }
188         }
189
190         /**
191          * Return the validation cycles of result documents defined in the workflow, ordered by study activities and ending by the default
192          * validation cycle, if defined.
193          * 
194          * @return the validation cycles of the workflow
195          */
196         List<ProjectSettingsValidationCycle> getAllValidationCycles();
197
198         /**
199          * Get a study step by its sequential number.
200          * 
201          * @param number
202          *            the step number
203          * @return the step
204          */
205         ProjectSettingsService.Step getStep(final int number);
206
207         /**
208          * Get ordered list of (transient) study steps.
209          * 
210          * @return the list of steps from project settings
211          */
212         List<ProjectSettingsService.Step> getAllSteps();
213
214         /**
215          * Get file naming scheme setting.
216          * 
217          * @return file naming scheme
218          * @see org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming
219          */
220         FileNaming getFileNamingScheme();
221
222         /**
223          * Get a pattern of study references.
224          * 
225          * @return the reference pattern
226          */
227         String getReferencePattern();
228
229         /**
230          * Get a pattern of the presentation of version numbers.
231          * 
232          * @return the version numbers presentation pattern
233          */
234         String getRevisionPattern();
235
236         /**
237          * Load workflow configuration from the given file. <br/> Create necessary default staff in the database if it is not initialized yet.
238          * 
239          * @param filename
240          *            the workflow configuration file
241          * @throws IOException
242          *             if there is a file reading or index creation problem
243          * @throws SQLException
244          *             if there is a database population problem
245          */
246         void configure(String filename) throws IOException, SQLException;
247
248         /**
249          * Check if a file of the given format should be imported during check-in of a document of the given type.
250          * 
251          * @param type
252          *            document type
253          * @param format
254          *            file format
255          * @return true if file should be imported
256          */
257         boolean doImport(final String type, final String format);
258
259         /**
260          * Get default document type for the given file format on the given study step.
261          * 
262          * @param step
263          *            the study step
264          * @param format
265          *            the file format (extension)
266          * @return document type
267          */
268         DocumentType getDefaultDocumentType(final Step step, final String format);
269
270         /**
271          * Get the list of default formats for the given study step.
272          * 
273          * @param step
274          *            the study step
275          * @return list of formats (file extensions)
276          */
277         List<String> getDefaultFormats(final Step step);
278 }