View Javadoc
1   /*
2    * Copyright (c) 2002-2022, City of 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.genericattributes.business;
35  
36  import fr.paris.lutece.plugins.genericattributes.util.GenericAttributesUtils;
37  
38  import org.apache.commons.collections.CollectionUtils;
39  import org.apache.commons.lang3.StringUtils;
40  
41  import java.util.List;
42  
43  /**
44   *
45   * class ResponseFilter
46   *
47   */
48  public class ResponseFilter
49  {
50      private int _nIdResource = GenericAttributesUtils.CONSTANT_ID_NULL;
51      private int _nIdField = GenericAttributesUtils.CONSTANT_ID_NULL;
52      private int _nIdEntry = GenericAttributesUtils.CONSTANT_ID_NULL;
53      private boolean _bGroupbyDay;
54      private boolean _bGroupbyWeek;
55      private boolean _bGroupbyMonth;
56      private String _strOrderBy;
57      private boolean _bIsOrderByAsc = true;
58      private List<Integer> _listId;
59      private String _strCodeEntry;
60      private String _strResponseValue;
61  
62      /**
63       * Get the id of a resource in the filter
64       * 
65       * @return The id of the resource to insert in the filter
66       */
67      public int getIdResource( )
68      {
69          return _nIdResource;
70      }
71  
72      /**
73       * Set the id of a resource in the filter
74       * 
75       * @param nIdResource
76       *            the id of resource to insert in the filter
77       */
78      public void setIdResource( int nIdResource )
79      {
80          _nIdResource = nIdResource;
81      }
82  
83      /**
84       *
85       * @return true if the filter contain an id of a resource
86       */
87      public boolean containsIdResource( )
88      {
89          return ( _nIdResource != GenericAttributesUtils.CONSTANT_ID_NULL );
90      }
91  
92      /**
93       *
94       * @return the id of field insert in the filter
95       */
96      public int getIdField( )
97      {
98          return _nIdField;
99      }
100 
101     /**
102      * set the id of field depend in the filter
103      * 
104      * @param idField
105      *            the id of field depend to insert in the filter
106      */
107     public void setIdField( int idField )
108     {
109         _nIdField = idField;
110     }
111 
112     /**
113      *
114      * @return true if the filter contain an id of field depend
115      */
116     public boolean containsIdField( )
117     {
118         return ( _nIdField != GenericAttributesUtils.CONSTANT_ID_NULL );
119     }
120 
121     /**
122      *
123      * @return the id of entry insert in the filter
124      */
125     public int getIdEntry( )
126     {
127         return _nIdEntry;
128     }
129 
130     /**
131      * set the id of entry depend in the filter
132      * 
133      * @param idEntry
134      *            the id of entry depend to insert in the filter
135      */
136     public void setIdEntry( int idEntry )
137     {
138         _nIdEntry = idEntry;
139     }
140 
141     /**
142      *
143      * @return true if the filter contain an id of entry depend
144      */
145     public boolean containsIdEntry( )
146     {
147         return ( _nIdEntry != GenericAttributesUtils.CONSTANT_ID_NULL );
148     }
149 
150     /**
151      *
152      * @return true if the response must be group by day
153      */
154     public boolean isGroupbyDay( )
155     {
156         return _bGroupbyDay;
157     }
158 
159     /**
160      * set true if the response must be group by day
161      * 
162      * @param groupbyDay
163      *            true if the response must be group by day
164      */
165     public void setGroupbyDay( boolean groupbyDay )
166     {
167         _bGroupbyDay = groupbyDay;
168     }
169 
170     /**
171      * true if the response must be group by month
172      * 
173      * @return true if the response must be group by month
174      */
175     public boolean isGroupbyMonth( )
176     {
177         return _bGroupbyMonth;
178     }
179 
180     /**
181      * set true if the response must be group by month
182      * 
183      * @param groupbyMonth
184      *            true if the response must be group by month
185      */
186     public void setGroupbyMonth( boolean groupbyMonth )
187     {
188         _bGroupbyMonth = groupbyMonth;
189     }
190 
191     /**
192      * true if the response must be group by week
193      * 
194      * @return true if the response must be group by week
195      */
196     public boolean isGroupbyWeek( )
197     {
198         return _bGroupbyWeek;
199     }
200 
201     /**
202      * set true if the response must be group by week
203      * 
204      * @param groupbyWeek
205      *            true if the response must be group by week
206      */
207     public void setGroupbyWeek( boolean groupbyWeek )
208     {
209         _bGroupbyWeek = groupbyWeek;
210     }
211 
212     /**
213      * Set order by
214      * 
215      * @param strOrderBy
216      *            The order by
217      */
218     public void setOrderBy( String strOrderBy )
219     {
220         _strOrderBy = strOrderBy;
221     }
222 
223     /**
224      * Get order by
225      * 
226      * @return the order by
227      */
228     public String getOrderBy( )
229     {
230         return _strOrderBy;
231     }
232 
233     /**
234      * Check if the filter contains order by
235      * 
236      * @return true if it contains, false otherwise
237      */
238     public boolean containsOrderBy( )
239     {
240         return StringUtils.isNotBlank( _strOrderBy );
241     }
242 
243     /**
244      * Set order by asc
245      * 
246      * @param bIsOrderByAsc
247      *            true if the order by is asc
248      */
249     public void setOrderByAsc( boolean bIsOrderByAsc )
250     {
251         _bIsOrderByAsc = bIsOrderByAsc;
252     }
253 
254     /**
255      * Check if the order by is asc
256      * 
257      * @return true if the order by is asc;
258      */
259     public boolean isOrderByAsc( )
260     {
261         return _bIsOrderByAsc;
262     }
263 
264     /**
265      * @return the _listId
266      */
267     public List<Integer> getListId( )
268     {
269         return this._listId;
270     }
271 
272     /**
273      * @param listId
274      *            the _listId to set
275      */
276     public void setListId( List<Integer> listId )
277     {
278         this._listId = listId;
279     }
280 
281     /**
282      *
283      * @return true if the filter contain an id of entry depend
284      */
285     public boolean containsListIdResource( )
286     {
287         return CollectionUtils.isNotEmpty( _listId );
288     }
289 
290     /**
291      * Check if the filter contains code entry
292      * 
293      * @return true if it contains, false otherwise
294      */
295     public boolean containsCodeEntry( )
296     {
297         return StringUtils.isNotBlank( _strCodeEntry );
298     }
299 
300     /**
301      * @return the _strCodeEntry
302      */
303     public String getCodeEntry( )
304     {
305         return _strCodeEntry;
306     }
307 
308     /**
309      * @param strCodeEntry
310      *            the _strCodeEntry to set
311      */
312     public void setCodeEntry( String strCodeEntry )
313     {
314         this._strCodeEntry = strCodeEntry;
315     }
316 
317     /**
318      * @return the _strResponseValue
319      */
320     public String getResponseValue( )
321     {
322         return _strResponseValue;
323     }
324 
325     /**
326      * @param strResponseValue
327      *            the _strResponseValue to set
328      */
329     public void setResponseValue( String strResponseValue )
330     {
331         _strResponseValue = strResponseValue;
332     }
333 
334     /**
335      * Check if the filter contains response value
336      * 
337      * @return true if it contains, false otherwise
338      */
339     public boolean containsResponseValue( )
340     {
341         return StringUtils.isNotBlank( _strResponseValue );
342     }
343 }