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.List;
37 import java.util.Optional;
38
39 /**
40 * This interface represents a data access object for Notification object
41 *
42 */
43 public interface INotificationDAO
44 {
45
46 /**
47 * Finds notifications associated to the id
48 *
49 * @param strId
50 * @return the notification coresponding to given id.
51 */
52 Optional<Notification> loadById( int id );
53
54 /**
55 * Finds notifications associated to the specified demand id and demand type id. The notifications must be sorted by date descending
56 *
57 * @param strDemandId
58 * the demand id
59 * @param strDemandTypeId
60 * the demand type id
61 * @return the notifications. An empty list is returned if no notification has been found.
62 */
63 List<Notification> loadByDemand( String strDemandId, String strDemandTypeId );
64
65 /**
66 * Get notification by demand ids and notification date
67 *
68 * @param strDemandId
69 * @param strDemandTypeId
70 * @param lDate
71 * @return the notification
72 */
73 List<Notification> loadByDemandAndDate( String strDemandId, String strDemandTypeId, long lDate );
74
75 /**
76 * Finds and populate notification according to the filter
77 *
78 * @param notificationFilter
79 * the filter
80 * @return the notifications. An empty list is returned if no notification has been found.
81 */
82 List<Notification> loadByFilter( NotificationFilter notificationFilter );
83
84 /**
85 * Finds and populate notification by demand id, type id, customer id
86 *
87 * @param strDemandId
88 * @param strDemandTypeId
89 * @param strCustomerId
90 * @return the notifications. An empty list is returned if no notification has been found.
91 */
92 List<Notification> loadByDemandIdTypeIdCustomerId( String strDemandId, String strDemandTypeId, String strCustomerId );
93
94 /**
95 * Find last notification by demand id and demand type id
96 *
97 * @param strDemandId
98 * @param strDemandTypeId
99 * @return last notification
100 */
101 Notification loadLastNotifByDemandIdAndDemandTypeId( String strDemandId, String strDemandTypeId );
102
103 /**
104 * Inserts a notification
105 *
106 * @param notification
107 * the notification to insert
108 * @return the inserted notification
109 */
110 Notification insert( Notification notification );
111
112 /**
113 * Deletes notifications associated to the specified demand id and demand type id
114 *
115 * @param strDemandId
116 * the demand id
117 * @param strDemandTypeId
118 * the demand type id
119 */
120 void deleteByDemand( String strDemandId, String strDemandTypeId );
121
122 /**
123 * Load the ids of the notification by filter
124 *
125 * @param notificationFilter
126 * The notification filter
127 * @return The list of notifications ids
128 */
129 List<Integer> loadIdsByFilter( NotificationFilter notificationFilter );
130
131 /**
132 * load distinct demand type ids
133 *
134 * @return the id list
135 */
136 List<String> loadDistinctDemandTypeIds( );
137
138 /**
139 * Loads list by Ids
140 *
141 * @param listIds
142 * @return list of Notification
143 */
144 List<Notification> loadByIds( List<Integer> listIds );
145
146 /**
147 * delete notification
148 *
149 * @param id
150 */
151 void delete( int id );
152 }