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.uif.UifConstants;
7 import org.kuali.rice.krad.uif.UifParameters;
8 import org.kuali.rice.krad.util.KRADConstants;
9 import org.kuali.rice.krad.util.KRADUtils;
10 import org.kuali.rice.krad.util.UrlFactory;
11 import org.kuali.rice.krad.web.form.LookupForm;
12 import org.kuali.student.enrollment.acal.dto.TermInfo;
13 import org.kuali.student.enrollment.acal.service.AcademicCalendarService;
14 import org.kuali.student.enrollment.class2.acal.dto.TermWrapper;
15 import org.kuali.student.r2.common.dto.ContextInfo;
16 import org.kuali.student.r2.common.exceptions.*;
17
18 import javax.xml.namespace.QName;
19 import java.util.ArrayList;
20 import java.util.List;
21 import java.util.Map;
22 import java.util.Properties;
23
24
25
26
27
28
29
30 @Deprecated
31 public class TermLookupableImpl extends LookupableImpl {
32 public final static String TERM_KEY = "key";
33 private transient AcademicCalendarService academicCalendarService;
34
35
36 @Override
37 protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) {
38 TermInfo termInfo = null;
39 List<TermInfo> termInfoList = new ArrayList<TermInfo>();
40
41 String termKey = fieldValues.get(TERM_KEY);
42 ContextInfo context = new ContextInfo();
43 try{
44 termInfo = getAcademicCalendarService().getTerm(termKey, context);
45 termInfoList.add(termInfo);
46 return termInfoList;
47 }catch (DoesNotExistException dnee){
48 System.out.println("call getAcademicCalendarService().getKeyDatesForTerm(termKey, context), and get DoesNotExistException: "+dnee.toString());
49 }catch (InvalidParameterException ipe){
50 System.out.println("call getAcademicCalendarService().getKeyDatesForTerm(termKey, context), and get InvalidParameterException: "+ipe.toString());
51 }catch (MissingParameterException mpe){
52 System.out.println("call getAcademicCalendarService().getKeyDatesForTerm(termKey, context), and get MissingParameterException: "+mpe.toString());
53 }catch (OperationFailedException ofe){
54 System.out.println("call getAcademicCalendarService().getKeyDatesForTerm(termKey, context), and get OperationFailedException: "+ofe.toString());
55 }catch (PermissionDeniedException pde){
56 System.out.println("call getAcademicCalendarService().getKeyDatesForTerm(termKey, context), and get PermissionDeniedException: "+pde.toString());
57 }
58 return null;
59
60 }
61
62 @Override
63 protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall, List<String> pkNames) {
64
65 Properties props = new Properties();
66 props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
67
68 Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
69 for (String primaryKey : primaryKeyValues.keySet()) {
70 String primaryKeyValue = primaryKeyValues.get(primaryKey);
71 props.put(primaryKey, primaryKeyValue);
72 props.put(KRADConstants.OVERRIDE_KEYS, primaryKey);
73 }
74
75 if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
76 props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
77 }
78
79 props.put(UifParameters.DATA_OBJECT_CLASS_NAME, TermWrapper.class.getName());
80 props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE);
81
82 return UrlFactory.parameterizeUrl(KRADConstants.Maintenance.REQUEST_MAPPING_MAINTENANCE, props);
83
84 }
85
86 protected AcademicCalendarService getAcademicCalendarService() {
87 if(academicCalendarService == null) {
88 academicCalendarService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName("http://student.kuali.org/wsdl/acal", "AcademicCalendarService"));
89 }
90 return academicCalendarService;
91 }
92
93
94
95
96 }