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