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.common.util.CalendarSearchViewHelperUtil;
23 import org.kuali.student.r2.common.dto.ContextInfo;
24 import org.kuali.student.r2.common.util.ContextUtils;
25 import org.kuali.student.r2.core.acal.dto.TermInfo;
26 import org.kuali.student.r2.core.atp.service.AtpService;
27 import org.kuali.student.r2.core.class1.type.service.TypeService;
28 import org.kuali.student.r2.core.constants.AtpServiceConstants;
29 import org.kuali.student.r2.core.constants.TypeServiceConstants;
30
31 import javax.xml.namespace.QName;
32 import java.util.List;
33 import java.util.Map;
34
35
36 public class AcademicTermLookupableImpl extends LookupableImpl {
37 private static final long serialVersionUID = 1L;
38
39 private transient AtpService atpService;
40 private transient TypeService typeService;
41
42 private final static Logger LOG = Logger.getLogger(AcademicTermLookupableImpl.class);
43
44 @Override
45 protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) {
46
47 List<TermInfo> rList;
48 String name = fieldValues.get("code");
49 String year = fieldValues.get("startDate");
50
51 try{
52 rList = CalendarSearchViewHelperUtil.searchForTerms(name, year, ContextUtils.createDefaultContextInfo(), getAtpService(), getTypeService());
53 } catch (Exception ex){
54 LOG.error(ex);
55 throw new RuntimeException("Error in AcademicTermLookupableImpl searching for term. name[" + name +"] year["+year +"]", ex);
56 }
57
58 return rList;
59 }
60
61 protected AtpService getAtpService() {
62 if(atpService == null) {
63 atpService = (AtpService) GlobalResourceLoader.getService(new QName(AtpServiceConstants.NAMESPACE, AtpServiceConstants.SERVICE_NAME_LOCAL_PART));
64 }
65 return this.atpService;
66 }
67
68 protected TypeService getTypeService(){
69 if (typeService == null){
70 typeService = GlobalResourceLoader.getService(new QName(TypeServiceConstants.NAMESPACE, TypeServiceConstants.SERVICE_NAME_LOCAL_PART));
71 }
72 return typeService;
73 }
74 }
75