Salome HOME
81cf39681b25214861fb14d8ab968e35d883b491
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / dto / SearchFilterDTO.java
1 /*****************************************************************************
2  * Company         OPEN CASCADE
3  * Application     SIMAN
4  * File            $Id$ 
5  * Creation date   04.03.2013
6  * @author         $Author$
7  * @version        $Revision$
8  * @copyright      OPEN CASCADE 2012
9  *****************************************************************************/
10
11 package org.splat.service.dto;
12
13 import java.util.ArrayList;
14 import java.util.Date;
15 import java.util.List;
16
17 import org.splat.dal.bo.som.ProgressState;
18 import org.splat.dal.bo.som.SimulationContext;
19
20 /**
21  * Base search criteria.
22  * 
23  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
24  */
25 public class SearchFilterDTO {
26
27         /**
28          * "all": match all criteria.
29          */
30         public final static String MATCH_ALL = "all";
31         /**
32          * "any": match any criteria.
33          */
34         public final static String MATCH_ANY = "any";
35         /**
36          * "ANY": match any status.
37          */
38         public final static String ANY_STATE = "ANY";
39         /**
40          * Study author id to search.
41          */
42         protected String _author = "0";
43         /**
44          * Current contexts search criteria.
45          */
46         protected transient List<SimulationContext> _simContexts = new ArrayList<SimulationContext>();
47         /**
48          * Simulation context match: "all" or "any".
49          */
50         private String _contextMatch = MATCH_ALL;
51         /**
52          * Criteria match: "all" or "any".
53          */
54         private String _criteriaMatch = MATCH_ALL;
55         /**
56          * Search studies created after this date.
57          */
58         private Date _createdAfter;
59         /**
60          * Search studies created before this date.
61          */
62         private Date _createdBefore;
63         /**
64          * Full text search words.
65          */
66         private String _words = "";
67         /**
68          * Study reference.
69          */
70         private String _reference = "";
71         /**
72          * Currently connected user id.
73          */
74         private long _connectedUserId = 0;
75         /**
76          * "In-Work", "In-Draft", "In-Check"...
77          */
78         private String _state = ANY_STATE;
79
80         /**
81          * Get author id of objects to find.
82          * 
83          * @return the author id criteria
84          */
85         public String getAuthor() {
86                 return _author;
87         }
88
89         /**
90          * Get context criteria operation (all or any).
91          * 
92          * @return the simulation context criteria operation value
93          */
94         public String getContextMatch() {
95                 return _contextMatch;
96         }
97
98         /**
99          * Get the createdAfter.
100          * 
101          * @return the createdAfter
102          */
103         public Date getCreatedAfter() {
104                 return _createdAfter;
105         }
106
107         /**
108          * Get the createdBefore.
109          * 
110          * @return the createdBefore
111          */
112         public Date getCreatedBefore() {
113                 return _createdBefore;
114         }
115
116         /**
117          * Get main criteria operation (all or any).
118          * 
119          * @return the main criteria operation value
120          */
121         public String getCriteriaMatch() {
122                 return _criteriaMatch;
123         }
124
125         /**
126          * Get full text search criterion value.
127          * 
128          * @return the full text search criterion value
129          */
130         public String getWords() {
131                 return _words;
132         }
133
134         // ==============================================================================================================================
135         // Setters
136         // ==============================================================================================================================
137
138         /**
139          * Set author id to search.
140          * 
141          * @param index
142          *            persistent user id
143          */
144         public void setAuthor(final String index) {
145                 this._author = index;
146         }
147
148         /**
149          * Set context criteria operation (all or any).
150          * 
151          * @param value
152          *            "all" or "any"
153          */
154         public void setContextMatch(final String value) {
155                 this._contextMatch = value;
156         }
157
158         /**
159          * Set the createdAfter.
160          * 
161          * @param createdAfter
162          *            the createdAfter to set
163          */
164         public void setCreatedAfter(final Date createdAfter) {
165                 _createdAfter = createdAfter;
166         }
167
168         /**
169          * Set the createdBefore.
170          * 
171          * @param createdBefore
172          *            the createdBefore to set
173          */
174         public void setCreatedBefore(final Date createdBefore) {
175                 _createdBefore = createdBefore;
176         }
177
178         /**
179          * Set main criteria operation (all or any).
180          * 
181          * @param value
182          *            "all" or "any"
183          */
184         public void setCriteriaMatch(final String value) {
185                 this._criteriaMatch = value;
186         }
187
188         /**
189          * Set full text search criterion value.
190          * 
191          * @param value
192          *            the full text search criterion value
193          */
194         public void setWords(final String value) {
195                 this._words = value;
196         }
197
198         /**
199          * Get the context.
200          * 
201          * @return the context
202          */
203         public List<SimulationContext> getSimContexts() {
204                 return _simContexts;
205         }
206
207         /**
208          * Check if it is necessary to satisfy all main criteria.
209          * 
210          * @return true if it is necessary to satisfy all main criteria
211          */
212         public boolean isMatchAllCriteria() {
213                 return MATCH_ALL.equals(getCriteriaMatch());
214         }
215
216         /**
217          * Check if it is necessary to satisfy all simulation contexts criteria.
218          * 
219          * @return true if it is necessary to satisfy all simulation contexts criteria
220          */
221         public boolean isMatchAllContexts() {
222                 return MATCH_ALL.equals(getContextMatch());
223         }
224
225         // ==============================================================================================================================
226         // Getters
227         // ==============================================================================================================================
228         
229         /**
230          * Get study reference criteria.
231          * 
232          * @return study reference to search
233          */
234         public String getReference() {
235                 return _reference;
236         }
237
238         /**
239          * Set study reference criteria.
240          * 
241          * @param value
242          *            the study reference to search
243          */
244         public void setReference(final String value) {
245                 this._reference = value;
246         }
247
248         /**
249          * Set the simContexts.
250          * @param simContexts the simContexts to set
251          */
252         public void setSimContexts(final List<SimulationContext> simContexts) {
253                 _simContexts = simContexts;
254         }
255
256         /**
257          * Get the connectedUserId.
258          * @return the connectedUserId
259          */
260         public long getConnectedUserId() {
261                 return _connectedUserId;
262         }
263
264         /**
265          * Set the connectedUserId.
266          * @param connectedUserId the connectedUserId to set
267          */
268         public void setConnectedUserId(final long connectedUserId) {
269                 _connectedUserId = connectedUserId;
270         }
271
272         // ==============================================================================================================================
273         // Getters
274         // ==============================================================================================================================
275         
276         /**
277          * Get progress state criteria.
278          * 
279          * @return study progress state to search
280          */
281         public String getState() {
282                 return _state;
283         }
284
285         /**
286          * Set progress state criteria.
287          * 
288          * @param value
289          *            the progress state to search
290          */
291         public void setState(final String value) {
292                 this._state = value;
293         }
294         
295         /**
296          * Set progress state criteria.
297          * 
298          * @param value
299          *            the progress state to search
300          */
301         public void setState(final ProgressState value) {
302                 this._state = value.toString();
303         }
304 }