View Javadoc
1   /*
2    * Copyright (c) 2002-2023, 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.document.business;
35  
36  /**
37   *
38   */
39  public class DocumentFilter
40  {
41      private static final String ALL_STRING = "all";
42      private static final int ALL_INT = -1;
43  
44      // Variables declarations
45      private int _nIdSpace = ALL_INT;
46      private int _nIdState = ALL_INT;
47      private String _strCodeDocumentType = ALL_STRING;
48      private int [ ] _arrayCategoriesId;
49      private int [ ] _arrayId;
50  
51      // The default value is true to assure ascendant compatibility
52      private boolean _bLoadBinaries = true;
53      private Boolean _bIsPublished;
54      private String _dateMin;
55      private String _dateMax;
56  
57      /**
58       * Returns the IdSpace
59       *
60       * @return The IdSpace
61       */
62      public int getIdSpace( )
63      {
64          return _nIdSpace;
65      }
66  
67      /**
68       * Sets the IdSpace
69       *
70       * @param nIdSpace
71       *            The IdSpace
72       */
73      public void setIdSpace( int nIdSpace )
74      {
75          _nIdSpace = nIdSpace;
76      }
77  
78      /**
79       * Tell if the filter contains a criteria on the Document space
80       * 
81       * @return True if the filter contains a criteria on the Document space otherwise false
82       */
83      public boolean containsSpaceCriteria( )
84      {
85          return ( _nIdSpace != ALL_INT );
86      }
87  
88      /**
89       * Returns the IdState
90       *
91       * @return The IdState
92       */
93      public int getIdState( )
94      {
95          return _nIdState;
96      }
97  
98      /**
99       * Tell if the filter contains a criteria on the Document state
100      * 
101      * @return True if the filter contains a criteria on the Document state otherwise false
102      */
103     public boolean containsStateCriteria( )
104     {
105         return ( _nIdState != ALL_INT );
106     }
107 
108     /**
109      * Sets the IdState
110      *
111      * @param nIdState
112      *            The IdState
113      */
114     public void setIdState( int nIdState )
115     {
116         _nIdState = nIdState;
117     }
118 
119     /**
120      * Returns the CodeDocumentType
121      *
122      * @return The CodeDocumentType
123      */
124     public String getCodeDocumentType( )
125     {
126         return _strCodeDocumentType;
127     }
128 
129     /**
130      * Sets the CodeDocumentType
131      *
132      * @param strCodeDocumentType
133      *            The CodeDocumentType
134      */
135     public void setCodeDocumentType( String strCodeDocumentType )
136     {
137         _strCodeDocumentType = strCodeDocumentType;
138     }
139 
140     /**
141      * Tell if the filter contains a criteria on the Document type
142      * 
143      * @return True if the filter contains a criteria on the Document type otherwise false
144      */
145     public boolean containsDocumentTypeCriteria( )
146     {
147         return ( !_strCodeDocumentType.equals( ALL_STRING ) );
148     }
149 
150     /**
151      * @return the _arrayCategoriesId
152      */
153     public int [ ] getCategoriesId( )
154     {
155         return _arrayCategoriesId;
156     }
157 
158     /**
159      * @param arrayCategoriesId
160      *            the _arrayCategoriesId to set
161      */
162     public void setCategoriesId( int [ ] arrayCategoriesId )
163     {
164         _arrayCategoriesId = arrayCategoriesId;
165     }
166 
167     /**
168      * Tell if the filter contains a criteria on the Category
169      * 
170      * @return True if the filter contains a criteria on the categories otherwise false
171      */
172     public boolean containsCategoriesCriteria( )
173     {
174         return ( ( _arrayCategoriesId != null ) && ( _arrayCategoriesId.length != 0 ) );
175     }
176 
177     /**
178      * Tell if the filter contains a criteria on the Id
179      * 
180      * @return True if the filter contains a criteria on the Ids otherwise false
181      */
182     public boolean containsIdsCriteria( )
183     {
184         return ( ( _arrayId != null ) && ( _arrayId.length != 0 ) );
185     }
186 
187     /**
188      * @return the _arrayId
189      */
190     public int [ ] getIds( )
191     {
192         return _arrayId;
193     }
194 
195     /**
196      * @param arrayId
197      *            the _arrayId to set
198      */
199     public void setIds( int [ ] arrayId )
200     {
201         _arrayId = arrayId;
202     }
203 
204     /**
205      * Get the boolean that indicates whether binaries of documents should be loaded
206      * 
207      * @return True if binaries should be loaded, false otherwise
208      */
209     public boolean getLoadBinaries( )
210     {
211         return _bLoadBinaries;
212     }
213 
214     /**
215      * Set the boolean that indicates whether binaries of documents should be loaded
216      * 
217      * @param bLoadBinaries
218      *            True if binaries should be loaded, false otherwise
219      */
220     public void setLoadBinaries( boolean bLoadBinaries )
221     {
222         this._bLoadBinaries = bLoadBinaries;
223     }
224 
225     /**
226      * @return the _bIsPublished
227      */
228     public Boolean isPublished( )
229     {
230         return _bIsPublished;
231     }
232 
233     /**
234      * @param bIsPublished
235      *            the _bIsPublished to set
236      */
237     public void setIsPublished( Boolean bIsPublished )
238     {
239         this._bIsPublished = bIsPublished;
240     }
241 
242     /**
243      * @return the _dateMin
244      */
245     public String getDateMin( )
246     {
247         return _dateMin;
248     }
249 
250     /**
251      * @param dateMin
252      *            the _dateMin to set
253      */
254     public void setDateMin( String dateMin )
255     {
256         this._dateMin = dateMin;
257     }
258 
259     /**
260      * @return the _dateMax
261      */
262     public String getDateMax( )
263     {
264         return _dateMax;
265     }
266 
267     /**
268      * @param dateMax
269      *            the _dateMax to set
270      */
271     public void setDateMax( String dateMax )
272     {
273         this._dateMax = dateMax;
274     }
275 }