| 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 | 0 | appointmentEntity.setUpdateId(contextInfo.getPrincipalId()); |
| 210 | 0 | appointmentEntity.setUpdateTime(contextInfo.getCurrentDate()); |
| 211 | 0 | appointmentDao.merge(appointmentEntity); |
| 212 | 0 | return appointmentEntity.toDto(); |
| 213 | |
} else { |
| 214 | 0 | throw new DoesNotExistException(appointmentId); |
| 215 | |
} |
| 216 | |
} |
| 217 | |
|
| 218 | |
@Override |
| 219 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
| 220 | |
public StatusInfo deleteAppointment(String appointmentId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 221 | 0 | StatusInfo status = new StatusInfo(); |
| 222 | 0 | status.setSuccess(Boolean.TRUE); |
| 223 | |
|
| 224 | 0 | AppointmentEntity appt = appointmentDao.find(appointmentId); |
| 225 | 0 | if (null != appt) { |
| 226 | 0 | appointmentDao.remove(appt); |
| 227 | |
} else { |
| 228 | 0 | throw new DoesNotExistException(appointmentId); |
| 229 | |
} |
| 230 | |
|
| 231 | 0 | return status; |
| 232 | |
} |
| 233 | |
|
| 234 | |
@Override |
| 235 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
| 236 | |
public StatusInfo deleteAppointmentsBySlot(String appointmentSlotId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 237 | 0 | StatusInfo status = new StatusInfo(); |
| 238 | 0 | status.setSuccess(Boolean.TRUE); |
| 239 | |
|
| 240 | 0 | AppointmentSlotEntity apptSlot = appointmentSlotDao.find(appointmentSlotId); |
| 241 | 0 | if (null != apptSlot) { |
| 242 | 0 | helper.deleteAppointmentsBySlotCascading(appointmentSlotId); |
| 243 | |
} else { |
| 244 | 0 | throw new DoesNotExistException(appointmentSlotId); |
| 245 | |
} |
| 246 | |
|
| 247 | 0 | return status; |
| 248 | |
} |
| 249 | |
|
| 250 | |
@Override |
| 251 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
| 252 | |
public StatusInfo deleteAppointmentsByWindow(String appointmentWindowId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 253 | 0 | StatusInfo status = new StatusInfo(); |
| 254 | 0 | status.setSuccess(Boolean.TRUE); |
| 255 | |
|
| 256 | 0 | AppointmentWindowEntity apptWin = appointmentWindowDao.find(appointmentWindowId); |
| 257 | 0 | if (null != apptWin) { |
| 258 | 0 | helper.deleteAppointmentsByWindow(apptWin, false); |
| 259 | |
} else { |
| 260 | 0 | throw new DoesNotExistException(apptWin.getId()); |
| 261 | |
} |
| 262 | 0 | return status; |
| 263 | |
} |
| 264 | |
|
| 265 | |
@Override |
| 266 | |
@Transactional(readOnly = true) |
| 267 | |
public AppointmentWindowInfo getAppointmentWindow(String appointmentWindowId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 268 | 0 | AppointmentWindowEntity apptWin = appointmentWindowDao.find(appointmentWindowId); |
| 269 | 0 | if (null == apptWin) { |
| 270 | 0 | throw new DoesNotExistException(appointmentWindowId); |
| 271 | |
} |
| 272 | 0 | return apptWin.toDto(); |
| 273 | |
} |
| 274 | |
|
| 275 | |
@Override |
| 276 | |
@Transactional(readOnly = true) |
| 277 | |
public List<AppointmentWindowInfo> getAppointmentWindowsByIds(@WebParam(name = "appointmentWindowIds") List<String> appointmentWindowIds, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 278 | 0 | return null; |
| 279 | |
} |
| 280 | |
|
| 281 | |
@Override |
| 282 | |
@Transactional(readOnly = true) |
| 283 | |
public List<String> getAppointmentWindowIdsByType(@WebParam(name = "appointmentWindowTypeKey") String appointmentWindowTypeKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 284 | 0 | return null; |
| 285 | |
} |
| 286 | |
|
| 287 | |
@Override |
| 288 | |
@Transactional(readOnly = true) |
| 289 | |
public List<String> getAppointmentWindowIdsByPopulation(@WebParam(name = "populationId") String populationId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 290 | 0 | return null; |
| 291 | |
} |
| 292 | |
|
| 293 | |
@Override |
| 294 | |
@Transactional(readOnly = true) |
| 295 | |
public List<AppointmentWindowInfo> getAppointmentWindowsByPeriod(String periodMilestoneId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 296 | 0 | List<AppointmentWindowEntity> winEntList = appointmentWindowDao.getAppointmentWindowsByMilestoneId(periodMilestoneId); |
| 297 | 0 | List<AppointmentWindowInfo> winInfoList = new ArrayList<AppointmentWindowInfo>(); |
| 298 | 0 | for (AppointmentWindowEntity entity: winEntList) { |
| 299 | 0 | AppointmentWindowInfo winInfo = entity.toDto(); |
| 300 | 0 | winInfoList.add(winInfo); |
| 301 | 0 | } |
| 302 | 0 | return winInfoList; |
| 303 | |
} |
| 304 | |
|
| 305 | |
@Override |
| 306 | |
@Transactional(readOnly = true) |
| 307 | |
public List<String> searchForAppointmentWindowIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 308 | 0 | return null; |
| 309 | |
} |
| 310 | |
|
| 311 | |
@Override |
| 312 | |
@Transactional(readOnly = true) |
| 313 | |
public List<AppointmentWindowInfo> searchForAppointmentWindows(@WebParam(name = "criteria") QueryByCriteria criteria, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 314 | 0 | return null; |
| 315 | |
} |
| 316 | |
|
| 317 | |
@Override |
| 318 | |
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 { |
| 319 | 0 | return null; |
| 320 | |
} |
| 321 | |
|
| 322 | |
@Override |
| 323 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
| 324 | |
public AppointmentWindowInfo createAppointmentWindow(String appointmentWindowTypeKey, AppointmentWindowInfo appointmentWindowInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
| 325 | |
|
| 326 | 0 | AppointmentWindowEntity apptWin = new AppointmentWindowEntity(appointmentWindowTypeKey, appointmentWindowInfo); |
| 327 | 0 | apptWin.setCreateId(contextInfo.getPrincipalId()); |
| 328 | 0 | apptWin.setCreateTime(contextInfo.getCurrentDate()); |
| 329 | 0 | apptWin.setUpdateId(contextInfo.getPrincipalId()); |
| 330 | 0 | apptWin.setUpdateTime(contextInfo.getCurrentDate()); |
| 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 | 0 | appointmentWindowEntity.setUpdateId(contextInfo.getPrincipalId()); |
| 342 | 0 | appointmentWindowEntity.setUpdateTime(contextInfo.getCurrentDate()); |
| 343 | 0 | appointmentWindowDao.merge(appointmentWindowEntity); |
| 344 | 0 | return appointmentWindowEntity.toDto(); |
| 345 | |
} else { |
| 346 | 0 | throw new DoesNotExistException(appointmentWindowId); |
| 347 | |
} |
| 348 | |
} |
| 349 | |
|
| 350 | |
@Override |
| 351 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
| 352 | |
public StatusInfo deleteAppointmentWindowCascading(String appointmentWindowId, ContextInfo contextInfo) |
| 353 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 354 | |
OperationFailedException, PermissionDeniedException { |
| 355 | 0 | StatusInfo status = new StatusInfo(); |
| 356 | 0 | status.setSuccess(Boolean.TRUE); |
| 357 | |
|
| 358 | 0 | AppointmentWindowEntity apptWin = appointmentWindowDao.find(appointmentWindowId); |
| 359 | 0 | if (null != apptWin) { |
| 360 | 0 | helper.deleteAppointmentWindowCascading(apptWin); |
| 361 | |
} else { |
| 362 | 0 | throw new DoesNotExistException(appointmentWindowId); |
| 363 | |
} |
| 364 | |
|
| 365 | 0 | return status; |
| 366 | |
} |
| 367 | |
|
| 368 | |
@Override |
| 369 | |
@Transactional(readOnly = true) |
| 370 | |
public List<AppointmentSlotInfo> getAppointmentSlotsByPersonAndPeriod(@WebParam(name = "personId") String personId, @WebParam(name = "periodMilestoneId") String periodMilestoneId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 371 | 0 | return null; |
| 372 | |
} |
| 373 | |
|
| 374 | |
@Override |
| 375 | |
@Transactional(readOnly = true) |
| 376 | |
public List<AppointmentSlotInfo> getAppointmentSlotsByWindow(String appointmentWindowId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 377 | 0 | List<AppointmentSlotEntity> entities = appointmentSlotDao.getSlotsByWindowIdSorted(appointmentWindowId); |
| 378 | 0 | List<AppointmentSlotInfo> infoList = new ArrayList<AppointmentSlotInfo>(); |
| 379 | 0 | for (AppointmentSlotEntity entity: entities) { |
| 380 | 0 | AppointmentSlotInfo slotInfo = entity.toDto(); |
| 381 | 0 | infoList.add(slotInfo); |
| 382 | 0 | } |
| 383 | 0 | return infoList; |
| 384 | |
} |
| 385 | |
|
| 386 | |
@Override |
| 387 | |
@Transactional(readOnly = true) |
| 388 | |
public List<String> searchForAppointmentSlotIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 389 | 0 | return null; |
| 390 | |
} |
| 391 | |
|
| 392 | |
@Override |
| 393 | |
@Transactional(readOnly = true) |
| 394 | |
public List<AppointmentSlotInfo> searchForAppointmentSlots(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 395 | 0 | return null; |
| 396 | |
} |
| 397 | |
|
| 398 | |
@Override |
| 399 | |
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 { |
| 400 | 0 | return null; |
| 401 | |
} |
| 402 | |
|
| 403 | |
@Override |
| 404 | |
@Transactional(readOnly = true) |
| 405 | |
public AppointmentSlotInfo getAppointmentSlot(String appointmentSlotId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 406 | 0 | AppointmentSlotEntity apptSlot = appointmentSlotDao.find(appointmentSlotId); |
| 407 | 0 | if (null == apptSlot) { |
| 408 | 0 | throw new DoesNotExistException(appointmentSlotId); |
| 409 | |
} |
| 410 | 0 | return apptSlot.toDto(); |
| 411 | |
} |
| 412 | |
|
| 413 | |
@Override |
| 414 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
| 415 | |
public AppointmentSlotInfo createAppointmentSlot(String appointmentWindowId, String appointmentSlotTypeKey, AppointmentSlotInfo appointmentSlotInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
| 416 | 0 | AppointmentSlotEntity appointmentSlotEntity = new AppointmentSlotEntity(appointmentSlotTypeKey, appointmentSlotInfo); |
| 417 | 0 | appointmentSlotEntity.setCreateId(contextInfo.getPrincipalId()); |
| 418 | 0 | appointmentSlotEntity.setCreateTime(contextInfo.getCurrentDate()); |
| 419 | 0 | appointmentSlotEntity.setUpdateId(contextInfo.getPrincipalId()); |
| 420 | 0 | appointmentSlotEntity.setUpdateTime(contextInfo.getCurrentDate()); |
| 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 | 0 | appointmentSlotEntity.setUpdateId(contextInfo.getPrincipalId()); |
| 489 | 0 | appointmentSlotEntity.setUpdateTime(contextInfo.getCurrentDate()); |
| 490 | 0 | appointmentSlotDao.merge(appointmentSlotEntity); |
| 491 | 0 | return appointmentSlotEntity.toDto(); |
| 492 | |
} else { |
| 493 | 0 | throw new DoesNotExistException(appointmentSlotId); |
| 494 | |
} |
| 495 | |
} |
| 496 | |
|
| 497 | |
@Override |
| 498 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
| 499 | |
public StatusInfo deleteAppointmentSlotCascading(String appointmentSlotId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 500 | 0 | StatusInfo status = new StatusInfo(); |
| 501 | 0 | status.setSuccess(Boolean.TRUE); |
| 502 | |
|
| 503 | 0 | AppointmentSlotEntity apptSlot = appointmentSlotDao.find(appointmentSlotId); |
| 504 | 0 | if (null != apptSlot) { |
| 505 | 0 | helper.deleteAppointmentsBySlotCascading(apptSlot.getId()); |
| 506 | |
} else { |
| 507 | 0 | throw new DoesNotExistException(appointmentSlotId); |
| 508 | |
} |
| 509 | 0 | return status; |
| 510 | |
} |
| 511 | |
|
| 512 | |
@Override |
| 513 | |
@Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
| 514 | |
public StatusInfo deleteAppointmentSlotsByWindowCascading(@WebParam(name = "appointmentWindowId") String appointmentWindowId, @WebParam(name = "contextInfo") ContextInfo contextInfo) |
| 515 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 516 | |
OperationFailedException, PermissionDeniedException { |
| 517 | |
|
| 518 | 0 | StatusInfo status = new StatusInfo(); |
| 519 | 0 | status.setSuccess(Boolean.TRUE); |
| 520 | |
|
| 521 | 0 | AppointmentWindowEntity apptWin = appointmentWindowDao.find(appointmentWindowId); |
| 522 | 0 | if (null != apptWin) { |
| 523 | 0 | helper.deleteAppointmentSlotsByWindowCascading(apptWin); |
| 524 | |
} else { |
| 525 | 0 | throw new DoesNotExistException(appointmentWindowId); |
| 526 | |
} |
| 527 | 0 | return status; |
| 528 | |
} |
| 529 | |
|
| 530 | |
@Override |
| 531 | |
@Transactional(readOnly = true) |
| 532 | |
public List<AppointmentSlotInfo> getAppointmentSlotsByIds(List<String> appointmentSlotIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, |
| 533 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 534 | |
|
| 535 | 0 | throw new UnsupportedOperationException(); |
| 536 | |
} |
| 537 | |
} |