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