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