1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.enrollment.class2.courseoffering.service.impl; |
17 | |
|
18 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
19 | |
import org.kuali.rice.krad.lookup.LookupableImpl; |
20 | |
import org.kuali.rice.krad.util.GlobalVariables; |
21 | |
import org.kuali.rice.krad.web.form.LookupForm; |
22 | |
import org.kuali.student.enrollment.class2.courseoffering.util.ActivityOfferingConstants; |
23 | |
import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingResourceLoader; |
24 | |
import org.kuali.student.enrollment.common.util.ContextBuilder; |
25 | |
import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo; |
26 | |
import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService; |
27 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
28 | |
import org.kuali.student.r2.common.dto.LocaleInfo; |
29 | |
import org.kuali.student.r2.common.dto.RichTextInfo; |
30 | |
import org.kuali.student.r2.common.exceptions.*; |
31 | |
import org.kuali.student.r2.common.util.constants.FeeServiceConstants; |
32 | |
import org.kuali.student.r2.common.util.constants.TypeServiceConstants; |
33 | |
import org.kuali.student.r2.core.fee.dto.EnrollmentFeeAmountInfo; |
34 | |
import org.kuali.student.r2.core.fee.dto.EnrollmentFeeInfo; |
35 | |
import org.kuali.student.r2.core.fee.infc.EnrollmentFeeAmount; |
36 | |
import org.kuali.student.r2.core.fee.service.FeeService; |
37 | |
import org.kuali.student.r2.core.type.service.TypeService; |
38 | |
|
39 | |
import javax.xml.namespace.QName; |
40 | |
import java.util.ArrayList; |
41 | |
import java.util.List; |
42 | |
import java.util.Locale; |
43 | |
import java.util.Map; |
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | 0 | public class EnrollmentFeeLookupableImpl extends LookupableImpl { |
51 | |
|
52 | |
private FeeService feeService; |
53 | |
private ContextInfo contextInfo; |
54 | |
|
55 | |
@Override |
56 | |
protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) { |
57 | 0 | List<EnrollmentFeeInfo> enrollmentFeeInfos = new ArrayList<EnrollmentFeeInfo>(); |
58 | |
|
59 | |
try { |
60 | 0 | String id = fieldValues.get("id"); |
61 | 0 | String refObjectURI = fieldValues.get("refObjectURI"); |
62 | 0 | String refObjectId = fieldValues.get("refObjectId"); |
63 | |
|
64 | |
|
65 | 0 | if(refObjectId != null && !"".equals(refObjectId) && refObjectURI != null && !"".equals(refObjectURI) ){ |
66 | 0 | List<EnrollmentFeeInfo> efiList = getFeeService().getFeesByReference(refObjectURI,refObjectId,getContextInfo()); |
67 | |
|
68 | 0 | for(EnrollmentFeeInfo efi : efiList){ |
69 | 0 | enrollmentFeeInfos.add(efi); |
70 | |
} |
71 | |
} |
72 | |
|
73 | |
|
74 | 0 | if(id != null && !"".equals(id)){ |
75 | 0 | EnrollmentFeeInfo efi = getFeeService().getFee(id,getContextInfo() ); |
76 | |
|
77 | 0 | if(efi != null && !enrollmentFeeInfos.contains(efi)){ |
78 | 0 | enrollmentFeeInfos.add(efi); |
79 | |
} |
80 | |
} |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | 0 | } catch (Exception e) { |
102 | 0 | e.printStackTrace(); |
103 | 0 | } |
104 | |
|
105 | 0 | return enrollmentFeeInfos; |
106 | |
} |
107 | |
|
108 | |
public FeeService getFeeService() { |
109 | 0 | if (feeService == null) { |
110 | 0 | this.feeService = (FeeService) GlobalResourceLoader.getService(new QName(FeeServiceConstants.NAMESPACE, FeeServiceConstants.SERVICE_NAME_LOCAL_PART)); |
111 | |
} |
112 | 0 | return this.feeService; |
113 | |
} |
114 | |
|
115 | |
public void setFeeService(FeeService feeService) { |
116 | 0 | this.feeService = feeService; |
117 | 0 | } |
118 | |
|
119 | |
public CourseOfferingService getCourseOfferingService() { |
120 | 0 | return CourseOfferingResourceLoader.loadCourseOfferingService(); |
121 | |
} |
122 | |
|
123 | |
public ContextInfo getContextInfo() { |
124 | 0 | if (null == contextInfo) { |
125 | 0 | contextInfo = new ContextInfo(); |
126 | 0 | contextInfo.setAuthenticatedPrincipalId(GlobalVariables.getUserSession().getPrincipalId()); |
127 | 0 | contextInfo.setPrincipalId(GlobalVariables.getUserSession().getPrincipalId()); |
128 | 0 | LocaleInfo localeInfo = new LocaleInfo(); |
129 | 0 | localeInfo.setLocaleLanguage(Locale.getDefault().getLanguage()); |
130 | 0 | localeInfo.setLocaleRegion(Locale.getDefault().getCountry()); |
131 | 0 | contextInfo.setLocale(localeInfo); |
132 | |
} |
133 | 0 | return contextInfo; |
134 | |
} |
135 | |
|
136 | |
|
137 | |
} |