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.ArrayList;
41  import java.util.Date;
42  import java.util.List;
43  
44  /**
45   *
46   * DemandFilter
47   *
48   */
49  public class DemandFilter
50  {
51      private static final int ALL_INT = -1;
52      private boolean _bIsWideSearch;
53      private int _nIdCRMUser;
54      private int _nIdDemandType;
55      private Date _dateModification;
56      private int _nIdStatusCRM;
57      private OperatorEnum _operatorDateModification;
58      private String _strNotification;
59      private List<DemandSort> _listDemandSort;
60  
61      /**
62       * Constructor
63       */
64      public DemandFilter( )
65      {
66          _bIsWideSearch = false;
67          _nIdCRMUser = ALL_INT;
68          _nIdDemandType = ALL_INT;
69          _nIdStatusCRM = ALL_INT;
70          _operatorDateModification = OperatorEnum.EQUAL;
71          _strNotification = StringUtils.EMPTY;
72          _listDemandSort = new ArrayList<DemandSort>( );
73      }
74  
75      /**
76       * Set true if the filter is applied to a wide search. <br/>
77       * In other words, the SQL query will use
78       * <ul>
79       * <li>SQL <b>OR</b> if it is applied to a wide search</li>
80       * <li>SQL <b>AND</b> if it is not applied to a wide search</li>
81       * </ul>
82       * 
83       * @param bIsWideSearch
84       *            true if it a wide search, false otherwise
85       */
86      public void setIsWideSearch( boolean bIsWideSearch )
87      {
88          _bIsWideSearch = bIsWideSearch;
89      }
90  
91      /**
92       * Check if the filter is applied to a wide search or not. <br/>
93       * In other words, the SQL query will use
94       * <ul>
95       * <li>SQL <b>OR</b> if it is applied to a wide search</li>
96       * <li>SQL <b>AND</b> if it is not applied to a wide search</li>
97       * </ul>
98       * 
99       * @return true if it is applied to a wide search
100      */
101     public boolean getIsWideSearch( )
102     {
103         return _bIsWideSearch;
104     }
105 
106     /**
107      * Returns the User crm id
108      * 
109      * @return The User crm id
110      */
111     public int getIdCRMUser( )
112     {
113         return _nIdCRMUser;
114     }
115 
116     /**
117      * Sets the User crm id
118      * 
119      * @param nIdCRMUser
120      *            The user crm id
121      */
122     public void setIdCRMUser( int nIdCRMUser )
123     {
124         _nIdCRMUser = nIdCRMUser;
125     }
126 
127     /**
128      * Check if the filter contains the attribute UserGuid
129      * 
130      * @return true if it contains, false otherwise
131      */
132     public boolean containsIdCRMUser( )
133     {
134         return _nIdCRMUser != ALL_INT;
135     }
136 
137     /**
138      * Returns the IdDemandType
139      * 
140      * @return The IdDemandType
141      */
142     public int getIdDemandType( )
143     {
144         return _nIdDemandType;
145     }
146 
147     /**
148      * Sets the nIdDemandType
149      * 
150      * @param nIdDemandType
151      *            The nIdDemandType
152      */
153     public void setIdDemandType( int nIdDemandType )
154     {
155         _nIdDemandType = nIdDemandType;
156     }
157 
158     /**
159      * Check if the filter contains the attribute ID demand type
160      * 
161      * @return true if it contains, false otherwise
162      */
163     public boolean containsIdDemandType( )
164     {
165         return _nIdDemandType != ALL_INT;
166     }
167 
168     /**
169      * Set the Modification date
170      * 
171      * @param dateModification
172      *            the Modification date
173      */
174     public void setDateModification( Date dateModification )
175     {
176         _dateModification = dateModification;
177     }
178 
179     /**
180      * Get the Modification date
181      * 
182      * @return the Modification date
183      */
184     public Date getDateModification( )
185     {
186         return _dateModification;
187     }
188 
189     /**
190      * Check if the filter contains the attribute date Modification
191      * 
192      * @return true if it contains, false otherwise
193      */
194     public boolean containsDateModification( )
195     {
196         return _dateModification != null;
197     }
198 
199     /**
200      * Set the IdStatusCRM
201      * 
202      * @param nIdStatusCRM
203      *            the IdStatusCRM
204      */
205     public void setIdStatusCRM( int nIdStatusCRM )
206     {
207         _nIdStatusCRM = nIdStatusCRM;
208     }
209 
210     /**
211      * Get the IdStatusCRM
212      * 
213      * @return the IdStatusCRM
214      */
215     public int getIdStatusCRM( )
216     {
217         return _nIdStatusCRM;
218     }
219 
220     /**
221      * Check if the filter contains the attribute IdStatusCRM
222      * 
223      * @return true if it contains, false otherwise
224      */
225     public boolean containsIdStatusCRM( )
226     {
227         return _nIdStatusCRM != ALL_INT;
228     }
229 
230     /**
231      * Set the operator for the modification date
232      * 
233      * @param operator
234      *            the operator
235      */
236     public void setOperatorDateModification( OperatorEnum operator )
237     {
238         _operatorDateModification = operator;
239     }
240 
241     /**
242      * Get the operator for the modification date
243      * 
244      * @return the operator
245      */
246     public OperatorEnum getOperatorDateModification( )
247     {
248         return _operatorDateModification;
249     }
250 
251     /**
252      * Get the notification
253      * 
254      * @return the notification
255      */
256     public String getNotification( )
257     {
258         return _strNotification;
259     }
260 
261     /**
262      * Set the notification
263      */
264     public void setNotification( String notification )
265     {
266         this._strNotification = notification;
267     }
268 
269     /**
270      * @return the listDemandSort
271      */
272     public List<DemandSort> getListDemandSort( )
273     {
274         return _listDemandSort;
275     }
276 
277     /**
278      * @param listDemandSort
279      *            the listDemandSort to set
280      */
281     public void setListDemandSort( List<DemandSort> listDemandSort )
282     {
283         this._listDemandSort = listDemandSort;
284     }
285 
286     /**
287      * Add a sort
288      * 
289      * @param demandSort
290      *            the demandSort to add
291      */
292     public void addDemandSort( DemandSort demandSort )
293     {
294         this._listDemandSort.add( demandSort );
295     }
296 }