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.lang3.StringUtils;
39  
40  /**
41   *
42   * class EntryFilter
43   *
44   */
45  public class EntryFilter
46  {
47      /**
48       * Value for boolean filters to represent Boolean.FALSE
49       */
50      public static final int FILTER_FALSE = 0;
51  
52      /**
53       * Value for boolean filters to represent Boolean.TRUE
54       */
55      public static final int FILTER_TRUE = 1;
56      private int _nIdResource = GenericAttributesUtils.CONSTANT_ID_NULL;
57      private String _strResourceType;
58      private int _nIdFieldDepend = GenericAttributesUtils.CONSTANT_ID_NULL;
59      private int _nIdEntryParent = GenericAttributesUtils.CONSTANT_ID_NULL;
60      private int _nEntryParentNull = GenericAttributesUtils.CONSTANT_ID_NULL;
61      private int _nFieldDependNull = GenericAttributesUtils.CONSTANT_ID_NULL;
62      private int _nIdIsGroup = GenericAttributesUtils.CONSTANT_ID_NULL;
63      private int _nIdIsComment = GenericAttributesUtils.CONSTANT_ID_NULL;
64      private int _nIdEntryType = GenericAttributesUtils.CONSTANT_ID_NULL;
65      private int _nIsOnlyDisplayInBack = GenericAttributesUtils.CONSTANT_ID_NULL;
66      private int _nIsIndexed = GenericAttributesUtils.CONSTANT_ID_NULL;
67  
68      /**
69       * Get the id of the resource in the filter
70       * 
71       * @return The id of resource insert in the filter
72       */
73      public int getIdResource( )
74      {
75          return _nIdResource;
76      }
77  
78      /**
79       * Set the id of resource in the filter
80       * 
81       * @param nIdResource
82       *            The id of resource to insert in the filter
83       */
84      public void setIdResource( int nIdResource )
85      {
86          _nIdResource = nIdResource;
87      }
88  
89      /**
90       * Check if this filter contains a resource id
91       * 
92       * @return true if the filter contain an id of resource
93       */
94      public boolean containsIdResource( )
95      {
96          return ( _nIdResource != GenericAttributesUtils.CONSTANT_ID_NULL );
97      }
98  
99      /**
100      *
101      * @return the id of field insert in the filter
102      */
103     public int getIdFieldDepend( )
104     {
105         return _nIdFieldDepend;
106     }
107 
108     /**
109      * Set the id of field depend in the filter
110      * 
111      * @param idField
112      *            the id of field depend to insert in the filter
113      */
114     public void setIdFieldDepend( int idField )
115     {
116         _nIdFieldDepend = idField;
117     }
118 
119     /**
120      * Check if this filter contains a field id
121      * 
122      * @return true if the filter contain an id of field depend
123      */
124     public boolean containsIdField( )
125     {
126         return ( _nIdFieldDepend != GenericAttributesUtils.CONSTANT_ID_NULL );
127     }
128 
129     /**
130      *
131      * @return the id of parent entry insert in the filter
132      */
133     public int getIdEntryParent( )
134     {
135         return _nIdEntryParent;
136     }
137 
138     /**
139      * set the id of parent entry
140      * 
141      * @param idEntryParent
142      *            the id of parent entry to insert in the filter
143      */
144     public void setIdEntryParent( int idEntryParent )
145     {
146         _nIdEntryParent = idEntryParent;
147     }
148 
149     /**
150      *
151      * @return true if the filter contain an parent id
152      */
153     public boolean containsIdEntryParent( )
154     {
155         return ( _nIdEntryParent != GenericAttributesUtils.CONSTANT_ID_NULL );
156     }
157 
158     /**
159      *
160      * @return 1 if the id of parent entry must be null
161      */
162     public int getEntryParentNull( )
163     {
164         return _nEntryParentNull;
165     }
166 
167     /**
168      * set 1 if the id of parent entry must be null
169      * 
170      * @param idEntryParentNull
171      *            1 if the id of parent entry must be null
172      */
173     public void setEntryParentNull( int idEntryParentNull )
174     {
175         _nEntryParentNull = idEntryParentNull;
176     }
177 
178     /**
179      *
180      * @return true if the parent entry must be null
181      */
182     public boolean containsEntryParentNull( )
183     {
184         return ( _nEntryParentNull != GenericAttributesUtils.CONSTANT_ID_NULL );
185     }
186 
187     /**
188      *
189      * @return 1 if the id of field depend must be null
190      */
191     public int getFieldDependNull( )
192     {
193         return _nFieldDependNull;
194     }
195 
196     /**
197      * set 1 if the id of field depend must be null
198      * 
199      * @param idFieldDependNull
200      *            1 if the id of field depend must be null
201      */
202     public void setFieldDependNull( int idFieldDependNull )
203     {
204         _nFieldDependNull = idFieldDependNull;
205     }
206 
207     /**
208      *
209      * @return true if the id of field depend must be null
210      */
211     public boolean containsFieldDependNull( )
212     {
213         return ( _nFieldDependNull != GenericAttributesUtils.CONSTANT_ID_NULL );
214     }
215 
216     /**
217      *
218      * @return 1 if the entry is a group,0 if the entry is not a group
219      */
220     public int getIdIsGroup( )
221     {
222         return _nIdIsGroup;
223     }
224 
225     /**
226      * set 1 if the entry must be a group,0 if the entry must not be a group
227      * 
228      * @param idIsGroup
229      *            1 if the entry must be a group,0 if the entry must not be a group
230      */
231     public void setIdIsGroup( int idIsGroup )
232     {
233         _nIdIsGroup = idIsGroup;
234     }
235 
236     /**
237      *
238      * @return true if the entry must be a group or must not be a group
239      */
240     public boolean containsIdIsGroup( )
241     {
242         return ( _nIdIsGroup != GenericAttributesUtils.CONSTANT_ID_NULL );
243     }
244 
245     /**
246      *
247      * @return 1 if the entry must be a comment,0 if the entry must not be a comment
248      */
249     public int getIdIsComment( )
250     {
251         return _nIdIsComment;
252     }
253 
254     /**
255      * set 1 if the entry must be a comment,0 if the entry must not be a comment
256      * 
257      * @param idComment
258      *            1 if the entry must be a comment,0 if the entry must not be a comment
259      */
260     public void setIdIsComment( int idComment )
261     {
262         _nIdIsComment = idComment;
263     }
264 
265     /**
266      *
267      * @return true if the entry must be a comment or must not be a comment
268      */
269     public boolean containsIdIsComment( )
270     {
271         return ( _nIdIsComment != GenericAttributesUtils.CONSTANT_ID_NULL );
272     }
273 
274     /**
275      * Get the id entry type
276      * 
277      * @return the id of entry type insert in the filter
278      */
279     public int getIdEntryType( )
280     {
281         return _nIdEntryType;
282     }
283 
284     /**
285      * set the id of entry type
286      * 
287      * @param nIdEntryType
288      *            the id of entry type to insert in the filter
289      */
290     public void setIdEntryType( int nIdEntryType )
291     {
292         _nIdEntryType = nIdEntryType;
293     }
294 
295     /**
296      * Check if the filter contains the id entry type
297      * 
298      * @return true if the filter contains an id entry type
299      */
300     public boolean containsIdEntryType( )
301     {
302         return ( _nIdEntryType != GenericAttributesUtils.CONSTANT_ID_NULL );
303     }
304 
305     /**
306      * Get the resource type of the filter
307      * 
308      * @return The resource type of the filter
309      */
310     public String getResourceType( )
311     {
312         return _strResourceType;
313     }
314 
315     /**
316      * Set the result type of the filter
317      * 
318      * @param strResourceType
319      *            The resource type of the filter
320      */
321     public void setResourceType( String strResourceType )
322     {
323         this._strResourceType = strResourceType;
324     }
325 
326     /**
327      * Check if the filter contains the resource type
328      * 
329      * @return True if the filter contains the resource type, false otherwise
330      */
331     public boolean containsResourceType( )
332     {
333         return StringUtils.isNotEmpty( _strResourceType );
334     }
335 
336     /**
337      *
338      * @return 1 if the entry must only display in back a comment,0 if the entry must not only display in back
339      */
340     public int getIsOnlyDisplayInBack( )
341     {
342         return _nIsOnlyDisplayInBack;
343     }
344 
345     /**
346      *
347      * @param isOnlyDisplayInBack
348      */
349     public void setIsOnlyDisplayInBack( int isOnlyDisplayInBack )
350     {
351         this._nIsOnlyDisplayInBack = isOnlyDisplayInBack;
352     }
353 
354     /**
355      *
356      * @return true if the entry must be only display in back or must not be only display in back
357      */
358     public boolean containsIsOnlyDisplayInBack( )
359     {
360         return ( _nIsOnlyDisplayInBack != GenericAttributesUtils.CONSTANT_ID_NULL );
361     }
362 
363     public int getIsIndexed( )
364     {
365         return _nIsIndexed;
366     }
367 
368     public void setIsIndexed( int nIsIndexed )
369     {
370         _nIsIndexed = nIsIndexed;
371     }
372 
373     public boolean containsIsIndexed( )
374     {
375         return ( _nIsIndexed != GenericAttributesUtils.CONSTANT_ID_NULL );
376     }
377 }