View Javadoc
1   /*
2    * Copyright (c) 2002-2014, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.crm.business.demand;
35  
36  import fr.paris.lutece.plugins.crm.util.OperatorEnum;
37  
38  import org.apache.commons.lang3.StringUtils;
39  
40  import java.util.Date;
41  
42  /**
43   *
44   * DemandTypeFilter
45   *
46   */
47  public class DemandTypeFilter
48  {
49      private static final int ALL_INT = -1;
50      private boolean _bIsWideSearch;
51      private String _strLabel;
52      private String _strUrlResource;
53      private int _nIdCategory;
54      private Date _dateBegin;
55      private Date _dateEnd;
56      private String _strWorkgroupKey;
57      private String _strRoleKey;
58      private int _nOrder;
59      private OperatorEnum _operatorOrder;
60      private OperatorEnum _operatorDateBegin;
61      private OperatorEnum _operatorDateEnd;
62      private String _strUrlDelete;
63  
64      /**
65       * Constructor
66       */
67      public DemandTypeFilter( )
68      {
69          _bIsWideSearch = false;
70          _strLabel = StringUtils.EMPTY;
71          _strUrlResource = StringUtils.EMPTY;
72          _nIdCategory = ALL_INT;
73          _strWorkgroupKey = StringUtils.EMPTY;
74          _nOrder = ALL_INT;
75          _operatorOrder = OperatorEnum.EQUAL;
76          _operatorDateBegin = OperatorEnum.EQUAL;
77          _operatorDateEnd = OperatorEnum.EQUAL;
78          _strUrlDelete = StringUtils.EMPTY;
79      }
80  
81      /**
82       * Set true if the filter is applied to a wide search. <br/>
83       * In other words, the SQL query will use
84       * <ul>
85       * <li>SQL <b>OR</b> if it is applied to a wide search</li>
86       * <li>SQL <b>AND</b> if it is not applied to a wide search</li>
87       * </ul>
88       * 
89       * @param bIsWideSearch
90       *            true if it a wide search, false otherwise
91       */
92      public void setIsWideSearch( boolean bIsWideSearch )
93      {
94          _bIsWideSearch = bIsWideSearch;
95      }
96  
97      /**
98       * Check if the filter is applied to a wide search or not. <br/>
99       * In other words, the SQL query will use
100      * <ul>
101      * <li>SQL <b>OR</b> if it is applied to a wide search</li>
102      * <li>SQL <b>AND</b> if it is not applied to a wide search</li>
103      * </ul>
104      * 
105      * @return true if it is applied to a wide search
106      */
107     public boolean getIsWideSearch( )
108     {
109         return _bIsWideSearch;
110     }
111 
112     /**
113      * Returns the Label
114      * 
115      * @return The Label
116      */
117     public String getLabel( )
118     {
119         return _strLabel;
120     }
121 
122     /**
123      * Sets the Label
124      * 
125      * @param strLabel
126      *            The Label
127      */
128     public void setLabel( String strLabel )
129     {
130         _strLabel = strLabel;
131     }
132 
133     /**
134      * Check if the filter contains the attribute Label
135      * 
136      * @return true if it contains, false otherwise
137      */
138     public boolean containsLabel( )
139     {
140         return StringUtils.isNotBlank( _strLabel );
141     }
142 
143     /**
144      * Returns the UrlResource
145      * 
146      * @return The UrlResource
147      */
148     public String getUrlResource( )
149     {
150         return _strUrlResource;
151     }
152 
153     /**
154      * Sets the UrlResource
155      * 
156      * @param strUrlResource
157      *            The UrlResource
158      */
159     public void setUrlResource( String strUrlResource )
160     {
161         _strUrlResource = strUrlResource;
162     }
163 
164     /**
165      * Check if the filter contains the attribute UrlResource
166      * 
167      * @return true if it contains, false otherwise
168      */
169     public boolean containsUrlResource( )
170     {
171         return StringUtils.isNotBlank( _strUrlResource );
172     }
173 
174     /**
175      * Returns the IdCategory
176      * 
177      * @return The IdCategory
178      */
179     public int getIdCategory( )
180     {
181         return _nIdCategory;
182     }
183 
184     /**
185      * Sets the IdCategory
186      * 
187      * @param nIdCategory
188      *            The IdCategory
189      */
190     public void setIdCategory( int nIdCategory )
191     {
192         _nIdCategory = nIdCategory;
193     }
194 
195     /**
196      * Check if the filter contains the attribute ID category
197      * 
198      * @return true if it contains, false otherwise
199      */
200     public boolean containsIdCategory( )
201     {
202         return _nIdCategory != ALL_INT;
203     }
204 
205     /**
206      * Set the beginning date
207      * 
208      * @param dateBegin
209      *            the beginning date
210      */
211     public void setDateBegin( Date dateBegin )
212     {
213         _dateBegin = dateBegin;
214     }
215 
216     /**
217      * Get the beginning date
218      * 
219      * @return the beginning date
220      */
221     public Date getDateBegin( )
222     {
223         return _dateBegin;
224     }
225 
226     /**
227      * Check if the filter contains the attribute date begin
228      * 
229      * @return true if it contains, false otherwise
230      */
231     public boolean containsDateBegin( )
232     {
233         return _dateBegin != null;
234     }
235 
236     /**
237      * Set the closing date
238      * 
239      * @param dateEnd
240      *            the closing date
241      */
242     public void setDateEnd( Date dateEnd )
243     {
244         _dateEnd = dateEnd;
245     }
246 
247     /**
248      * Get the closing date
249      * 
250      * @return the closing date
251      */
252     public Date getDateEnd( )
253     {
254         return _dateEnd;
255     }
256 
257     /**
258      * Check if the filter contains the attribute date end
259      * 
260      * @return true if it contains, false otherwise
261      */
262     public boolean containsDateEnd( )
263     {
264         return _dateEnd != null;
265     }
266 
267     /**
268      * Set the workgroup
269      * 
270      * @param strWorkgroupKey
271      *            the workgroup key
272      */
273     public void setWorkgroup( String strWorkgroupKey )
274     {
275         _strWorkgroupKey = strWorkgroupKey;
276     }
277 
278     /**
279      * Get the workgroup
280      * 
281      * @return the workgroup key
282      */
283     public String getWorkgroup( )
284     {
285         return _strWorkgroupKey;
286     }
287 
288     /**
289      * Check whether the filter contains or not the workgroup
290      * 
291      * @return true if it contains, false otherwise
292      */
293     public boolean containsWorkgroup( )
294     {
295         return StringUtils.isNotBlank( _strWorkgroupKey );
296     }
297 
298     /**
299      * Set role
300      * 
301      * @param strRoleKey
302      *            the role key
303      */
304     public void setRole( String strRoleKey )
305     {
306         _strRoleKey = strRoleKey;
307     }
308 
309     /**
310      * Get role
311      * 
312      * @return the role key
313      */
314     public String getRole( )
315     {
316         return _strRoleKey;
317     }
318 
319     /**
320      * Check whether the filter contains or not the role
321      * 
322      * @return true if it contains, false otherwise
323      */
324     public boolean containsRole( )
325     {
326         return StringUtils.isNotBlank( _strRoleKey );
327     }
328 
329     /**
330      * Set the order
331      * 
332      * @param nOrder
333      *            the order
334      */
335     public void setOrder( int nOrder )
336     {
337         _nOrder = nOrder;
338     }
339 
340     /**
341      * Get the order
342      * 
343      * @return the order
344      */
345     public int getOrder( )
346     {
347         return _nOrder;
348     }
349 
350     /**
351      * Check if the filter contains the attribute order
352      * 
353      * @return true if it contains, false otherwise
354      */
355     public boolean containsOrder( )
356     {
357         return _nOrder != ALL_INT;
358     }
359 
360     /**
361      * Set the operator for the order
362      * 
363      * @param operator
364      *            the operator
365      */
366     public void setOperatorOrder( OperatorEnum operator )
367     {
368         _operatorOrder = operator;
369     }
370 
371     /**
372      * Get the operator for the order
373      * 
374      * @return the operator for the order
375      */
376     public OperatorEnum getOperatorOrder( )
377     {
378         return _operatorOrder;
379     }
380 
381     /**
382      * Set the operator for the beginning date
383      * 
384      * @param operator
385      *            the operator
386      */
387     public void setOperatorDateBegin( OperatorEnum operator )
388     {
389         _operatorDateBegin = operator;
390     }
391 
392     /**
393      * Get the operator for the beginning date
394      * 
395      * @return the operator
396      */
397     public OperatorEnum getOperatorDateBegin( )
398     {
399         return _operatorDateBegin;
400     }
401 
402     /**
403      * Set the operator for the closing date
404      * 
405      * @param operator
406      *            the operator
407      */
408     public void setOperatorDateEnd( OperatorEnum operator )
409     {
410         _operatorDateEnd = operator;
411     }
412 
413     /**
414      * Get the operator for the closing date
415      * 
416      * @return the operator
417      */
418     public OperatorEnum getOperatorDateEnd( )
419     {
420         return _operatorDateEnd;
421     }
422 
423     /**
424      * Returns the UrlDelete
425      * 
426      * @return The UrlDelete
427      */
428     public String getUrlDelete( )
429     {
430         return _strUrlDelete;
431     }
432 
433     /**
434      * Sets the UrlDelete
435      * 
436      * @param strUrlDelete
437      *            The UrlDelete
438      */
439     public void setUrlDelete( String strUrlDelete )
440     {
441         _strUrlResource = strUrlDelete;
442     }
443 
444     /**
445      * Check if the filter contains the attribute UrlDelete
446      * 
447      * @return true if it contains, false otherwise
448      */
449     public boolean containsUrlDelete( )
450     {
451         return StringUtils.isNotBlank( _strUrlResource );
452     }
453 }