001 /**
002 * Copyright 2011 The Kuali Foundation Licensed under the
003 * Educational Community License, Version 2.0 (the "License"); you may
004 * not use this file except in compliance with the License. You may
005 * obtain a copy of the License at
006 *
007 * http://www.osedu.org/licenses/ECL-2.0
008 *
009 * Unless required by applicable law or agreed to in writing,
010 * software distributed under the License is distributed on an "AS IS"
011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012 * or implied. See the License for the specific language governing
013 * permissions and limitations under the License.
014 */
015
016 package org.kuali.student.common.util.krms.proposition;
017
018 import java.util.Collection;
019 import java.util.Collections;
020
021 import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
022 import org.kuali.rice.krms.api.engine.Term;
023 import org.kuali.student.common.util.krms.RulesExecutionConstants;
024
025 /**
026 * Proposition that checks for completion of a set of courses
027 *
028 * @author alubbers
029 */
030 public class CourseSetCompletionProposition extends CourseCompletionProposition {
031
032 private String courseSetId;
033
034 private Collection<String> courseIds;
035
036 public CourseSetCompletionProposition(String courseSetId, Integer minToComplete) {
037 super(minToComplete);
038 this.courseSetId = courseSetId;
039 }
040
041 public CourseSetCompletionProposition(String courseSetId) {
042 super();
043 this.courseSetId = courseSetId;
044 }
045
046 @Override
047 protected Collection<String> getTermCourseIds(ExecutionEnvironment environment) {
048
049 if(courseIds == null) {
050
051 Term term = new Term(RulesExecutionConstants.COURSE_SET_TERM_NAME, Collections.singletonMap(RulesExecutionConstants.COURSE_SET_ID_TERM_PROPERTY, courseSetId));
052
053 courseIds = environment.resolveTerm(term, this);
054 }
055
056 return courseIds;
057 }
058
059 }