1 | |
package org.kuali.student.enrollment.class2.courseoffering.service.impl; |
2 | |
|
3 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
4 | |
import org.kuali.rice.krad.lookup.LookupableImpl; |
5 | |
import org.kuali.rice.krad.web.form.LookupForm; |
6 | |
import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingResourceLoader; |
7 | |
import org.kuali.student.enrollment.common.util.ContextBuilder; |
8 | |
import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo; |
9 | |
import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService; |
10 | |
import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingConstants; |
11 | |
import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService; |
12 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
13 | |
import org.kuali.student.r2.common.exceptions.*; |
14 | |
|
15 | |
import javax.xml.namespace.QName; |
16 | |
import java.util.ArrayList; |
17 | |
import java.util.List; |
18 | |
import java.util.Map; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | 0 | public class CourseOfferingInfoLookupableImpl extends LookupableImpl { |
25 | |
|
26 | |
private transient CourseOfferingService courseOfferingService; |
27 | 0 | private ContextInfo contextInfo = null; |
28 | |
|
29 | |
@Override |
30 | |
protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) { |
31 | |
|
32 | 0 | String termKey = fieldValues.get(CourseOfferingConstants.COURSEOFFERING_TERM_ID); |
33 | 0 | String subjectArea = fieldValues.get(CourseOfferingConstants.COURSEOFFERING_SUBJECT_AREA); |
34 | |
|
35 | |
List<CourseOfferingInfo> courseOfferings; |
36 | |
|
37 | |
try { |
38 | 0 | List<String> courseOfferingIds = getCourseOfferingService().getCourseOfferingIdsByTermAndSubjectArea(termKey, subjectArea, getContextInfo()); |
39 | 0 | courseOfferings = new ArrayList<CourseOfferingInfo>(courseOfferingIds.size()); |
40 | |
|
41 | 0 | for(String coId : courseOfferingIds) { |
42 | 0 | courseOfferings.add(getCourseOfferingService().getCourseOffering(coId, getContextInfo())); |
43 | |
} |
44 | |
|
45 | 0 | } catch (DoesNotExistException e) { |
46 | 0 | throw new RuntimeException(e); |
47 | 0 | } catch (InvalidParameterException e) { |
48 | 0 | throw new RuntimeException(e); |
49 | 0 | } catch (MissingParameterException e) { |
50 | 0 | throw new RuntimeException(e); |
51 | 0 | } catch (OperationFailedException e) { |
52 | 0 | throw new RuntimeException(e); |
53 | 0 | } catch (PermissionDeniedException e) { |
54 | 0 | throw new RuntimeException(e); |
55 | 0 | } |
56 | |
|
57 | 0 | return courseOfferings; |
58 | |
} |
59 | |
|
60 | |
public CourseOfferingService getCourseOfferingService() { |
61 | 0 | if(courseOfferingService == null) |
62 | 0 | courseOfferingService= CourseOfferingResourceLoader.loadCourseOfferingService(); |
63 | 0 | return courseOfferingService; |
64 | |
} |
65 | |
|
66 | |
public ContextInfo getContextInfo() { |
67 | 0 | if (contextInfo == null){ |
68 | 0 | contextInfo = ContextBuilder.loadContextInfo(); |
69 | |
} |
70 | 0 | return contextInfo; |
71 | |
} |
72 | |
} |