1
2
3
4
5 package org.kuali.student.enrollment.class2.courseoffering.service.impl;
6
7 import org.kuali.rice.core.api.criteria.EqualPredicate;
8 import org.kuali.rice.core.api.criteria.QueryByCriteria;
9 import org.kuali.student.common.mock.MockService;
10 import org.kuali.student.common.util.UUIDHelper;
11 import org.kuali.student.r2.common.dto.ContextInfo;
12 import org.kuali.student.r2.common.dto.MetaInfo;
13 import org.kuali.student.r2.common.dto.StatusInfo;
14 import org.kuali.student.r2.common.dto.ValidationResultInfo;
15 import org.kuali.student.r2.common.exceptions.AlreadyExistsException;
16 import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
17 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
18 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
19 import org.kuali.student.r2.common.exceptions.MissingParameterException;
20 import org.kuali.student.r2.common.exceptions.OperationFailedException;
21 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
22 import org.kuali.student.r2.common.exceptions.ReadOnlyException;
23 import org.kuali.student.r2.common.exceptions.VersionMismatchException;
24 import org.kuali.student.r2.core.acal.dto.AcademicCalendarInfo;
25 import org.kuali.student.r2.core.acal.dto.AcalEventInfo;
26 import org.kuali.student.r2.core.acal.dto.ExamPeriodInfo;
27 import org.kuali.student.r2.core.acal.dto.HolidayCalendarInfo;
28 import org.kuali.student.r2.core.acal.dto.HolidayInfo;
29 import org.kuali.student.r2.core.acal.dto.KeyDateInfo;
30 import org.kuali.student.r2.core.acal.dto.TermInfo;
31 import org.kuali.student.r2.core.acal.service.AcademicCalendarService;
32 import org.kuali.student.r2.core.class1.state.dto.StateInfo;
33 import org.kuali.student.r2.core.class1.type.dto.TypeInfo;
34 import org.kuali.student.r2.core.constants.AtpServiceConstants;
35
36 import javax.jws.WebParam;
37 import java.util.ArrayList;
38 import java.util.Date;
39 import java.util.HashSet;
40 import java.util.LinkedHashMap;
41 import java.util.List;
42 import java.util.Map;
43 import java.util.Set;
44
45
46
47
48
49 public class AcademicCalendarServiceMockImpl implements AcademicCalendarService, MockService {
50
51
52 private Map<String, AcademicCalendarInfo> acals = new LinkedHashMap<String, AcademicCalendarInfo>();
53
54 private Map<String, TermInfo> terms = new LinkedHashMap<String, TermInfo>();
55
56 private Map<String, Set<String>> term2calSet = new LinkedHashMap<String, Set<String>>();
57
58
59 private Map<String, Set<String>> subterm2termSet = new LinkedHashMap<String, Set<String>>();
60
61 private Map<String, KeyDateInfo> keydates = new LinkedHashMap<String, KeyDateInfo>();
62
63 private Map<String, Set<String>> term2KeydateSet = new LinkedHashMap<String, Set<String>>();
64
65 private Map<String, ExamPeriodInfo> examPeriodMap = new LinkedHashMap<String, ExamPeriodInfo>();
66
67 private Map<String, Set<String>> term2examPeriodSet = new LinkedHashMap<String, Set<String>>();
68
69 @Override
70 public void clear() {
71 this.acals.clear();
72 this.terms.clear();
73 this.term2calSet.clear();
74 this.subterm2termSet.clear();
75 this.keydates.clear();
76 this.term2KeydateSet.clear();
77 this.examPeriodMap.clear();
78 this.term2examPeriodSet.clear();
79 }
80
81 @Override
82 public List<String> getKeyDateIdsForTerm(@WebParam(name = "termId") String termId, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
83 List<KeyDateInfo> keyDates = getKeyDatesForTerm(termId, contextInfo);
84 List<String> keyDateIds = new ArrayList<String>();
85 for (KeyDateInfo keyDate: keyDates) {
86 keyDateIds.add(keyDate.getId());
87 }
88 return keyDateIds;
89 }
90
91 @Override
92 public StatusInfo addTermToAcademicCalendar(String academicCalendarId, String termId, ContextInfo contextInfo) throws AlreadyExistsException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
93
94 if (!terms.containsKey(termId)) {
95 throw new DoesNotExistException("termId=" + termId + " does not exist");
96 }
97 if (!acals.containsKey(academicCalendarId)) {
98 throw new DoesNotExistException("academicCalendarId=" + academicCalendarId + " does not exist");
99 }
100 if (!term2calSet.containsKey(termId)) {
101 term2calSet.put(termId, new HashSet<String>());
102 }
103 this.term2calSet.get(termId).add(academicCalendarId);
104 return _successStatus();
105 }
106
107 @Override
108 public StatusInfo addTermToTerm(String parentTermId, String childTermId, ContextInfo contextInfo) throws AlreadyExistsException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
109
110 if (!terms.containsKey(childTermId)) {
111 throw new DoesNotExistException("childTermId=" + childTermId + " does not exist");
112 }
113 if (!terms.containsKey(parentTermId)) {
114 throw new DoesNotExistException("parentTermId=" + childTermId + " does not exist");
115 }
116 if (!this.subterm2termSet.containsKey(childTermId)) {
117 this.subterm2termSet.put(childTermId, new HashSet<String>());
118 }
119 Set<String> parentTermIds = this.subterm2termSet.get(childTermId);
120 if (parentTermIds.contains(parentTermId)) {
121 throw new AlreadyExistsException("parentTermId=" + parentTermId + " already exists");
122 }
123 parentTermIds.add(parentTermId);
124 return _successStatus();
125 }
126
127 @Override
128 public AcalEventInfo calculateAcalEvent(String acalEventId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
129 throw new UnsupportedOperationException("Not supported yet.");
130 }
131
132 @Override
133 public HolidayInfo calculateHoliday(String holidayId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
134 throw new UnsupportedOperationException("Not supported yet.");
135 }
136
137 @Override
138 public KeyDateInfo calculateKeyDate(String keyDateId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
139 throw new UnsupportedOperationException("Not supported yet.");
140 }
141
142 @Override
143 public AcademicCalendarInfo copyAcademicCalendar(String academicCalendarId, Date startDate, Date endDate, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
144 throw new UnsupportedOperationException("Not supported yet.");
145 }
146
147 @Override
148 public HolidayCalendarInfo copyHolidayCalendar(String holidayCalendarId, Date startDate, Date endDate, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
149 throw new UnsupportedOperationException("Not supported yet.");
150 }
151
152 @Override
153 public AcademicCalendarInfo createAcademicCalendar(String academicCalendarTypeKey, AcademicCalendarInfo academicCalendarInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
154 AcademicCalendarInfo copy = new AcademicCalendarInfo(academicCalendarInfo);
155 if (copy.getId() == null) {
156 copy.setId(UUIDHelper.genStringUUID());
157 }
158 this.acals.put(copy.getId(), copy);
159 return new AcademicCalendarInfo(copy);
160 }
161
162 @Override
163 public AcalEventInfo createAcalEvent(String academicCalendarId, String acalEventTypeKey, AcalEventInfo acalEventInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
164 throw new UnsupportedOperationException("Not supported yet.");
165 }
166
167 @Override
168 public HolidayInfo createHoliday(String holidayCalendarId, String holidayTypeKey, HolidayInfo holidayInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
169 throw new UnsupportedOperationException("Not supported yet.");
170 }
171
172 @Override
173 public HolidayCalendarInfo createHolidayCalendar(String holidayCalendarTypeKey, HolidayCalendarInfo holidayCalendarInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
174 throw new UnsupportedOperationException("Not supported yet.");
175 }
176
177 @Override
178 public KeyDateInfo createKeyDate(String termId, String keyDateTypeKey, KeyDateInfo keyDateInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
179 if (!terms.containsKey(termId)) {
180 throw new DoesNotExistException("termId=" + termId + "does not exist");
181 }
182 KeyDateInfo copy = new KeyDateInfo(keyDateInfo);
183 if (copy.getId() == null) {
184 copy.setId(UUIDHelper.genStringUUID());
185 }
186 keydates.put(copy.getId(), copy);
187 if (!term2KeydateSet.containsKey(termId)) {
188 term2KeydateSet.put(termId, new HashSet<String>());
189 }
190
191 term2KeydateSet.get(termId).add(copy.getId());
192 return new KeyDateInfo(copy);
193 }
194
195 @Override
196 public TermInfo createTerm(String termTypeKey, TermInfo termInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException {
197 TermInfo copy = new TermInfo(termInfo);
198 if (copy.getId() == null) {
199 copy.setId(UUIDHelper.genStringUUID());
200 }
201 terms.put(copy.getId(), copy);
202 return new TermInfo(copy);
203 }
204
205 @Override
206 public StatusInfo deleteAcademicCalendar(String academicCalendarId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
207 this.getAcademicCalendar(academicCalendarId, contextInfo);
208 acals.remove(academicCalendarId);
209 StatusInfo status = new StatusInfo();
210 status.setSuccess(Boolean.TRUE);
211 return status;
212 }
213
214 @Override
215 public StatusInfo deleteAcalEvent(String acalEventId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
216 throw new UnsupportedOperationException("Not supported yet.");
217 }
218
219 @Override
220 public StatusInfo deleteHoliday(String holidayId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
221 throw new UnsupportedOperationException("Not supported yet.");
222 }
223
224 @Override
225 public StatusInfo deleteHolidayCalendar(String holidayCalendarId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
226 throw new UnsupportedOperationException("Not supported yet.");
227 }
228
229 @Override
230 public StatusInfo deleteKeyDate(String keyDateId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
231 throw new UnsupportedOperationException("Not supported yet.");
232 }
233
234 @Override
235 public StatusInfo deleteTerm(String termId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException,
236 MissingParameterException, OperationFailedException, PermissionDeniedException {
237
238
239
240 if (!terms.containsKey(termId)) {
241 throw new DoesNotExistException("termId=" + termId + " does not exist");
242 }
243 TermInfo term = getTerm(termId, contextInfo);
244 if (term.getStateKey().equals(AtpServiceConstants.ATP_OFFICIAL_STATE_KEY)) {
245 throw new OperationFailedException("Can't delete term that is official");
246 }
247 List<TermInfo> childTerms = getIncludedTermsInTerm(termId, contextInfo);
248
249 for (TermInfo child: childTerms) {
250 subterm2termSet.get(child.getId()).remove(termId);
251 }
252
253 if (subterm2termSet.containsKey(termId)) {
254 subterm2termSet.remove(termId);
255 }
256
257 if (term2calSet.containsKey(termId)) {
258 term2calSet.remove(termId);
259 }
260
261 this.getTerm(termId, contextInfo);
262 terms.remove(termId);
263 StatusInfo status = new StatusInfo();
264 status.setSuccess(Boolean.TRUE);
265 return status;
266 }
267
268 @Override
269 public AcademicCalendarInfo getAcademicCalendar(String academicCalendarId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
270 if (!acals.containsKey(academicCalendarId)) {
271 throw new DoesNotExistException(academicCalendarId);
272 }
273 return acals.get(academicCalendarId);
274 }
275
276 @Override
277 public String getAcademicCalendarData(String academicCalendarId, String calendarDataFormatTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
278 throw new UnsupportedOperationException("Not supported yet.");
279 }
280
281 @Override
282 public List<String> getAcademicCalendarIdsByType(String academicCalendarTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
283 throw new UnsupportedOperationException("Not supported yet.");
284 }
285
286 @Override
287 public StateInfo getAcademicCalendarState(String academicCalendarStateKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
288 throw new UnsupportedOperationException("Not supported yet.");
289 }
290
291 @Override
292 public List<StateInfo> getAcademicCalendarStates(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
293 throw new UnsupportedOperationException("Not supported yet.");
294 }
295
296 @Override
297 public TypeInfo getAcademicCalendarType(String academicCalendarTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
298 throw new UnsupportedOperationException("Not supported yet.");
299 }
300
301 @Override
302 public List<TypeInfo> getAcademicCalendarTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
303 throw new UnsupportedOperationException("Not supported yet.");
304 }
305
306 @Override
307 public List<AcademicCalendarInfo> getAcademicCalendarsByIds(List<String> academicCalendarIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
308 throw new UnsupportedOperationException("Not supported yet.");
309 }
310
311 @Override
312 public List<AcademicCalendarInfo> getAcademicCalendarsByStartYear(Integer year, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
313 throw new UnsupportedOperationException("Not supported yet.");
314 }
315
316 @Override
317 public List<AcademicCalendarInfo> getAcademicCalendarsForTerm(String termId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
318
319 if (!terms.containsKey(termId)) {
320 throw new DoesNotExistException("termId=" + termId + " does not exist");
321 }
322 if (!term2calSet.containsKey(termId)) {
323
324 return new ArrayList<AcademicCalendarInfo>();
325 }
326 TermInfo termInfo = terms.get(termId);
327 Set<String> acalIds = term2calSet.get(termId);
328 List<AcademicCalendarInfo> acalInfos = new ArrayList<AcademicCalendarInfo>();
329 for (String id: acalIds) {
330 if (!acals.containsKey(id)) {
331 throw new DoesNotExistException("acalId=" + id + " does not exist");
332 }
333 AcademicCalendarInfo acalInfo = getAcademicCalendar(id, contextInfo);
334 acalInfos.add(acalInfo);
335 }
336 return acalInfos;
337 }
338
339 @Override
340 public AcalEventInfo getAcalEvent(String acalEventId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
341 throw new UnsupportedOperationException("Not supported yet.");
342 }
343
344 @Override
345 public List<String> getAcalEventIdsByType(String acalEventTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
346 throw new UnsupportedOperationException("Not supported yet.");
347 }
348
349 @Override
350 public StateInfo getAcalEventState(String acalEventStateKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
351 throw new UnsupportedOperationException("Not supported yet.");
352 }
353
354 @Override
355 public List<StateInfo> getAcalEventStates(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
356 throw new UnsupportedOperationException("Not supported yet.");
357 }
358
359 @Override
360 public TypeInfo getAcalEventType(String acalEventTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
361 throw new UnsupportedOperationException("Not supported yet.");
362 }
363
364 @Override
365 public List<TypeInfo> getAcalEventTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
366 throw new UnsupportedOperationException("Not supported yet.");
367 }
368
369 @Override
370 public List<TypeInfo> getAcalEventTypesForAcademicCalendarType(String academicCalendarTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
371 throw new UnsupportedOperationException("Not supported yet.");
372 }
373
374 @Override
375 public List<AcalEventInfo> getAcalEventsByIds(List<String> acalEventIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
376 throw new UnsupportedOperationException("Not supported yet.");
377 }
378
379 @Override
380 public List<AcalEventInfo> getAcalEventsForAcademicCalendar(String academicCalendarId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
381 throw new UnsupportedOperationException("Not supported yet.");
382 }
383
384 @Override
385 public List<AcalEventInfo> getAcalEventsForAcademicCalendarByDate(String academicCalendarId, Date startDate, Date endDate, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
386 throw new UnsupportedOperationException("Not supported yet.");
387 }
388
389 @Override
390 public List<TermInfo> getContainingTerms(String childTermId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
391
392 if (!this.terms.containsKey(childTermId)) {
393 throw new DoesNotExistException("childTermId=" + childTermId + " does not exists");
394 }
395 if (!this.subterm2termSet.containsKey(childTermId)) {
396 return new ArrayList<TermInfo>();
397 }
398 Set<String> parentTermIds = this.subterm2termSet.get(childTermId);
399 List<TermInfo> parentTermInfos = new ArrayList<TermInfo>();
400 for (String termId: parentTermIds) {
401 if (!this.terms.containsKey(termId)) {
402 throw new DoesNotExistException("parentTermId=" + termId + " does not exist");
403 }
404 parentTermInfos.add(this.terms.get(termId));
405 }
406 return parentTermInfos;
407 }
408
409 @Override
410 public List<TermInfo> getCurrentTerms(String usageKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
411 throw new UnsupportedOperationException("Not supported yet.");
412 }
413
414 @Override
415 public HolidayInfo getHoliday(String holidayId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
416 throw new UnsupportedOperationException("Not supported yet.");
417 }
418
419 @Override
420 public HolidayCalendarInfo getHolidayCalendar(String holidayCalendarId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
421 throw new UnsupportedOperationException("Not supported yet.");
422 }
423
424 @Override
425 public List<String> getHolidayCalendarIdsByType(String holidayCalendarTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
426 throw new UnsupportedOperationException("Not supported yet.");
427 }
428
429 @Override
430 public StateInfo getHolidayCalendarState(String holidayCalendarStateKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
431 throw new UnsupportedOperationException("Not supported yet.");
432 }
433
434 @Override
435 public List<StateInfo> getHolidayCalendarStates(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
436 throw new UnsupportedOperationException("Not supported yet.");
437 }
438
439 @Override
440 public TypeInfo getHolidayCalendarType(String holidayCalendarTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
441 throw new UnsupportedOperationException("Not supported yet.");
442 }
443
444 @Override
445 public List<TypeInfo> getHolidayCalendarTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
446 throw new UnsupportedOperationException("Not supported yet.");
447 }
448
449 @Override
450 public List<HolidayCalendarInfo> getHolidayCalendarsByIds(List<String> holidayCalendarIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
451 throw new UnsupportedOperationException("Not supported yet.");
452 }
453
454 @Override
455 public List<HolidayCalendarInfo> getHolidayCalendarsByStartYear(Integer year, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
456 throw new UnsupportedOperationException("Not supported yet.");
457 }
458
459 @Override
460 public List<String> getHolidayIdsByType(String holidayTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
461 throw new UnsupportedOperationException("Not supported yet.");
462 }
463
464 @Override
465 public StateInfo getHolidayState(String holidayStateKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
466 throw new UnsupportedOperationException("Not supported yet.");
467 }
468
469 @Override
470 public List<StateInfo> getHolidayStates(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
471 throw new UnsupportedOperationException("Not supported yet.");
472 }
473
474 @Override
475 public TypeInfo getHolidayType(String holidayTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
476 throw new UnsupportedOperationException("Not supported yet.");
477 }
478
479 @Override
480 public List<TypeInfo> getHolidayTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
481 throw new UnsupportedOperationException("Not supported yet.");
482 }
483
484 @Override
485 public List<TypeInfo> getHolidayTypesForHolidayCalendarType(String holidayCalendarTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
486 throw new UnsupportedOperationException("Not supported yet.");
487 }
488
489 @Override
490 public List<HolidayInfo> getHolidaysByDateForAcademicCalendar(String academicCalendarId, Date startDate, Date endDate, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
491 throw new UnsupportedOperationException("Not supported yet.");
492 }
493
494 @Override
495 public List<HolidayInfo> getHolidaysByIds(List<String> holidayIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
496 throw new UnsupportedOperationException("Not supported yet.");
497 }
498
499 @Override
500 public List<HolidayInfo> getHolidaysForHolidayCalendar(String holidayCalendarId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
501 throw new UnsupportedOperationException("Not supported yet.");
502 }
503
504 @Override
505 public List<HolidayInfo> getHolidaysForHolidayCalendarByDate(String holidayCalendarId, Date startDate, Date endDate, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
506 throw new UnsupportedOperationException("Not supported yet.");
507 }
508
509 @Override
510 public List<AcalEventInfo> getImpactedAcalEvents(String acalEventId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
511 throw new UnsupportedOperationException("Not supported yet.");
512 }
513
514 @Override
515 public List<HolidayInfo> getImpactedHolidays(String holidayId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
516 throw new UnsupportedOperationException("Not supported yet.");
517 }
518
519 @Override
520 public List<KeyDateInfo> getImpactedKeyDates(String keyDateId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
521 throw new UnsupportedOperationException("Not supported yet.");
522 }
523
524 @Override
525 public List<TermInfo> getIncludedTermsInTerm(String parentTermId, ContextInfo contextInfo)
526 throws DoesNotExistException, InvalidParameterException, MissingParameterException,
527 OperationFailedException, PermissionDeniedException {
528 Set<String> childIds = new HashSet<String>();
529 for (Map.Entry<String, Set<String>> entry: subterm2termSet.entrySet()) {
530 Set<String> parentTerms = entry.getValue();
531 String childId = entry.getKey();
532 if (parentTerms.contains(parentTermId)) {
533 childIds.add(childId);
534 }
535 }
536 List<TermInfo> result = new ArrayList<TermInfo>();
537 for (String childId: childIds) {
538 if (!terms.containsKey(childId)) {
539 throw new DoesNotExistException("termId=" + childId + "does not exist");
540 }
541 result.add(terms.get(childId));
542 }
543 return result;
544 }
545
546 @Override
547 public Integer getInstructionalDaysForTerm(String termId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
548 throw new UnsupportedOperationException("Not supported yet.");
549 }
550
551 @Override
552 public KeyDateInfo getKeyDate(String keyDateId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
553 throw new UnsupportedOperationException("Not supported yet.");
554 }
555
556 @Override
557 public List<String> getKeyDateIdsByType(String keyDateTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
558 throw new UnsupportedOperationException("Not supported yet.");
559 }
560
561 @Override
562 public List<String> getKeyDateIdsByTypeForTerm(String keyDateTypeKey, String termId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
563 throw new UnsupportedOperationException("Not supported yet.");
564 }
565
566 @Override
567 public StateInfo getKeyDateState(String keyDateStateKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
568 throw new UnsupportedOperationException("Not supported yet.");
569 }
570
571 @Override
572 public List<StateInfo> getKeyDateStates(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
573 throw new UnsupportedOperationException("Not supported yet.");
574 }
575
576 @Override
577 public TypeInfo getKeyDateType(String keyDateTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
578 throw new UnsupportedOperationException("Not supported yet.");
579 }
580
581 @Override
582 public List<TypeInfo> getKeyDateTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
583 throw new UnsupportedOperationException("Not supported yet.");
584 }
585
586 @Override
587 public List<TypeInfo> getKeyDateTypesForTermType(String termTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
588 throw new UnsupportedOperationException("Not supported yet.");
589 }
590
591 @Override
592 public List<KeyDateInfo> getKeyDatesByIds(List<String> keyDateIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
593 throw new UnsupportedOperationException("Not supported yet.");
594 }
595
596 @Override
597 public List<KeyDateInfo> getKeyDatesForTerm(String termId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
598 Set<String> keydateSet = term2KeydateSet.get(termId);
599 if (keydateSet == null) {
600 return new ArrayList<KeyDateInfo>();
601 }
602 List<KeyDateInfo> keyDateInfos = new ArrayList<KeyDateInfo>();
603 for (String keydateId: keydateSet) {
604 if (!keydates.containsKey(keydateId)) {
605 throw new DoesNotExistException("keydate=" + keydateId + "does not exist");
606 }
607 keyDateInfos.add(keydates.get(keydateId));
608 }
609 return keyDateInfos;
610 }
611
612 @Override
613 public List<KeyDateInfo> getKeyDatesForTermByDate(String termId, Date startDate, Date endDate, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
614 throw new UnsupportedOperationException("Not supported yet.");
615 }
616
617 @Override
618 public TermInfo getTerm(String termId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
619 if (!terms.containsKey(termId)) {
620 throw new DoesNotExistException(termId);
621 }
622 return new TermInfo(terms.get(termId));
623 }
624
625 @Override
626 public List<String> getTermIdsByType(String termTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
627 throw new UnsupportedOperationException("Not supported yet.");
628 }
629
630 @Override
631 public StateInfo getTermState(String termStateKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
632 throw new UnsupportedOperationException("Not supported yet.");
633 }
634
635 @Override
636 public List<StateInfo> getTermStates(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
637 throw new UnsupportedOperationException("Not supported yet.");
638 }
639
640 @Override
641 public TypeInfo getTermType(String termTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
642 throw new UnsupportedOperationException("Not supported yet.");
643 }
644
645 @Override
646 public List<TypeInfo> getTermTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
647 throw new UnsupportedOperationException("Not supported yet.");
648 }
649
650 @Override
651 public List<TypeInfo> getTermTypesForAcademicCalendarType(String academicCalendarTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
652 throw new UnsupportedOperationException("Not supported yet.");
653 }
654
655 @Override
656 public List<TypeInfo> getTermTypesForTermType(String termTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
657 throw new UnsupportedOperationException("Not supported yet.");
658 }
659
660 @Override
661 public List<TermInfo> getTermsByCode(String code, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
662 throw new UnsupportedOperationException("Not supported yet.");
663 }
664
665 @Override
666 public List<TermInfo> getTermsByIds(List<String> termIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
667 throw new UnsupportedOperationException("Not supported yet.");
668 }
669
670 @Override
671 public List<TermInfo> getTermsForAcademicCalendar(String academicCalendarId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
672 if (!acals.containsKey(academicCalendarId)) {
673 throw new OperationFailedException("acalId=" + academicCalendarId + " does not exist");
674 }
675 Set<String> resultSet = new HashSet<String>();
676 for (String termId: term2calSet.keySet()) {
677 if (term2calSet.get(termId).contains(academicCalendarId)) {
678 resultSet.add(termId);
679 }
680 }
681 List<TermInfo> termInfos = new ArrayList<TermInfo>();
682 for (String termId: resultSet) {
683 termInfos.add(terms.get(termId));
684 }
685 return termInfos;
686 }
687
688 @Override
689 public StatusInfo removeTermFromAcademicCalendar(String academicCalendarId, String termId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
690 throw new UnsupportedOperationException("Not supported yet.");
691 }
692
693 @Override
694 public StatusInfo removeTermFromTerm(String termId, String includedTermId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
695 throw new UnsupportedOperationException("Not supported yet.");
696 }
697
698 @Override
699 public List<String> searchForAcademicCalendarIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
700 throw new UnsupportedOperationException("Not supported yet.");
701 }
702
703 @Override
704 public List<AcademicCalendarInfo> searchForAcademicCalendars(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
705 throw new UnsupportedOperationException("Not supported yet.");
706 }
707
708 @Override
709 public List<String> searchForAcalEventIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
710 throw new UnsupportedOperationException("Not supported yet.");
711 }
712
713 @Override
714 public List<AcalEventInfo> searchForAcalEvents(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
715 throw new UnsupportedOperationException("Not supported yet.");
716 }
717
718 @Override
719 public List<String> searchForHolidayCalendarIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
720 throw new UnsupportedOperationException("Not supported yet.");
721 }
722
723 @Override
724 public List<HolidayCalendarInfo> searchForHolidayCalendars(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
725 throw new UnsupportedOperationException("Not supported yet.");
726 }
727
728 @Override
729 public List<String> searchForHolidayIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
730 throw new UnsupportedOperationException("Not supported yet.");
731 }
732
733 @Override
734 public List<HolidayInfo> searchForHolidays(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
735 throw new UnsupportedOperationException("Not supported yet.");
736 }
737
738 @Override
739 public List<String> searchForKeyDateIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
740 throw new UnsupportedOperationException("Not supported yet.");
741 }
742
743 @Override
744 public List<KeyDateInfo> searchForKeyDates(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
745 throw new UnsupportedOperationException("Not supported yet.");
746 }
747
748 @Override
749 public List<String> searchForTermIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
750 throw new UnsupportedOperationException("Not supported yet.");
751 }
752
753 @Override
754 public List<TermInfo> searchForTerms(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
755 List<TermInfo> list = new ArrayList<TermInfo>();
756 if(criteria.getPredicate() instanceof EqualPredicate){
757 EqualPredicate p = (EqualPredicate) criteria.getPredicate();
758 if("atpCode".equals(p.getPropertyPath())){
759 list.add(this.terms.get(p.getValue().getValue()));
760 }
761 }
762 return list;
763 }
764
765 @Override
766 public AcademicCalendarInfo updateAcademicCalendar(String academicCalendarId, AcademicCalendarInfo academicCalendarInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
767 throw new UnsupportedOperationException("Not supported yet.");
768 }
769
770 @Override
771 public StatusInfo changeAcademicCalendarState(String academicCalendarId, @WebParam(name = "nextStateKey") String nextStateKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
772
773 try {
774 AcademicCalendarInfo acal = this.acals.get(academicCalendarId);
775 if (acal == null) {
776 throw new DoesNotExistException("No academic calendar for id = " + academicCalendarId);
777 }
778 acal.setStateKey(nextStateKey);
779 return _successStatus();
780
781 } catch (Exception e) {
782 throw new OperationFailedException("changeAcademicCalendarState (id=" + academicCalendarId + ", nextStateKey=" + nextStateKey, e);
783 }
784 }
785
786 private StatusInfo _successStatus() {
787 StatusInfo status = new StatusInfo();
788 status.setSuccess(Boolean.TRUE);
789 return status;
790 }
791
792 @Override
793 public AcalEventInfo updateAcalEvent(String acalEventId, AcalEventInfo acalEventInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
794 throw new UnsupportedOperationException("Not supported yet.");
795 }
796
797 @Override
798 public StatusInfo changeAcalEventState(@WebParam(name = "acalEventId") String acalEventId, @WebParam(name = "nextStateKey") String nextStateKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
799 throw new UnsupportedOperationException("changeAcalEventState");
800 }
801
802 @Override
803 public HolidayInfo updateHoliday(String holidayId, HolidayInfo holidayInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
804 throw new UnsupportedOperationException("Not supported yet.");
805 }
806
807 @Override
808 public StatusInfo changeHolidayState(@WebParam(name = "holidayId") String holidayId, @WebParam(name = "nextStateKey") String nextStateKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
809 throw new UnsupportedOperationException("changeHolidayState");
810 }
811
812 @Override
813 public HolidayCalendarInfo updateHolidayCalendar(String holidayCalendarId, HolidayCalendarInfo holidayCalendarInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
814 throw new UnsupportedOperationException("Not supported yet.");
815 }
816
817 @Override
818 public StatusInfo changeHolidayCalendarState(@WebParam(name = "holidayCalendarId") String holidayCalendarId, @WebParam(name = "nextStateKey") String nextStateKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
819 throw new UnsupportedOperationException("changeHolidayCalendarState");
820 }
821
822 @Override
823 public KeyDateInfo updateKeyDate(String keyDateId, KeyDateInfo keyDateInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
824 throw new UnsupportedOperationException("Not supported yet.");
825 }
826
827 @Override
828 public StatusInfo changeKeyDateState(@WebParam(name = "keyDateId") String keyDateId, @WebParam(name = "nextStateKey") String nextStateKey, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
829 throw new UnsupportedOperationException("changeKeyDateState");
830 }
831
832 @Override
833 public TermInfo updateTerm(String termId, TermInfo termInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException {
834 throw new UnsupportedOperationException("Not supported yet.");
835 }
836
837 @Override
838 public StatusInfo changeTermState(String termId, String nextStateKey, ContextInfo contextInfo)
839 throws DoesNotExistException, InvalidParameterException, MissingParameterException,
840 OperationFailedException, PermissionDeniedException {
841
842 try {
843 TermInfo termInfo = this.terms.get(termId);
844 if (termInfo == null) {
845 throw new DoesNotExistException("No term for id = " + termId);
846 }
847 termInfo.setStateKey(nextStateKey);
848 return _successStatus();
849
850 } catch (Exception e) {
851 throw new OperationFailedException("changeTermState (id=" + termId + ", nextStateKey=" + nextStateKey, e);
852 }
853 }
854
855 @Override
856 public List<ValidationResultInfo> validateAcademicCalendar(String validationTypeKey, String academicCalendarTypeKey, AcademicCalendarInfo academicCalendarInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
857 throw new UnsupportedOperationException("Not supported yet.");
858 }
859
860 @Override
861 public List<ValidationResultInfo> validateAcalEvent(String validationTypeKey, String termId, String acalEventTypeKey, AcalEventInfo acalEventInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
862 throw new UnsupportedOperationException("Not supported yet.");
863 }
864
865 @Override
866 public List<ValidationResultInfo> validateHoliday(String validationTypeKey, String holidayCalendarId, String holidayTypeKey, HolidayInfo holidayInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
867 throw new UnsupportedOperationException("Not supported yet.");
868 }
869
870 @Override
871 public List<ValidationResultInfo> validateHolidayCalendar(String validationTypeKey, String holidayCalendarTypeKey, HolidayCalendarInfo holidayCalendarInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
872 throw new UnsupportedOperationException("Not supported yet.");
873 }
874
875 @Override
876 public List<ValidationResultInfo> validateKeyDate(String validationTypeKey, String termId, String keyDateTypeKey, KeyDateInfo keyDateInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
877 throw new UnsupportedOperationException("Not supported yet.");
878 }
879
880 @Override
881 public List<ValidationResultInfo> validateTerm(String validationTypeKey, String termTypeKey, TermInfo termInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
882 throw new UnsupportedOperationException("Not supported yet.");
883 }
884
885 @Override
886 public TypeInfo getExamPeriodType(String examPeriodTypeKey, ContextInfo contextInfo)
887 throws DoesNotExistException
888 ,InvalidParameterException
889 ,MissingParameterException
890 ,OperationFailedException
891 ,PermissionDeniedException
892 {
893 throw new UnsupportedOperationException("getExamPeriodType not implemented yet.");
894 }
895
896 @Override
897 public List<TypeInfo> getExamPeriodTypes(ContextInfo contextInfo)
898 throws InvalidParameterException
899 ,MissingParameterException
900 ,OperationFailedException
901 ,PermissionDeniedException
902 {
903 throw new UnsupportedOperationException("getExamPeriodTypes not implemented yet.");
904 }
905
906 @Override
907 public List<TypeInfo> getExamPeriodTypesForTermType(String termTypeKey, ContextInfo contextInfo)
908 throws DoesNotExistException
909 ,InvalidParameterException
910 ,MissingParameterException
911 ,OperationFailedException
912 ,PermissionDeniedException
913 {
914 throw new UnsupportedOperationException("getExamPeriodTypesForTermType not implemented yet.");
915 }
916
917 @Override
918 public StateInfo getExamPeriodState(String examPeriodStateKey, ContextInfo contextInfo)
919 throws DoesNotExistException
920 ,InvalidParameterException
921 ,MissingParameterException
922 ,OperationFailedException
923 ,PermissionDeniedException
924 {
925 throw new OperationFailedException ("getExamPeriodState has not been implemented");
926 }
927
928 @Override
929 public List<StateInfo> getExamPeriodStates(ContextInfo contextInfo)
930 throws InvalidParameterException
931 ,MissingParameterException
932 ,OperationFailedException
933 ,PermissionDeniedException
934 {
935 throw new OperationFailedException ("getExamPeriodStates has not been implemented");
936 }
937
938 @Override
939 public ExamPeriodInfo getExamPeriod(String examPeriodId, ContextInfo contextInfo)
940 throws DoesNotExistException
941 ,InvalidParameterException
942 ,MissingParameterException
943 ,OperationFailedException
944 ,PermissionDeniedException
945 {
946 if (!this.examPeriodMap.containsKey(examPeriodId)) {
947 throw new DoesNotExistException(examPeriodId);
948 }
949 return new ExamPeriodInfo(this.examPeriodMap.get (examPeriodId));
950 }
951
952 @Override
953 public List<ExamPeriodInfo> getExamPeriodsByIds(List<String> examPeriodIds, ContextInfo contextInfo)
954 throws DoesNotExistException
955 ,InvalidParameterException
956 ,MissingParameterException
957 ,OperationFailedException
958 ,PermissionDeniedException
959 {
960 List<ExamPeriodInfo> list = new ArrayList<ExamPeriodInfo> ();
961 for (String id: examPeriodIds) {
962 list.add (this.getExamPeriod(id, contextInfo));
963 }
964 return list;
965 }
966
967 @Override
968 public List<String> getExamPeriodIdsByType(String examPeriodTypeKey, ContextInfo contextInfo)
969 throws DoesNotExistException
970 ,InvalidParameterException
971 ,MissingParameterException
972 ,OperationFailedException
973 ,PermissionDeniedException
974 {
975 List<String> list = new ArrayList<String> ();
976 for (ExamPeriodInfo info: examPeriodMap.values ()) {
977 if (examPeriodTypeKey.equals(info.getTypeKey())) {
978 list.add (info.getId ());
979 }
980 }
981 return list;
982 }
983
984 @Override
985 public List<ExamPeriodInfo> getExamPeriodsByCode(String code, ContextInfo contextInfo)
986 throws InvalidParameterException
987 ,MissingParameterException
988 ,OperationFailedException
989 ,PermissionDeniedException
990 {
991 List<ExamPeriodInfo> list = new ArrayList<ExamPeriodInfo> ();
992 for (ExamPeriodInfo info: examPeriodMap.values ()) {
993 if (code.equals(info.getCode())) {
994 list.add (info);
995 }
996 }
997 return list;
998 }
999
1000 @Override
1001 public List<String> searchForExamPeriodIds(QueryByCriteria criteria, ContextInfo contextInfo)
1002 throws InvalidParameterException
1003 ,MissingParameterException
1004 ,OperationFailedException
1005 ,PermissionDeniedException
1006 {
1007 throw new OperationFailedException ("searchForExamPeriodIds has not been implemented");
1008 }
1009
1010 @Override
1011 public List<ExamPeriodInfo> searchForExamPeriods(QueryByCriteria criteria, ContextInfo contextInfo)
1012 throws InvalidParameterException
1013 ,MissingParameterException
1014 ,OperationFailedException
1015 ,PermissionDeniedException
1016 {
1017 throw new OperationFailedException ("searchForExamPeriods has not been implemented");
1018 }
1019
1020 @Override
1021 public List<ValidationResultInfo> validateExamPeriod(String validationTypeKey, String examPeriodTypeKey, ExamPeriodInfo examPeriodInfo, ContextInfo contextInfo)
1022 throws DoesNotExistException
1023 ,InvalidParameterException
1024 ,MissingParameterException
1025 ,OperationFailedException
1026 ,PermissionDeniedException
1027 {
1028
1029 return new ArrayList<ValidationResultInfo> ();
1030 }
1031
1032 @Override
1033 public ExamPeriodInfo createExamPeriod(String examPeriodTypeKey, ExamPeriodInfo examPeriodInfo, ContextInfo contextInfo)
1034 throws DataValidationErrorException
1035 ,DoesNotExistException
1036 ,InvalidParameterException
1037 ,MissingParameterException
1038 ,OperationFailedException
1039 ,PermissionDeniedException
1040 ,ReadOnlyException
1041 {
1042
1043 if (!examPeriodTypeKey.equals (examPeriodInfo.getTypeKey())) {
1044 throw new InvalidParameterException ("The type parameter does not match the type on the info object");
1045 }
1046 ExamPeriodInfo copy = new ExamPeriodInfo(examPeriodInfo);
1047 if (copy.getId() == null) {
1048 copy.setId(UUIDHelper.genStringUUID());
1049 }
1050 copy.setMeta(newMeta(contextInfo));
1051 examPeriodMap.put(copy.getId(), copy);
1052 return new ExamPeriodInfo(copy);
1053 }
1054
1055 @Override
1056 public ExamPeriodInfo updateExamPeriod(String examPeriodId, ExamPeriodInfo examPeriodInfo, ContextInfo contextInfo)
1057 throws DataValidationErrorException
1058 ,DoesNotExistException
1059 ,InvalidParameterException
1060 ,MissingParameterException
1061 ,OperationFailedException
1062 ,PermissionDeniedException
1063 ,ReadOnlyException
1064 ,VersionMismatchException
1065 {
1066
1067 if (!examPeriodId.equals (examPeriodInfo.getId())) {
1068 throw new InvalidParameterException ("The id parameter does not match the id on the info object");
1069 }
1070 ExamPeriodInfo copy = new ExamPeriodInfo(examPeriodInfo);
1071 ExamPeriodInfo old = this.getExamPeriod(examPeriodInfo.getId(), contextInfo);
1072 if (!old.getMeta().getVersionInd().equals(copy.getMeta().getVersionInd())) {
1073 throw new VersionMismatchException(old.getMeta().getVersionInd());
1074 }
1075 copy.setMeta(updateMeta(copy.getMeta(), contextInfo));
1076 this.examPeriodMap .put(examPeriodInfo.getId(), copy);
1077 return new ExamPeriodInfo(copy);
1078 }
1079
1080 @Override
1081 public StatusInfo changeExamPeriodState(String examPeriodId, String nextStateKey, ContextInfo contextInfo)
1082 throws DoesNotExistException
1083 ,InvalidParameterException
1084 ,MissingParameterException
1085 ,OperationFailedException
1086 ,PermissionDeniedException
1087 {
1088 try {
1089 ExamPeriodInfo examPeriodInfo = this.examPeriodMap.get(examPeriodId);
1090 if (examPeriodInfo == null) {
1091 throw new DoesNotExistException("No examperiod for id = " + examPeriodId);
1092 }
1093 examPeriodInfo.setStateKey(nextStateKey);
1094 return _successStatus();
1095
1096 } catch (Exception e) {
1097 throw new OperationFailedException("changeExamPeriodState (id=" + examPeriodId + ", nextStateKey=" + nextStateKey, e);
1098 }
1099 }
1100
1101 @Override
1102 public StatusInfo deleteExamPeriod(String examPeriodId, ContextInfo contextInfo)
1103 throws DoesNotExistException
1104 ,InvalidParameterException
1105 ,MissingParameterException
1106 ,OperationFailedException
1107 ,PermissionDeniedException
1108 {
1109 if (this.examPeriodMap.remove(examPeriodId) == null) {
1110 throw new DoesNotExistException(examPeriodId);
1111 }
1112 return newStatus();
1113 }
1114
1115 @Override
1116 public StatusInfo addExamPeriodToTerm(String termId, String examPeriodId, ContextInfo contextInfo)
1117 throws AlreadyExistsException
1118 ,DoesNotExistException
1119 ,InvalidParameterException
1120 ,MissingParameterException
1121 ,OperationFailedException
1122 ,PermissionDeniedException
1123 {
1124 if (!term2examPeriodSet.containsKey(termId)) {
1125 term2examPeriodSet.put(termId, new HashSet<String>());
1126 }
1127
1128 term2examPeriodSet.get(termId).add(examPeriodId);
1129 return newStatus();
1130 }
1131
1132 @Override
1133 public StatusInfo removeExamPeriodFromTerm(String termId, String examPeriodId, ContextInfo contextInfo)
1134 throws DoesNotExistException
1135 ,InvalidParameterException
1136 ,MissingParameterException
1137 ,OperationFailedException
1138 ,PermissionDeniedException
1139 {
1140 throw new OperationFailedException ("removeExamPeriodFromTerm has not been implemented");
1141 }
1142
1143 @Override
1144 public List<ExamPeriodInfo> getExamPeriodsForTerm(String termId, ContextInfo contextInfo)
1145 throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
1146 PermissionDeniedException {
1147
1148 List<ExamPeriodInfo> examPeriodInfos = new ArrayList<ExamPeriodInfo>();
1149
1150 Set<String> examPeriodIds = term2examPeriodSet.get(termId);
1151 if(examPeriodIds==null){
1152 return examPeriodInfos;
1153 }
1154
1155 for(String examPeriodId : examPeriodIds){
1156 examPeriodInfos.add(this.getExamPeriod(examPeriodId, contextInfo));
1157 }
1158 return examPeriodInfos;
1159 }
1160
1161 @Override
1162 public List<TermInfo> getTermsForExamPeriod(String examPeriodId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
1163 throw new OperationFailedException ("getTermsForExamPeriod has not been implemented");
1164 }
1165
1166
1167
1168
1169
1170 private StatusInfo newStatus() {
1171 StatusInfo status = new StatusInfo();
1172 status.setSuccess(Boolean.TRUE);
1173 return status;
1174 }
1175
1176 private MetaInfo newMeta(ContextInfo context) {
1177 MetaInfo meta = new MetaInfo();
1178 meta.setCreateId(context.getPrincipalId());
1179 meta.setCreateTime(new Date());
1180 meta.setUpdateId(context.getPrincipalId());
1181 meta.setUpdateTime(meta.getCreateTime());
1182 meta.setVersionInd("0");
1183 return meta;
1184 }
1185
1186 private MetaInfo updateMeta(MetaInfo old, ContextInfo context) {
1187 MetaInfo meta = new MetaInfo(old);
1188 meta.setUpdateId(context.getPrincipalId());
1189 meta.setUpdateTime(new Date());
1190 meta.setVersionInd((Integer.parseInt(meta.getVersionInd()) + 1) + "");
1191 return meta;
1192 }
1193
1194 }