1 | |
package org.kuali.student.enrollment.class2.courseoffering.service; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.List; |
5 | |
import java.util.Map; |
6 | |
|
7 | |
import javax.xml.namespace.QName; |
8 | |
|
9 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
10 | |
import org.kuali.rice.kns.uif.service.impl.LookupViewHelperServiceImpl; |
11 | |
|
12 | |
import org.kuali.student.common.search.dto.SearchParam; |
13 | |
import org.kuali.student.common.search.dto.SearchRequest; |
14 | |
import org.kuali.student.common.search.dto.SearchResult; |
15 | |
import org.kuali.student.common.search.dto.SearchResultRow; |
16 | |
import org.kuali.student.common.search.dto.SearchResultCell; |
17 | |
|
18 | |
import org.kuali.student.lum.course.dto.CourseInfo; |
19 | |
import org.kuali.student.lum.course.service.CourseServiceConstants; |
20 | |
import org.kuali.student.lum.course.service.CourseService; |
21 | |
import org.kuali.student.lum.lu.service.LuService; |
22 | |
import org.kuali.student.lum.lu.service.LuServiceConstants; |
23 | |
|
24 | 0 | public class CourseInfoLookupViewHelperServiceImpl extends LookupViewHelperServiceImpl { |
25 | |
private static final long serialVersionUID = 1L; |
26 | |
|
27 | |
private transient LuService luService; |
28 | |
private transient CourseService courseService; |
29 | |
|
30 | |
@Override |
31 | |
protected List<?> getSearchResultsWithBounding(Map<String, String> fieldValues, boolean unbounded) { |
32 | 0 | List <CourseInfo> courseInfoList = new ArrayList<CourseInfo>(); |
33 | 0 | String courseId = null; |
34 | 0 | List<SearchParam> searchParams = new ArrayList<SearchParam>(); |
35 | 0 | SearchParam qpv1 = new SearchParam(); |
36 | 0 | qpv1.setKey("lu.queryParam.luOptionalType"); |
37 | |
|
38 | |
|
39 | 0 | qpv1.setValue("kuali.lu.type.CreditCourse"); |
40 | 0 | searchParams.add(qpv1); |
41 | |
|
42 | 0 | SearchRequest searchRequest = new SearchRequest(); |
43 | 0 | searchRequest.setParams(searchParams); |
44 | 0 | searchRequest.setSearchKey("lu.search.mostCurrent.union"); |
45 | |
|
46 | |
|
47 | |
|
48 | |
try { |
49 | 0 | SearchResult searchResult = getLuService().search(searchRequest); |
50 | |
|
51 | 0 | if (searchResult.getRows().size() > 0) { |
52 | 0 | for(SearchResultRow srrow : searchResult.getRows()){ |
53 | 0 | List<SearchResultCell> srCells = srrow.getCells(); |
54 | 0 | if(srCells != null && srCells.size() > 0){ |
55 | 0 | for(SearchResultCell srcell : srCells){ |
56 | 0 | if (srcell.getKey().equals("lu.resultColumn.cluId")) { |
57 | 0 | courseId = srcell.getValue(); |
58 | 0 | CourseInfo course = getCourseService().getCourse(courseId); |
59 | 0 | courseInfoList.add(course); |
60 | 0 | } |
61 | |
} |
62 | |
} |
63 | 0 | } |
64 | |
} |
65 | |
|
66 | 0 | return courseInfoList; |
67 | 0 | } catch (Exception e) { |
68 | 0 | throw new RuntimeException(e); |
69 | |
} |
70 | |
|
71 | |
|
72 | |
} |
73 | |
|
74 | |
|
75 | |
protected LuService getLuService() { |
76 | 0 | if(luService == null) { |
77 | 0 | luService = (LuService)GlobalResourceLoader.getService(new QName(LuServiceConstants.LU_NAMESPACE,"LuService")); |
78 | |
} |
79 | 0 | return this.luService; |
80 | |
} |
81 | |
|
82 | |
protected CourseService getCourseService() { |
83 | 0 | if(courseService == null) { |
84 | 0 | courseService = (CourseService)GlobalResourceLoader.getService(new QName(CourseServiceConstants.COURSE_NAMESPACE,"CourseService")); |
85 | |
} |
86 | 0 | return this.courseService; |
87 | |
} |
88 | |
} |