1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.enrollment.class2.courseofferingset.service.impl;
18
19 import org.kuali.rice.core.api.criteria.GenericQueryResults;
20 import org.kuali.rice.core.api.criteria.QueryByCriteria;
21 import org.kuali.student.enrollment.class2.courseofferingset.dao.SocDao;
22 import org.kuali.student.enrollment.class2.courseofferingset.dao.SocRolloverResultDao;
23 import org.kuali.student.enrollment.class2.courseofferingset.dao.SocRolloverResultItemDao;
24 import org.kuali.student.enrollment.class2.courseofferingset.model.SocEntity;
25 import org.kuali.student.enrollment.class2.courseofferingset.model.SocRolloverResultAttributeEntity;
26 import org.kuali.student.enrollment.class2.courseofferingset.model.SocRolloverResultEntity;
27 import org.kuali.student.enrollment.class2.courseofferingset.model.SocRolloverResultItemEntity;
28 import org.kuali.student.enrollment.class2.courseofferingset.model.SocRolloverResultOptionEntity;
29 import org.kuali.student.enrollment.courseofferingset.dto.SocInfo;
30 import org.kuali.student.enrollment.courseofferingset.dto.SocRolloverResultInfo;
31 import org.kuali.student.enrollment.courseofferingset.dto.SocRolloverResultItemInfo;
32 import org.kuali.student.enrollment.courseofferingset.service.CourseOfferingSetService;
33 import org.kuali.student.enrollment.courseofferingset.service.CourseOfferingSetServiceBusinessLogic;
34 import org.kuali.student.r2.common.assembler.TransformUtility;
35 import org.kuali.student.r2.common.criteria.CriteriaLookupService;
36 import org.kuali.student.r2.common.dto.ContextInfo;
37 import org.kuali.student.r2.common.dto.StatusInfo;
38 import org.kuali.student.r2.common.dto.ValidationResultInfo;
39 import org.kuali.student.r2.common.exceptions.*;
40 import org.kuali.student.r2.common.util.constants.CourseOfferingSetServiceConstants;
41 import org.springframework.transaction.annotation.Transactional;
42
43 import javax.annotation.Resource;
44 import javax.jws.WebParam;
45 import java.util.ArrayList;
46 import java.util.Date;
47 import java.util.List;
48 import java.util.Set;
49
50 public class CourseOfferingSetServiceImpl implements CourseOfferingSetService {
51
52 @Resource
53 private SocDao socDao;
54 @Resource
55 private SocRolloverResultDao socRorDao;
56 @Resource
57 private SocRolloverResultItemDao socRorItemDao;
58 private CourseOfferingSetServiceBusinessLogic businessLogic;
59 private CriteriaLookupService criteriaLookupService;
60
61 public CourseOfferingSetServiceBusinessLogic getBusinessLogic() {
62 return businessLogic;
63 }
64
65 public void setBusinessLogic(CourseOfferingSetServiceBusinessLogic businessLogic) {
66 this.businessLogic = businessLogic;
67 }
68
69 public SocDao getSocDao() {
70 return socDao;
71 }
72
73 public void setSocDao(SocDao socDao) {
74 this.socDao = socDao;
75 }
76
77 public SocRolloverResultDao getSocRorDao() {
78 return socRorDao;
79 }
80
81 public void setSocRorDao(SocRolloverResultDao socRorDao) {
82 this.socRorDao = socRorDao;
83 }
84
85 public SocRolloverResultItemDao getSocRorItemDao() {
86 return socRorItemDao;
87 }
88
89 public void setSocRorItemDao(SocRolloverResultItemDao socRorItemDao) {
90 this.socRorItemDao = socRorItemDao;
91 }
92
93
94
95
96 @Override
97 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
98 public SocInfo createSoc(String termId, String typeKey, SocInfo info, ContextInfo context) throws DoesNotExistException,
99 DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException,
100 PermissionDeniedException, ReadOnlyException {
101 if (!termId.equals(info.getTermId())) {
102 throw new InvalidParameterException("termId does not match the value in the info object");
103 }
104 if (!typeKey.equals(info.getTypeKey())) {
105 throw new InvalidParameterException("typeKey does not match the value in the info object");
106 }
107 SocEntity entity = new SocEntity(info);
108 entity.setId(info.getId());
109 entity.setSocType(typeKey);
110
111 entity.setEntityCreated(context);
112
113 socDao.persist(entity);
114 return entity.toDto();
115 }
116
117 @Override
118 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
119 public SocRolloverResultInfo createSocRolloverResult(String typeKey, SocRolloverResultInfo info, ContextInfo context) throws
120 DoesNotExistException,
121 DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException,
122 PermissionDeniedException, ReadOnlyException {
123 if (!typeKey.equals(info.getTypeKey())) {
124 throw new InvalidParameterException("TypeKey does not match the value in the info object");
125 }
126 SocRolloverResultEntity entity = new SocRolloverResultEntity(info);
127 entity.setId(info.getId());
128 entity.setSocRorType(typeKey);
129
130 entity.setEntityCreated(context);
131
132 socRorDao.persist(entity);
133 return entity.toDto();
134 }
135
136 @Override
137 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
138 public SocRolloverResultItemInfo createSocRolloverResultItem(String socRorId, String typeKey, SocRolloverResultItemInfo info, ContextInfo context) throws
139 DoesNotExistException,
140 DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException,
141 PermissionDeniedException, ReadOnlyException {
142 if (!typeKey.equals(info.getTypeKey())) {
143 throw new InvalidParameterException("TypeKey does not match the value in the info object");
144 }
145 SocRolloverResultItemEntity entity = new SocRolloverResultItemEntity(info);
146 entity.setId(info.getId());
147 entity.setSocRorType(typeKey);
148
149 entity.setEntityCreated(context);
150
151 socRorItemDao.persist(entity);
152 return entity.toDto();
153 }
154
155 @Override
156 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
157 public Integer createSocRolloverResultItems(String socRorId, String typeKey, List<SocRolloverResultItemInfo> infos, ContextInfo context)
158 throws DoesNotExistException,
159 DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException,
160 PermissionDeniedException, ReadOnlyException {
161 int count = 0;
162 for (SocRolloverResultItemInfo info : infos) {
163 count++;
164 if (!typeKey.equals(info.getTypeKey())) {
165 throw new InvalidParameterException("TypeKey does not match the value in the info object " + count);
166 }
167 if (!socRorId.equals(info.getSocRolloverResultId())) {
168 throw new InvalidParameterException("rollover result id does not match the value in the info object " + count);
169 }
170 SocRolloverResultItemEntity entity = new SocRolloverResultItemEntity(info);
171 entity.setId(info.getId());
172 entity.setSocRorType(typeKey);
173
174 entity.setEntityCreated(context);
175
176 socRorItemDao.persist(entity);
177 }
178 return new Integer(count);
179 }
180
181 @Override
182 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
183 public Integer deleteCourseOfferingsBySoc(String socId, ContextInfo context) throws DoesNotExistException,
184 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
185 return this.businessLogic.deleteCourseOfferingsBySoc(socId, context);
186 }
187
188 @Override
189 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
190 public StatusInfo deleteSoc(String id, ContextInfo context) throws DependentObjectsExistException, DoesNotExistException,
191 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
192 SocEntity entity = socDao.find(id);
193 if (null == entity) {
194 throw new DoesNotExistException(id);
195 }
196 socDao.remove(entity);
197 StatusInfo status = new StatusInfo();
198 status.setSuccess(Boolean.TRUE);
199 return status;
200 }
201
202 @Override
203 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
204 public StatusInfo deleteSocRolloverResult(String id, ContextInfo context) throws DoesNotExistException,
205 DependentObjectsExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
206 PermissionDeniedException {
207 SocRolloverResultEntity entity = socRorDao.find(id);
208 if (null == entity) {
209 throw new DoesNotExistException(id);
210 }
211 List<SocRolloverResultItemInfo> items = this.getSocRolloverResultItemsByResultId(id, context);
212 if (!items.isEmpty()) {
213 throw new DependentObjectsExistException(items.size() + " items exist");
214 }
215 socRorDao.remove(entity);
216 StatusInfo status = new StatusInfo();
217 status.setSuccess(Boolean.TRUE);
218 return status;
219 }
220
221 @Override
222 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
223 public StatusInfo deleteSocRolloverResultItem(String id, ContextInfo context) throws
224 DoesNotExistException,
225 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
226 SocRolloverResultItemEntity entity = socRorItemDao.find(id);
227 if (null == entity) {
228 throw new DoesNotExistException(id);
229 }
230 socRorItemDao.remove(entity);
231 StatusInfo status = new StatusInfo();
232 status.setSuccess(Boolean.TRUE);
233 return status;
234 }
235
236 @Override
237 @Transactional(readOnly = true)
238 public List<String> getCourseOfferingIdsBySoc(String socId, ContextInfo context) throws DoesNotExistException,
239 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
240 return this.businessLogic.getCourseOfferingIdsBySoc(socId, context);
241 }
242
243 @Override
244 @Transactional(readOnly = true)
245 public List<String> getCourseOfferingIdsWithUnscheduledFinalExamsBySoc(String socId, ContextInfo context) throws
246 DoesNotExistException,
247 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
248 throw new OperationFailedException("Configuration error Implemented in the calculuation layer");
249 }
250
251 @Override
252 @Transactional(readOnly = true)
253 public List<String> getPublishedCourseOfferingIdsBySoc(String socId, ContextInfo context) throws DoesNotExistException,
254 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
255 return this.businessLogic.getPublishedCourseOfferingIdsBySoc(socId, context);
256 }
257
258 @Override
259 @Transactional(readOnly = true)
260 public SocInfo getSoc(String id, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
261 MissingParameterException, OperationFailedException, PermissionDeniedException {
262 SocEntity entity = socDao.find(id);
263 if (null == entity) {
264 throw new DoesNotExistException(id);
265 }
266 return entity.toDto();
267 }
268
269 @Override
270 @Transactional(readOnly = true)
271 public List<String> getSocIdsByCourseOffering(String courseOfferingId, ContextInfo context) throws DoesNotExistException,
272 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
273 throw new OperationFailedException("Configuration error Implemented in the calculuation layer");
274 }
275
276 @Override
277 @Transactional(readOnly = true)
278 public List<String> getSocIdsByTerm(String termId, ContextInfo context) throws DoesNotExistException,
279 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
280 List<SocEntity> entities = socDao.getByTerm(termId);
281 List<String> list = new ArrayList<String>(entities.size());
282 for (SocEntity entity : entities) {
283 list.add(entity.getId());
284 }
285 return list;
286 }
287
288 @Override
289 @Transactional(readOnly = true)
290 public List<String> getSocIdsByTermAndSubjectArea(String termId, String subjectArea, ContextInfo context) throws
291 DoesNotExistException,
292 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
293 List<SocEntity> entities = socDao.getByTermAndSubjectArea(termId, subjectArea);
294 List<String> list = new ArrayList<String>(entities.size());
295 for (SocEntity entity : entities) {
296 list.add(entity.getId());
297 }
298 return list;
299 }
300
301 @Override
302 @Transactional(readOnly = true)
303 public List<String> getSocIdsByTermAndUnitsContentOwner(String termId, String unitsContentOwnerId, ContextInfo context) throws
304 DoesNotExistException,
305 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
306 List<SocEntity> entities = socDao.getByTermAndUnitsContentOwner(termId, unitsContentOwnerId);
307 List<String> list = new ArrayList<String>(entities.size());
308 for (SocEntity entity : entities) {
309 list.add(entity.getId());
310 }
311 return list;
312 }
313
314 @Override
315 @Transactional(readOnly = true)
316 public List<String> getSocIdsByType(String typeKey, ContextInfo context) throws DoesNotExistException,
317 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
318 List<SocEntity> entities = socDao.getBySocTypeId(typeKey);
319 List<String> list = new ArrayList<String>(entities.size());
320 for (SocEntity entity : entities) {
321 list.add(entity.getId());
322 }
323 return list;
324 }
325
326 @Override
327 @Transactional(readOnly = true)
328 public SocRolloverResultInfo getSocRolloverResult(String id, ContextInfo context) throws DoesNotExistException,
329 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
330 SocRolloverResultEntity entity = socRorDao.find(id);
331 if (null == entity) {
332 throw new DoesNotExistException(id);
333 }
334 SocRolloverResultInfo info = entity.toDto();
335 this.updateCalculatedFields(info, context);
336 return info;
337 }
338
339
340
341 private void updateCalculatedFields(SocRolloverResultInfo info, ContextInfo context) throws OperationFailedException {
342 try {
343 if (info.getSourceSocId() != null) {
344 SocInfo sourceSoc = this.getSoc(info.getSourceSocId(), context);
345 info.setSourceTermId(sourceSoc.getTermId());
346 }
347
348 if (info.getStateKey().equals(CourseOfferingSetServiceConstants.FINISHED_RESULT_STATE_KEY)) {
349 List<SocRolloverResultItemInfo> items = this.getSocRolloverResultItemsByResultId(info.getId(), context);
350 int success = 0;
351 int failure = 0;
352 for (SocRolloverResultItemInfo item : items) {
353 if (CourseOfferingSetServiceConstants.SUCCESSFUL_RESULT_ITEM_STATES.contains(item.getStateKey())) {
354 success++;
355 } else {
356 failure++;
357 }
358 }
359 info.setCourseOfferingsCreated(success);
360 info.setCourseOfferingsSkipped(failure);
361 }
362 } catch (Exception ex) {
363 throw new OperationFailedException("unexpected", ex);
364 }
365 }
366
367 @Override
368 public List<SocRolloverResultInfo> getSocRolloverResultsBySourceAndTargetSocs(String sourceSocId, String targetSocId, ContextInfo context) throws
369 DoesNotExistException,
370 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
371
372 List<SocRolloverResultInfo> list = new ArrayList<SocRolloverResultInfo>();
373 List<String> ids = this.getSocRolloverResultIdsBySourceSoc(sourceSocId, context);
374 for (String id : ids) {
375 SocRolloverResultInfo info = this.getSocRolloverResult(id, context);
376 if (targetSocId.equals(info.getTargetSocId())) {
377 list.add(info);
378 }
379 }
380 return list;
381 }
382
383 @Override
384 @Transactional(readOnly = true)
385 public List<String> getSocRolloverResultIdsBySourceSoc(String sourceSocId, ContextInfo context) throws DoesNotExistException,
386 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
387 List<SocRolloverResultEntity> entities = socRorDao.getBySourceSocId(sourceSocId);
388 List<String> list = new ArrayList<String>(entities.size());
389 for (SocRolloverResultEntity entity : entities) {
390 list.add(entity.getId());
391 }
392 return list;
393 }
394
395 @Override
396 @Transactional(readOnly = true)
397 public List<String> getSocRolloverResultIdsByTargetSoc(String targetSocId, ContextInfo context) throws DoesNotExistException,
398 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
399 List<SocRolloverResultEntity> entities = socRorDao.getByTargetSocId(targetSocId);
400 List<String> list = new ArrayList<String>(entities.size());
401 for (SocRolloverResultEntity entity : entities) {
402 list.add(entity.getId());
403 }
404 return list;
405 }
406
407 @Override
408 @Transactional(readOnly = true)
409 public SocRolloverResultItemInfo getSocRolloverResultItem(String id, ContextInfo context) throws
410 DoesNotExistException,
411 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
412 SocRolloverResultItemEntity entity = socRorItemDao.find(id);
413 if (null == entity) {
414 throw new DoesNotExistException(id);
415 }
416 return entity.toDto();
417 }
418
419 @Override
420 @Transactional(readOnly = true)
421 public List<SocRolloverResultItemInfo> getSocRolloverResultItemsByResultId(String socRolloverResultId, ContextInfo context) throws
422 DoesNotExistException,
423 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
424 List<SocRolloverResultItemEntity> entities = socRorItemDao.getBySocRolloverResultId(socRolloverResultId);
425 List<SocRolloverResultItemInfo> list = new ArrayList<SocRolloverResultItemInfo>(entities.size());
426 for (SocRolloverResultItemEntity entity : entities) {
427 list.add(entity.toDto());
428 }
429 return list;
430 }
431
432 @Override
433 @Transactional(readOnly = true)
434 public List<SocRolloverResultItemInfo> getSocRolloverResultItemsByResultIdAndSourceCourseOfferingId(String socRolloverResultId, String sourceCourseOfferingId, ContextInfo context) throws
435 DoesNotExistException,
436 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
437 List<SocRolloverResultItemEntity> entities = socRorItemDao.getBySocRolloverResultIdAndSourceCourseOfferingId(
438 socRolloverResultId, sourceCourseOfferingId);
439 List<SocRolloverResultItemInfo> list = new ArrayList<SocRolloverResultItemInfo>(entities.size());
440 for (SocRolloverResultItemEntity entity : entities) {
441 list.add(entity.toDto());
442 }
443 return list;
444 }
445
446 @Override
447 @Transactional(readOnly = true)
448 public List<SocRolloverResultItemInfo> getSocRolloverResultItemsByResultIdAndTargetCourseOfferingId(String socRolloverResultId, String targetCourseOfferingId, ContextInfo context) throws
449 DoesNotExistException,
450 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
451 List<SocRolloverResultItemEntity> entities = socRorItemDao.getBySocRolloverResultIdAndTargetCourseOfferingId(
452 socRolloverResultId, targetCourseOfferingId);
453 List<SocRolloverResultItemInfo> list = new ArrayList<SocRolloverResultItemInfo>(entities.size());
454 for (SocRolloverResultItemEntity entity : entities) {
455 list.add(entity.toDto());
456 }
457 return list;
458 }
459
460 @Override
461 @Transactional(readOnly = true)
462 public List<SocRolloverResultInfo> getSocRolloverResultsByIds(List<String> ids, ContextInfo context) throws
463 DoesNotExistException,
464 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
465 List<SocRolloverResultEntity> entities = socRorDao.findByIds(ids);
466 List<SocRolloverResultInfo> list = new ArrayList<SocRolloverResultInfo>(entities.size());
467 for (SocRolloverResultEntity entity : entities) {
468 if (entity == null) {
469
470
471 throw new DoesNotExistException(ids.get(list.size()));
472 }
473 list.add(entity.toDto());
474 }
475 return list;
476 }
477
478 @Override
479 @Transactional(readOnly = true)
480 public List<SocRolloverResultItemInfo> getSocRolloverResultItemsByIds(List<String> ids, ContextInfo context) throws
481 DoesNotExistException,
482 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
483 List<SocRolloverResultItemEntity> entities = socRorItemDao.findByIds(ids);
484 List<SocRolloverResultItemInfo> list = new ArrayList<SocRolloverResultItemInfo>(entities.size());
485 for (SocRolloverResultItemEntity entity : entities) {
486 if (entity == null) {
487
488
489 throw new DoesNotExistException(ids.get(list.size()));
490 }
491 list.add(entity.toDto());
492 }
493 return list;
494 }
495
496 @Override
497 @Transactional(readOnly = true)
498 public List<SocInfo> getSocsByIds(List<String> ids, ContextInfo context) throws DoesNotExistException,
499 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
500 List<SocEntity> entities = socDao.findByIds(ids);
501 List<SocInfo> list = new ArrayList<SocInfo>(entities.size());
502 for (SocEntity entity : entities) {
503 if (entity == null) {
504
505
506 throw new DoesNotExistException(ids.get(list.size()));
507 }
508 list.add(entity.toDto());
509 }
510 return list;
511 }
512
513 @Override
514 @Transactional(readOnly = true)
515 public List<String> getUnpublishedActivityOfferingIdsBySoc(String socId, ContextInfo context) throws DoesNotExistException,
516 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
517 throw new OperationFailedException("Configuration error Implemented in the calculuation layer");
518 }
519
520 @Override
521 @Transactional(readOnly = true)
522 public List<String> getUnpublishedCourseOfferingIdsBySoc(String socId, ContextInfo context) throws DoesNotExistException,
523 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
524 return this.businessLogic.getUnpublishedCourseOfferingIdsBySoc(socId, context);
525 }
526
527 @Override
528 @Transactional(readOnly = true)
529 public List<String> getUnscheduledActivityOfferingIdsBySoc(String socId, ContextInfo context) throws DoesNotExistException,
530 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
531 return this.businessLogic.getUnscheduledActivityOfferingIdsBySoc(socId, context);
532 }
533
534 @Override
535 @Transactional(readOnly = true)
536 public Boolean isCourseOfferingInSoc(String socId, String courseOfferingId, ContextInfo context) throws DoesNotExistException,
537 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
538 return this.businessLogic.isCourseOfferingInSoc(socId, courseOfferingId, context);
539 }
540
541 @Override
542 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
543 public SocRolloverResultInfo reverseRollover(String rolloverResultId, List<String> optionKeys, ContextInfo context) throws
544 DoesNotExistException,
545 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
546 return this.businessLogic.reverseRollover(rolloverResultId, optionKeys, context);
547 }
548
549 @Override
550
551 public SocInfo rolloverSoc(String sourceSocId, String targetTermId, List<String> optionKeys, ContextInfo context) throws
552 DoesNotExistException,
553 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
554 return this.businessLogic.rolloverSoc(sourceSocId, targetTermId, optionKeys, context);
555 }
556
557 @Override
558 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
559 public StatusInfo scheduleSoc(String socId, ContextInfo context) throws DoesNotExistException, InvalidParameterException,
560 MissingParameterException, OperationFailedException, PermissionDeniedException {
561 throw new OperationFailedException("not implemented yet");
562 }
563
564 @Override
565 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
566 public SocInfo updateSoc(String id, SocInfo info, ContextInfo context) throws DataValidationErrorException,
567 DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
568 PermissionDeniedException, ReadOnlyException, VersionMismatchException {
569 SocEntity entity = socDao.find(id);
570 if (entity == null) {
571 throw new DoesNotExistException(id);
572 }
573 entity.fromDTO(info);
574
575 entity.setEntityUpdated(context);
576
577 entity = socDao.merge(entity);
578 return entity.toDto();
579 }
580
581 @Override
582 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
583 public SocRolloverResultInfo updateSocRolloverProgress(String id, Integer itemsProcessed, ContextInfo context) throws
584 DataValidationErrorException,
585 DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
586 PermissionDeniedException, ReadOnlyException, VersionMismatchException {
587 SocRolloverResultEntity entity = socRorDao.find(id);
588 if (entity == null) {
589 throw new DoesNotExistException(id);
590 }
591 entity.setItemsProcessed(itemsProcessed);
592
593 entity.setEntityUpdated(context);
594
595 Set<SocRolloverResultAttributeEntity> resultAttributeEntities = entity.getAttributes();
596 for (SocRolloverResultAttributeEntity attr: resultAttributeEntities) {
597 if (CourseOfferingSetServiceConstants.DATE_COMPLETED_RESULT_DYNATTR_KEY.equals(attr.getKey())) {
598
599 attr.setValue(TransformUtility.dateTimeToDynamicAttributeString(new Date()));
600 }
601 }
602 socRorDao.merge(entity);
603 return entity.toDto();
604 }
605
606 @Override
607 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
608 public SocRolloverResultInfo updateSocRolloverResult(String id, SocRolloverResultInfo info, ContextInfo context) throws
609 DataValidationErrorException,
610 DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
611 PermissionDeniedException, ReadOnlyException, VersionMismatchException {
612 SocRolloverResultEntity entity = socRorDao.find(id);
613 if (entity == null) {
614 throw new DoesNotExistException(id);
615 }
616
617
618
619 List<SocRolloverResultOptionEntity> notDeletedOptions = new ArrayList<SocRolloverResultOptionEntity>(
620 entity.getOptions().size());
621 for (SocRolloverResultOptionEntity optionEntity : entity.getOptions()) {
622 if (!info.getOptionKeys().contains(optionEntity.getOptionId())) {
623 socDao.getEm().remove(optionEntity);
624 } else {
625 notDeletedOptions.add(optionEntity);
626 }
627 }
628 entity.setOptions(notDeletedOptions);
629 entity.fromDTO(info);
630
631 entity.setEntityUpdated(context);
632
633 socRorDao.merge(entity);
634 return entity.toDto();
635 }
636
637 @Override
638 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
639 public SocRolloverResultItemInfo updateSocRolloverResultItem(String id, SocRolloverResultItemInfo info, ContextInfo context) throws
640 DataValidationErrorException,
641 DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException,
642 PermissionDeniedException, ReadOnlyException, VersionMismatchException {
643 SocRolloverResultItemEntity entity = socRorItemDao.find(id);
644 if (entity == null) {
645 throw new DoesNotExistException(id);
646 }
647 entity.fromDTO(info);
648
649 entity.setEntityUpdated(context);
650
651 socRorItemDao.merge(entity);
652 return entity.toDto();
653 }
654
655 @Override
656 public List<ValidationResultInfo> validateSoc(String validationType, SocInfo socInfo, ContextInfo context) throws
657 DoesNotExistException,
658 InvalidParameterException, MissingParameterException, OperationFailedException {
659 throw new UnsupportedOperationException("Not supported yet.");
660 }
661
662 @Override
663 public List<ValidationResultInfo> validateSocRolloverResult(String validationType, SocRolloverResultInfo socRolloverResultInfo, ContextInfo context) throws
664 DoesNotExistException,
665 InvalidParameterException, MissingParameterException, OperationFailedException {
666 throw new UnsupportedOperationException("Not supported yet.");
667 }
668
669 @Override
670 public List<ValidationResultInfo> validateSocRolloverResultItem(String validationType, SocRolloverResultItemInfo socRolloverResultItemInfo, ContextInfo context) throws
671 DoesNotExistException,
672 InvalidParameterException, MissingParameterException, OperationFailedException {
673 throw new UnsupportedOperationException("Not supported yet.");
674 }
675
676 @Override
677 @Transactional(readOnly = true)
678 public List<String> searchForSocRolloverResultIds(@WebParam(name = "criteria") QueryByCriteria criteria, @WebParam(name = "context") ContextInfo context) throws
679 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
680 throw new UnsupportedOperationException("Not supported yet.");
681 }
682
683 @Override
684 @Transactional(readOnly = true)
685 public List<SocRolloverResultInfo> searchForSocRolloverResults(@WebParam(name = "criteria") QueryByCriteria criteria, @WebParam(name = "context") ContextInfo context) throws
686 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
687 GenericQueryResults<SocRolloverResultEntity> results = criteriaLookupService.lookup(SocRolloverResultEntity.class,
688 criteria);
689 List<SocRolloverResultInfo> socRolloverResultInfos = new ArrayList<SocRolloverResultInfo>(results.getResults().size());
690 for (SocRolloverResultEntity socRolloverResult : results.getResults()) {
691 SocRolloverResultInfo socRolloverResultInfo = socRolloverResult.toDto();
692 socRolloverResultInfos.add(socRolloverResultInfo);
693 }
694 return socRolloverResultInfos;
695 }
696
697 public void setCriteriaLookupService(CriteriaLookupService criteriaLookupService) {
698 this.criteriaLookupService = criteriaLookupService;
699 }
700 }