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.demand;
35
36 import java.util.Collection;
37 import java.util.List;
38 import java.util.Optional;
39
40 import fr.paris.lutece.plugins.grubusiness.business.notification.INotificationDAO;
41 import fr.paris.lutece.plugins.grubusiness.business.notification.INotificationEventDAO;
42 import fr.paris.lutece.plugins.grubusiness.business.notification.INotificationListener;
43 import fr.paris.lutece.plugins.grubusiness.business.notification.Notification;
44 import fr.paris.lutece.plugins.grubusiness.business.notification.NotificationEvent;
45
46 public interface IDemandServiceProvider
47 {
48
49 /**
50 * init DAO
51 *
52 * @param dao
53 */
54 public void setDemandDao( IDemandDAO dao );
55
56 /**
57 * init DAO
58 *
59 * @param dao
60 */
61 public void setDemandTypeDao( IDemandTypeDAO dao );
62
63 /**
64 * init DAO
65 *
66 * @param dao
67 */
68 public void setNotificationDao( INotificationDAO dao );
69
70 /**
71 * init DAO
72 *
73 * @param dao
74 */
75 public void setNotificationEventDao( INotificationEventDAO dao );
76
77 /**
78 * init DAO
79 *
80 * @param dao
81 */
82 public void setStatusDao( IDemandStatusDAO dao );
83
84 /**
85 * Finds demands for the specified customer id
86 *
87 * @param strCustomerId
88 * the customer id
89 * @return the demands. An empty collection is returned if no demand has been found
90 */
91 public Collection<Demand> findByCustomerId( String strCustomerId );
92
93 /**
94 * Finds demands for the specified reference
95 *
96 * @param strReference
97 * the reference
98 * @return the demands. An empty collection is returned if no demand has been found
99 */
100 public Collection<Demand> findByReference( String strReference );
101
102 /**
103 * Finds a demand for the specified id and type id
104 *
105 * @param strDemandId
106 * the demand id
107 * @param strDemandTypeId
108 * the demand type id
109 * @return the demand if found, {@code null} otherwise
110 */
111 public Demand findByPrimaryKey( String strDemandId, String strDemandTypeId );
112
113 /**
114 * Creates a demand
115 *
116 * @param demand
117 * the demand to create
118 * @return the created demand
119 */
120 public Demand create( Demand demand );
121
122 /**
123 * Creates a notification
124 *
125 * @param notification
126 * the notification to create
127 * @return the created notification
128 */
129 public Notification create( Notification notification );
130
131 /**
132 * Creates a notification event
133 *
134 * @param notificationEvent
135 * @return the created notification event
136 */
137 public NotificationEvent create( NotificationEvent notificationEvent );
138
139 /**
140 * Updates a demand
141 *
142 * @param demand
143 * the demand to update
144 * @return the updated demand
145 */
146 public Demand update( Demand demand );
147
148 /**
149 * Removes a demand with the specified id and type id
150 *
151 * @param strDemandId
152 * the demand id
153 * @param strDemandTypeId
154 * the demand type id
155 */
156 public void remove( String strDemandId, String strDemandTypeId );
157
158 /**
159 * Finds events by date and demand_type_id and status
160 *
161 * @param dStart
162 * @param dEnd
163 * @param strDemandTypeId
164 * @param strStatus
165 *
166 * @return the demands. An empty list is returned if no event has been found
167 */
168 public List<NotificationEvent> findEventsByDateAndDemandTypeIdAndStatus( long dStart, long dEnd, String strDemandTypeId, String strStatus );
169
170 /**
171 * get demand types list
172 *
173 * @return the list
174 */
175 public List<DemandType> getDemandTypesList( );
176
177 /**
178 * get demand type
179 *
180 * @param id
181 * @return the demand type as optional
182 */
183 public Optional<DemandType> getDemandType( int id );
184
185 /**
186 * get demand Ids by customer Id and demand Type
187 *
188 * @param strCustomerId
189 * @param strNotificationType
190 * @param strIdDemandType
191 * @return the demand Id list
192 */
193 public List<Integer> getIdsByCustomerIdAndDemandTypeId( String strCustomerId, String strNotificationType, String strIdDemandType );
194
195 /**
196 * get status
197 *
198 * @param strStatusLabel
199 * @return the status
200 */
201 public Optional<DemandStatus> getStatusByLabel( String strStatusLabel );
202 }