View Javadoc

1   /**
2    * Copyright 2011 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.krms.termresolver;
17  
18  import org.kuali.rice.krms.api.engine.TermResolutionException;
19  import org.kuali.student.enrollment.academicrecord.dto.StudentCourseRecordInfo;
20  import org.kuali.student.enrollment.academicrecord.service.AcademicRecordService;
21  import org.kuali.student.krms.util.KSKRMSExecutionConstants;
22  import org.kuali.student.r2.common.dto.ContextInfo;
23  
24  import java.util.Arrays;
25  import java.util.Collections;
26  import java.util.HashSet;
27  import java.util.List;
28  import java.util.Map;
29  import java.util.Set;
30  
31  public class CompletedCourseTermResolver extends CompletedCoursesTermResolver {
32  
33  
34      @Override
35      public String getOutput() {
36          return this.getClass().getSimpleName();
37      }
38  
39      @Override
40      public Set<String> getParameterNames() {
41          Set<String> temp = new HashSet<String>(2);
42          temp.add(KSKRMSExecutionConstants.PERSON_ID_TERM_PROPERTY);
43          temp.add(KSKRMSExecutionConstants.COURSE_CODE_TERM_PROPERTY);
44  
45          return Collections.unmodifiableSet(temp);
46      }
47  
48      @Override
49      public int getCost() {
50          // TODO Analyze, though probably not much to check here
51          return 0;
52      }
53  
54  
55      @Override
56      public List<StudentCourseRecordInfo> resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters)
57              throws TermResolutionException {
58          // Get the list of course records from the superclass and then just return the one we need. (in this case we know there will only be one)
59          List<StudentCourseRecordInfo> completedCourseRecords = super.resolve(resolvedPrereqs, parameters);
60          String courseCode = parameters.get(KSKRMSExecutionConstants.COURSE_CODE_TERM_PROPERTY);
61  
62          for (StudentCourseRecordInfo studentCourseRecordInfo : completedCourseRecords) {
63              if (studentCourseRecordInfo.getCourseCode().equals(courseCode)) {
64                  return Arrays.asList(studentCourseRecordInfo);
65              }
66          }
67  
68          return null; //TODO should we return null here or an empty list?
69      }
70  
71  }