View Javadoc
1   /*
2    * Copyright (c) 2002-2025, 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.appointment.web.dto;
35  
36  import java.time.LocalDateTime;
37  import java.time.LocalTime;
38  import java.util.ArrayList;
39  import java.util.Collection;
40  import java.util.HashMap;
41  import java.util.List;
42  import java.util.Locale;
43  import java.util.Map;
44  
45  import fr.paris.lutece.plugins.appointment.business.appointment.Appointment;
46  import fr.paris.lutece.plugins.genericattributes.business.Response;
47  import fr.paris.lutece.plugins.workflowcore.business.action.Action;
48  import fr.paris.lutece.plugins.workflowcore.business.state.State;
49  import fr.paris.lutece.portal.service.i18n.I18nService;
50  
51  /**
52   * The DTO for an appointment in front office
53   *
54   * @author Laurent Payen
55   *
56   */
57  public final class AppointmentDTO extends Appointment
58  {
59  
60      private static final String PROPERTY_EMPTY_FIELD_FIRST_NAME = "appointment.validation.appointment.FirstName.notEmpty";
61      private static final String PROPERTY_EMPTY_FIELD_LAST_NAME = "appointment.validation.appointment.LastName.notEmpty";
62      private static final String PROPERTY_UNVAILABLE_EMAIL = "appointment.validation.appointment.Email.email";
63      private static final String PROPERTY_MESSAGE_EMPTY_EMAIL = "appointment.validation.appointment.Email.notEmpty";
64      private static final String PROPERTY_EMPTY_CONFIRM_EMAIL = "appointment.validation.appointment.EmailConfirmation.email";
65      private static final String PROPERTY_UNVAILABLE_CONFIRM_EMAIL = "appointment.message.error.confirmEmail";
66      private static final String PROPERTY_EMPTY_NB_SEATS = "appointment.validation.appointment.NbBookedSeat.notEmpty";
67      private static final String PROPERTY_UNVAILABLE_NB_SEATS = "appointment.validation.appointment.NbBookedSeat.error";
68      private static final String PROPERTY_MAX_APPOINTMENT_PERIODE = "appointment.message.error.MaxAppointmentPeriode";
69      private static final String PROPERTY_MAX_APPOINTMENT_PERIODE_BACK = "appointment.info.appointment.emailerror";
70      private static final String PROPERTY_NB_DAY_BETWEEN_TWO_APPOINTMENTS = "appointment.validation.appointment.NbMinDaysBetweenTwoAppointments.error";
71      public static final String PROPERTY_APPOINTMENT_STATUS_UNRESERVED = "appointment.message.labelStatusUnreserved";
72      public static final String PROPERTY_APPOINTMENT_STATUS_RESERVED = "appointment.message.labelStatusReserved";
73  
74      /**
75       * Serial version UID
76       */
77      private static final long serialVersionUID = 703930649594406505L;
78  
79      /**
80       * The Date of the appointment in string format
81       */
82      private String _strDateOfTheAppointment;
83  
84      /**
85       * The name of the admin user
86       */
87      private String _strAdminUser;
88  
89      /**
90       * The starting date in LocalDateTime
91       */
92      private LocalDateTime _startingDateTime;
93  
94      /**
95       * The ending date in LocalDateTime
96       */
97      private LocalDateTime _endingDateTime;
98  
99      /**
100      * The starting time
101      */
102     private LocalTime _startingTime;
103 
104     /**
105      * The ending time
106      */
107     private LocalTime _endingTime;
108 
109     /**
110      * The state of the appointment
111      */
112     private transient State _state;
113 
114     /**
115      * The Form Id
116      */
117     private int _nIdForm;
118 
119     /**
120      * the number of booked seats for this appointment
121      */
122     private int _nNbBookedSeats = 1;
123 
124     /**
125      * The maximum number of seats the user can book
126      */
127     private int _nNbMaxPotentialBookedSeats;
128 
129     /**
130      * The Map of the responses for the additional entries of the form
131      */
132     private Map<Integer, List<Response>> _mapResponsesByIdEntry = new HashMap<>( );
133 
134     /**
135      * The list of the responses for the additional entries of the form
136      */
137     private List<Response> _listResponse;
138 
139     /**
140      * List of the available action of the workflow for this appointment
141      */
142     private transient Collection<Action> _listWorkflowActions;
143     /**
144      * The appointment is saved
145      */
146     private boolean _bIsSaved;
147     /**
148      * The overbooking is allowed
149      */
150     private boolean _bOverbookingAllowed;
151 
152     /**
153      * Email confirm of the User
154      */
155     private String _strEmailConfirm;
156 
157     /**
158      * Date Appointment Taken
159      */
160     private String _strFormattedDateAppointmentTaken;
161 
162 
163     /**
164      * Get the name of the admin user
165      *
166      * @return the admin user name
167      */
168     public String getAdminUser( )
169     {
170         return _strAdminUser;
171     }
172 
173     /**
174      * Set the name of the admin user
175      *
176      * @param strAdminUser
177      *            the admin user name to set
178      */
179     public void setAdminUser( String strAdminUser )
180     {
181         this._strAdminUser = strAdminUser;
182     }
183 
184     /**
185      * Get the state of the appointment
186      *
187      * @return the state of the appointment
188      */
189     public State getState( )
190     {
191         return _state;
192     }
193 
194     /**
195      * Set the state of the appointment
196      *
197      * @param state
198      *            the state to set
199      */
200     public void setState( State state )
201     {
202         this._state = state;
203     }
204 
205     /**
206      * Get the starting date time of the appointment
207      *
208      * @return the starting date time
209      */
210     public LocalDateTime getStartingDateTime( )
211     {
212         return _startingDateTime;
213     }
214 
215     /**
216      * Set the starting date time of the appointment
217      *
218      * @param startingDateTime
219      *            the starting date time
220      */
221     public void setStartingDateTime( LocalDateTime startingDateTime )
222     {
223         this._startingDateTime = startingDateTime;
224     }
225 
226     /**
227      * Get the ending date time of the appointment
228      *
229      * @return the ending date time
230      */
231     public LocalDateTime getEndingDateTime( )
232     {
233         return _endingDateTime;
234     }
235 
236     /**
237      * Set the ending date time of the appointment
238      *
239      * @param endingDateTime
240      *            the ending date time
241      */
242     public void setEndingDateTime( LocalDateTime endingDateTime )
243     {
244         this._endingDateTime = endingDateTime;
245     }
246 
247     /**
248      * Get the starting time of the appointment
249      *
250      * @return the starting time
251      */
252     public LocalTime getStartingTime( )
253     {
254         return _startingTime;
255     }
256 
257     /**
258      * Set the starting time of the appointment
259      *
260      * @param startingTime
261      *            the starting time to set
262      */
263     public void setStartingTime( LocalTime startingTime )
264     {
265         this._startingTime = startingTime;
266     }
267 
268     /**
269      * Get the ending time of the appointment
270      *
271      * @return the ending time
272      */
273     public LocalTime getEndingTime( )
274     {
275         return _endingTime;
276     }
277 
278     /**
279      * Set the ending time of the appointment
280      *
281      * @param endingTime
282      *            the ending time
283      */
284     public void setEndingTime( LocalTime endingTime )
285     {
286         this._endingTime = endingTime;
287     }
288 
289     /**
290      * Get the date of the appointment
291      *
292      * @return the date of the appointment
293      */
294     public String getDateOfTheAppointment( )
295     {
296         return _strDateOfTheAppointment;
297     }
298 
299     /**
300      * Set the date of the appointment
301      *
302      * @param strDateOfTheAppointment
303      *            the date to set
304      */
305     public void setDateOfTheAppointment( String strDateOfTheAppointment )
306     {
307         this._strDateOfTheAppointment = strDateOfTheAppointment;
308     }
309 
310     /**
311      * Get the list of the responses of the additional entries of the form
312      *
313      * @return the list of the responses
314      */
315     public List<Response> getListResponse( )
316     {
317         return _listResponse;
318     }
319 
320     /**
321      * Set the list of the responses of the additional entries of the form
322      *
323      * @param listResponse
324      *            the list of the responses to set
325      */
326     public void setListResponse( List<Response> listResponse )
327     {
328         this._listResponse = listResponse;
329     }
330 
331     /**
332      * Get the form Id
333      *
334      * @return the form Id
335      */
336     public int getIdForm( )
337     {
338         return _nIdForm;
339     }
340 
341     /**
342      * Set the Form Id
343      *
344      * @param nIdForm
345      *            the form Id to set
346      */
347     public void setIdForm( int nIdForm )
348     {
349         this._nIdForm = nIdForm;
350     }
351 
352     /**
353      * Get the number of booked seats for the appointment
354      *
355      * @return the number of booked seats
356      */
357     public int getNbBookedSeats( )
358     {
359         return _nNbBookedSeats;
360     }
361 
362     /**
363      * Set the number of booked seats for the appointment
364      *
365      * @param nNumberOfPlacesReserved
366      *            the number to set
367      */
368     public void setNbBookedSeats( int nNumberOfPlacesReserved )
369     {
370         this._nNbBookedSeats = nNumberOfPlacesReserved;
371     }
372 
373     /**
374      * Get the maximum number of booked seats the user can take
375      *
376      * @return the max number of booked seats
377      */
378     public int getNbMaxPotentialBookedSeats( )
379     {
380         return _nNbMaxPotentialBookedSeats;
381     }
382 
383     /**
384      * Set the maximum number of booked seats the user can take
385      *
386      * @param nNbMaxPotentialBookedSeats
387      *            the maximum number to set
388      */
389     public void setNbMaxPotentialBookedSeats( int nNbMaxPotentialBookedSeats )
390     {
391         this._nNbMaxPotentialBookedSeats = nNbMaxPotentialBookedSeats;
392     }
393 
394     /**
395      * Get the available actions of the workflow for this appointment
396      *
397      * @return the actions
398      */
399     public Collection<Action> getListWorkflowActions( )
400     {
401         return _listWorkflowActions;
402     }
403 
404     /**
405      * Set the available actions of the workflow for this appointment
406      *
407      * @param listWorkflowActions
408      */
409     public void setListWorkflowActions( Collection<Action> listWorkflowActions )
410     {
411         this._listWorkflowActions = listWorkflowActions;
412     }
413 
414     /**
415      * Get the map of the responses of the additional entries of the form
416      *
417      * @return the map of the responses
418      */
419     public Map<Integer, List<Response>> getMapResponsesByIdEntry( )
420     {
421         return _mapResponsesByIdEntry;
422     }
423 
424     /**
425      * Set the map of the responses of the addtional entries of the form to the appointment
426      *
427      * @param mapResponsesByIdEntry
428      *            the map to set
429      */
430     public void setMapResponsesByIdEntry( Map<Integer, List<Response>> mapResponsesByIdEntry )
431     {
432         this._mapResponsesByIdEntry = mapResponsesByIdEntry;
433     }
434 
435     public void clearMapResponsesByIdEntry( )
436     {
437         this._mapResponsesByIdEntry.clear( );
438     }
439 
440     /**
441      * Returns the IsSaved
442      *
443      * @return The IsSaved
444      */
445     public boolean getIsSaved( )
446     {
447         return _bIsSaved;
448     }
449 
450     /**
451      * Sets the IsSaved
452      *
453      * @param bIsSaved
454      *            The IsSaved
455      */
456     public void setIsSaved( boolean bIsSaved )
457     {
458         _bIsSaved = bIsSaved;
459     }
460 
461     /**
462      * Returns the OverbookingAllowed
463      *
464      * @return The OverbookingAllowed
465      */
466     public boolean getOverbookingAllowed( )
467     {
468         return _bOverbookingAllowed;
469     }
470 
471     /**
472      * Sets the OverbookingAllowed
473      *
474      * @param bOverbookingAllowed
475      *            The OverbookingAllowed
476      */
477     public void setOverbookingAllowed( boolean bOverbookingAllowed )
478     {
479         _bOverbookingAllowed = bOverbookingAllowed;
480     }
481 
482     /**
483      * Returns the email confirm
484      *
485      * @return The email confirm
486      */
487     public String getEmailConfirm() {
488         return _strEmailConfirm;
489     }
490 
491     /**
492      * Sets the email confirm
493      *
494      * @param strEmailConfirm
495      *            The email confirm
496      */
497     public void setConfirmEmail(String strEmailConfirm) {
498         this._strEmailConfirm = strEmailConfirm;
499     }
500 
501     /**
502      * return the formatted date of the appointment taken
503      */
504     public String getFormattedDateAppointmentTaken() {
505         return _strFormattedDateAppointmentTaken;
506     }
507 
508     /**
509      * set the formatted date of the appointment taken
510      * @param strFormattedDateAppointmentTaken
511      *            the formatted date of the appointment taken
512      */
513     public void setFormattedDateAppointmentTaken(String strFormattedDateAppointmentTaken)
514     {
515         this._strFormattedDateAppointmentTaken = strFormattedDateAppointmentTaken;
516     }
517 
518     /**
519      * Get all the possible errors of the form
520      *
521      * @param locale
522      *            the locale
523      * @return a list of all the possible errors of the form
524      */
525     public static List<String> getAllErrors( Locale locale )
526     {
527         List<String> listAllErrors = new ArrayList<>( );
528         listAllErrors.add( I18nService.getLocalizedString( PROPERTY_EMPTY_FIELD_LAST_NAME, locale ) );
529         listAllErrors.add( I18nService.getLocalizedString( PROPERTY_EMPTY_FIELD_FIRST_NAME, locale ) );
530         listAllErrors.add( I18nService.getLocalizedString( PROPERTY_UNVAILABLE_EMAIL, locale ) );
531         listAllErrors.add( I18nService.getLocalizedString( PROPERTY_MESSAGE_EMPTY_EMAIL, locale ) );
532         listAllErrors.add( I18nService.getLocalizedString( PROPERTY_EMPTY_CONFIRM_EMAIL, locale ) );
533         listAllErrors.add( I18nService.getLocalizedString( PROPERTY_UNVAILABLE_CONFIRM_EMAIL, locale ) );
534         listAllErrors.add( I18nService.getLocalizedString( PROPERTY_EMPTY_NB_SEATS, locale ) );
535         listAllErrors.add( I18nService.getLocalizedString( PROPERTY_UNVAILABLE_NB_SEATS, locale ) );
536         listAllErrors.add( I18nService.getLocalizedString( PROPERTY_MAX_APPOINTMENT_PERIODE, locale ) );
537         listAllErrors.add( I18nService.getLocalizedString( PROPERTY_MAX_APPOINTMENT_PERIODE_BACK, locale ) );
538         listAllErrors.add( I18nService.getLocalizedString( PROPERTY_NB_DAY_BETWEEN_TWO_APPOINTMENTS, locale ) );
539         return listAllErrors;
540     }
541 
542 }