Coverage Report - org.kuali.student.enrollment.class2.courseoffering.service.impl.EnrollmentFeeLookupableImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
EnrollmentFeeLookupableImpl
0%
0/32
0%
0/22
3.4
 
 1  
 /**
 2  
  * Copyright 2012 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  *
 15  
  */
 16  
 package org.kuali.student.enrollment.class2.courseoffering.service.impl;
 17  
 
 18  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 19  
 import org.kuali.rice.krad.lookup.LookupableImpl;
 20  
 import org.kuali.rice.krad.util.GlobalVariables;
 21  
 import org.kuali.rice.krad.web.form.LookupForm;
 22  
 import org.kuali.student.enrollment.class2.courseoffering.util.ActivityOfferingConstants;
 23  
 import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingResourceLoader;
 24  
 import org.kuali.student.enrollment.common.util.ContextBuilder;
 25  
 import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
 26  
 import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
 27  
 import org.kuali.student.r2.common.dto.ContextInfo;
 28  
 import org.kuali.student.r2.common.dto.LocaleInfo;
 29  
 import org.kuali.student.r2.common.dto.RichTextInfo;
 30  
 import org.kuali.student.r2.common.exceptions.*;
 31  
 import org.kuali.student.r2.common.util.constants.FeeServiceConstants;
 32  
 import org.kuali.student.r2.common.util.constants.TypeServiceConstants;
 33  
 import org.kuali.student.r2.core.fee.dto.EnrollmentFeeAmountInfo;
 34  
 import org.kuali.student.r2.core.fee.dto.EnrollmentFeeInfo;
 35  
 import org.kuali.student.r2.core.fee.infc.EnrollmentFeeAmount;
 36  
 import org.kuali.student.r2.core.fee.service.FeeService;
 37  
 import org.kuali.student.r2.core.type.service.TypeService;
 38  
 
 39  
 import javax.xml.namespace.QName;
 40  
 import java.util.ArrayList;
 41  
 import java.util.List;
 42  
 import java.util.Locale;
 43  
 import java.util.Map;
 44  
 
 45  
 /**
 46  
  * This class //TODO ...
 47  
  *
 48  
  * @author Kuali Student Team
 49  
  */
 50  0
 public class EnrollmentFeeLookupableImpl extends LookupableImpl {
 51  
 
 52  
     private FeeService feeService;
 53  
     private ContextInfo contextInfo;
 54  
 
 55  
     @Override
 56  
     protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) {
 57  0
         List<EnrollmentFeeInfo> enrollmentFeeInfos = new ArrayList<EnrollmentFeeInfo>();
 58  
 
 59  
         try {
 60  0
             String id = fieldValues.get("id");
 61  0
             String refObjectURI = fieldValues.get("refObjectURI");
 62  0
             String refObjectId = fieldValues.get("refObjectId");
 63  
 
 64  
             // perform this search first so we don't have to search through the list for duplicates later
 65  0
             if(refObjectId != null && !"".equals(refObjectId) && refObjectURI != null && !"".equals(refObjectURI) ){
 66  0
                 List<EnrollmentFeeInfo> efiList = getFeeService().getFeesByReference(refObjectURI,refObjectId,getContextInfo());
 67  
 
 68  0
                 for(EnrollmentFeeInfo efi : efiList){
 69  0
                     enrollmentFeeInfos.add(efi);
 70  
                 }
 71  
             }
 72  
 
 73  
 
 74  0
             if(id != null && !"".equals(id)){
 75  0
                EnrollmentFeeInfo efi = getFeeService().getFee(id,getContextInfo() );
 76  
 
 77  0
                if(efi != null && !enrollmentFeeInfos.contains(efi)){
 78  0
                    enrollmentFeeInfos.add(efi);
 79  
                }
 80  
             }
 81  
 
 82  
 
 83  
               /*
 84  
             EnrollmentFeeInfo tempObj = new EnrollmentFeeInfo();
 85  
 
 86  
             EnrollmentFeeAmountInfo efa = new EnrollmentFeeAmountInfo();
 87  
             efa.setCurrencyQuantity(5);
 88  
             efa.setCurrencyTypeKey("some.type.key.for.currency");
 89  
 
 90  
             tempObj.setAmount(efa);
 91  
             tempObj.setDescr(new RichTextInfo("This is a test description of the EnrollmentFeeInfo", "Just a stub"));
 92  
             tempObj.setOrgId("123 Org");
 93  
             tempObj.setRefObjectId("42");
 94  
             tempObj.setId("112211");
 95  
             tempObj.setStateKey("active");
 96  
             tempObj.setTypeKey("some.type.key");
 97  
 
 98  
 
 99  
             enrollmentFeeInfos.add(tempObj);
 100  
             */
 101  0
         } catch (Exception e) {
 102  0
             e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
 103  0
         }
 104  
 
 105  0
         return enrollmentFeeInfos;
 106  
     }
 107  
 
 108  
     public FeeService getFeeService() {
 109  0
         if (feeService == null) {
 110  0
             this.feeService = (FeeService) GlobalResourceLoader.getService(new QName(FeeServiceConstants.NAMESPACE, FeeServiceConstants.SERVICE_NAME_LOCAL_PART));
 111  
         }
 112  0
         return this.feeService;
 113  
     }
 114  
 
 115  
     public void setFeeService(FeeService feeService) {
 116  0
         this.feeService = feeService;
 117  0
     }
 118  
 
 119  
     public CourseOfferingService getCourseOfferingService() {
 120  0
         return CourseOfferingResourceLoader.loadCourseOfferingService();
 121  
     }
 122  
 
 123  
     public ContextInfo getContextInfo() {
 124  0
         if (null == contextInfo) {
 125  0
             contextInfo = new ContextInfo();
 126  0
             contextInfo.setAuthenticatedPrincipalId(GlobalVariables.getUserSession().getPrincipalId());
 127  0
             contextInfo.setPrincipalId(GlobalVariables.getUserSession().getPrincipalId());
 128  0
             LocaleInfo localeInfo = new LocaleInfo();
 129  0
             localeInfo.setLocaleLanguage(Locale.getDefault().getLanguage());
 130  0
             localeInfo.setLocaleRegion(Locale.getDefault().getCountry());
 131  0
             contextInfo.setLocale(localeInfo);
 132  
         }
 133  0
         return contextInfo;
 134  
     }
 135  
 
 136  
 
 137  
 }