Salome HOME
ScenarioService.getScenarioInfo method is added.
[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.ProjectElement;
19 import org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming;
20 import org.splat.service.technical.ProjectSettingsServiceImpl.ProjectSettingsValidationCycle;
21
22 /**
23  * Project settings service interface.
24  */
25 public interface ProjectSettingsService {
26
27         /**
28          * Transient study step data.
29          */
30     class Step {
31                 /**
32                  * The sequential number of the step.
33                  */
34                 private int _number;
35                 /**
36                  * The step's key name.
37                  */
38                 private String _key;
39
40                 /**
41                  * The owner of the step: study or scenario.
42                  */
43                 private Class<? extends ProjectElement> _level;
44                 /**
45                  * Set of Document and/or Knowledge applicable on this step.
46                  */
47                 protected Set<Class<?>> _contents;
48                 /**
49                  * Data path for this step.
50                  */
51                 private String _path;
52                 /**
53                  * Executable module for this step.
54                  */
55                 private String _module;
56
57                 /**
58                  * Create a transient study step definition.
59                  * 
60                  * @param number
61                  *            the step sequential number
62                  * @param level
63                  *            the level (study or scenario) the step is applied to
64                  * @param path
65                  *            the step data path
66                  */
67                 Step(final int number, final Class<? extends ProjectElement> level,
68                                 final String path) {
69                         this.initialize(number, level, path);
70                 }
71
72                 /**
73                  * Create a transient study step definition.
74                  * 
75                  * @param number
76                  *            the step sequential number
77                  * @param level
78                  *            the level (study or scenario) the step is applied to
79                  * @param contents
80                  *            the set of applicable data types
81                  * @param path
82                  *            the step data path
83                  */
84                 @SuppressWarnings("unused")
85                 private Step(final int number,
86                                 final Class<? extends ProjectElement> level,
87                                 final Class<?> contents, final String path) {
88                         this.initialize(number, level, path);
89                         this._contents.add(contents);
90                 }
91
92                 /**
93                  * Initialize the study step.
94                  * 
95                  * @param number
96                  *            the step sequential number
97                  * @param level
98                  *            the level (study or scenario) the step is applied to
99                  * @param path
100                  *            the step data path
101                  */
102                 private void initialize(final int number,
103                                 final Class<? extends ProjectElement> level, final String path) {
104                         this._number = number;
105                         this._level = level;
106                         this._path = path + "/";
107                         this._contents = new HashSet<Class<?>>();
108                 }
109
110                 /**
111                  * Check if the step is applied to a study or a scenario level.
112                  * 
113                  * @param level
114                  *            the study or a scenario to check the step applicability
115                  * @return true if the step is applied to the given level
116                  */
117                 public boolean appliesTo(final Class<? extends ProjectElement> level) {
118                         return (level == this._level);
119                 }
120
121                 /**
122                  * Check if the step can contain documents or knowledges of the given type.
123                  * 
124                  * @param type
125                  *            the document type
126                  * @return true if the step can contain data of the given type
127                  */
128                 public boolean mayContain(final Class<?> type) {
129                         return _contents.contains(type);
130                 }
131
132                 /**
133                  * Get the sequential number of the step.
134                  * 
135                  * @return the sequential number of the step
136                  */
137                 public int getNumber() {
138                         return _number;
139                 }
140
141                 /**
142                  * Get data path for this step.
143                  * 
144                  * @return data path for this step
145                  */
146                 public String getPath() {
147                         return _path;
148                 }
149
150                 /**
151                  * Get the module.
152                  * @return the module
153                  */
154                 public String getModule() {
155                         return _module;
156                 }
157
158                 /**
159                  * Set the module.
160                  * @param module the module to set
161                  */
162                 public void setModule(final String module) {
163                         _module = module;
164                 }
165
166                 /**
167                  * Get the key.
168                  * @return the key
169                  */
170                 public String getKey() {
171                         return _key;
172                 }
173
174                 /**
175                  * Set the key.
176                  * @param key the key to set
177                  */
178                 public void setKey(final String key) {
179                         _key = key;
180                 }
181         }
182
183         /**
184          * Return the validation cycles of result documents defined in the workflow, ordered by study activities and ending by the default
185          * validation cycle, if defined.
186          * 
187          * @return the validation cycles of the workflow
188          */
189         List<ProjectSettingsValidationCycle> getAllValidationCycles();
190
191         /**
192          * Get a study step by its sequential number.
193          * 
194          * @param number
195          *            the step number
196          * @return the step
197          */
198         ProjectSettingsService.Step getStep(final int number);
199
200         /**
201          * Get ordered list of (transient) study steps.
202          * 
203          * @return the list of steps from project settings
204          */
205         List<ProjectSettingsService.Step> getAllSteps();
206
207         /**
208          * Get file naming scheme setting.
209          * 
210          * @return file naming scheme
211          * @see org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming
212          */
213         FileNaming getFileNamingScheme();
214
215         /**
216          * Get a pattern of study references.
217          * 
218          * @return the reference pattern
219          */
220         String getReferencePattern();
221
222         /**
223          * Get a pattern of the presentation of version numbers.
224          * 
225          * @return the version numbers presentation pattern
226          */
227         String getRevisionPattern();
228
229         /**
230          * Load workflow configuration from the given file. <br/> Create necessary default staff in the database if it is not initialized yet.
231          * 
232          * @param filename
233          *            the workflow configuration file
234          * @throws IOException
235          *             if there is a file reading or index creation problem
236          * @throws SQLException
237          *             if there is a database population problem
238          */
239         void configure(String filename) throws IOException, SQLException;
240
241         /**
242          * Get steps of the given project element (study or scenario).
243          * 
244          * @param level
245          *            the project element (study or scenario)
246          * @return the list of steps
247          */
248         List<ProjectSettingsService.Step> getStepsOf(
249                         Class<? extends ProjectElement> level);
250 }