1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.student.r2.core.class1.appointment.service.impl; |
18 | |
|
19 | |
import org.kuali.rice.core.api.criteria.QueryByCriteria; |
20 | |
import org.kuali.student.r2.common.dto.*; |
21 | |
import org.kuali.student.r2.common.exceptions.DataValidationErrorException; |
22 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
23 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
24 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
25 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
26 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
27 | |
import org.kuali.student.r2.common.exceptions.ReadOnlyException; |
28 | |
import org.kuali.student.r2.common.exceptions.VersionMismatchException; |
29 | |
import org.kuali.student.r2.core.appointment.constants.AppointmentServiceConstants; |
30 | |
import org.kuali.student.r2.core.appointment.dto.AppointmentInfo; |
31 | |
import org.kuali.student.r2.core.appointment.dto.AppointmentSlotInfo; |
32 | |
import org.kuali.student.r2.core.appointment.dto.AppointmentSlotRuleInfo; |
33 | |
import org.kuali.student.r2.core.appointment.dto.AppointmentWindowInfo; |
34 | |
import org.kuali.student.r2.core.appointment.service.AppointmentService; |
35 | |
import org.kuali.student.r2.core.class1.appointment.dao.AppointmentDao; |
36 | |
import org.kuali.student.r2.core.class1.appointment.dao.AppointmentSlotDao; |
37 | |
import org.kuali.student.r2.core.class1.appointment.dao.AppointmentWindowDao; |
38 | |
import org.kuali.student.r2.core.class1.appointment.model.AppointmentEntity; |
39 | |
import org.kuali.student.r2.core.class1.appointment.model.AppointmentSlotEntity; |
40 | |
import org.kuali.student.r2.core.class1.appointment.model.AppointmentWindowEntity; |
41 | |
|
42 | |
import java.util.*; |
43 | |
import javax.annotation.Resource; |
44 | |
import javax.jws.WebParam; |
45 | |
import javax.jws.WebService; |
46 | |
|
47 | |
import org.kuali.student.r2.core.population.service.PopulationService; |
48 | |
import org.springframework.transaction.annotation.Transactional; |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
@WebService(name = "AppointmentWindowService", serviceName = "AppointmentWindowService", portName = "AppointmentWindowService", targetNamespace = "http://student.kuali.org/wsdl/appointmentwindow") |
56 | 0 | public class AppointmentServiceImpl implements AppointmentService { |
57 | |
|
58 | |
@Resource |
59 | |
private AppointmentWindowDao appointmentWindowDao; |
60 | |
@Resource |
61 | |
private AppointmentSlotDao appointmentSlotDao; |
62 | |
@Resource |
63 | |
private AppointmentDao appointmentDao; |
64 | |
|
65 | |
private PopulationService populationService; |
66 | |
|
67 | 0 | private static AppointmentServiceImplHelper helper = null; |
68 | |
|
69 | |
|
70 | |
|
71 | 0 | private static int MILLIS_IN_SECOND = 1000; |
72 | 0 | private static int MILLIS_IN_MINUTE = MILLIS_IN_SECOND * 60; |
73 | 0 | private static int MINUTES_IN_HOUR = 60; |
74 | |
|
75 | |
private AppointmentServiceImplHelper _getHelper() { |
76 | 0 | if (helper == null) { |
77 | 0 | helper = new AppointmentServiceImplHelper(); |
78 | |
} |
79 | 0 | return helper; |
80 | |
} |
81 | |
|
82 | |
public PopulationService getPopulationService() { |
83 | 0 | return populationService; |
84 | |
} |
85 | |
|
86 | |
public void setPopulationService(PopulationService populationService) { |
87 | 0 | this.populationService = populationService; |
88 | 0 | _getHelper().setPopulationService(populationService); |
89 | 0 | } |
90 | |
|
91 | |
public AppointmentWindowDao getAppointmentWindowDao() { |
92 | 0 | return appointmentWindowDao; |
93 | |
} |
94 | |
|
95 | |
public void setAppointmentWindowDao(AppointmentWindowDao appointmentWindowDao) { |
96 | 0 | this.appointmentWindowDao = appointmentWindowDao; |
97 | 0 | _getHelper().setAppointmentWindowDao(appointmentWindowDao); |
98 | 0 | } |
99 | |
|
100 | |
public AppointmentSlotDao getAppointmentSlotDao() { |
101 | 0 | return appointmentSlotDao; |
102 | |
} |
103 | |
|
104 | |
public void setAppointmentSlotDao(AppointmentSlotDao appointmentSlotDao) { |
105 | 0 | this.appointmentSlotDao = appointmentSlotDao; |
106 | 0 | _getHelper().setAppointmentSlotDao(appointmentSlotDao); |
107 | 0 | } |
108 | |
|
109 | |
public AppointmentDao getAppointmentDao() { |
110 | 0 | return appointmentDao; |
111 | |
} |
112 | |
|
113 | |
public void setAppointmentDao(AppointmentDao appointmentDao) { |
114 | 0 | this.appointmentDao = appointmentDao; |
115 | 0 | _getHelper().setAppointmentDao(appointmentDao); |
116 | 0 | } |
117 | |
@Override |
118 | |
@Transactional(readOnly = true) |
119 | |
public AppointmentInfo getAppointment(@WebParam(name = "appointmentId") String appointmentId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
120 | 0 | return null; |
121 | |
} |
122 | |
|
123 | |
@Override |
124 | |
@Transactional(readOnly = true) |
125 | |
public List<AppointmentInfo> getAppointmentsByIds(@WebParam(name = "appointmentIds") List<String> appointmentIds, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
126 | 0 | return null; |
127 | |
} |
128 | |
|
129 | |
@Override |
130 | |
@Transactional(readOnly = true) |
131 | |
public List<String> getAppointmentIdsByType(@WebParam(name = "appointmentTypeKey") String appointmentTypeKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
132 | 0 | return null; |
133 | |
} |
134 | |
|
135 | |
@Override |
136 | |
@Transactional(readOnly = true) |
137 | |
public List<AppointmentInfo> getAppointmentsBySlot(String appointmentSlotId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
138 | 0 | return helper.getAppointmentsBySlotNoTransact(appointmentSlotId, contextInfo); |
139 | |
} |
140 | |
|
141 | |
@Override |
142 | |
@Transactional(readOnly = true) |
143 | |
public List<String> getAppointmentIdsByPerson(@WebParam(name = "personId") String personId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
144 | 0 | return null; |
145 | |
} |
146 | |
|
147 | |
@Override |
148 | |
@Transactional(readOnly = true) |
149 | |
public List<AppointmentInfo> getAppointmentsByPersonAndSlot(@WebParam(name = "personId") String personId, @WebParam(name = "appointmentSlotId") String appointmentSlotId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
150 | 0 | return null; |
151 | |
} |
152 | |
|
153 | |
@Override |
154 | |
@Transactional(readOnly = true) |
155 | |
public List<String> searchForAppointmentIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
156 | 0 | return null; |
157 | |
} |
158 | |
|
159 | |
@Override |
160 | |
@Transactional(readOnly = true) |
161 | |
public List<AppointmentInfo> searchForAppointments(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
162 | 0 | return null; |
163 | |
} |
164 | |
|
165 | |
@Override |
166 | |
public List<ValidationResultInfo> validateAppointment(@WebParam(name = "validationTypeKey") String validationTypeKey, @WebParam(name = "personId") String personId, @WebParam(name = "appointmentSlotId") String appointmentSlotId, @WebParam(name = "appointmentTypeKey") String appointmentTypeKey, @WebParam(name = "appointmentInfo") AppointmentInfo appointmentInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
167 | 0 | return null; |
168 | |
} |
169 | |
|
170 | |
@Override |
171 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
172 | |
public AppointmentInfo createAppointment(String personId, String appointmentSlotId, String appointmentTypeKey, AppointmentInfo appointmentInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
173 | 0 | return helper.createAppointmentNoTransact(personId, appointmentSlotId, appointmentTypeKey, appointmentInfo, contextInfo); |
174 | |
} |
175 | |
|
176 | |
@Override |
177 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
178 | |
public StatusInfo generateAppointmentsByWindow(String appointmentWindowId, String appointmentTypeKey, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
179 | 0 | StatusInfo statusInfo = null; |
180 | 0 | AppointmentWindowEntity entity = appointmentWindowDao.find(appointmentWindowId); |
181 | 0 | if (entity == null) { |
182 | 0 | throw new DoesNotExistException(appointmentWindowId); |
183 | |
} |
184 | 0 | String populationId = entity.getAssignedPopulationId(); |
185 | 0 | List<AppointmentSlotInfo> slotInfoList = getAppointmentSlotsByWindow(appointmentWindowId, contextInfo); |
186 | 0 | statusInfo = new StatusInfo(); |
187 | |
|
188 | 0 | List<String> studentIds = populationService.getMembers(populationId, contextInfo); |
189 | |
|
190 | |
|
191 | 0 | statusInfo.setSuccess(true); |
192 | |
|
193 | |
|
194 | 0 | helper.generateAppointments(appointmentWindowId, appointmentTypeKey, entity.getMaxAppointmentsPerSlot(), studentIds, slotInfoList, contextInfo, statusInfo); |
195 | |
|
196 | |
|
197 | 0 | helper.changeApptWinState(entity, AppointmentServiceConstants.APPOINTMENT_WINDOW_STATE_ASSIGNED_KEY); |
198 | |
|
199 | 0 | return statusInfo; |
200 | |
} |
201 | |
|
202 | |
|
203 | |
@Override |
204 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
205 | |
public AppointmentInfo updateAppointment(@WebParam(name = "appointmentId") String appointmentId, @WebParam(name = "appointmentInfo") AppointmentInfo appointmentInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
206 | 0 | AppointmentEntity appointmentEntity = appointmentDao.find(appointmentId); |
207 | 0 | if (null != appointmentEntity) { |
208 | 0 | appointmentEntity.fromDto(appointmentInfo); |
209 | |
|
210 | 0 | appointmentEntity.setEntityUpdated(contextInfo); |
211 | |
|
212 | 0 | appointmentDao.merge(appointmentEntity); |
213 | 0 | return appointmentEntity.toDto(); |
214 | |
} else { |
215 | 0 | throw new DoesNotExistException(appointmentId); |
216 | |
} |
217 | |
} |
218 | |
|
219 | |
@Override |
220 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
221 | |
public StatusInfo deleteAppointment(String appointmentId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
222 | 0 | StatusInfo status = new StatusInfo(); |
223 | 0 | status.setSuccess(Boolean.TRUE); |
224 | |
|
225 | 0 | AppointmentEntity appt = appointmentDao.find(appointmentId); |
226 | 0 | if (null != appt) { |
227 | 0 | appointmentDao.remove(appt); |
228 | |
} else { |
229 | 0 | throw new DoesNotExistException(appointmentId); |
230 | |
} |
231 | |
|
232 | 0 | return status; |
233 | |
} |
234 | |
|
235 | |
@Override |
236 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
237 | |
public StatusInfo deleteAppointmentsBySlot(String appointmentSlotId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
238 | 0 | StatusInfo status = new StatusInfo(); |
239 | 0 | status.setSuccess(Boolean.TRUE); |
240 | |
|
241 | 0 | AppointmentSlotEntity apptSlot = appointmentSlotDao.find(appointmentSlotId); |
242 | 0 | if (null != apptSlot) { |
243 | 0 | helper.deleteAppointmentsBySlotCascading(appointmentSlotId); |
244 | |
} else { |
245 | 0 | throw new DoesNotExistException(appointmentSlotId); |
246 | |
} |
247 | |
|
248 | 0 | return status; |
249 | |
} |
250 | |
|
251 | |
@Override |
252 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
253 | |
public StatusInfo deleteAppointmentsByWindow(String appointmentWindowId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
254 | 0 | StatusInfo status = new StatusInfo(); |
255 | 0 | status.setSuccess(Boolean.TRUE); |
256 | |
|
257 | 0 | AppointmentWindowEntity apptWin = appointmentWindowDao.find(appointmentWindowId); |
258 | 0 | if (null != apptWin) { |
259 | 0 | helper.deleteAppointmentsByWindow(apptWin, false); |
260 | |
} else { |
261 | 0 | throw new DoesNotExistException(apptWin.getId()); |
262 | |
} |
263 | 0 | return status; |
264 | |
} |
265 | |
|
266 | |
@Override |
267 | |
@Transactional(readOnly = true) |
268 | |
public AppointmentWindowInfo getAppointmentWindow(String appointmentWindowId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
269 | 0 | AppointmentWindowEntity apptWin = appointmentWindowDao.find(appointmentWindowId); |
270 | 0 | if (null == apptWin) { |
271 | 0 | throw new DoesNotExistException(appointmentWindowId); |
272 | |
} |
273 | 0 | return apptWin.toDto(); |
274 | |
} |
275 | |
|
276 | |
@Override |
277 | |
@Transactional(readOnly = true) |
278 | |
public List<AppointmentWindowInfo> getAppointmentWindowsByIds(@WebParam(name = "appointmentWindowIds") List<String> appointmentWindowIds, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
279 | 0 | return null; |
280 | |
} |
281 | |
|
282 | |
@Override |
283 | |
@Transactional(readOnly = true) |
284 | |
public List<String> getAppointmentWindowIdsByType(@WebParam(name = "appointmentWindowTypeKey") String appointmentWindowTypeKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
285 | 0 | return null; |
286 | |
} |
287 | |
|
288 | |
@Override |
289 | |
@Transactional(readOnly = true) |
290 | |
public List<String> getAppointmentWindowIdsByPopulation(@WebParam(name = "populationId") String populationId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
291 | 0 | return null; |
292 | |
} |
293 | |
|
294 | |
@Override |
295 | |
@Transactional(readOnly = true) |
296 | |
public List<AppointmentWindowInfo> getAppointmentWindowsByPeriod(String periodMilestoneId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
297 | 0 | List<AppointmentWindowEntity> winEntList = appointmentWindowDao.getAppointmentWindowsByMilestoneId(periodMilestoneId); |
298 | 0 | List<AppointmentWindowInfo> winInfoList = new ArrayList<AppointmentWindowInfo>(); |
299 | 0 | for (AppointmentWindowEntity entity: winEntList) { |
300 | 0 | AppointmentWindowInfo winInfo = entity.toDto(); |
301 | 0 | winInfoList.add(winInfo); |
302 | 0 | } |
303 | 0 | return winInfoList; |
304 | |
} |
305 | |
|
306 | |
@Override |
307 | |
@Transactional(readOnly = true) |
308 | |
public List<String> searchForAppointmentWindowIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
309 | 0 | return null; |
310 | |
} |
311 | |
|
312 | |
@Override |
313 | |
@Transactional(readOnly = true) |
314 | |
public List<AppointmentWindowInfo> searchForAppointmentWindows(@WebParam(name = "criteria") QueryByCriteria criteria, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
315 | 0 | return null; |
316 | |
} |
317 | |
|
318 | |
@Override |
319 | |
public List<ValidationResultInfo> validateAppointmentWindow(@WebParam(name = "validationTypeKey") String validationTypeKey, @WebParam(name = "appointmentWindowTypeKey") String appointmentWindowTypeKey, @WebParam(name = "appointmentWindowInfo") AppointmentWindowInfo appointmentWindowInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
320 | 0 | return null; |
321 | |
} |
322 | |
|
323 | |
@Override |
324 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
325 | |
public AppointmentWindowInfo createAppointmentWindow(String appointmentWindowTypeKey, AppointmentWindowInfo appointmentWindowInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
326 | |
|
327 | 0 | AppointmentWindowEntity apptWin = new AppointmentWindowEntity(appointmentWindowTypeKey, appointmentWindowInfo); |
328 | |
|
329 | 0 | apptWin.setEntityCreated(contextInfo); |
330 | |
|
331 | 0 | appointmentWindowDao.persist(apptWin); |
332 | 0 | return apptWin.toDto(); |
333 | |
} |
334 | |
|
335 | |
@Override |
336 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
337 | |
public AppointmentWindowInfo updateAppointmentWindow(String appointmentWindowId, AppointmentWindowInfo appointmentWindowInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
338 | 0 | AppointmentWindowEntity appointmentWindowEntity = appointmentWindowDao.find(appointmentWindowId); |
339 | 0 | if (null != appointmentWindowEntity) { |
340 | 0 | appointmentWindowEntity.fromDto(appointmentWindowInfo); |
341 | |
|
342 | 0 | appointmentWindowEntity.setEntityUpdated(contextInfo); |
343 | |
|
344 | 0 | appointmentWindowDao.merge(appointmentWindowEntity); |
345 | 0 | return appointmentWindowEntity.toDto(); |
346 | |
} else { |
347 | 0 | throw new DoesNotExistException(appointmentWindowId); |
348 | |
} |
349 | |
} |
350 | |
|
351 | |
@Override |
352 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
353 | |
public StatusInfo deleteAppointmentWindowCascading(String appointmentWindowId, ContextInfo contextInfo) |
354 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
355 | |
OperationFailedException, PermissionDeniedException { |
356 | 0 | StatusInfo status = new StatusInfo(); |
357 | 0 | status.setSuccess(Boolean.TRUE); |
358 | |
|
359 | 0 | AppointmentWindowEntity apptWin = appointmentWindowDao.find(appointmentWindowId); |
360 | 0 | if (null != apptWin) { |
361 | 0 | helper.deleteAppointmentWindowCascading(apptWin); |
362 | |
} else { |
363 | 0 | throw new DoesNotExistException(appointmentWindowId); |
364 | |
} |
365 | |
|
366 | 0 | return status; |
367 | |
} |
368 | |
|
369 | |
@Override |
370 | |
@Transactional(readOnly = true) |
371 | |
public List<AppointmentSlotInfo> getAppointmentSlotsByPersonAndPeriod(@WebParam(name = "personId") String personId, @WebParam(name = "periodMilestoneId") String periodMilestoneId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
372 | 0 | return null; |
373 | |
} |
374 | |
|
375 | |
@Override |
376 | |
@Transactional(readOnly = true) |
377 | |
public List<AppointmentSlotInfo> getAppointmentSlotsByWindow(String appointmentWindowId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
378 | 0 | List<AppointmentSlotEntity> entities = appointmentSlotDao.getSlotsByWindowIdSorted(appointmentWindowId); |
379 | 0 | List<AppointmentSlotInfo> infoList = new ArrayList<AppointmentSlotInfo>(); |
380 | 0 | for (AppointmentSlotEntity entity: entities) { |
381 | 0 | AppointmentSlotInfo slotInfo = entity.toDto(); |
382 | 0 | infoList.add(slotInfo); |
383 | 0 | } |
384 | 0 | return infoList; |
385 | |
} |
386 | |
|
387 | |
@Override |
388 | |
@Transactional(readOnly = true) |
389 | |
public List<String> searchForAppointmentSlotIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
390 | 0 | return null; |
391 | |
} |
392 | |
|
393 | |
@Override |
394 | |
@Transactional(readOnly = true) |
395 | |
public List<AppointmentSlotInfo> searchForAppointmentSlots(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
396 | 0 | return null; |
397 | |
} |
398 | |
|
399 | |
@Override |
400 | |
public List<ValidationResultInfo> validateAppointmentSlot(@WebParam(name = "validationTypeKey") String validationTypeKey, @WebParam(name = "appointmentWindowId") String appointmentWindowId, @WebParam(name = "appointmentSlotTypeKey") String appointmentSlotTypeKey, @WebParam(name = "appointmentSlotInfo") AppointmentSlotInfo appointmentSlotInfo, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
401 | 0 | return null; |
402 | |
} |
403 | |
|
404 | |
@Override |
405 | |
@Transactional(readOnly = true) |
406 | |
public AppointmentSlotInfo getAppointmentSlot(String appointmentSlotId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
407 | 0 | AppointmentSlotEntity apptSlot = appointmentSlotDao.find(appointmentSlotId); |
408 | 0 | if (null == apptSlot) { |
409 | 0 | throw new DoesNotExistException(appointmentSlotId); |
410 | |
} |
411 | 0 | return apptSlot.toDto(); |
412 | |
} |
413 | |
|
414 | |
@Override |
415 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
416 | |
public AppointmentSlotInfo createAppointmentSlot(String appointmentWindowId, String appointmentSlotTypeKey, AppointmentSlotInfo appointmentSlotInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
417 | 0 | AppointmentSlotEntity appointmentSlotEntity = new AppointmentSlotEntity(appointmentSlotTypeKey, appointmentSlotInfo); |
418 | |
|
419 | 0 | appointmentSlotEntity.setEntityCreated(contextInfo); |
420 | |
|
421 | |
|
422 | 0 | AppointmentWindowEntity windowEntity = appointmentWindowDao.find(appointmentWindowId); |
423 | 0 | if(null == windowEntity) { |
424 | 0 | throw new DoesNotExistException(appointmentWindowId); |
425 | |
} |
426 | 0 | appointmentSlotEntity.setApptWinEntity(windowEntity); |
427 | 0 | appointmentSlotDao.persist(appointmentSlotEntity); |
428 | 0 | return appointmentSlotEntity.toDto(); |
429 | |
} |
430 | |
|
431 | |
private boolean _isSupportedAppointmentWindowState(String windowType) { |
432 | 0 | return AppointmentServiceConstants.APPOINTMENT_WINDOW_TYPE_ONE_SLOT_KEY.equals(windowType) || |
433 | |
AppointmentServiceConstants.APPOINTMENT_WINDOW_TYPE_SLOTTED_UNIFORM_KEY.equals(windowType) || |
434 | |
AppointmentServiceConstants.APPOINTMENT_WINDOW_TYPE_SLOTTED_MAX_KEY.equals(windowType); |
435 | |
} |
436 | |
|
437 | |
@Override |
438 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
439 | |
public List<AppointmentSlotInfo> generateAppointmentSlotsByWindow(String appointmentWindowId, ContextInfo contextInfo) |
440 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
441 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
442 | 0 | AppointmentWindowEntity apptWin = appointmentWindowDao.find(appointmentWindowId); |
443 | 0 | if (apptWin == null) { |
444 | 0 | throw new DoesNotExistException(appointmentWindowId); |
445 | |
} |
446 | 0 | AppointmentWindowInfo apptWinInfo = apptWin.toDto(); |
447 | 0 | List<AppointmentSlotInfo> slotList = null; |
448 | |
|
449 | 0 | if (_isSupportedAppointmentWindowState(apptWinInfo.getTypeKey())) { |
450 | 0 | helper.deleteAppointmentSlotsByWindowCascading(apptWin); |
451 | |
} |
452 | |
|
453 | 0 | if (apptWin.getApptWindowType().equals(AppointmentServiceConstants.APPOINTMENT_WINDOW_TYPE_ONE_SLOT_KEY)) { |
454 | 0 | slotList = helper.createOneSlotPerWindow(apptWin, contextInfo); |
455 | 0 | } else if (apptWin.getApptWindowType().equals(AppointmentServiceConstants.APPOINTMENT_WINDOW_TYPE_SLOTTED_MAX_KEY) || |
456 | |
apptWin.getApptWindowType().equals(AppointmentServiceConstants.APPOINTMENT_WINDOW_TYPE_SLOTTED_UNIFORM_KEY)) { |
457 | 0 | AppointmentSlotRuleInfo slotRule = apptWinInfo.getSlotRule(); |
458 | 0 | if (slotRule == null) { |
459 | 0 | throw new MissingParameterException("Missing slot rule"); |
460 | 0 | } else if (slotRule.getStartTimeOfDay() == null) { |
461 | 0 | throw new MissingParameterException("Missing start time of day in slot rule"); |
462 | 0 | } else if (slotRule.getEndTimeOfDay() == null) { |
463 | 0 | throw new MissingParameterException("Missing end time of day in slot rule"); |
464 | 0 | } else if (slotRule.getStartTimeOfDay().getMilliSeconds() >= slotRule.getEndTimeOfDay().getMilliSeconds()) { |
465 | 0 | throw new InvalidParameterException("End time of day should be AFTER start time of day"); |
466 | 0 | } else if (slotRule.getStartTimeOfDay().getMilliSeconds() < 1L * MINUTES_IN_HOUR * MILLIS_IN_MINUTE) { |
467 | 0 | throw new InvalidParameterException("Start time should be 1 AM or after"); |
468 | 0 | } else if (slotRule.getEndTimeOfDay().getMilliSeconds() < 1L * MINUTES_IN_HOUR * MILLIS_IN_MINUTE) { |
469 | 0 | throw new InvalidParameterException("End time should be 1 AM or after"); |
470 | |
} |
471 | |
|
472 | 0 | Object [] result = helper.createMultiSlots(apptWinInfo, contextInfo); |
473 | 0 | slotList = (List<AppointmentSlotInfo>) result[0]; |
474 | 0 | } else { |
475 | 0 | throw new UnsupportedOperationException("Only support one slot, max, and uniform slotting"); |
476 | |
} |
477 | |
|
478 | 0 | slotList = helper.createAppointmentSlots(slotList, apptWin.getApptWindowType(), appointmentWindowId, contextInfo); |
479 | 0 | return slotList; |
480 | |
} |
481 | |
|
482 | |
@Override |
483 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
484 | |
public AppointmentSlotInfo updateAppointmentSlot(String appointmentSlotId, AppointmentSlotInfo appointmentSlotInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
485 | 0 | AppointmentSlotEntity appointmentSlotEntity = appointmentSlotDao.find(appointmentSlotId); |
486 | 0 | if (null != appointmentSlotEntity) { |
487 | 0 | appointmentSlotEntity.fromDto(appointmentSlotInfo); |
488 | |
|
489 | 0 | appointmentSlotEntity.setEntityUpdated(contextInfo); |
490 | |
|
491 | 0 | appointmentSlotDao.merge(appointmentSlotEntity); |
492 | 0 | return appointmentSlotEntity.toDto(); |
493 | |
} else { |
494 | 0 | throw new DoesNotExistException(appointmentSlotId); |
495 | |
} |
496 | |
} |
497 | |
|
498 | |
@Override |
499 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
500 | |
public StatusInfo deleteAppointmentSlotCascading(String appointmentSlotId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
501 | 0 | StatusInfo status = new StatusInfo(); |
502 | 0 | status.setSuccess(Boolean.TRUE); |
503 | |
|
504 | 0 | AppointmentSlotEntity apptSlot = appointmentSlotDao.find(appointmentSlotId); |
505 | 0 | if (null != apptSlot) { |
506 | 0 | helper.deleteAppointmentsBySlotCascading(apptSlot.getId()); |
507 | |
} else { |
508 | 0 | throw new DoesNotExistException(appointmentSlotId); |
509 | |
} |
510 | 0 | return status; |
511 | |
} |
512 | |
|
513 | |
@Override |
514 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
515 | |
public StatusInfo deleteAppointmentSlotsByWindowCascading(@WebParam(name = "appointmentWindowId") String appointmentWindowId, @WebParam(name = "contextInfo") ContextInfo contextInfo) |
516 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
517 | |
OperationFailedException, PermissionDeniedException { |
518 | |
|
519 | 0 | StatusInfo status = new StatusInfo(); |
520 | 0 | status.setSuccess(Boolean.TRUE); |
521 | |
|
522 | 0 | AppointmentWindowEntity apptWin = appointmentWindowDao.find(appointmentWindowId); |
523 | 0 | if (null != apptWin) { |
524 | 0 | helper.deleteAppointmentSlotsByWindowCascading(apptWin); |
525 | |
} else { |
526 | 0 | throw new DoesNotExistException(appointmentWindowId); |
527 | |
} |
528 | 0 | return status; |
529 | |
} |
530 | |
|
531 | |
@Override |
532 | |
@Transactional(readOnly = true) |
533 | |
public List<AppointmentSlotInfo> getAppointmentSlotsByIds(List<String> appointmentSlotIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, |
534 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
535 | |
|
536 | 0 | throw new UnsupportedOperationException(); |
537 | |
} |
538 | |
} |