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.notification;
35  
36  /**
37   *
38   * NotificationFilter
39   *
40   */
41  public class NotificationFilter
42  {
43      private static final int ALL_INT = -1;
44      private static final int TRUE = 1;
45      private static final int FALSE = 0;
46      private boolean _bIsWideSearch;
47      private int _nIdDemand;
48      private int _nIsRead;
49  
50      /**
51       * Constructor
52       */
53      public NotificationFilter( )
54      {
55          _bIsWideSearch = false;
56          _nIdDemand = ALL_INT;
57          _nIsRead = ALL_INT;
58      }
59  
60      /**
61       * Set true if the filter is applied to a wide search. <br/>
62       * In other words, the SQL query will use
63       * <ul>
64       * <li>SQL <b>OR</b> if it is applied to a wide search</li>
65       * <li>SQL <b>AND</b> if it is not applied to a wide search</li>
66       * </ul>
67       * 
68       * @param bIsWideSearch
69       *            true if it a wide search, false otherwise
70       */
71      public void setIsWideSearch( boolean bIsWideSearch )
72      {
73          _bIsWideSearch = bIsWideSearch;
74      }
75  
76      /**
77       * Check if the filter is applied to a wide search or not. <br/>
78       * In other words, the SQL query will use
79       * <ul>
80       * <li>SQL <b>OR</b> if it is applied to a wide search</li>
81       * <li>SQL <b>AND</b> if it is not applied to a wide search</li>
82       * </ul>
83       * 
84       * @return true if it is applied to a wide search
85       */
86      public boolean getIsWideSearch( )
87      {
88          return _bIsWideSearch;
89      }
90  
91      /**
92       * Returns the IdDemand
93       * 
94       * @return The IdDemand
95       */
96      public int getIdDemand( )
97      {
98          return _nIdDemand;
99      }
100 
101     /**
102      * Sets the IdDemand
103      * 
104      * @param strIdDemand
105      *            The IdDemand
106      */
107     public void setIdDemand( int strIdDemand )
108     {
109         _nIdDemand = strIdDemand;
110     }
111 
112     /**
113      * Check if the filter contains the attribute ID Demand
114      * 
115      * @return true if it contains, false otherwise
116      */
117     public boolean containsIdDemand( )
118     {
119         return _nIdDemand != ALL_INT;
120     }
121 
122     /**
123      * Set the status is_read of the notification
124      * 
125      * @param bIsRead
126      *            true if the notification is read, false otherwise
127      */
128     public void setIsRead( boolean bIsRead )
129     {
130         _nIsRead = bIsRead ? TRUE : FALSE;
131     }
132 
133     /**
134      * Check if the notification is read
135      * 
136      * @return true if it is read, false otherwise
137      */
138     public boolean isRead( )
139     {
140         return _nIsRead == TRUE;
141     }
142 
143     /**
144      * Check if the filter contains the attribute is_read
145      * 
146      * @return true if it contains, false otherwise
147      */
148     public boolean containsIsRead( )
149     {
150         return _nIsRead != ALL_INT;
151     }
152 }