View Javadoc

1   package org.kuali.student.enrollment.class2.courseoffering.service.impl;
2   
3   import org.kuali.rice.krad.lookup.LookupableImpl;
4   import org.kuali.rice.krad.web.form.LookupForm;
5   import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingConstants;
6   import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingResourceLoader;
7   import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo;
8   import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
9   import org.kuali.student.r2.common.dto.ContextInfo;
10  import org.kuali.student.r2.common.util.ContextUtils;
11  
12  import java.util.ArrayList;
13  import java.util.List;
14  import java.util.Map;
15  
16  /**
17   * This class is leftover from Core Slice. Delete when no longer needed or un deprecate if needed.
18   */
19  
20  public class CourseOfferingInfoLookupableImpl extends LookupableImpl {
21      private static final long serialVersionUID = 1L;
22      private transient CourseOfferingService courseOfferingService;
23  
24      @Override
25      protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) {
26  
27          String termKey = fieldValues.get(CourseOfferingConstants.COURSEOFFERING_TERM_ID);
28          String subjectArea = fieldValues.get(CourseOfferingConstants.COURSEOFFERING_SUBJECT_AREA);
29  
30          List<CourseOfferingInfo> courseOfferings;
31  
32          try {
33              ContextInfo contextInfo = ContextUtils.createDefaultContextInfo();
34  
35              List<String> courseOfferingIds = getCourseOfferingService().getCourseOfferingIdsByTermAndSubjectArea(termKey, subjectArea, contextInfo);
36              courseOfferings = new ArrayList<CourseOfferingInfo>(courseOfferingIds.size());
37  
38              for(String coId : courseOfferingIds) {
39                  courseOfferings.add(getCourseOfferingService().getCourseOffering(coId, contextInfo));
40              }
41  
42          } catch (Exception e) {
43              throw new RuntimeException(e);
44          }
45  
46          return courseOfferings;
47      }
48  
49      public CourseOfferingService getCourseOfferingService() {
50          if(courseOfferingService == null)
51              courseOfferingService= CourseOfferingResourceLoader.loadCourseOfferingService();
52          return courseOfferingService;
53      }
54  
55  }