| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
package org.kuali.student.r2.core.class1.appointment.service.impl; |
| 6 | |
|
| 7 | |
import java.util.ArrayList; |
| 8 | |
import java.util.LinkedHashMap; |
| 9 | |
import java.util.List; |
| 10 | |
import java.util.Map; |
| 11 | |
import org.kuali.rice.core.api.criteria.QueryByCriteria; |
| 12 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 13 | |
import org.kuali.student.common.util.UUIDHelper; |
| 14 | |
import org.kuali.student.r2.common.dto.StatusInfo; |
| 15 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
| 16 | |
import org.kuali.student.r2.common.exceptions.DataValidationErrorException; |
| 17 | |
import org.kuali.student.r2.common.exceptions.DependentObjectsExistException; |
| 18 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
| 19 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
| 20 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
| 21 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
| 22 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
| 23 | |
import org.kuali.student.r2.common.exceptions.ReadOnlyException; |
| 24 | |
import org.kuali.student.r2.common.exceptions.VersionMismatchException; |
| 25 | |
import org.kuali.student.r2.core.appointment.dto.AppointmentInfo; |
| 26 | |
import org.kuali.student.r2.core.appointment.dto.AppointmentSlotInfo; |
| 27 | |
import org.kuali.student.r2.core.appointment.dto.AppointmentWindowInfo; |
| 28 | |
import org.kuali.student.r2.core.appointment.service.AppointmentService; |
| 29 | |
import org.kuali.student.r2.core.class1.atp.service.impl.MockHelper; |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | 0 | public class AppointmentServiceMockImpl implements AppointmentService { |
| 36 | |
|
| 37 | 0 | private Map<String, AppointmentWindowInfo> windows = new LinkedHashMap<String, AppointmentWindowInfo>(); |
| 38 | 0 | private Map<String, AppointmentSlotInfo> slots = new LinkedHashMap<String, AppointmentSlotInfo>(); |
| 39 | 0 | private Map<String, AppointmentInfo> appointments = new LinkedHashMap<String, AppointmentInfo>(); |
| 40 | |
|
| 41 | |
@Override |
| 42 | |
public AppointmentInfo createAppointment(String personId, |
| 43 | |
String appointmentSlotId, |
| 44 | |
String appointmentTypeKey, |
| 45 | |
AppointmentInfo appointmentInfo, |
| 46 | |
ContextInfo contextInfo) |
| 47 | |
throws DataValidationErrorException, DoesNotExistException, |
| 48 | |
InvalidParameterException, |
| 49 | |
MissingParameterException, OperationFailedException, |
| 50 | |
PermissionDeniedException, ReadOnlyException { |
| 51 | |
|
| 52 | 0 | if (!personId.equals(appointmentInfo.getPersonId())) { |
| 53 | 0 | throw new InvalidParameterException("personId: " + personId + " <> " + |
| 54 | |
appointmentInfo.getPersonId()); |
| 55 | |
} |
| 56 | 0 | if (!appointmentSlotId.equals(appointmentInfo.getSlotId())) { |
| 57 | 0 | throw new InvalidParameterException("slotId: " + appointmentSlotId + " <> " + |
| 58 | |
appointmentInfo.getSlotId()); |
| 59 | |
} |
| 60 | 0 | if (!appointmentTypeKey.equals(appointmentInfo.getTypeKey())) { |
| 61 | 0 | throw new InvalidParameterException("TypeKey: " + appointmentTypeKey + " <> " + |
| 62 | |
appointmentInfo.getTypeKey()); |
| 63 | |
} |
| 64 | 0 | AppointmentInfo copy = new AppointmentInfo(appointmentInfo); |
| 65 | 0 | if (copy.getId() == null) { |
| 66 | 0 | copy.setId(UUIDHelper.genStringUUID()); |
| 67 | |
} |
| 68 | 0 | copy.setMeta(new MockHelper().createMeta(contextInfo)); |
| 69 | 0 | new MockHelper().setIdOnAttributesThatDoNotHaveOne(copy.getAttributes()); |
| 70 | 0 | this.appointments.put(copy.getId(), copy); |
| 71 | 0 | return new AppointmentInfo(copy); |
| 72 | |
} |
| 73 | |
|
| 74 | |
@Override |
| 75 | |
public AppointmentSlotInfo createAppointmentSlot(String appointmentWindowId, |
| 76 | |
String appointmentSlotTypeKey, |
| 77 | |
AppointmentSlotInfo appointmentSlotInfo, |
| 78 | |
ContextInfo contextInfo) |
| 79 | |
throws DataValidationErrorException, |
| 80 | |
DoesNotExistException, InvalidParameterException, |
| 81 | |
MissingParameterException, |
| 82 | |
OperationFailedException, PermissionDeniedException, |
| 83 | |
ReadOnlyException { |
| 84 | |
|
| 85 | 0 | if (!appointmentWindowId.equals(appointmentSlotInfo.getAppointmentWindowId())) { |
| 86 | 0 | throw new InvalidParameterException("appointmentWindowId: " + |
| 87 | |
appointmentWindowId + " <> " + appointmentSlotInfo. |
| 88 | |
getAppointmentWindowId()); |
| 89 | |
} |
| 90 | 0 | if (!appointmentSlotTypeKey.equals(appointmentSlotInfo.getTypeKey())) { |
| 91 | 0 | throw new InvalidParameterException("TypeKey: " + appointmentSlotTypeKey + |
| 92 | |
" <> " + appointmentSlotInfo.getTypeKey()); |
| 93 | |
} |
| 94 | 0 | AppointmentSlotInfo copy = new AppointmentSlotInfo(appointmentSlotInfo); |
| 95 | 0 | if (copy.getId() == null) { |
| 96 | 0 | copy.setId(UUIDHelper.genStringUUID()); |
| 97 | |
} |
| 98 | 0 | copy.setMeta(new MockHelper().createMeta(contextInfo)); |
| 99 | 0 | new MockHelper().setIdOnAttributesThatDoNotHaveOne(copy.getAttributes()); |
| 100 | 0 | this.slots.put(copy.getId(), copy); |
| 101 | 0 | return new AppointmentSlotInfo(copy); |
| 102 | |
} |
| 103 | |
|
| 104 | |
@Override |
| 105 | |
public AppointmentWindowInfo createAppointmentWindow( |
| 106 | |
String appointmentWindowTypeKey, |
| 107 | |
AppointmentWindowInfo appointmentWindowInfo, |
| 108 | |
ContextInfo contextInfo) |
| 109 | |
throws DataValidationErrorException, DoesNotExistException, |
| 110 | |
InvalidParameterException, MissingParameterException, |
| 111 | |
OperationFailedException, |
| 112 | |
PermissionDeniedException, ReadOnlyException { |
| 113 | 0 | if (!appointmentWindowTypeKey.equals(appointmentWindowInfo.getTypeKey())) { |
| 114 | 0 | throw new InvalidParameterException("TypeKey: " + appointmentWindowTypeKey + |
| 115 | |
" <> " + appointmentWindowInfo.getTypeKey()); |
| 116 | |
} |
| 117 | 0 | AppointmentWindowInfo copy = new AppointmentWindowInfo(appointmentWindowInfo); |
| 118 | 0 | if (copy.getId() == null) { |
| 119 | 0 | copy.setId(UUIDHelper.genStringUUID()); |
| 120 | |
} |
| 121 | 0 | copy.setMeta(new MockHelper().createMeta(contextInfo)); |
| 122 | 0 | new MockHelper().setIdOnAttributesThatDoNotHaveOne(copy.getAttributes()); |
| 123 | 0 | this.windows.put(copy.getId(), copy); |
| 124 | 0 | return new AppointmentWindowInfo(copy); |
| 125 | |
} |
| 126 | |
|
| 127 | |
@Override |
| 128 | |
public StatusInfo deleteAppointment(String appointmentId, |
| 129 | |
ContextInfo contextInfo) throws DoesNotExistException, |
| 130 | |
InvalidParameterException, MissingParameterException, |
| 131 | |
OperationFailedException, PermissionDeniedException { |
| 132 | 0 | if (!this.appointments.containsKey(appointmentId)) { |
| 133 | 0 | throw new DoesNotExistException(appointmentId); |
| 134 | |
} |
| 135 | 0 | this.appointments.remove(appointmentId); |
| 136 | 0 | StatusInfo status = new StatusInfo(); |
| 137 | 0 | status.setSuccess(Boolean.TRUE); |
| 138 | 0 | return status; |
| 139 | |
} |
| 140 | |
|
| 141 | |
@Override |
| 142 | |
public StatusInfo deleteAppointmentSlotCascading(String appointmentSlotId, |
| 143 | |
ContextInfo contextInfo) |
| 144 | |
throws DoesNotExistException, |
| 145 | |
InvalidParameterException, |
| 146 | |
MissingParameterException, OperationFailedException, |
| 147 | |
PermissionDeniedException { |
| 148 | 0 | if (!this.slots.containsKey(appointmentSlotId)) { |
| 149 | 0 | throw new DoesNotExistException(appointmentSlotId); |
| 150 | |
} |
| 151 | |
|
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | 0 | deleteAppointmentsBySlot(appointmentSlotId, contextInfo); |
| 158 | |
|
| 159 | 0 | this.slots.remove(appointmentSlotId); |
| 160 | 0 | StatusInfo status = new StatusInfo(); |
| 161 | 0 | status.setSuccess(Boolean.TRUE); |
| 162 | 0 | return status; |
| 163 | |
} |
| 164 | |
|
| 165 | |
@Override |
| 166 | |
public StatusInfo deleteAppointmentSlotsByWindowCascading(String appointmentWindowId, |
| 167 | |
ContextInfo contextInfo) |
| 168 | |
throws DoesNotExistException, |
| 169 | |
InvalidParameterException, |
| 170 | |
MissingParameterException, OperationFailedException, |
| 171 | |
PermissionDeniedException { |
| 172 | 0 | for (AppointmentSlotInfo info : this.slots.values()) { |
| 173 | 0 | if (info.getAppointmentWindowId().equals(appointmentWindowId)) { |
| 174 | 0 | this.deleteAppointmentSlotCascading(info.getId(), contextInfo); |
| 175 | |
} |
| 176 | |
} |
| 177 | 0 | StatusInfo status = new StatusInfo(); |
| 178 | 0 | status.setSuccess(Boolean.TRUE); |
| 179 | 0 | return status; |
| 180 | |
} |
| 181 | |
|
| 182 | |
@Override |
| 183 | |
public StatusInfo deleteAppointmentWindowCascading(String appointmentWindowId, |
| 184 | |
ContextInfo contextInfo) |
| 185 | |
throws DoesNotExistException, |
| 186 | |
InvalidParameterException, |
| 187 | |
MissingParameterException, |
| 188 | |
OperationFailedException, PermissionDeniedException { |
| 189 | 0 | if (!this.windows.containsKey(appointmentWindowId)) { |
| 190 | 0 | throw new DoesNotExistException(appointmentWindowId); |
| 191 | |
} |
| 192 | |
|
| 193 | |
|
| 194 | |
|
| 195 | |
|
| 196 | |
|
| 197 | |
|
| 198 | |
|
| 199 | 0 | List<AppointmentSlotInfo> slotList = getAppointmentSlotsByWindow(appointmentWindowId, contextInfo); |
| 200 | 0 | for (AppointmentSlotInfo slot: slotList) { |
| 201 | 0 | deleteAppointmentSlotCascading(slot.getId(), contextInfo); |
| 202 | |
} |
| 203 | 0 | this.windows.remove(appointmentWindowId); |
| 204 | 0 | StatusInfo status = new StatusInfo(); |
| 205 | 0 | status.setSuccess(Boolean.TRUE); |
| 206 | 0 | return status; |
| 207 | |
} |
| 208 | |
|
| 209 | |
@Override |
| 210 | |
public StatusInfo deleteAppointmentsBySlot(String appointmentSlotId, |
| 211 | |
ContextInfo contextInfo) |
| 212 | |
throws DoesNotExistException, InvalidParameterException, |
| 213 | |
MissingParameterException, |
| 214 | |
OperationFailedException, PermissionDeniedException { |
| 215 | |
|
| 216 | 0 | this.getAppointmentSlot(appointmentSlotId, contextInfo); |
| 217 | 0 | List<AppointmentInfo> appts = new ArrayList<AppointmentInfo> (this.appointments.values()); |
| 218 | 0 | for (AppointmentInfo info : appts) { |
| 219 | 0 | if (info.getSlotId().equals(appointmentSlotId)) { |
| 220 | 0 | this.deleteAppointment(info.getId(), contextInfo); |
| 221 | |
} |
| 222 | |
} |
| 223 | 0 | StatusInfo status = new StatusInfo(); |
| 224 | 0 | status.setSuccess(Boolean.TRUE); |
| 225 | 0 | return status; |
| 226 | |
} |
| 227 | |
|
| 228 | |
@Override |
| 229 | |
public StatusInfo deleteAppointmentsByWindow(String appointmentWindowId, |
| 230 | |
ContextInfo contextInfo) |
| 231 | |
throws DoesNotExistException, InvalidParameterException, |
| 232 | |
MissingParameterException, |
| 233 | |
OperationFailedException, PermissionDeniedException { |
| 234 | |
|
| 235 | 0 | this.getAppointmentWindow(appointmentWindowId, contextInfo); |
| 236 | 0 | for (AppointmentSlotInfo info : this.getAppointmentSlotsByWindow(appointmentWindowId, contextInfo)) { |
| 237 | 0 | this.deleteAppointmentsBySlot(info.getId(), contextInfo); |
| 238 | |
} |
| 239 | 0 | StatusInfo status = new StatusInfo(); |
| 240 | 0 | status.setSuccess(Boolean.TRUE); |
| 241 | 0 | return status; |
| 242 | |
} |
| 243 | |
|
| 244 | |
@Override |
| 245 | |
public List<AppointmentSlotInfo> generateAppointmentSlotsByWindow( |
| 246 | |
String appointmentWindowId, ContextInfo contextInfo) throws |
| 247 | |
DataValidationErrorException, DoesNotExistException, |
| 248 | |
InvalidParameterException, MissingParameterException, |
| 249 | |
OperationFailedException, PermissionDeniedException, |
| 250 | |
ReadOnlyException { |
| 251 | |
|
| 252 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 253 | |
} |
| 254 | |
|
| 255 | |
@Override |
| 256 | |
public StatusInfo generateAppointmentsByWindow(String appointmentWindowId, |
| 257 | |
String appointmentTypeKey, ContextInfo contextInfo) throws |
| 258 | |
DataValidationErrorException, DoesNotExistException, |
| 259 | |
InvalidParameterException, MissingParameterException, |
| 260 | |
OperationFailedException, PermissionDeniedException, |
| 261 | |
ReadOnlyException { |
| 262 | |
|
| 263 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 264 | |
} |
| 265 | |
|
| 266 | |
@Override |
| 267 | |
public AppointmentInfo getAppointment(String appointmentId, |
| 268 | |
ContextInfo contextInfo) throws DoesNotExistException, |
| 269 | |
InvalidParameterException, MissingParameterException, |
| 270 | |
OperationFailedException, PermissionDeniedException { |
| 271 | 0 | if (!this.appointments.containsKey(appointmentId)) { |
| 272 | 0 | throw new DoesNotExistException(appointmentId); |
| 273 | |
} |
| 274 | 0 | return new AppointmentInfo(this.appointments.get(appointmentId)); |
| 275 | |
} |
| 276 | |
|
| 277 | |
@Override |
| 278 | |
public List<String> getAppointmentIdsByPerson(String personId, |
| 279 | |
ContextInfo contextInfo) throws InvalidParameterException, |
| 280 | |
MissingParameterException, OperationFailedException, |
| 281 | |
PermissionDeniedException { |
| 282 | 0 | List<String> list = new ArrayList<String>(); |
| 283 | 0 | for (AppointmentInfo info : this.appointments.values()) { |
| 284 | 0 | if (info.getPersonId().equals(personId)) { |
| 285 | 0 | list.add(info.getId()); |
| 286 | |
} |
| 287 | |
} |
| 288 | 0 | return list; |
| 289 | |
} |
| 290 | |
|
| 291 | |
@Override |
| 292 | |
public List<String> getAppointmentIdsByType(String appointmentTypeKey, |
| 293 | |
ContextInfo contextInfo) throws InvalidParameterException, |
| 294 | |
MissingParameterException, OperationFailedException, |
| 295 | |
PermissionDeniedException { |
| 296 | 0 | List<String> list = new ArrayList<String>(); |
| 297 | 0 | for (AppointmentInfo info : this.appointments.values()) { |
| 298 | 0 | if (info.getTypeKey().equals(appointmentTypeKey)) { |
| 299 | 0 | list.add(info.getId()); |
| 300 | |
} |
| 301 | |
} |
| 302 | 0 | return list; |
| 303 | |
} |
| 304 | |
|
| 305 | |
@Override |
| 306 | |
public AppointmentSlotInfo getAppointmentSlot(String appointmentSlotId, |
| 307 | |
ContextInfo contextInfo) |
| 308 | |
throws DoesNotExistException, InvalidParameterException, |
| 309 | |
MissingParameterException, |
| 310 | |
OperationFailedException, PermissionDeniedException { |
| 311 | 0 | if (!this.slots.containsKey(appointmentSlotId)) { |
| 312 | 0 | throw new DoesNotExistException(appointmentSlotId); |
| 313 | |
} |
| 314 | 0 | return new AppointmentSlotInfo(this.slots.get(appointmentSlotId)); |
| 315 | |
} |
| 316 | |
|
| 317 | |
@Override |
| 318 | |
public List<AppointmentSlotInfo> getAppointmentSlotsByIds( |
| 319 | |
List<String> appointmentSlotIds, ContextInfo contextInfo) throws |
| 320 | |
DoesNotExistException, InvalidParameterException, |
| 321 | |
MissingParameterException, OperationFailedException, |
| 322 | |
PermissionDeniedException { |
| 323 | 0 | List<AppointmentSlotInfo> list = new ArrayList<AppointmentSlotInfo>(); |
| 324 | 0 | for (String id : appointmentSlotIds) { |
| 325 | 0 | list.add(this.getAppointmentSlot(id, contextInfo)); |
| 326 | |
} |
| 327 | 0 | return list; |
| 328 | |
} |
| 329 | |
|
| 330 | |
@Override |
| 331 | |
public List<AppointmentSlotInfo> getAppointmentSlotsByPersonAndPeriod( |
| 332 | |
String personId, String periodMilestoneId, ContextInfo contextInfo) throws |
| 333 | |
InvalidParameterException, MissingParameterException, |
| 334 | |
OperationFailedException, PermissionDeniedException { |
| 335 | 0 | List<AppointmentSlotInfo> list = new ArrayList<AppointmentSlotInfo>(); |
| 336 | 0 | for (String apptId : this.getAppointmentIdsByPerson(personId, contextInfo)) { |
| 337 | |
AppointmentInfo appt; |
| 338 | |
try { |
| 339 | 0 | appt = this.getAppointment(apptId, contextInfo); |
| 340 | 0 | } catch (DoesNotExistException ex) { |
| 341 | 0 | throw new OperationFailedException("Unexpected", ex); |
| 342 | 0 | } |
| 343 | |
AppointmentSlotInfo slot; |
| 344 | |
try { |
| 345 | 0 | slot = this.getAppointmentSlot(appt.getSlotId(), contextInfo); |
| 346 | 0 | } catch (DoesNotExistException ex) { |
| 347 | 0 | throw new OperationFailedException("Unexpected", ex); |
| 348 | 0 | } |
| 349 | |
AppointmentWindowInfo wind; |
| 350 | |
try { |
| 351 | 0 | wind = this.getAppointmentWindow(slot.getAppointmentWindowId(), contextInfo); |
| 352 | 0 | } catch (DoesNotExistException ex) { |
| 353 | 0 | throw new OperationFailedException("Unexpected", ex); |
| 354 | 0 | } |
| 355 | 0 | if (wind.getPeriodMilestoneId().equals(periodMilestoneId)) { |
| 356 | 0 | list.add(slot); |
| 357 | |
} |
| 358 | 0 | } |
| 359 | 0 | return list; |
| 360 | |
} |
| 361 | |
|
| 362 | |
@Override |
| 363 | |
public List<AppointmentSlotInfo> getAppointmentSlotsByWindow( |
| 364 | |
String appointmentWindowId, ContextInfo contextInfo) throws |
| 365 | |
InvalidParameterException, MissingParameterException, |
| 366 | |
OperationFailedException, PermissionDeniedException { |
| 367 | 0 | List<AppointmentSlotInfo> list = new ArrayList<AppointmentSlotInfo>(); |
| 368 | 0 | for (AppointmentSlotInfo info : this.slots.values()) { |
| 369 | 0 | if (info.getAppointmentWindowId().equals(appointmentWindowId)) { |
| 370 | 0 | list.add(new AppointmentSlotInfo(info)); |
| 371 | |
} |
| 372 | |
} |
| 373 | 0 | return list; |
| 374 | |
} |
| 375 | |
|
| 376 | |
@Override |
| 377 | |
public AppointmentWindowInfo getAppointmentWindow(String appointmentWindowId, |
| 378 | |
ContextInfo contextInfo) |
| 379 | |
throws DoesNotExistException, InvalidParameterException, |
| 380 | |
MissingParameterException, |
| 381 | |
OperationFailedException, PermissionDeniedException { |
| 382 | 0 | if (!this.windows.containsKey(appointmentWindowId)) { |
| 383 | 0 | throw new DoesNotExistException(appointmentWindowId); |
| 384 | |
} |
| 385 | 0 | return new AppointmentWindowInfo(this.windows.get(appointmentWindowId)); |
| 386 | |
} |
| 387 | |
|
| 388 | |
@Override |
| 389 | |
public List<String> getAppointmentWindowIdsByPopulation(String populationId, |
| 390 | |
ContextInfo contextInfo) throws InvalidParameterException, |
| 391 | |
MissingParameterException, OperationFailedException, |
| 392 | |
PermissionDeniedException { |
| 393 | 0 | List<String> list = new ArrayList<String>(); |
| 394 | 0 | for (AppointmentWindowInfo info : this.windows.values()) { |
| 395 | 0 | if (info.getAssignedPopulationId().equals(populationId)) { |
| 396 | 0 | list.add(info.getId()); |
| 397 | |
} |
| 398 | |
} |
| 399 | 0 | return list; |
| 400 | |
} |
| 401 | |
|
| 402 | |
@Override |
| 403 | |
public List<String> getAppointmentWindowIdsByType( |
| 404 | |
String appointmentWindowTypeKey, ContextInfo contextInfo) throws |
| 405 | |
InvalidParameterException, MissingParameterException, |
| 406 | |
OperationFailedException, PermissionDeniedException { |
| 407 | 0 | List<String> list = new ArrayList<String>(); |
| 408 | 0 | for (AppointmentWindowInfo info : this.windows.values()) { |
| 409 | 0 | if (info.getTypeKey().equals(appointmentWindowTypeKey)) { |
| 410 | 0 | list.add(info.getId()); |
| 411 | |
} |
| 412 | |
} |
| 413 | 0 | return list; |
| 414 | |
} |
| 415 | |
|
| 416 | |
@Override |
| 417 | |
public List<AppointmentWindowInfo> getAppointmentWindowsByIds( |
| 418 | |
List<String> appointmentWindowIds, ContextInfo contextInfo) throws |
| 419 | |
DoesNotExistException, InvalidParameterException, |
| 420 | |
MissingParameterException, OperationFailedException, |
| 421 | |
PermissionDeniedException { |
| 422 | 0 | List<AppointmentWindowInfo> list = new ArrayList<AppointmentWindowInfo>(); |
| 423 | 0 | for (String id : appointmentWindowIds) { |
| 424 | 0 | list.add(this.getAppointmentWindow(id, contextInfo)); |
| 425 | |
} |
| 426 | 0 | return list; |
| 427 | |
} |
| 428 | |
|
| 429 | |
@Override |
| 430 | |
public List<AppointmentWindowInfo> getAppointmentWindowsByPeriod( |
| 431 | |
String periodMilestoneId, ContextInfo contextInfo) throws |
| 432 | |
InvalidParameterException, MissingParameterException, |
| 433 | |
OperationFailedException, PermissionDeniedException { |
| 434 | 0 | List<AppointmentWindowInfo> list = new ArrayList<AppointmentWindowInfo>(); |
| 435 | 0 | for (AppointmentWindowInfo info : this.windows.values()) { |
| 436 | 0 | list.add(new AppointmentWindowInfo(info)); |
| 437 | |
} |
| 438 | 0 | return list; |
| 439 | |
} |
| 440 | |
|
| 441 | |
@Override |
| 442 | |
public List<AppointmentInfo> getAppointmentsByIds( |
| 443 | |
List<String> appointmentIds, ContextInfo contextInfo) throws |
| 444 | |
DoesNotExistException, InvalidParameterException, |
| 445 | |
MissingParameterException, OperationFailedException, |
| 446 | |
PermissionDeniedException { |
| 447 | 0 | List<AppointmentInfo> list = new ArrayList<AppointmentInfo>(); |
| 448 | 0 | for (String id : appointmentIds) { |
| 449 | 0 | list.add(this.getAppointment(id, contextInfo)); |
| 450 | |
} |
| 451 | 0 | return list; |
| 452 | |
} |
| 453 | |
|
| 454 | |
@Override |
| 455 | |
public List<AppointmentInfo> getAppointmentsByPersonAndSlot(String personId, |
| 456 | |
String appointmentSlotId, ContextInfo contextInfo) throws |
| 457 | |
InvalidParameterException, MissingParameterException, |
| 458 | |
OperationFailedException, PermissionDeniedException { |
| 459 | 0 | List<AppointmentInfo> list = new ArrayList<AppointmentInfo>(); |
| 460 | 0 | for (AppointmentInfo info : this.getAppointmentsBySlot(appointmentSlotId, contextInfo)) { |
| 461 | 0 | if (info.getPersonId().equals(personId)) { |
| 462 | 0 | list.add(info); |
| 463 | |
} |
| 464 | |
} |
| 465 | 0 | return list; |
| 466 | |
} |
| 467 | |
|
| 468 | |
@Override |
| 469 | |
public List<AppointmentInfo> getAppointmentsBySlot(String appointmentSlotId, |
| 470 | |
ContextInfo contextInfo) throws InvalidParameterException, |
| 471 | |
MissingParameterException, OperationFailedException, |
| 472 | |
PermissionDeniedException { |
| 473 | 0 | List<AppointmentInfo> list = new ArrayList<AppointmentInfo>(); |
| 474 | 0 | for (AppointmentInfo info : this.appointments.values()) { |
| 475 | 0 | if (info.getSlotId().equals(appointmentSlotId)) { |
| 476 | 0 | list.add(new AppointmentInfo(info)); |
| 477 | |
} |
| 478 | |
} |
| 479 | 0 | return list; |
| 480 | |
} |
| 481 | |
|
| 482 | |
@Override |
| 483 | |
public List<String> searchForAppointmentIds(QueryByCriteria criteria, |
| 484 | |
ContextInfo contextInfo) throws InvalidParameterException, |
| 485 | |
MissingParameterException, OperationFailedException, |
| 486 | |
PermissionDeniedException { |
| 487 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 488 | |
} |
| 489 | |
|
| 490 | |
@Override |
| 491 | |
public List<String> searchForAppointmentSlotIds(QueryByCriteria criteria, |
| 492 | |
ContextInfo contextInfo) throws InvalidParameterException, |
| 493 | |
MissingParameterException, OperationFailedException, |
| 494 | |
PermissionDeniedException { |
| 495 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 496 | |
} |
| 497 | |
|
| 498 | |
@Override |
| 499 | |
public List<AppointmentSlotInfo> searchForAppointmentSlots( |
| 500 | |
QueryByCriteria criteria, ContextInfo contextInfo) throws |
| 501 | |
InvalidParameterException, MissingParameterException, |
| 502 | |
OperationFailedException, PermissionDeniedException { |
| 503 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 504 | |
} |
| 505 | |
|
| 506 | |
@Override |
| 507 | |
public List<String> searchForAppointmentWindowIds(QueryByCriteria criteria, |
| 508 | |
ContextInfo contextInfo) throws InvalidParameterException, |
| 509 | |
MissingParameterException, OperationFailedException, |
| 510 | |
PermissionDeniedException { |
| 511 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 512 | |
} |
| 513 | |
|
| 514 | |
@Override |
| 515 | |
public List<AppointmentWindowInfo> searchForAppointmentWindows( |
| 516 | |
QueryByCriteria criteria, ContextInfo contextInfo) throws |
| 517 | |
InvalidParameterException, MissingParameterException, |
| 518 | |
OperationFailedException, PermissionDeniedException { |
| 519 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 520 | |
} |
| 521 | |
|
| 522 | |
@Override |
| 523 | |
public List<AppointmentInfo> searchForAppointments(QueryByCriteria criteria, |
| 524 | |
ContextInfo contextInfo) throws InvalidParameterException, |
| 525 | |
MissingParameterException, OperationFailedException, |
| 526 | |
PermissionDeniedException { |
| 527 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 528 | |
} |
| 529 | |
|
| 530 | |
@Override |
| 531 | |
public AppointmentInfo updateAppointment(String appointmentId, |
| 532 | |
AppointmentInfo appointmentInfo, ContextInfo contextInfo) throws |
| 533 | |
DataValidationErrorException, DoesNotExistException, |
| 534 | |
InvalidParameterException, MissingParameterException, |
| 535 | |
OperationFailedException, PermissionDeniedException, |
| 536 | |
ReadOnlyException, VersionMismatchException { |
| 537 | 0 | if (!appointmentId.equals(appointmentInfo.getId())) { |
| 538 | 0 | throw new InvalidParameterException("appointmentSlotId: " + appointmentId + |
| 539 | |
" " + appointmentInfo.getId()); |
| 540 | |
} |
| 541 | 0 | AppointmentInfo existing = this.appointments.get(appointmentId); |
| 542 | 0 | if (existing == null) { |
| 543 | 0 | throw new DoesNotExistException(appointmentId); |
| 544 | |
} |
| 545 | 0 | if (!appointmentInfo.getMeta().getVersionInd().equals(existing.getMeta(). |
| 546 | |
getVersionInd())) { |
| 547 | 0 | throw new VersionMismatchException("Updated by " + existing.getMeta(). |
| 548 | |
getUpdateId() + " on " + existing.getMeta().getUpdateId() + |
| 549 | |
" with version of " + existing.getMeta().getVersionInd()); |
| 550 | |
} |
| 551 | 0 | AppointmentInfo info = new AppointmentInfo(appointmentInfo); |
| 552 | 0 | info.setMeta(new MockHelper().updateMeta(existing.getMeta(), contextInfo)); |
| 553 | 0 | new MockHelper().setIdOnAttributesThatDoNotHaveOne(info.getAttributes()); |
| 554 | 0 | this.appointments.put(info.getId(), info); |
| 555 | 0 | return new AppointmentInfo(info); |
| 556 | |
} |
| 557 | |
|
| 558 | |
@Override |
| 559 | |
public AppointmentSlotInfo updateAppointmentSlot(String appointmentSlotId, |
| 560 | |
AppointmentSlotInfo appointmentSlotInfo, ContextInfo contextInfo) throws |
| 561 | |
DataValidationErrorException, DoesNotExistException, |
| 562 | |
InvalidParameterException, MissingParameterException, |
| 563 | |
OperationFailedException, PermissionDeniedException, |
| 564 | |
ReadOnlyException, VersionMismatchException { |
| 565 | 0 | if (!appointmentSlotId.equals(appointmentSlotInfo.getId())) { |
| 566 | 0 | throw new InvalidParameterException("appointmentSlotId: " + appointmentSlotId + |
| 567 | |
" " + appointmentSlotInfo.getId()); |
| 568 | |
} |
| 569 | 0 | AppointmentSlotInfo existing = this.slots.get(appointmentSlotId); |
| 570 | 0 | if (existing == null) { |
| 571 | 0 | throw new DoesNotExistException(appointmentSlotId); |
| 572 | |
} |
| 573 | 0 | if (!appointmentSlotInfo.getMeta().getVersionInd().equals(existing.getMeta(). |
| 574 | |
getVersionInd())) { |
| 575 | 0 | throw new VersionMismatchException("Updated by " + existing.getMeta(). |
| 576 | |
getUpdateId() + " on " + existing.getMeta().getUpdateId() + |
| 577 | |
" with version of " + existing.getMeta().getVersionInd()); |
| 578 | |
} |
| 579 | |
|
| 580 | 0 | AppointmentSlotInfo info = new AppointmentSlotInfo(appointmentSlotInfo); |
| 581 | 0 | info.setMeta(new MockHelper().updateMeta(existing.getMeta(), contextInfo)); |
| 582 | 0 | new MockHelper().setIdOnAttributesThatDoNotHaveOne(info.getAttributes()); |
| 583 | 0 | this.slots.put(info.getId(), info); |
| 584 | 0 | return new AppointmentSlotInfo(info); |
| 585 | |
} |
| 586 | |
|
| 587 | |
@Override |
| 588 | |
public AppointmentWindowInfo updateAppointmentWindow( |
| 589 | |
String appointmentWindowId, |
| 590 | |
AppointmentWindowInfo appointmentWindowInfo, ContextInfo contextInfo) throws |
| 591 | |
DataValidationErrorException, DoesNotExistException, |
| 592 | |
InvalidParameterException, MissingParameterException, |
| 593 | |
OperationFailedException, PermissionDeniedException, |
| 594 | |
ReadOnlyException, VersionMismatchException { |
| 595 | 0 | if (!appointmentWindowId.equals(appointmentWindowInfo.getId())) { |
| 596 | 0 | throw new InvalidParameterException("appointmentWindowId: " + appointmentWindowId + |
| 597 | |
" " + appointmentWindowInfo.getId()); |
| 598 | |
} |
| 599 | 0 | AppointmentWindowInfo existing = this.windows.get(appointmentWindowId); |
| 600 | 0 | if (existing == null) { |
| 601 | 0 | throw new DoesNotExistException(appointmentWindowId); |
| 602 | |
} |
| 603 | 0 | if (!appointmentWindowInfo.getMeta().getVersionInd().equals(existing.getMeta(). |
| 604 | |
getVersionInd())) { |
| 605 | 0 | throw new VersionMismatchException("Updated by " + existing.getMeta(). |
| 606 | |
getUpdateId() + " on " + existing.getMeta().getUpdateId() + |
| 607 | |
" with version of " + existing.getMeta().getVersionInd()); |
| 608 | |
} |
| 609 | |
|
| 610 | 0 | AppointmentWindowInfo info = new AppointmentWindowInfo(appointmentWindowInfo); |
| 611 | 0 | info.setMeta(new MockHelper().updateMeta(existing.getMeta(), contextInfo)); |
| 612 | 0 | new MockHelper().setIdOnAttributesThatDoNotHaveOne(info.getAttributes()); |
| 613 | 0 | this.windows.put(info.getId(), info); |
| 614 | 0 | return new AppointmentWindowInfo(info); |
| 615 | |
} |
| 616 | |
|
| 617 | |
@Override |
| 618 | |
public List<ValidationResultInfo> validateAppointment( |
| 619 | |
String validationTypeKey, String personId, String appointmentSlotId, |
| 620 | |
String appointmentTypeKey, AppointmentInfo appointmentInfo, |
| 621 | |
ContextInfo contextInfo) throws DoesNotExistException, |
| 622 | |
InvalidParameterException, MissingParameterException, |
| 623 | |
OperationFailedException, PermissionDeniedException { |
| 624 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 625 | |
} |
| 626 | |
|
| 627 | |
@Override |
| 628 | |
public List<ValidationResultInfo> validateAppointmentSlot( |
| 629 | |
String validationTypeKey, String appointmentWindowId, |
| 630 | |
String appointmentSlotTypeKey, |
| 631 | |
AppointmentSlotInfo appointmentSlotInfo, ContextInfo contextInfo) throws |
| 632 | |
DoesNotExistException, InvalidParameterException, |
| 633 | |
MissingParameterException, OperationFailedException, |
| 634 | |
PermissionDeniedException { |
| 635 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 636 | |
} |
| 637 | |
|
| 638 | |
@Override |
| 639 | |
public List<ValidationResultInfo> validateAppointmentWindow( |
| 640 | |
String validationTypeKey, String appointmentWindowTypeKey, |
| 641 | |
AppointmentWindowInfo appointmentWindowInfo, ContextInfo contextInfo) throws |
| 642 | |
DoesNotExistException, InvalidParameterException, |
| 643 | |
MissingParameterException, OperationFailedException, |
| 644 | |
PermissionDeniedException { |
| 645 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 646 | |
} |
| 647 | |
} |