1 /*
2 * Copyright (c) 2002-2024, 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.grubusiness.business.notification;
35
36 import java.util.ArrayList;
37 import java.util.List;
38
39 /**
40 * NotificationFilter for DAO A base notificationFilter return all notifications without details on sub object
41 */
42 public class NotificationFilter
43 {
44 // filter on id
45 private List<Integer> _listIds;
46
47 // filter on demand
48 private String _strDemandId;
49 private String _strDemandTypeId;
50
51 // filter on date
52 private long _lStartDate;
53 private long _lEndDate;
54
55 // Notification type
56 private List<EnumNotificationType> _listNotificationType = new ArrayList<>( );
57
58 // filter on eventStatus
59 private String _strEventStatus;
60
61 /**
62 * Check if this filter contains a id
63 *
64 * @return true if the filter contain an id
65 */
66 public boolean containsId( )
67 {
68 return ( _listIds != null && !_listIds.isEmpty( ) );
69 }
70
71 /**
72 * Get the id
73 *
74 * @return the id
75 */
76 public List<Integer> getIds( )
77 {
78 return _listIds;
79 }
80
81 /**
82 * The id
83 *
84 * @param strId
85 * the id
86 */
87 public void setIds( List<Integer> listIds )
88 {
89 _listIds = listIds;
90 }
91
92 /**
93 * Check if this filter contains a demandId
94 *
95 * @return true if the filter contain an id of demand
96 */
97 public boolean containsDemandId( )
98 {
99 return ( _strDemandId != null && !"".equals( _strDemandId.trim( ) ) );
100 }
101
102 /**
103 * @return the demandId
104 */
105 public String getDemandId( )
106 {
107 return _strDemandId;
108 }
109
110 /**
111 * @param strDemandId
112 * the demandId to set
113 */
114 public void setDemandId( String strDemandId )
115 {
116 this._strDemandId = strDemandId;
117 }
118
119 /**
120 * Check if this filter contains a demandTypeId
121 *
122 * @return true if the filter contain an id of demandType
123 */
124 public boolean containsDemandTypeId( )
125 {
126 return ( _strDemandTypeId != null && !"".equals( _strDemandTypeId.trim( ) ) );
127 }
128
129 /**
130 * @return the demandTypeId
131 */
132 public String getDemandTypeId( )
133 {
134 return _strDemandTypeId;
135 }
136
137 /**
138 * @param strDemandTypeId
139 * the demandTypeId to set
140 */
141 public void setDemandTypeId( String strDemandTypeId )
142 {
143 this._strDemandTypeId = strDemandTypeId;
144 }
145
146 /**
147 * Check if this filter contains a hasCustomerEmailNotification
148 *
149 * @return true if the filter contain a hasCustomerEmailNotification
150 */
151 public boolean containsCustomerEmailNotificationType( )
152 {
153 return ( !_listNotificationType.isEmpty( ) && _listNotificationType.contains( EnumNotificationType.CUSTOMER_EMAIL ) );
154 }
155
156 /**
157 * Check if this filter contains a hasSmsNotification
158 *
159 * @return true if the filter contain a hasSmsNotification
160 */
161 public boolean containsSmsNotificationType( )
162 {
163 return ( !_listNotificationType.isEmpty( ) && _listNotificationType.contains( EnumNotificationType.SMS ) );
164 }
165
166 /**
167 * Check if this filter contains a hasBackofficeNotification
168 *
169 * @return true if the filter contain a hasBackofficeNotification
170 */
171 public boolean containsBackofficeNotificationType( )
172 {
173 return ( !_listNotificationType.isEmpty( ) && _listNotificationType.contains( EnumNotificationType.BACKOFFICE ) );
174 }
175
176 /**
177 * Check if this filter contains a hasMyDashboardNotification
178 *
179 * @return true if the filter contain a hasMyDashboardNotification
180 */
181 public boolean containsMyDashboardNotificationType( )
182 {
183 return ( !_listNotificationType.isEmpty( ) && _listNotificationType.contains( EnumNotificationType.MYDASHBOARD ) );
184 }
185
186 /**
187 * Check if this filter contains a hasBroadcastEmailNotification
188 *
189 * @return true if the filter contain a hasBroadcastEmailNotification
190 */
191 public boolean containsBroadcastEmailNotificationType( )
192 {
193 return ( !_listNotificationType.isEmpty( ) && _listNotificationType.contains( EnumNotificationType.BROADCAST_EMAIL ) );
194 }
195
196 /**
197 * Check if this filter contains a notification type filter
198 *
199 * @return true if the filter contain a notification type filter
200 */
201 public boolean containsNotificationTypeFilter( )
202 {
203 return containsCustomerEmailNotificationType( ) || containsSmsNotificationType( ) || containsBackofficeNotificationType( )
204 || containsMyDashboardNotificationType( ) || containsBroadcastEmailNotificationType( );
205 }
206
207 /**
208 * test if filter contains start date
209 *
210 * @return true if starDate > 0
211 */
212 public boolean containsStartDate( )
213 {
214 return ( _lStartDate > 0 );
215 }
216
217 /**
218 * get start date
219 *
220 * @return the start date
221 */
222 public long getStartDate( )
223 {
224 return _lStartDate;
225 }
226
227 /**
228 * set start date
229 *
230 * @param _lStartDate
231 */
232 public void setStartDate( long _lStartDate )
233 {
234 this._lStartDate = _lStartDate;
235 }
236
237 /**
238 * test if filter contains end date
239 *
240 * @return true if endDate > 0
241 */
242 public boolean containsEndDate( )
243 {
244 return ( _lEndDate > 0 );
245 }
246
247 /**
248 * get end date
249 *
250 * @return the end date
251 */
252 public long getEndDate( )
253 {
254 return _lEndDate;
255 }
256
257 /**
258 * set end date
259 *
260 * @param _lEndDate
261 */
262 public void setEndDate( long _lEndDate )
263 {
264 this._lEndDate = _lEndDate;
265 }
266
267 /**
268 * get event status
269 *
270 * @return the status filter
271 */
272 public String getEventStatus( )
273 {
274 return _strEventStatus;
275 }
276
277 /**
278 * set event status
279 *
280 * @param strEventStatus
281 */
282 public void setEventStatus( String strEventStatus )
283 {
284 this._strEventStatus = strEventStatus;
285 }
286
287 /**
288 * @return the _listNotificationType
289 */
290 public List<EnumNotificationType> getListNotificationType( )
291 {
292 return _listNotificationType;
293 }
294
295 /**
296 * @param listNotificationType
297 * the _listNotificationType to set
298 */
299 public void setListNotificationType( List<EnumNotificationType> listNotificationType )
300 {
301 this._listNotificationType = listNotificationType;
302 }
303
304 }