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.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
19 import org.kuali.rice.krad.lookup.LookupForm;
20 import org.kuali.rice.krad.lookup.LookupableImpl;
21 import org.kuali.student.common.util.CalendarSearchViewHelperUtil;
22 import org.kuali.student.common.util.security.ContextUtils;
23 import org.kuali.student.r2.core.acal.dto.TermInfo;
24 import org.kuali.student.r2.core.atp.service.AtpService;
25 import org.kuali.student.r2.core.class1.type.service.TypeService;
26 import org.kuali.student.r2.core.constants.AtpServiceConstants;
27 import org.kuali.student.r2.core.constants.TypeServiceConstants;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
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 static final Logger LOG = LoggerFactory.getLogger(AcademicTermLookupableImpl.class);
43
44 @Override
45 public List<?> performSearch(LookupForm lookupForm, Map<String, String> searchCriteria, boolean bounded) {
46
47 List<TermInfo> rList;
48 String name = searchCriteria.get("code");
49 String year = searchCriteria.get("startDate");
50
51 try{
52 rList = CalendarSearchViewHelperUtil.searchForTerms(name, year, ContextUtils.createDefaultContextInfo(), getAtpService(), getTypeService());
53 } catch (Exception ex){
54 LOG.error("Exception occurred", 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