1 | |
package org.kuali.student.enrollment.class2.acal.service; |
2 | |
|
3 | |
import org.apache.commons.lang.StringUtils; |
4 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
5 | |
import org.kuali.rice.krad.lookup.LookupableImpl; |
6 | |
import org.kuali.rice.krad.web.form.LookupForm; |
7 | |
import org.kuali.student.enrollment.acal.dto.AcademicCalendarInfo; |
8 | |
import org.kuali.student.enrollment.acal.dto.TermInfo; |
9 | |
import org.kuali.student.enrollment.acal.service.AcademicCalendarService; |
10 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
11 | |
|
12 | |
import javax.xml.namespace.QName; |
13 | |
import java.util.ArrayList; |
14 | |
import java.util.Calendar; |
15 | |
import java.util.List; |
16 | |
import java.util.Map; |
17 | |
|
18 | |
|
19 | |
@Deprecated |
20 | 0 | public class TermInfoLookupableImpl extends LookupableImpl { |
21 | |
public final static String TERM_TYPE_KEY = "typeKey"; |
22 | |
public final static String TERM_KEY = "key"; |
23 | |
private transient AcademicCalendarService academicCalendarService; |
24 | |
|
25 | |
|
26 | |
@Override |
27 | |
protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) { |
28 | 0 | TermInfo termInfo = null; |
29 | 0 | List<TermInfo> termInfoList = new ArrayList<TermInfo>(); |
30 | 0 | List<AcademicCalendarInfo> acalInfoList = new ArrayList<AcademicCalendarInfo>(); |
31 | |
|
32 | 0 | String termKey = fieldValues.get(TERM_KEY); |
33 | 0 | ContextInfo context = new ContextInfo(); |
34 | 0 | if (StringUtils.isBlank(termKey)) { |
35 | 0 | Calendar now = Calendar.getInstance(); |
36 | 0 | int thisYear = now.get(Calendar.YEAR); |
37 | |
try { |
38 | |
|
39 | 0 | acalInfoList.addAll(getAcademicCalendarService().getAcademicCalendarsByStartYear(thisYear + 1, context)); |
40 | |
|
41 | 0 | acalInfoList.addAll(getAcademicCalendarService().getAcademicCalendarsByStartYear(thisYear, context)); |
42 | |
|
43 | 0 | acalInfoList.addAll(getAcademicCalendarService().getAcademicCalendarsByStartYear(thisYear - 1, context)); |
44 | 0 | for (AcademicCalendarInfo acalInfo : acalInfoList) { |
45 | 0 | termInfoList.addAll(getAcademicCalendarService().getTermsForAcademicCalendar(acalInfo.getId(), context)); |
46 | |
} |
47 | 0 | } catch (Exception e) { |
48 | 0 | e.printStackTrace(); |
49 | 0 | return null; |
50 | 0 | } |
51 | 0 | } |
52 | |
else { |
53 | |
try{ |
54 | 0 | termInfo = getAcademicCalendarService().getTerm(termKey, context); |
55 | 0 | termInfoList.add(termInfo); |
56 | 0 | } catch (Exception e){ |
57 | 0 | e.printStackTrace(); |
58 | 0 | return null; |
59 | 0 | } |
60 | |
} |
61 | 0 | return termInfoList; |
62 | |
} |
63 | |
|
64 | |
protected AcademicCalendarService getAcademicCalendarService() { |
65 | 0 | if(academicCalendarService == null) { |
66 | 0 | academicCalendarService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName("http://student.kuali.org/wsdl/acal","AcademicCalendarService")); |
67 | |
} |
68 | |
|
69 | 0 | return academicCalendarService; |
70 | |
} |
71 | |
|
72 | |
} |