1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.enrollment.kitchensink;
18
19 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20 import org.kuali.rice.krad.lookup.LookupableImpl;
21 import org.kuali.rice.krad.web.form.LookupForm;
22 import org.kuali.student.r2.core.acal.dto.TermInfo;
23 import org.kuali.student.r2.core.acal.service.AcademicCalendarService;
24 import org.kuali.student.enrollment.class2.acal.util.CalendarSearchViewHelperUtil;
25 import org.kuali.student.enrollment.common.util.ContextBuilder;
26 import org.kuali.student.r2.common.dto.ContextInfo;
27 import org.kuali.student.r2.core.constants.AcademicCalendarServiceConstants;
28
29 import javax.xml.namespace.QName;
30 import java.util.List;
31 import java.util.Map;
32
33
34
35
36
37
38
39 public class KitchenSinkTermInfoLookupableImpl extends LookupableImpl {
40
41 private transient AcademicCalendarService academicCalendarService;
42 private ContextInfo contextInfo;
43
44 @Override
45 protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) {
46 List<TermInfo> rList = null;
47 String name = fieldValues.get("code");
48 String year = fieldValues.get("startDate");
49
50 try {
51 rList = CalendarSearchViewHelperUtil.searchForTerms(name, year, getContextInfo(), getAcademicCalendarService());
52 }
53 catch (Exception ex){
54 throw new RuntimeException("Error in AcademicTermLookupableImpl searching for term. name[" + name +"] year["+year +"]", ex);
55 }
56
57 return rList;
58 }
59
60 protected AcademicCalendarService getAcademicCalendarService() {
61 if (academicCalendarService == null) {
62 academicCalendarService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName(AcademicCalendarServiceConstants.NAMESPACE, AcademicCalendarServiceConstants.SERVICE_NAME_LOCAL_PART));
63 }
64 return this.academicCalendarService;
65 }
66
67 public ContextInfo getContextInfo() {
68 if (null == contextInfo) {
69 contextInfo = ContextBuilder.loadContextInfo();
70 }
71 return contextInfo;
72 }
73
74 }