View Javadoc
1   /*
2    * Copyright (c) 2002-2022, 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.service;
35  
36  import java.time.LocalDateTime;
37  import java.util.ArrayList;
38  import java.util.List;
39  import java.util.StringJoiner;
40  import java.util.stream.Collectors;
41  
42  import javax.servlet.http.HttpServletRequest;
43  
44  import org.apache.commons.collections.CollectionUtils;
45  import org.apache.commons.lang3.StringUtils;
46  
47  import fr.paris.lutece.plugins.appointment.business.appointment.Appointment;
48  import fr.paris.lutece.plugins.appointment.business.appointment.AppointmentHome;
49  import fr.paris.lutece.plugins.appointment.business.appointment.AppointmentSlot;
50  import fr.paris.lutece.plugins.appointment.business.form.Form;
51  import fr.paris.lutece.plugins.appointment.business.slot.Slot;
52  import fr.paris.lutece.plugins.appointment.business.user.User;
53  import fr.paris.lutece.plugins.appointment.business.user.UserHome;
54  import fr.paris.lutece.plugins.appointment.service.listeners.AppointmentListenerManager;
55  import fr.paris.lutece.plugins.appointment.service.listeners.SlotListenerManager;
56  import fr.paris.lutece.plugins.appointment.web.dto.AppointmentDTO;
57  import fr.paris.lutece.plugins.appointment.web.dto.AppointmentFilterDTO;
58  import fr.paris.lutece.plugins.genericattributes.business.Response;
59  import fr.paris.lutece.plugins.genericattributes.business.ResponseHome;
60  import fr.paris.lutece.portal.business.user.AdminUser;
61  import fr.paris.lutece.portal.business.user.AdminUserHome;
62  import fr.paris.lutece.portal.service.util.AppException;
63  import fr.paris.lutece.portal.service.util.AppLogService;
64  import fr.paris.lutece.portal.service.util.AppPropertiesService;
65  import fr.paris.lutece.portal.service.util.CryptoService;
66  import fr.paris.lutece.portal.service.workflow.WorkflowService;
67  import fr.paris.lutece.util.sql.TransactionManager;
68  
69  /**
70   * Service class for an appointment
71   * 
72   * @author Laurent Payen
73   *
74   */
75  public final class AppointmentService
76  {
77  
78      private static final String PROPERTY_REF_ENCRYPTION_ALGORITHM = "appointment.refEncryptionAlgorithm";
79      private static final String CONSTANT_SHA256 = "SHA-256";
80      private static final String PROPERTY_REF_SIZE_RANDOM_PART = "appointment.refSizeRandomPart";
81      private static final String CONSTANT_SEPARATOR = "$";
82      /**
83       * Get the number of characters of the random part of appointment reference
84       */
85      private static final int CONSTANT_REF_SIZE_RANDOM_PART = 5;
86  
87      /**
88       * Private constructor - this class does not need to be instantiated
89       */
90      private AppointmentService( )
91      {
92      }
93  
94      /**
95       * Find all the appointments of the slots given in parameter
96       * 
97       * @param listSlot
98       *            the list of slots
99       * @return a list of the appointments on these slots
100      */
101     public static List<Appointment> findListAppointmentByListSlot( List<Slot> listSlot )
102     {
103         List<Integer> listIdSlot = listSlot.stream( ).map( Slot::getIdSlot ).collect( Collectors.toList( ) );
104 
105         return AppointmentHome.findByListIdSlot( listIdSlot );
106     }
107 
108     /**
109      * Find the appointments of a slot
110      * 
111      * @param nIdSlot
112      *            the slot Id
113      * @return the appointments of the slot
114      */
115     public static List<Appointment> findListAppointmentBySlot( int nIdSlot )
116     {
117         return AppointmentHome.findByIdSlot( nIdSlot );
118     }
119 
120     /**
121      * Find the appointments of a user
122      * 
123      * @param nIdUser
124      *            the user Id
125      * @return the appointment of the user
126      */
127     public static List<Appointment> findListAppointmentByUserId( int nIdUser )
128     {
129         return AppointmentHome.findByIdUser( nIdUser );
130 
131     }
132 
133     /**
134      * Find the appointments of a user by guid
135      * 
136      * @param nIdUser
137      *            the user guid
138      * @return the appointment of the guid
139      */
140     public static List<Appointment> findListAppointmentByUserGuid( String strGuidUser )
141     {
142         List<Appointment> listAppointment = AppointmentHome.findByGuidUser( strGuidUser );
143         for ( Appointment appointment : listAppointment )
144         {
145             List<Slot> listSlot = SlotService.findListSlotByIdAppointment( appointment.getIdAppointment( ) );
146             appointment.setSlot( listSlot );
147 
148         }
149         return listAppointment;
150 
151     }
152 
153     /**
154      * Find the appointments by form
155      * 
156      * @param nIdForm
157      *            the form Id
158      * 
159      * @return the appointments that matches the criteria
160      */
161     public static List<Appointment> findListAppointmentByIdForm( int nIdForm )
162     {
163         return AppointmentHome.findByIdForm( nIdForm );
164     }
165 
166     /**
167      * Build and create in database an appointment from the dto
168      * 
169      * @param appointmentDTO
170      *            the appointment dto
171      * @param user
172      *            the user
173      * @param slot
174      *            the slot
175      * @return the appointment created
176      */
177     static Appointment buildAndCreateAppointment( AppointmentDTO appointmentDTO, User user )
178     {
179         Appointmentent/business/appointment/Appointment.html#Appointment">Appointment appointment = new Appointment( );
180         if ( appointmentDTO.getIdAppointment( ) != 0 )
181         {
182             appointment = AppointmentService.findAppointmentById( appointmentDTO.getIdAppointment( ) );
183         }
184         if ( appointmentDTO.getIdAdminUser( ) != 0 )
185         {
186             appointment.setIdAdminUser( appointmentDTO.getIdAdminUser( ) );
187         }
188         if ( appointmentDTO.getAdminUserCreate( ) != null )
189         {
190             appointment.setAdminUserCreate( appointmentDTO.getAdminUserCreate( ) );
191         }
192         appointment.setListAppointmentSlot( appointmentDTO.getListAppointmentSlot( ) );
193         appointment.setNbPlaces( appointmentDTO.getNbBookedSeats( ) );
194         appointment.setIdUser( user.getIdUser( ) );
195         appointment.setIsSurbooked( appointmentDTO.getIsSurbooked( ) );
196 
197         if ( appointment.getIdAppointment( ) == 0 )
198         {
199             appointment = AppointmentHome.create( appointment );
200             String strEmailLastNameFirstName = new StringJoiner( StringUtils.SPACE ).add( user.getEmail( ) ).add( CONSTANT_SEPARATOR )
201                     .add( user.getLastName( ) ).add( CONSTANT_SEPARATOR ).add( user.getFirstName( ) ).toString( );
202             String strReference = appointment.getIdAppointment( ) + CryptoService
203                     .encrypt( appointment.getIdAppointment( ) + strEmailLastNameFirstName,
204                             AppPropertiesService.getProperty( PROPERTY_REF_ENCRYPTION_ALGORITHM, CONSTANT_SHA256 ) )
205                     .substring( 0, AppPropertiesService.getPropertyInt( PROPERTY_REF_SIZE_RANDOM_PART, CONSTANT_REF_SIZE_RANDOM_PART ) );
206 
207             Form form = FormService.findFormLightByPrimaryKey( appointmentDTO.getIdForm( ) );
208             if ( StringUtils.isNotEmpty( form.getReference( ) ) )
209             {
210                 strReference = form.getReference( ) + strReference;
211             }
212             appointment.setReference( strReference );
213             appointment = AppointmentHome.update( appointment );
214         }
215         else
216         {
217             AppointmentHome.updateAppointmentDate( appointment );
218 
219         }
220         return appointment;
221     }
222 
223     /**
224      * Find an appointment by its primary key
225      * 
226      * @param nIdAppointment
227      *            the appointment Id
228      * @return the appointment
229      */
230     public static Appointment findAppointmentById( int nIdAppointment )
231     {
232         return AppointmentHome.findByPrimaryKey( nIdAppointment );
233     }
234 
235     /**
236      * Find an appointment by its reference
237      * 
238      * @param strReference
239      *            the appointment Reference
240      * @return the appointment
241      */
242     public static Appointment findAppointmentByReference( String strReference )
243     {
244         return AppointmentHome.findByReference( strReference );
245     }
246 
247     /**
248      * Find a list of appointments matching the filter
249      * 
250      * @param appointmentFilter
251      *            the filter
252      * @return a list of appointments
253      */
254     public static List<AppointmentDTO> findListAppointmentsDTOByFilter( AppointmentFilterDTO appointmentFilter )
255     {
256         List<AppointmentDTO> listAppointmentsDTO = new ArrayList<>( );
257         for ( Appointment appointment : AppointmentHome.findByFilter( appointmentFilter ) )
258         {
259             listAppointmentsDTO.add( buildAppointmentDTO( appointment ) );
260         }
261         return listAppointmentsDTO;
262     }
263 
264     /**
265      * Find a list of appointments by id category and mail
266      * 
267      * @param nIdCategory
268      *            the id category
269      * @param mail
270      *            the mail
271      * @return list of appointments
272      */
273     public static List<AppointmentDTO> findAppointmentByMailAndCategory( int nIdCategory, String mail )
274     {
275         List<AppointmentDTO> listAppointmentsDTO = new ArrayList<>( );
276         for ( Appointment appointment : AppointmentHome.findByMailAndCategory( nIdCategory, mail ) )
277         {
278             listAppointmentsDTO.add( buildAppointmentDTO( appointment ) );
279         }
280         return listAppointmentsDTO;
281     }
282 
283     /**
284      * Find a list of appointments matching the filter
285      * 
286      * @param appointmentFilter
287      * @return a list of appointments
288      */
289     public static List<Appointment> findListAppointmentsByFilter( AppointmentFilterDTO appointmentFilter )
290     {
291         return AppointmentHome.findByFilter( appointmentFilter );
292     }
293 
294     /**
295      * Find a list of appointments ids matching the filter
296      *
297      * @param appointmentFilter
298      *         the filter
299      * @return a list of appointments
300      */
301     public static List<Integer> findListAppointmentsIdsByFilter( AppointmentFilterDTO appointmentFilter )
302     {
303         return AppointmentHome.findIdsByFilter( appointmentFilter );
304     }
305 
306     /**
307      * Build an appointment dto from an appointment business object
308      * 
309      * @param appointment
310      *            the appointment business object
311      * @return the appointment DTO
312      */
313     private static AppointmentDTO buildAppointmentDTO( Appointment appointment )
314     {
315         AppointmentDTOb/dto/AppointmentDTO.html#AppointmentDTO">AppointmentDTO appointmentDTO = new AppointmentDTO( );
316         appointmentDTO.setIdForm( appointment.getSlot( ).get( 0 ).getIdForm( ) );
317         appointmentDTO.setIdUser( appointment.getIdUser( ) );
318         appointmentDTO.setListAppointmentSlot( appointment.getListAppointmentSlot( ) );
319         appointmentDTO.setIdAppointment( appointment.getIdAppointment( ) );
320         appointmentDTO.setFirstName( appointment.getUser( ).getFirstName( ) );
321         appointmentDTO.setLastName( appointment.getUser( ).getLastName( ) );
322         appointmentDTO.setEmail( appointment.getUser( ).getEmail( ) );
323         appointmentDTO.setPhoneNumber( appointment.getUser( ).getPhoneNumber( ) );
324         appointmentDTO.setGuid( appointment.getUser( ).getGuid( ) );
325         appointmentDTO.setReference( appointment.getReference( ) );
326         LocalDateTime startingDateTime = AppointmentUtilities.getStartingDateTime( appointment );
327         LocalDateTime endingDateTime = AppointmentUtilities.getEndingDateTime( appointment );
328         appointmentDTO.setStartingDateTime( startingDateTime );
329         appointmentDTO.setEndingDateTime( endingDateTime );
330         appointmentDTO.setDateOfTheAppointment( startingDateTime.toLocalDate( ).format( Utilities.getFormatter( ) ) );
331         appointmentDTO.setStartingTime( startingDateTime.toLocalTime( ) );
332         appointmentDTO.setEndingTime( endingDateTime.toLocalTime( ) );
333         appointmentDTO.setIsCancelled( appointment.getIsCancelled( ) );
334         appointmentDTO.setNbBookedSeats( appointment.getNbPlaces( ) );
335         for ( Slot slt : appointment.getSlot( ) )
336         {
337 
338             SlotService.addDateAndTimeToSlot( slt );
339         }
340         appointmentDTO.setSlot( appointment.getSlot( ) );
341         appointmentDTO.setUser( appointment.getUser( ) );
342         if ( appointment.getIdAdminUser( ) != 0 )
343         {
344             AdminUser adminUser = AdminUserHome.findByPrimaryKey( appointment.getIdAdminUser( ) );
345             if ( adminUser != null )
346             {
347                 appointmentDTO.setIdAdminUser( adminUser.getUserId());
348                 appointmentDTO.setAdminUser(
349                         new StringBuilder( adminUser.getFirstName( ) + org.apache.commons.lang3.StringUtils.SPACE + adminUser.getLastName( ) ).toString( ) );
350             }
351         }
352         else
353         {
354             appointmentDTO.setAdminUser( StringUtils.EMPTY );
355         }
356         appointmentDTO.setAdminUserCreate( appointment.getAdminUserCreate( ) );
357         appointmentDTO.setDateAppointmentTaken( appointment.getDateAppointmentTaken( ) );
358         return appointmentDTO;
359     }
360 
361     /**
362      * Fill the appointment data transfer object with complementary appointment responses
363      * 
364      * @param appointmentDto
365      *            The appointmentDTO object
366      */
367     public static void addAppointmentResponses( AppointmentDTO appointmentDto )
368     {
369         // Load the response list in the DTO
370         appointmentDto.setListResponse( AppointmentResponseService.findListResponse( appointmentDto.getIdAppointment( ) ) );
371     }
372 
373     /**
374      * Delete an appointment (and update the number of remaining places of the related slot)
375      * 
376      * @param nIdAppointment
377      *            the id of the appointment to delete
378      * @throws Exception
379      *             the exception
380      */
381     public static void deleteAppointment( int nIdAppointment )
382     {
383         TransactionManager.beginTransaction( AppointmentPlugin.getPlugin( ) );
384         try
385         {
386             Appointment appointmentToDelete = AppointmentHome.findByPrimaryKey( nIdAppointment );
387             deleteWorkflowResource( nIdAppointment );
388             if ( !appointmentToDelete.getIsCancelled( ) )
389             {
390                 for ( AppointmentSlot appSlot : appointmentToDelete.getListAppointmentSlot( ) )
391                 {
392                     // Need to update the nb remaining places of the related slot
393                     SlotSafeService.updateRemaningPlacesWithAppointmentMovedDeletedOrCanceled( appSlot.getNbPlaces( ), appSlot.getIdSlot( ) );
394                 }
395 
396             }
397             // Need to delete also the responses linked to this appointment
398             AppointmentResponseService.removeResponsesByIdAppointment( nIdAppointment );
399             AppointmentService.deleteAppointment( appointmentToDelete );
400             UserHome.delete( appointmentToDelete.getIdUser( ) );
401             TransactionManager.commitTransaction( AppointmentPlugin.getPlugin( ) );
402             AppointmentListenerManager.notifyListenersAppointmentRemoval( nIdAppointment );
403             for ( AppointmentSlot appSlot : appointmentToDelete.getListAppointmentSlot( ) )
404             {
405                 SlotListenerManager.notifyListenersSlotChange( appSlot.getIdSlot( ) );
406             }
407         }
408         catch( Exception e )
409         {
410             TransactionManager.rollBack( AppointmentPlugin.getPlugin( ) );
411             AppLogService.error( "Error delete appointment " + e.getMessage( ), e );
412             throw new AppException( e.getMessage( ), e );
413         }
414     }
415 
416     private static void deleteWorkflowResource( int nIdAppointment )
417     {
418         if ( WorkflowService.getInstance( ).isAvailable( ) )
419         {
420             try
421             {
422                 WorkflowService.getInstance( ).doRemoveWorkFlowResource( nIdAppointment, Appointment.APPOINTMENT_RESOURCE_TYPE );
423             }
424             catch( Exception e )
425             {
426                 AppLogService.error( "Error Workflow", e );
427             }
428         }
429     }
430 
431     /**
432      * Delete an appointment
433      * 
434      * @param appointment
435      *            the appointment to delete
436      */
437     private static void deleteAppointment( Appointment appointment )
438     {
439         AppointmentHome.delete( appointment.getIdAppointment( ) );
440     }
441 
442     /**
443      * Build an appointment DTO from the id of an appointment business object
444      * 
445      * @param nIdAppointment
446      *            the id of the appointment
447      * @return the appointment DTO
448      */
449     public static AppointmentDTO buildAppointmentDTOFromIdAppointment( int nIdAppointment )
450     {
451         Appointment appointment = AppointmentService.findAppointmentById( nIdAppointment );
452         User user = UserService.findUserById( appointment.getIdUser( ) );
453         List<Slot> listSlot = SlotService.findListSlotByIdAppointment( appointment.getIdAppointment( ) );
454         appointment.setSlot( listSlot );
455         appointment.setUser( user );
456         return buildAppointmentDTO( appointment );
457     }
458 
459     /**
460      * Build an appointment DTO from the reference of an appointment business object
461      * 
462      * @param refAppointment
463      *            the reference of the appointment
464      * @return the appointment DTO, or null if the appointment wasn't found
465      */
466     public static AppointmentDTO buildAppointmentDTOFromRefAppointment( String refAppointment )
467     {
468         Appointment appointment = AppointmentService.findAppointmentByReference( refAppointment );
469 
470         if ( appointment == null )
471         {
472         	return null;
473         }
474         User user = UserService.findUserById( appointment.getIdUser( ) );
475         List<Slot> listSlot = SlotService.findListSlotByIdAppointment( appointment.getIdAppointment( ) );
476         appointment.setSlot( listSlot );
477         appointment.setUser( user );
478 
479         return buildAppointmentDTO( appointment );
480     }
481 
482     /**
483      * Update an appointment DTO in database
484      * 
485      * @param nIdappointment
486      *            the id appointment
487      * @param user
488      *            the user
489      * @param listResponse
490      *            the listResponse
491      * @param deleteBoOnly
492      *            if the action is Bo only
493      */
494     public static void updateAppointmentDTO( int nIdappointment, User user, List<Response> listResponse, boolean deleteBoOnly )
495     {
496         UserHome.update( user );
497         AppointmentResponseService.removeResponsesByIdAppointmentAndBoOnly( nIdappointment, deleteBoOnly );
498         if ( CollectionUtils.isNotEmpty( listResponse ) )
499         {
500             for ( Response response : listResponse )
501             {
502                 ResponseHome.create( response );
503                 AppointmentResponseService.insertAppointmentResponse( nIdappointment, response.getIdResponse( ) );
504             }
505         }
506         AppointmentListenerManager.notifyListenersAppointmentUpdated( nIdappointment );
507     }
508 
509     /**
510      * Update an appointment in database
511      * 
512      * @param appointment
513      *            the appointment to update
514      */
515     public static void updateAppointment( Appointment appointment )
516     {
517         boolean statusUpdated = false;
518         // Get the old appointment in db
519         Appointment oldAppointment = AppointmentService.findAppointmentById( appointment.getIdAppointment( ) );
520         // If the update concerns a cancellation of the appointment
521         TransactionManager.beginTransaction( AppointmentPlugin.getPlugin( ) );
522         try
523         {
524             if ( !oldAppointment.getIsCancelled( ) && appointment.getIsCancelled( ) )
525             {
526                 for ( AppointmentSlot appSlot : oldAppointment.getListAppointmentSlot( ) )
527                 {
528                     // Need to update the nb remaining places of the related slot
529                     SlotSafeService.updateRemaningPlacesWithAppointmentMovedDeletedOrCanceled( appSlot.getNbPlaces( ), appSlot.getIdSlot( ) );
530                 }
531                 statusUpdated = true;
532             }
533             else
534                 if ( oldAppointment.getIsCancelled( ) && !appointment.getIsCancelled( ) )
535                 {
536                     for ( AppointmentSlot appSlot : oldAppointment.getListAppointmentSlot( ) )
537                     {
538                         // Need to update the nb remaining places of the related slot
539                         SlotSafeService.updateRemaningPlacesWithAppointmentReactivated( appSlot.getNbPlaces( ), appSlot.getIdSlot( ) );
540                     }
541                     statusUpdated = true;
542                 }
543             AppointmentHome.update( appointment );
544             TransactionManager.commitTransaction( AppointmentPlugin.getPlugin( ) );
545             AppointmentListenerManager.notifyListenersAppointmentUpdated( appointment.getIdAppointment( ) );
546             if ( statusUpdated )
547             {
548                 for ( AppointmentSlot appSlot : oldAppointment.getListAppointmentSlot( ) )
549                 {
550                     SlotListenerManager.notifyListenersSlotChange( appSlot.getIdSlot( ) );
551                 }
552             }
553         }
554         catch( Exception e )
555         {
556             TransactionManager.rollBack( AppointmentPlugin.getPlugin( ) );
557             AppLogService.error( "Error update appointment " + e.getMessage( ), e );
558             throw new AppException( e.getMessage( ), e );
559         }
560 
561     }
562 
563     /**
564      * Save an appointment in database
565      * 
566      * @param appointmentDTO
567      *            the appointment dto
568      * @return the id of the appointment saved
569      * @throws Exception
570      */
571     public static int saveAppointment( AppointmentDTO appointmentDTO )
572     {
573         return SlotSafeService.saveAppointment( appointmentDTO, null );
574 
575     }
576 
577     /**
578      * Save an appointment in database
579      * 
580      * @param appointmentDTO
581      *            the appointment dto
582      * @return the id of the appointment saved
583      * @throws Exception
584      */
585     public static int saveAppointment( AppointmentDTO appointmentDTO, HttpServletRequest request )
586     {
587         return SlotSafeService.saveAppointment( appointmentDTO, request );
588 
589     }
590 
591     public static void buildListAppointmentSlot( AppointmentDTO appointmentDTO )
592     {
593 
594         List<AppointmentSlot> listApptSlot = new ArrayList<>( );
595         int nIdAppointment = appointmentDTO.getIdAppointment( );
596         int nNumberPlace = appointmentDTO.getNbBookedSeats( );
597         List<Slot> listSlot = appointmentDTO.getSlot( );
598 
599         if ( listSlot.size( ) > 1 )
600         {
601 
602             nNumberPlace = 1;
603             listSlot.sort( ( slot1, slot2 ) -> slot1.getStartingDateTime( ).compareTo( slot2.getStartingDateTime( ) ) );
604         }
605         for ( Slot slot : listSlot )
606         {
607 
608             AppointmentSlotnt/business/appointment/AppointmentSlot.html#AppointmentSlot">AppointmentSlot apptSlot = new AppointmentSlot( );
609             apptSlot.setIdAppointment( nIdAppointment );
610             apptSlot.setIdSlot( slot.getIdSlot( ) );
611 
612             apptSlot.setNbPlaces( nNumberPlace );
613             listApptSlot.add( apptSlot );
614         }
615         appointmentDTO.setListAppointmentSlot( listApptSlot );
616     }
617 
618 }