Coverage Report - org.kuali.student.enrollment.class2.courseoffering.service.impl.CourseInfoLookupableImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseInfoLookupableImpl
0%
0/40
0%
0/20
3.167
CourseInfoLookupableImpl$QueryParamEnum
0%
0/11
N/A
3.167
 
 1  
 package org.kuali.student.enrollment.class2.courseoffering.service.impl;
 2  
 
 3  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 4  
 import org.kuali.rice.krad.lookup.LookupableImpl;
 5  
 import org.kuali.rice.krad.web.form.LookupForm;
 6  
 import org.kuali.student.common.search.dto.*;
 7  
 import org.kuali.student.lum.course.dto.CourseInfo;
 8  
 import org.kuali.student.lum.course.service.CourseService;
 9  
 import org.kuali.student.lum.course.service.CourseServiceConstants;
 10  
 import org.kuali.student.lum.lu.service.LuService;
 11  
 import org.kuali.student.lum.lu.service.LuServiceConstants;
 12  
 
 13  
 import javax.xml.namespace.QName;
 14  
 import java.util.ArrayList;
 15  
 import java.util.List;
 16  
 import java.util.Map;
 17  
 
 18  
 import static org.apache.commons.lang.StringUtils.isEmpty;
 19  
 
 20  
 /**
 21  
  * @deprecated This class is leftover from Core Slice. Delete when no longer needed or un deprecate if needed.
 22  
  */
 23  
 @Deprecated
 24  0
 public class CourseInfoLookupableImpl extends LookupableImpl {
 25  
         private static final long serialVersionUID = 1L;        
 26  
         
 27  
     private transient LuService luService;
 28  
     private transient CourseService courseService;
 29  
 
 30  0
     private enum QueryParamEnum {
 31  0
         ID("lu.queryParam.luOptionalId","id"),
 32  0
         SUBJECT("lu.queryParam.luOptionalStudySubjectArea", "subjectArea"),
 33  0
         CODE("lu.queryParam.luOptionalCode", "code"),
 34  0
         TITLE("lu.queryParam.luOptionalLongName", "courseTitle");
 35  
 
 36  
         private final String fieldValue;
 37  
         private final String queryKey;
 38  
 
 39  0
         QueryParamEnum(String qKey, String fValue) {
 40  0
             this.queryKey = qKey;
 41  0
             this.fieldValue = fValue;
 42  0
         }
 43  
 
 44  
         public String getFieldValue() {
 45  0
             return fieldValue;
 46  
         }
 47  
 
 48  
         public String getQueryKey() {
 49  0
             return queryKey;
 50  
         }
 51  
     }
 52  
 
 53  
     @Override
 54  
     protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) {
 55  0
         List <CourseInfo> courseInfoList = new ArrayList<CourseInfo>();
 56  0
         String courseId = null;
 57  0
         List<SearchParam> searchParams = new ArrayList<SearchParam>();
 58  0
         SearchParam qpv1 = new SearchParam();
 59  0
         qpv1.setKey("lu.queryParam.luOptionalType");
 60  0
         qpv1.setValue("kuali.lu.type.CreditCourse");
 61  0
         searchParams.add(qpv1);
 62  0
         for (QueryParamEnum qpEnum : QueryParamEnum.values()) {
 63  0
             String fieldValue = fieldValues.get(qpEnum.getFieldValue());
 64  0
             if ( ! isEmpty(fieldValue) ) {
 65  0
                 SearchParam qpv = new SearchParam();
 66  0
                 qpv.setKey(qpEnum.getQueryKey());
 67  0
                 qpv.setValue(fieldValue);
 68  0
                 searchParams.add(qpv);
 69  
             }
 70  
         }
 71  
 
 72  0
         SearchRequest searchRequest = new SearchRequest();
 73  0
         searchRequest.setParams(searchParams);
 74  0
         searchRequest.setSearchKey("lu.search.mostCurrent.union");
 75  
 
 76  
         try {
 77  0
             SearchResult searchResult = getLuService().search(searchRequest);
 78  
 
 79  0
             if (searchResult.getRows().size() > 0) {
 80  0
                 for(SearchResultRow srrow : searchResult.getRows()){
 81  0
                     List<SearchResultCell> srCells = srrow.getCells();
 82  0
                     if(srCells != null && srCells.size() > 0){
 83  0
                         for(SearchResultCell srcell : srCells){
 84  0
                             if (srcell.getKey().equals("lu.resultColumn.cluId")) {
 85  0
                                 courseId = srcell.getValue();
 86  0
                                 CourseInfo course = getCourseService().getCourse(courseId);
 87  0
                                 courseInfoList.add(course);
 88  0
                             }
 89  
                         }
 90  
                     }
 91  0
                 }
 92  
             }
 93  
 
 94  0
             return courseInfoList;
 95  0
         } catch (Exception e) {
 96  0
             throw new RuntimeException(e);
 97  
         }
 98  
     }
 99  
 
 100  
     //Note: here I am using r1 LuService implementation!!!
 101  
     protected LuService getLuService() {
 102  0
         if(luService == null) {
 103  0
             luService = (LuService)GlobalResourceLoader.getService(new QName(LuServiceConstants.LU_NAMESPACE,"LuService"));
 104  
         }
 105  0
         return this.luService;
 106  
     }
 107  
 
 108  
     protected CourseService getCourseService() {
 109  0
         if(courseService == null) {
 110  0
             courseService = (CourseService)GlobalResourceLoader.getService(new QName(CourseServiceConstants.COURSE_NAMESPACE,"CourseService"));
 111  
         }
 112  0
         return this.courseService;
 113  
     }
 114  
 }