Coverage Report - org.kuali.student.enrollment.class2.courseoffering.service.assembler.RegistrationGroupAssembler
 
Classes in this File Line Coverage Branch Coverage Complexity
RegistrationGroupAssembler
0%
0/33
0%
0/22
2.714
 
 1  
 package org.kuali.student.enrollment.class2.courseoffering.service.assembler;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.List;
 5  
 
 6  
 import org.kuali.student.enrollment.class2.courseoffering.service.transformer.RegistrationGroupTransformer;
 7  
 import org.kuali.student.enrollment.courseoffering.dto.RegistrationGroupInfo;
 8  
 import org.kuali.student.enrollment.lui.dto.LuiInfo;
 9  
 import org.kuali.student.enrollment.lui.dto.LuiLuiRelationInfo;
 10  
 import org.kuali.student.enrollment.lui.service.LuiService;
 11  
 import org.kuali.student.r2.common.assembler.AssemblyException;
 12  
 import org.kuali.student.r2.common.assembler.DTOAssembler;
 13  
 import org.kuali.student.r2.common.dto.ContextInfo;
 14  
 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
 15  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 16  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 17  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 18  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 19  
 import org.kuali.student.r2.common.util.constants.LuiServiceConstants;
 20  
 
 21  0
 public class RegistrationGroupAssembler {
 22  
 
 23  
     private LuiService luiService;
 24  
     private RegistrationGroupTransformer regGroupTransformer;
 25  
 
 26  
     public RegistrationGroupTransformer getRegGroupTransformer() {
 27  0
         return regGroupTransformer;
 28  
     }
 29  
 
 30  
     public void setRegGroupTransformer(RegistrationGroupTransformer transformer) {
 31  0
         this.regGroupTransformer = transformer;
 32  0
     }
 33  
 
 34  
     public LuiService getLuiService() {
 35  0
         return luiService;
 36  
     }
 37  
 
 38  
     public void setLuiService(LuiService luiService) {
 39  0
         this.luiService = luiService;
 40  0
     }
 41  
 
 42  
     public RegistrationGroupInfo assemble(LuiInfo lui, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 43  0
         if (lui != null) {
 44  0
             RegistrationGroupInfo rg = regGroupTransformer.transform(lui);
 45  0
             assembleLuiLuiRelations(rg, lui.getId(), context);
 46  0
             return rg;
 47  
         } else {
 48  0
             return null;
 49  
         }
 50  
     }
 51  
 
 52  
     private void assembleLuiLuiRelations(RegistrationGroupInfo rg, String luiId, ContextInfo context) 
 53  
         throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 54  
                OperationFailedException, PermissionDeniedException {
 55  0
         String courseOfferingId = null;
 56  
         ;
 57  0
         List<String> activityIds = new ArrayList<String>();
 58  0
         List<LuiLuiRelationInfo> rels = luiService.getLuiLuiRelationsByLui(luiId, context);
 59  0
         if (rels != null && !rels.isEmpty()) {
 60  0
             for (LuiLuiRelationInfo rel : rels) {
 61  0
                 if (rel.getLuiId().equals(luiId)) {
 62  0
                     if (rel.getTypeKey().equals(LuiServiceConstants.LUI_LUI_RELATION_REGISTEREDFORVIA_TYPE_KEY)) {
 63  0
                         LuiInfo lui = luiService.getLui(rel.getRelatedLuiId(), context);
 64  0
                         if (lui != null) {
 65  0
                             if (lui.getTypeKey().equals(LuiServiceConstants.COURSE_OFFERING_TYPE_KEY)) {
 66  0
                                 courseOfferingId = rel.getRelatedLuiId();
 67  
                             } else {
 68  0
                                 if (!activityIds.contains(rel.getRelatedLuiId())) {
 69  0
                                     activityIds.add(rel.getRelatedLuiId());
 70  
                                 }
 71  
                             }
 72  
                         }
 73  0
                     }
 74  
                 }
 75  
             }
 76  
         }
 77  
 
 78  0
         if (null != courseOfferingId)
 79  0
             rg.setCourseOfferingId(courseOfferingId);
 80  0
         if (!activityIds.isEmpty())
 81  0
             rg.setActivityOfferingIds(activityIds);
 82  
 
 83  0
     }
 84  
 
 85  
     public LuiInfo disassemble(RegistrationGroupInfo rg, ContextInfo context) {
 86  0
         LuiInfo lui = regGroupTransformer.transform(rg);
 87  0
         return lui;
 88  
     }
 89  
 }