1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.appointment.service.listeners;
35
36 import java.util.ArrayList;
37 import java.util.List;
38 import java.util.Locale;
39
40 import org.apache.commons.lang3.StringUtils;
41
42 import fr.paris.lutece.plugins.appointment.service.AppointmentExecutorService;
43 import fr.paris.lutece.portal.service.spring.SpringContextService;
44
45
46
47
48
49
50
51 public final class AppointmentListenerManager
52 {
53
54
55
56 private AppointmentListenerManager( )
57 {
58
59 }
60
61
62
63
64
65
66
67 public static void notifyListenersAppointmentRemoval( int nIdAppointment )
68 {
69 AppointmentExecutorService.INSTANCE.execute( ( ) -> {
70 for ( IAppointmentListener appointmentRemovalListener : SpringContextService.getBeansOfType( IAppointmentListener.class ) )
71 {
72 appointmentRemovalListener.notifyAppointmentRemoval( nIdAppointment );
73 }
74 } );
75 }
76
77
78
79
80
81
82
83 public static void notifyListenersAppointmentCreated( int nIdAppointment )
84 {
85 AppointmentExecutorService.INSTANCE.execute( ( ) -> {
86
87 for ( IAppointmentListener appointmentListener : SpringContextService.getBeansOfType( IAppointmentListener.class ) )
88 {
89 appointmentListener.notifyAppointmentCreated( nIdAppointment );
90 }
91
92 } );
93
94 }
95
96
97
98
99
100
101
102 public static void notifyListenersAppointmentUpdated( int nIdAppointment )
103 {
104 AppointmentExecutorService.INSTANCE.execute( ( ) -> {
105 for ( IAppointmentListener appointmentListener : SpringContextService.getBeansOfType( IAppointmentListener.class ) )
106 {
107 appointmentListener.notifyAppointmentUpdated( nIdAppointment );
108 }
109 } );
110 }
111
112
113
114
115
116
117
118
119
120
121
122
123 public static List<String> notifyListenersAppointmentDateChanged( int nIdAppointment, List<Integer> listIdSlot, Locale locale )
124 {
125 List<String> listMessages = new ArrayList<>( );
126
127 for ( IAppointmentListener appointmentRemovalListener : SpringContextService.getBeansOfType( IAppointmentListener.class ) )
128 {
129 String strMessage = appointmentRemovalListener.appointmentDateChanged( nIdAppointment, listIdSlot, locale );
130
131 if ( StringUtils.isNotEmpty( strMessage ) )
132 {
133 listMessages.add( strMessage );
134 }
135 }
136
137 return listMessages;
138 }
139
140
141
142
143
144
145
146 public static void notifyListenersAppointmentFormRemoval( int nIdAppointmentForm )
147 {
148 AppointmentExecutorService.INSTANCE.execute( ( ) -> {
149 for ( IAppointmentFormRemovalListener appointmentRemovalListener : SpringContextService.getBeansOfType( IAppointmentFormRemovalListener.class ) )
150 {
151 appointmentRemovalListener.notifyAppointmentFormRemoval( nIdAppointmentForm );
152 }
153 } );
154 }
155
156
157
158
159
160
161
162
163
164 public static void notifyAppointmentWFActionTriggered( int nIdAppointment, int nIdAction )
165 {
166 AppointmentExecutorService.INSTANCE.execute( ( ) -> {
167 for ( IAppointmentWorkflowActionListener appointmentListener : SpringContextService.getBeansOfType( IAppointmentWorkflowActionListener.class ) )
168 {
169 appointmentListener.notifyAppointmentWFActionTriggered( nIdAppointment, nIdAction );
170 }
171 } );
172 }
173
174 }