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