Coverage Report - org.kuali.student.enrollment.class2.courseregistration.service.assembler.RegRequestAssembler
 
Classes in this File Line Coverage Branch Coverage Complexity
RegRequestAssembler
0%
0/65
0%
0/22
2.333
 
 1  
 package org.kuali.student.enrollment.class2.courseregistration.service.assembler;
 2  
 
 3  
 import org.kuali.student.enrollment.courseregistration.dto.RegRequestInfo;
 4  
 import org.kuali.student.enrollment.courseregistration.dto.RegRequestItemInfo;
 5  
 import org.kuali.student.enrollment.courseregistration.dto.RegResponseItemInfo;
 6  
 import org.kuali.student.enrollment.lpr.dto.LprTransactionInfo;
 7  
 import org.kuali.student.enrollment.lpr.dto.LprTransactionItemInfo;
 8  
 import org.kuali.student.enrollment.lpr.dto.LprTransactionItemResultInfo;
 9  
 import org.kuali.student.enrollment.lpr.dto.RequestOptionInfo;
 10  
 import org.kuali.student.r2.common.assembler.AssemblyException;
 11  
 import org.kuali.student.r2.common.assembler.DTOAssembler;
 12  
 import org.kuali.student.r2.common.assembler.EntityDTOAssembler;
 13  
 import org.kuali.student.r2.common.dto.ContextInfo;
 14  
 import org.kuali.student.r2.common.util.constants.GradingServiceConstants;
 15  
 import org.kuali.student.r2.common.util.constants.LuiPersonRelationServiceConstants;
 16  
 import org.kuali.student.r2.lum.lrc.dto.ResultValueInfo;
 17  
 import org.kuali.student.r2.lum.lrc.service.LRCService;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.List;
 21  
 
 22  0
 public class RegRequestAssembler implements DTOAssembler<RegRequestInfo, LprTransactionInfo> {
 23  
 
 24  
     private LRCService lrcService;
 25  
 
 26  
     public LRCService getLrcService() {
 27  0
         return lrcService;
 28  
     }
 29  
 
 30  
     public void setLrcService(LRCService lrcService) {
 31  0
         this.lrcService = lrcService;
 32  0
     }
 33  
 
 34  
     @Override
 35  
     public RegRequestInfo assemble(LprTransactionInfo baseDTO, ContextInfo context) throws AssemblyException {
 36  0
         RegRequestInfo regRequestInfo = new RegRequestInfo();
 37  0
         EntityDTOAssembler<LprTransactionInfo, RegRequestInfo> commonAssembler = new EntityDTOAssembler<LprTransactionInfo, RegRequestInfo>();
 38  0
         regRequestInfo = commonAssembler.assemble(baseDTO, regRequestInfo, context);
 39  0
         regRequestInfo.setRequestorId(baseDTO.getRequestingPersonId());
 40  
 
 41  0
         List<RegRequestItemInfo> regRequestItems = new ArrayList<RegRequestItemInfo>();
 42  0
         for (LprTransactionItemInfo lprTransaction : baseDTO.getLprTransactionItems()) {
 43  0
             regRequestItems.add(assembleItem(lprTransaction, context));
 44  
 
 45  
         }
 46  0
         regRequestInfo.setRegRequestItems(regRequestItems);
 47  0
         regRequestInfo.setTypeKey(baseDTO.getTypeKey());
 48  0
         regRequestInfo.setStateKey(baseDTO.getStateKey());
 49  0
         regRequestInfo.setId(baseDTO.getId());
 50  0
         return regRequestInfo;
 51  
     }
 52  
 
 53  
     public RegRequestItemInfo assembleItem(LprTransactionItemInfo baseDTO, ContextInfo context) {
 54  0
         RegRequestItemInfo regRequestItemInfo = new RegRequestItemInfo();
 55  0
         EntityDTOAssembler<LprTransactionItemInfo, RegRequestItemInfo> commonAssembler = new EntityDTOAssembler<LprTransactionItemInfo, RegRequestItemInfo>();
 56  0
         regRequestItemInfo = commonAssembler.assemble(baseDTO, regRequestItemInfo, context);
 57  0
         regRequestItemInfo.setId(baseDTO.getId());
 58  
 /*        regRequestItemInfo.setTypeKey(baseDTO.getTypeKey());
 59  
         regRequestItemInfo.setStateKey(baseDTO.getStateKey());*/
 60  
 
 61  
         // TODO - sambit . Post Core Slice, move this logic out of assembler and handle exception properly
 62  
         try {
 63  0
             if (baseDTO.getResultValuesGroupKeys() != null) {
 64  
 
 65  0
                 for (String key : baseDTO.getResultValuesGroupKeys()) {
 66  0
                     ResultValueInfo resultValue = lrcService.getResultValue(key, context);
 67  0
                     if (resultValue.getTypeKey().equals(GradingServiceConstants.RESULT_VALUE_LETTER_GRADE_TYPE)
 68  
                             || resultValue.getTypeKey().equals(GradingServiceConstants.RESULT_VALUE_NUMBER_GRADE_TYPE)) {
 69  0
                         regRequestItemInfo.setGradingOptionKey(resultValue.getKey());
 70  
                     }
 71  0
                     if (resultValue.getTypeKey().equals(GradingServiceConstants.RESULT_VALUE_CREDIT_TYPE)) {
 72  0
                         regRequestItemInfo.setCreditOptionKey(resultValue.getKey());
 73  
 
 74  
                     }
 75  0
                 }
 76  
             }
 77  0
         } catch (Exception ex) {
 78  
             // Log exception
 79  0
         }
 80  
 
 81  0
         regRequestItemInfo.setCreditOptionKey(null);
 82  
 
 83  0
         regRequestItemInfo.setStudentId(baseDTO.getPersonId());
 84  0
         regRequestItemInfo.setExistingRegGroupId(baseDTO.getExistingLuiId());
 85  0
         regRequestItemInfo.setNewRegGroupId(baseDTO.getNewLuiId());
 86  0
         for (RequestOptionInfo option : baseDTO.getRequestOptions()) {
 87  0
             if (option.getOptionKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM_HOLD_UNTIL_LIST_OPTION_KEY))
 88  0
                 regRequestItemInfo.setOkToHoldList(Boolean.valueOf(option.getOptionValue()));
 89  
 
 90  0
             else if (option.getOptionKey().equals(LuiPersonRelationServiceConstants.LPRTRANS_ITEM__WAITLIST_OPTION_KEY))
 91  0
                 regRequestItemInfo.setOkToWaitlist(Boolean.valueOf(option.getOptionValue()));
 92  
 
 93  
             else
 94  
                 break;
 95  
 
 96  
         }
 97  0
         return regRequestItemInfo;
 98  
     }
 99  
 
 100  
     public List<LprTransactionInfo> disassembleList(List<RegRequestInfo> businessDTOs, ContextInfo context) {
 101  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 102  0
         return null;
 103  
     }
 104  
 
 105  
     public List<RegRequestInfo> assembleList(List<LprTransactionInfo> businessDTOs, ContextInfo context) {
 106  
         // TODO sambit - THIS METHOD NEEDS JAVADOCS
 107  0
         return null;
 108  
     }
 109  
 
 110  
     @Override
 111  
     public LprTransactionInfo disassemble(RegRequestInfo businessDTO, ContextInfo context) throws AssemblyException {
 112  0
         LprTransactionInfo lprTransactionInfo = new LprTransactionInfo();
 113  0
         EntityDTOAssembler<RegRequestInfo, LprTransactionInfo> commonAssembler = new EntityDTOAssembler<RegRequestInfo, LprTransactionInfo>();
 114  0
         lprTransactionInfo = commonAssembler.assemble(businessDTO, lprTransactionInfo, context);
 115  0
         lprTransactionInfo.setId(businessDTO.getId());
 116  0
         lprTransactionInfo.setRequestingPersonId(businessDTO.getRequestorId());
 117  0
         List<LprTransactionItemInfo> lprtTransItems = new ArrayList<LprTransactionItemInfo>();
 118  0
         for (RegRequestItemInfo item : businessDTO.getRegRequestItems()) {
 119  0
             lprtTransItems.add(disassembleItem(item, null, context));
 120  
         }
 121  0
         lprTransactionInfo.setLprTransactionItems(lprtTransItems);
 122  0
         return lprTransactionInfo;
 123  
 
 124  
     }
 125  
 
 126  
     public LprTransactionItemInfo disassembleItem(RegRequestItemInfo regRequestItem, RegResponseItemInfo responseItem, ContextInfo context) {
 127  
 
 128  0
         LprTransactionItemInfo lprTransactionItemInfo = new LprTransactionItemInfo();
 129  0
         EntityDTOAssembler<RegRequestItemInfo, LprTransactionItemInfo> commonAssembler = new EntityDTOAssembler<RegRequestItemInfo, LprTransactionItemInfo>();
 130  0
         lprTransactionItemInfo = commonAssembler.assemble(regRequestItem, lprTransactionItemInfo, context);
 131  0
         lprTransactionItemInfo.setId(regRequestItem.getId());
 132  0
         lprTransactionItemInfo.setExistingLuiId(regRequestItem.getExistingRegGroupId());
 133  0
         lprTransactionItemInfo.setNewLuiId(regRequestItem.getNewRegGroupId());
 134  0
         lprTransactionItemInfo.setName(regRequestItem.getName());
 135  0
         lprTransactionItemInfo.setPersonId(regRequestItem.getStudentId());
 136  0
         lprTransactionItemInfo.setGroupId(regRequestItem.getId());
 137  0
         if (responseItem != null) {
 138  0
             lprTransactionItemInfo.setLprTransactionResult(disassembleTransItemResult(responseItem));
 139  
         }
 140  
 
 141  0
         return lprTransactionItemInfo;
 142  
     }
 143  
 
 144  
     public LprTransactionItemResultInfo disassembleTransItemResult(RegResponseItemInfo responseItem) {
 145  0
         return new LprTransactionItemResultInfo();
 146  
     }
 147  
 }