1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.enrollment.class1.lui.service.impl;
18
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.core.api.criteria.GenericQueryResults;
21 import org.kuali.rice.core.api.criteria.QueryByCriteria;
22 import org.kuali.student.enrollment.class1.lui.dao.LuiDao;
23 import org.kuali.student.enrollment.class1.lui.dao.LuiLuiRelationDao;
24 import org.kuali.student.enrollment.class1.lui.dao.LuiSetDao;
25 import org.kuali.student.enrollment.class1.lui.model.LuCodeEntity;
26 import org.kuali.student.enrollment.class1.lui.model.LuiAttributeEntity;
27 import org.kuali.student.enrollment.class1.lui.model.LuiEntity;
28 import org.kuali.student.enrollment.class1.lui.model.LuiIdentifierEntity;
29 import org.kuali.student.enrollment.class1.lui.model.LuiLuiRelationEntity;
30 import org.kuali.student.enrollment.class1.lui.model.LuiSetEntity;
31 import org.kuali.student.enrollment.class1.lui.model.LuiUnitsDeploymentEntity;
32 import org.kuali.student.enrollment.lui.dto.LuiCapacityInfo;
33 import org.kuali.student.enrollment.lui.dto.LuiInfo;
34 import org.kuali.student.enrollment.lui.dto.LuiLuiRelationInfo;
35 import org.kuali.student.enrollment.lui.dto.LuiSetInfo;
36 import org.kuali.student.enrollment.lui.service.LuiService;
37 import org.kuali.student.r2.common.criteria.CriteriaLookupService;
38 import org.kuali.student.r2.common.dto.ContextInfo;
39 import org.kuali.student.r2.common.dto.StatusInfo;
40 import org.kuali.student.r2.common.dto.ValidationResultInfo;
41 import org.kuali.student.r2.common.exceptions.*;
42 import org.kuali.student.r2.common.infc.ValidationResult;
43 import org.slf4j.Logger;
44 import org.slf4j.LoggerFactory;
45 import org.springframework.transaction.annotation.Transactional;
46
47 import java.util.ArrayList;
48 import java.util.List;
49
50
51 public class LuiServiceImpl
52 implements LuiService {
53
54 public static final Logger LOGGER = LoggerFactory.getLogger(LuiServiceImpl.class);
55
56 private CriteriaLookupService criteriaLookupService;
57
58 private LuiDao luiDao;
59 private LuiLuiRelationDao luiLuiRelationDao;
60 private LuiSetDao luiSetDao;
61
62 public LuiDao getLuiDao() {
63 return luiDao;
64 }
65
66 public void setLuiDao(LuiDao luiDao) {
67 this.luiDao = luiDao;
68 }
69
70 public LuiSetDao getLuiSetDao() {
71 return luiSetDao;
72 }
73
74 public void setLuiSetDao(LuiSetDao luiSetDao) {
75 this.luiSetDao = luiSetDao;
76 }
77
78 public CriteriaLookupService getCriteriaLookupService() {
79 return criteriaLookupService;
80 }
81
82 public void setCriteriaLookupService(CriteriaLookupService criteriaLookupService) {
83 this.criteriaLookupService = criteriaLookupService;
84 }
85
86 public LuiLuiRelationDao getLuiLuiRelationDao() {
87 return luiLuiRelationDao;
88 }
89
90 public void setLuiLuiRelationDao(LuiLuiRelationDao luiLuiRelationDao) {
91 this.luiLuiRelationDao = luiLuiRelationDao;
92 }
93
94 @Override
95 @Transactional(readOnly = true)
96 public LuiInfo getLui(String luiId, ContextInfo context)
97 throws DoesNotExistException, InvalidParameterException,
98 MissingParameterException, OperationFailedException,
99 PermissionDeniedException {
100
101 LuiEntity lui = luiDao.find(luiId);
102 if (null == lui) {
103 throw new DoesNotExistException(luiId);
104 }
105
106 return lui.toDto();
107 }
108
109 @Override
110 @Transactional(readOnly = true)
111 public List<LuiInfo> getLuisByIds(List<String> luiIds, ContextInfo context)
112 throws DoesNotExistException, InvalidParameterException,
113 MissingParameterException, OperationFailedException,
114 PermissionDeniedException {
115
116 List<LuiEntity> entityList = luiDao.findByIds(luiIds);
117 List<LuiInfo> infoList = new ArrayList<LuiInfo>();
118
119
120 for (LuiEntity luiEntity : entityList) {
121
122 infoList.add(luiEntity.toDto());
123 }
124
125 return infoList;
126 }
127
128 @Override
129 @Transactional(readOnly = true)
130 public List<String> getLuiIdsByType(String luiTypeKey, ContextInfo context)
131 throws InvalidParameterException, MissingParameterException,
132 OperationFailedException, PermissionDeniedException {
133
134
135
136 List<LuiEntity> luis = luiDao.getLuisByType(luiTypeKey);
137 List<String> luiIds = new ArrayList<String>();
138
139 for (LuiEntity lui : luis) {
140 luiIds.add(lui.getId());
141 }
142
143 return luiIds;
144 }
145
146 @Override
147 @Transactional(readOnly = true)
148 public List<String> getLuiIdsByClu(String cluId, ContextInfo context)
149 throws InvalidParameterException, MissingParameterException,
150 OperationFailedException, PermissionDeniedException {
151
152 List<LuiEntity> luis = luiDao.getLuisByClu(cluId);
153 List<String> luiIds = new ArrayList<String>();
154
155 for (LuiEntity lui : luis) {
156 luiIds.add(lui.getId());
157 }
158
159 return luiIds;
160 }
161
162 @Override
163 @Transactional(readOnly = true)
164 public List<String> getLuiIdsByAtpAndType(String atpId, String typeKey, ContextInfo context)
165 throws InvalidParameterException, MissingParameterException, OperationFailedException,
166 PermissionDeniedException {
167
168 return luiDao.getLuisIdsByAtpAndType(atpId,typeKey);
169 }
170
171 @Override
172 @Transactional(readOnly = true)
173 public List<LuiInfo> getLuisByAtpAndType(String atpId, String luiTypeKey, ContextInfo contextInfo) throws
174 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
175
176 List<LuiEntity> luiEntities = luiDao.getLuisByAtpAndType(atpId, luiTypeKey);
177 List<LuiInfo> luiInfos = new ArrayList<LuiInfo>();
178 for(LuiEntity luiEntity: luiEntities){
179 luiInfos.add(luiEntity.toDto());
180 }
181 return luiInfos;
182 }
183
184 @Override
185 @Transactional(readOnly = true)
186 public List<String> getLuiIdsByAtpAndClu(String cluId, String atpId,ContextInfo context)
187 throws InvalidParameterException, MissingParameterException,
188 OperationFailedException, PermissionDeniedException {
189
190 List<LuiEntity> luis = luiDao.getLuisByAtpAndClu(atpId, cluId);
191 List<String> luiIds = new ArrayList<String>();
192
193 for (LuiEntity lui : luis) {
194 luiIds.add(lui.getId());
195 }
196
197 return luiIds;
198 }
199
200 @Override
201 @Transactional(readOnly = true)
202 public List<LuiInfo> getLuisByAtpAndClu(String cluId, String atpId,
203 ContextInfo context)
204 throws InvalidParameterException, MissingParameterException,
205 OperationFailedException, PermissionDeniedException {
206
207 List<LuiEntity> luiEntities = luiDao.getLuisByAtpAndClu(atpId, cluId);
208 List<LuiInfo> luiInfos = new ArrayList<LuiInfo>();
209 for(LuiEntity luiEntity: luiEntities){
210 luiInfos.add(luiEntity.toDto());
211 }
212 return luiInfos;
213
214 }
215
216 @Override
217 @Transactional(readOnly = true)
218 public List<String> searchForLuiIds(QueryByCriteria criteria, ContextInfo context)
219 throws InvalidParameterException, MissingParameterException, OperationFailedException,
220 PermissionDeniedException {
221
222 GenericQueryResults<String> results = criteriaLookupService.lookupIds(LuiEntity.class, criteria);
223 return results.getResults();
224
225 }
226
227 @Override
228 @Transactional(readOnly = true)
229 public List<LuiInfo> searchForLuis(QueryByCriteria criteria, ContextInfo context)
230 throws InvalidParameterException, MissingParameterException, OperationFailedException,
231 PermissionDeniedException {
232
233 List<LuiInfo> luiInfos = new ArrayList<LuiInfo>();
234 GenericQueryResults<LuiEntity> results = this.getCriteriaLookupService().lookup(LuiEntity.class, criteria);
235 for (LuiEntity lui : results.getResults()) {
236 luiInfos.add(lui.toDto());
237 }
238
239 return luiInfos;
240 }
241
242 @Override
243 public List<ValidationResultInfo> validateLui(String validationTypeKey,
244 String luiTypeKey,
245 String cluId,
246 String atpId,
247 LuiInfo luiInfo,
248 ContextInfo context)
249 throws DoesNotExistException, InvalidParameterException,
250 MissingParameterException, OperationFailedException,
251 PermissionDeniedException {
252 return new ArrayList<ValidationResultInfo>();
253 }
254
255 @Override
256 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
257 public LuiInfo createLui(String cluId, String atpId, String luiTypeKey, LuiInfo luiInfo, ContextInfo context)
258 throws DataValidationErrorException, DoesNotExistException,
259 InvalidParameterException, MissingParameterException,
260 OperationFailedException, PermissionDeniedException,
261 ReadOnlyException {
262
263 if (!cluId.equals(luiInfo.getCluId())) {
264 throw new InvalidParameterException(cluId + " does not match the cluId in the info object " + luiInfo.getCluId());
265 }
266 if (!atpId.equals(luiInfo.getAtpId())) {
267 throw new InvalidParameterException(atpId + " does not match the atp in the info object " + luiInfo.getAtpId());
268 }
269 if (!luiTypeKey.equals(luiInfo.getTypeKey())) {
270 throw new InvalidParameterException(luiTypeKey + " does not match the type in the info object " + luiInfo.getTypeKey());
271 }
272
273 LuiEntity entity = new LuiEntity(luiInfo);
274 entity.setAtpId(atpId);
275 entity.setCluId(cluId);
276 entity.setLuiType(luiTypeKey);
277
278 entity.setEntityCreated(context);
279
280 if(entity.getIdentifiers() != null){
281 for(LuiIdentifierEntity ident:entity.getIdentifiers()){
282 ident.setEntityCreated(context);
283 }
284 }
285 if(entity.getLuiCodes() != null){
286 for(LuCodeEntity code : entity.getLuiCodes()){
287
288 code.setEntityCreated(context);
289 }
290 }
291
292
293 luiDao.persist(entity);
294
295 luiDao.getEm().flush();
296
297 return entity.toDto();
298 }
299
300 @Override
301 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
302 public LuiInfo updateLui(String luiId, LuiInfo luiInfo, ContextInfo context)
303 throws DataValidationErrorException, DoesNotExistException,
304 InvalidParameterException, MissingParameterException,
305 OperationFailedException, PermissionDeniedException,
306 ReadOnlyException, VersionMismatchException {
307
308 LOGGER.info("UpdateLui " + luiId + " " + luiInfo.getTypeKey());
309 LuiEntity entity = luiDao.find(luiId);
310
311 if (!luiId.equals(luiInfo.getId())) {
312 throw new InvalidParameterException(luiId + " does not match the id on the object " + luiInfo.getId());
313 }
314 if (null == entity) {
315 throw new DoesNotExistException(luiId);
316 }
317
318
319 List<Object> orphans = entity.fromDto(luiInfo);
320
321
322 for(Object orphan : orphans){
323 luiDao.getEm().remove(orphan);
324 }
325
326
327
328 entity.setEntityUpdated(context);
329
330
331 if(entity.getIdentifiers() != null){
332 for(LuiIdentifierEntity ident:entity.getIdentifiers()){
333 if(ident.getCreateId() == null){
334 ident.setCreateId(context.getPrincipalId());
335 }
336 if(ident.getCreateTime() == null){
337 ident.setCreateTime(context.getCurrentDate());
338 }
339 ident.setUpdateId(context.getPrincipalId());
340 ident.setUpdateTime(context.getCurrentDate());
341 }
342 }
343 if(entity.getLuiCodes() != null){
344 for(LuCodeEntity code : entity.getLuiCodes()){
345 if(code.getCreateId() == null){
346 code.setCreateId(context.getPrincipalId());
347 }
348 if(code.getCreateTime() == null){
349 code.setCreateTime(context.getCurrentDate());
350 }
351 code.setUpdateId(context.getPrincipalId());
352 code.setUpdateTime(context.getCurrentDate());
353 }
354 }
355
356
357 entity = luiDao.merge(entity);
358
359 luiDao.getEm().flush();
360
361 return entity.toDto();
362 }
363
364 @Override
365 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
366 public StatusInfo deleteLui(String luiId, ContextInfo context)
367 throws DependentObjectsExistException, DoesNotExistException,
368 InvalidParameterException, MissingParameterException,
369 OperationFailedException, PermissionDeniedException {
370
371 LuiEntity entity = luiDao.find(luiId);
372 if (null == entity) {
373 throw new DoesNotExistException(luiId);
374 }
375
376 for (LuiLuiRelationEntity rel : luiLuiRelationDao.getLuiLuiRelationsByLui(luiId)) {
377 luiLuiRelationDao.remove(rel);
378 }
379
380 if(entity.getAttributes()!=null){
381 for(LuiAttributeEntity attr:entity.getAttributes()){
382 luiDao.getEm().remove(attr);
383 }
384 }
385
386 if(entity.getIdentifiers()!=null){
387 for(LuiIdentifierEntity ident:entity.getIdentifiers()){
388 luiDao.getEm().remove(ident);
389 }
390 }
391
392 if(entity.getLuiUnitsDeployment()!=null){
393 for(LuiUnitsDeploymentEntity units:entity.getLuiUnitsDeployment()){
394 luiDao.getEm().remove(units);
395 }
396 }
397
398 if(entity.getLuiCodes()!=null){
399 for(LuCodeEntity luiCode:entity.getLuiCodes()){
400 luiDao.getEm().remove(luiCode);
401 }
402 }
403
404
405 luiDao.remove(entity);
406
407 return new StatusInfo();
408 }
409
410 @Override
411 @Transactional(readOnly = true)
412 public LuiLuiRelationInfo getLuiLuiRelation(String luiLuiRelationId,
413 ContextInfo context)
414 throws InvalidParameterException, MissingParameterException,
415 OperationFailedException, PermissionDeniedException {
416
417 return luiLuiRelationDao.find(luiLuiRelationId).toDto();
418 }
419
420 @Override
421 @Transactional(readOnly = true)
422 public List<LuiLuiRelationInfo> getLuiLuiRelationsByIds(List<String> luiLuiRelationIds,
423 ContextInfo context)
424 throws InvalidParameterException, MissingParameterException,
425 OperationFailedException, PermissionDeniedException {
426
427 List<LuiLuiRelationEntity> relEntities = luiLuiRelationDao.getLuiLuiRelationsByIds(luiLuiRelationIds);
428 List<LuiLuiRelationInfo> relInfos = new ArrayList<LuiLuiRelationInfo>();
429 if (relEntities != null && !relEntities.isEmpty()) {
430 for (LuiLuiRelationEntity relEntity : relEntities) {
431 LuiLuiRelationInfo relInfo = relEntity.toDto();
432 relInfos.add(relInfo);
433 }
434 }
435 return relInfos;
436 }
437
438 @Override
439 @Transactional(readOnly = true)
440 public List<String> getLuiLuiRelationIdsByType(String luiLuiRelationTypeKey,
441 ContextInfo context)
442 throws InvalidParameterException, MissingParameterException,
443 OperationFailedException, PermissionDeniedException {
444
445 return luiLuiRelationDao.getLuiLuiRelationIdsByType(luiLuiRelationTypeKey);
446 }
447
448 @Override
449 @Transactional(readOnly = true)
450 public List<LuiLuiRelationInfo> getLuiLuiRelationsByLui(String luiId,
451 ContextInfo context)
452 throws InvalidParameterException, MissingParameterException,
453 OperationFailedException, PermissionDeniedException {
454
455 List<LuiLuiRelationEntity> relEntities = luiLuiRelationDao.getLuiLuiRelationsByLui(luiId);
456 List<LuiLuiRelationInfo> relInfos = new ArrayList<LuiLuiRelationInfo>();
457 if (relEntities != null && !relEntities.isEmpty()) {
458 for (LuiLuiRelationEntity relEntity : relEntities) {
459 LuiLuiRelationInfo relInfo = relEntity.toDto();
460 relInfos.add(relInfo);
461 }
462 }
463 return relInfos;
464 }
465
466 @Override
467 @Transactional(readOnly = true)
468 public List<LuiLuiRelationInfo> getLuiLuiRelationsByLuiAndRelatedLui(String luiId,
469 String relatedLuiId,
470 ContextInfo context)
471 throws InvalidParameterException, MissingParameterException,
472 OperationFailedException, PermissionDeniedException {
473
474 throw new UnsupportedOperationException("Not supported yet.");
475 }
476
477 @Override
478 @Transactional(readOnly = true)
479 public List<LuiInfo> getLuiLuiRelationsByLuiAndRelatedLuiType(String luiId,
480 String relatedLuiTypeKey,
481 ContextInfo contextInfo)
482 throws InvalidParameterException, MissingParameterException,
483 OperationFailedException, PermissionDeniedException {
484 throw new UnsupportedOperationException("Not supported yet.");
485 }
486
487 @Override
488 @Transactional(readOnly = true)
489 public List<LuiInfo> getLuisByRelatedLuiAndRelationType(String relatedLuiId,
490 String luiLuiRelationTypeKey,
491 ContextInfo context)
492 throws InvalidParameterException, MissingParameterException,
493 OperationFailedException, PermissionDeniedException {
494
495 List<LuiEntity> entityList = luiLuiRelationDao.getLuisByRelation(relatedLuiId, luiLuiRelationTypeKey);
496 List<LuiInfo> infoList = new ArrayList<LuiInfo>();
497 if (entityList != null && !entityList.isEmpty()) {
498 for (LuiEntity entity : entityList) {
499 infoList.add(entity.toDto());
500 }
501
502 }
503
504 return infoList;
505 }
506
507 @Override
508 @Transactional(readOnly = true)
509 public List<String> getLuiIdsByRelatedLuiAndRelationType(String relatedLuiId,
510 String luiLuiRelationTypeKey,
511 ContextInfo context)
512 throws InvalidParameterException, MissingParameterException,
513 OperationFailedException, PermissionDeniedException {
514
515 List<String> returnVals = new ArrayList<String>();
516 returnVals.addAll(luiLuiRelationDao.getLuiIdsByRelation(relatedLuiId, luiLuiRelationTypeKey));
517 return returnVals;
518 }
519
520 @Override
521 @Transactional(readOnly = true)
522 public List<String> getLuiIdsByLuiAndRelationType(String luiId,
523 String luiLuiRelationTypeKey,
524 ContextInfo context)
525 throws InvalidParameterException, MissingParameterException,
526 OperationFailedException, PermissionDeniedException {
527
528 List<String> returnVals = new ArrayList<String>();
529 returnVals.addAll(luiLuiRelationDao.getRelatedLuisByLuiId(luiId, luiLuiRelationTypeKey));
530 return returnVals;
531 }
532
533 @Override
534 @Transactional(readOnly = true)
535 public List<LuiInfo> getRelatedLuisByLuiAndRelationType(String luiId,
536 String luiLuiRelationTypeKey,
537 ContextInfo context)
538 throws InvalidParameterException, MissingParameterException,
539 OperationFailedException, PermissionDeniedException {
540 if (luiId == null) {
541 throw new MissingParameterException("luiId is null");
542 }
543 List<LuiInfo> relatedLuis = new ArrayList<LuiInfo>();
544 List<LuiEntity> relatedLuiEntities = luiLuiRelationDao.getRelatedLuisByLuiIdAndRelationType(luiId, luiLuiRelationTypeKey);
545 for(LuiEntity relatedLuiEntity : relatedLuiEntities) {
546 relatedLuis.add(relatedLuiEntity.toDto());
547 }
548
549 return relatedLuis;
550 }
551
552 @Override
553 @Transactional(readOnly = true)
554 public List<String> searchForLuiLuiRelationIds(QueryByCriteria criteria,
555 ContextInfo context)
556 throws InvalidParameterException, MissingParameterException,
557 OperationFailedException, PermissionDeniedException {
558
559 GenericQueryResults<String> results = criteriaLookupService.lookupIds(LuiLuiRelationEntity.class, criteria);
560 return results.getResults();
561 }
562
563 @Override
564 @Transactional(readOnly = true)
565 public List<LuiLuiRelationInfo> searchForLuiLuiRelations(QueryByCriteria criteria,
566 ContextInfo context)
567 throws InvalidParameterException, MissingParameterException,
568 OperationFailedException, PermissionDeniedException {
569
570 List<LuiLuiRelationInfo> relationInfos = new ArrayList<LuiLuiRelationInfo>();
571
572 GenericQueryResults<LuiLuiRelationEntity> results = criteriaLookupService.lookup(LuiLuiRelationEntity.class, criteria);
573 for(LuiLuiRelationEntity entity : results.getResults()){
574 relationInfos.add(entity.toDto());
575 }
576 return relationInfos;
577 }
578
579 @Override
580 @Transactional(readOnly = true)
581 public List<ValidationResultInfo> validateLuiLuiRelation(String validationTypeKey,
582 String luiId,
583 String relatedLuiId,
584 String luiLuiRelationTypeKey,
585 LuiLuiRelationInfo luiLuiRelationInfo,
586 ContextInfo context)
587 throws DoesNotExistException, InvalidParameterException,
588 MissingParameterException, OperationFailedException {
589
590 List<ValidationResultInfo> validationResultInfos = new ArrayList<ValidationResultInfo>() ;
591 ValidationResultInfo invalidIdsValidationInfo = new ValidationResultInfo();
592 if(luiLuiRelationInfo.getLuiId() ==null || luiLuiRelationInfo.getRelatedLuiId() == null) {
593 invalidIdsValidationInfo.setError("Relation Info is missing relation id data");
594 invalidIdsValidationInfo.setLevel(ValidationResult.ErrorLevel.ERROR);
595 validationResultInfos.add(invalidIdsValidationInfo);
596 }
597 ValidationResultInfo typeStateValidation = new ValidationResultInfo();
598 if(luiLuiRelationInfo.getTypeKey() ==null || luiLuiRelationInfo.getStateKey()==null ){
599 typeStateValidation.setError("Missing type or state data");
600 typeStateValidation.setLevel(ValidationResult.ErrorLevel.ERROR);
601 validationResultInfos.add(typeStateValidation);
602
603 }
604 return validationResultInfos;
605 }
606
607 @Override
608 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
609 public LuiLuiRelationInfo createLuiLuiRelation(String luiId,
610 String relatedLuiId,
611 String luiLuiRelationTypeKey,
612 LuiLuiRelationInfo luiLuiRelationInfo,
613 ContextInfo context)
614 throws DataValidationErrorException,
615 DoesNotExistException, InvalidParameterException,
616 MissingParameterException, OperationFailedException,
617 PermissionDeniedException, ReadOnlyException {
618
619 LuiLuiRelationEntity entity = new LuiLuiRelationEntity(luiLuiRelationInfo);
620 entity.setLuiLuiRelationType(luiLuiRelationTypeKey);
621 entity.setLui(luiDao.find(luiId));
622 if (entity.getLui() == null) {
623 throw new DoesNotExistException(luiId);
624 }
625
626 entity.setRelatedLui(luiDao.find(relatedLuiId));
627 if (entity.getRelatedLui() == null) {
628 throw new DoesNotExistException(relatedLuiId);
629 }
630
631 entity.setLuiLuiRelationType(luiLuiRelationTypeKey);
632
633 entity.setEntityCreated(context);
634
635 luiLuiRelationDao.persist(entity);
636
637 luiLuiRelationDao.getEm().flush();
638
639 return entity.toDto();
640 }
641
642 @Override
643 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
644 public LuiLuiRelationInfo updateLuiLuiRelation(String luiLuiRelationId,
645 LuiLuiRelationInfo luiLuiRelationInfo,
646 ContextInfo context)
647 throws DataValidationErrorException, DoesNotExistException,
648 InvalidParameterException, MissingParameterException,
649 OperationFailedException, PermissionDeniedException,
650 ReadOnlyException, VersionMismatchException {
651
652
653 if (!luiLuiRelationId.equals(luiLuiRelationInfo.getId())) {
654 throw new InvalidParameterException(luiLuiRelationId + " does not match the id on the object " + luiLuiRelationInfo.getId());
655 }
656
657 LuiLuiRelationEntity entity = luiLuiRelationDao.find(luiLuiRelationId);
658 if (entity == null) {
659 throw new DoesNotExistException(luiLuiRelationId);
660 }
661
662
663
664 List<Object> orphans = entity.fromDto(luiLuiRelationInfo);
665
666 entity.setEntityUpdated(context);
667
668
669 entity = luiLuiRelationDao.merge(entity);
670
671
672 for(Object orphan : orphans){
673 luiLuiRelationDao.getEm().remove(orphan);
674 }
675
676 luiLuiRelationDao.getEm().flush();
677
678 return entity.toDto();
679 }
680
681 @Override
682 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
683 public StatusInfo deleteLuiLuiRelation(String luiLuiRelationId,
684 ContextInfo context)
685 throws DoesNotExistException, InvalidParameterException,
686 MissingParameterException, OperationFailedException,
687 PermissionDeniedException {
688
689 LuiLuiRelationEntity entity = luiLuiRelationDao.find(luiLuiRelationId);
690 if (entity == null) {
691 throw new DoesNotExistException(luiLuiRelationId);
692 }
693 luiLuiRelationDao.remove(entity);
694 StatusInfo status = new StatusInfo();
695 status.setSuccess(Boolean.TRUE);
696
697 return status;
698 }
699
700 @Override
701 @Transactional(readOnly = true)
702 public LuiCapacityInfo getLuiCapacity(String luiCapacityId,
703 ContextInfo context)
704 throws DoesNotExistException, InvalidParameterException,
705 MissingParameterException, OperationFailedException,
706 PermissionDeniedException {
707
708 throw new UnsupportedOperationException("Not supported yet.");
709 }
710
711 @Override
712 @Transactional(readOnly = true)
713 public List<LuiCapacityInfo> getLuiCapacitiesByIds(List<String> luiCapacityIds,
714 ContextInfo context)
715 throws DoesNotExistException, InvalidParameterException,
716 MissingParameterException, OperationFailedException,
717 PermissionDeniedException {
718
719 throw new UnsupportedOperationException("Not supported yet.");
720 }
721
722 @Override
723 @Transactional(readOnly = true)
724 public List<LuiCapacityInfo> getLuiCapacitiesByLui(String luiId,
725 ContextInfo context)
726 throws InvalidParameterException, MissingParameterException,
727 OperationFailedException, PermissionDeniedException {
728
729 throw new UnsupportedOperationException("Not supported yet.");
730 }
731
732 @Override
733 @Transactional(readOnly = true)
734 public List<String> getLuiCapacityIdsByType(String luiCapacityTypeKey,
735 ContextInfo context)
736 throws InvalidParameterException, MissingParameterException,
737 OperationFailedException, PermissionDeniedException {
738
739 throw new UnsupportedOperationException("Not supported yet.");
740 }
741
742 @Override
743 @Transactional(readOnly = true)
744 public List<String> searchForLuiCapacityIds(QueryByCriteria criteria,
745 ContextInfo context)
746 throws InvalidParameterException, MissingParameterException,
747 OperationFailedException, PermissionDeniedException {
748
749 throw new UnsupportedOperationException("Not supported yet.");
750 }
751
752 @Override
753 @Transactional(readOnly = true)
754 public List<LuiCapacityInfo> searchForLuiCapacities(QueryByCriteria criteria,
755 ContextInfo context)
756 throws InvalidParameterException, MissingParameterException,
757 OperationFailedException, PermissionDeniedException {
758
759 throw new UnsupportedOperationException("Not supported yet.");
760 }
761
762 @Override
763 public List<ValidationResultInfo> validateLuiCapacity(String validationTypeKey,
764 String luiCapacityTypeKey,
765 LuiCapacityInfo luiCapacityInfo,
766 ContextInfo context)
767 throws DoesNotExistException, InvalidParameterException,
768 MissingParameterException, OperationFailedException,
769 PermissionDeniedException {
770
771 throw new UnsupportedOperationException("Not supported yet.");
772 }
773
774 @Override
775 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
776 public LuiCapacityInfo createLuiCapacity(String luiCapacityTypeKey,
777 LuiCapacityInfo luiCapacityInfo,
778 ContextInfo context)
779 throws DataValidationErrorException, DoesNotExistException,
780 InvalidParameterException, MissingParameterException,
781 OperationFailedException, PermissionDeniedException,
782 ReadOnlyException {
783
784 throw new UnsupportedOperationException("Not supported yet.");
785 }
786
787 @Override
788 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
789 public LuiCapacityInfo updateLuiCapacity(String luiCapacityId,
790 LuiCapacityInfo luiCapacityInfo,
791 ContextInfo context)
792 throws DataValidationErrorException, DoesNotExistException,
793 InvalidParameterException, MissingParameterException,
794 OperationFailedException, PermissionDeniedException,
795 ReadOnlyException, VersionMismatchException {
796
797 throw new UnsupportedOperationException("Not supported yet.");
798 }
799
800 @Override
801 @Transactional(readOnly = false, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class})
802 public StatusInfo deleteLuiCapacity(String luiCapacityId,
803 ContextInfo context)
804 throws DoesNotExistException, InvalidParameterException,
805 MissingParameterException, OperationFailedException,
806 PermissionDeniedException {
807
808 throw new UnsupportedOperationException("Not supported yet.");
809 }
810
811 @Override
812 public LuiSetInfo getLuiSet(String luiSetId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
813 LuiSetEntity luiSetEntity = luiSetDao.find (luiSetId);
814
815 if (luiSetEntity == null) {
816 throw new DoesNotExistException("No existing Lui for id = " + luiSetId);
817 }
818
819 return luiSetEntity.toDto();
820 }
821
822 @Override
823 public List<LuiSetInfo> getLuiSetsByIds(List<String> luiSetIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
824
825 List<LuiSetEntity> luiSetEntities = luiSetDao.findByIds(luiSetIds);
826 List<LuiSetInfo> luiSetInfos = new ArrayList<LuiSetInfo>();
827
828 for (LuiSetEntity luiSetEntity : luiSetEntities) {
829 luiSetInfos.add(luiSetEntity.toDto());
830 }
831
832 return luiSetInfos;
833 }
834
835 @Override
836 public List<String> getLuiIdsFromLuiSet( String luiSetId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
837 LuiSetEntity luiSetEntity = luiSetDao.find(luiSetId);
838
839 if (luiSetEntity == null) {
840 throw new DoesNotExistException("No existing Lui set for id = " + luiSetId);
841 }
842
843 return luiSetEntity.getLuiIds();
844 }
845
846 @Override
847 public List<ValidationResultInfo> validateLuiSet( String validationTypeKey, String luiSetTypeKey, LuiSetInfo LuiSetInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
848 return new ArrayList<ValidationResultInfo>();
849 }
850
851 @Override
852 public LuiSetInfo createLuiSet( String luiSetTypeKey, LuiSetInfo luiSetInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, UnsupportedActionException {
853
854 if (!StringUtils.equals(luiSetTypeKey,luiSetInfo.getTypeKey())) {
855 throw new InvalidParameterException(luiSetTypeKey + " does not match the type in the info object " + luiSetInfo.getTypeKey());
856 }
857
858 LuiSetEntity entity = new LuiSetEntity(luiSetInfo);
859 entity.setEntityCreated(contextInfo);
860 luiSetDao.persist(entity);
861 luiSetDao.getEm().flush();
862 return entity.toDto();
863 }
864
865 @Override
866 public LuiSetInfo updateLuiSet( String luiSetId, LuiSetInfo luiSetInfo, ContextInfo contextInfo) throws CircularRelationshipException, DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, UnsupportedActionException, VersionMismatchException {
867 LuiSetEntity luiSetEntity = luiSetDao.find (luiSetId);
868
869 if (luiSetEntity == null) {
870 throw new DoesNotExistException("No existing Lui set for id = " + luiSetId);
871 }
872
873 luiSetEntity.fromDto(luiSetInfo);
874 luiSetEntity.setUpdateId(contextInfo.getPrincipalId());
875 luiSetEntity.setUpdateTime(contextInfo.getCurrentDate());
876
877 luiSetEntity = luiSetDao.merge(luiSetEntity);
878
879 luiSetDao.getEm().flush();
880
881 return luiSetEntity.toDto();
882 }
883
884 @Override
885 public StatusInfo deleteLuiSet( String luiSetId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
886 LuiSetEntity luiSetEntity = luiSetDao.find (luiSetId);
887
888 if (luiSetEntity == null) {
889 throw new DoesNotExistException("No existing Lui set for id = " + luiSetId);
890 }
891
892 luiSetDao.remove(luiSetEntity);
893
894 return new StatusInfo();
895 }
896
897 @Override
898 public List<LuiSetInfo> getLuiSetsByLui(String luiId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
899 List<LuiSetEntity> luiSetEntities = luiSetDao.getLuiSetsByLui(luiId);
900 List<LuiSetInfo> luiSetInfos = new ArrayList<LuiSetInfo>();
901 for (LuiSetEntity luiSetEntity : luiSetEntities) {
902 luiSetInfos.add(luiSetEntity.toDto());
903 }
904 return luiSetInfos;
905 }
906
907 @Override
908 public List<String> getLuiSetIdsByType(String luiSetTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
909 return luiSetDao.getLuiSetIdsByType(luiSetTypeKey);
910 }
911 }