Coverage Report - org.kuali.student.r2.core.class1.process.krms.proposition.RegistrationHoldProposition
 
Classes in this File Line Coverage Branch Coverage Complexity
RegistrationHoldProposition
0%
0/14
0%
0/4
2
 
 1  
 /**
 2  
  * Copyright 2011 The Kuali Foundation 
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the
 5  
  * "License"); you may not use this file except in compliance with the
 6  
  * License. You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.osedu.org/licenses/ECL-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 13  
  * implied. See the License for the specific language governing
 14  
  * permissions and limitations under the License.
 15  
  */
 16  
 
 17  
 package org.kuali.student.r2.core.class1.process.krms.proposition;
 18  
 
 19  
 import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
 20  
 import org.kuali.rice.krms.api.engine.ResultEvent;
 21  
 import org.kuali.rice.krms.api.engine.Term;
 22  
 import org.kuali.rice.krms.framework.engine.PropositionResult;
 23  
 import org.kuali.rice.krms.framework.engine.result.BasicResult;
 24  
 import org.kuali.student.common.util.krms.RulesExecutionConstants;
 25  
 import org.kuali.student.common.util.krms.proposition.AbstractLeafProposition;
 26  
 import org.kuali.student.r2.core.hold.dto.HoldInfo;
 27  
 
 28  
 import java.util.ArrayList;
 29  
 import java.util.Collections;
 30  
 import java.util.List;
 31  
 
 32  
 /**
 33  
  * This class represents a proposition to evaluate if a student has a
 34  
  * Hold that would prevent registration.
 35  
  *
 36  
  * @author alubbers
 37  
  */
 38  
 public class RegistrationHoldProposition extends AbstractLeafProposition {
 39  
 
 40  
     private final String issueId;
 41  
 
 42  0
     public RegistrationHoldProposition(String issueId) {
 43  0
         this.issueId = issueId;
 44  0
     }
 45  
 
 46  
     @Override
 47  
     public PropositionResult evaluate(ExecutionEnvironment environment) {
 48  
 
 49  0
         Term studentRegistrationHoldsTerm = new Term(RulesExecutionConstants.STUDENT_REGISTRATION_HOLDS_TERM_NAME, Collections.singletonMap(RulesExecutionConstants.ISSUE_KEY_TERM_PROPERTY, issueId));
 50  0
         List<HoldInfo> studentRegistrationHolds = environment.resolveTerm(studentRegistrationHoldsTerm, this);
 51  
 
 52  0
         PropositionResult result = null;
 53  
 
 54  0
         if (studentRegistrationHolds.isEmpty()) {
 55  0
             result = new PropositionResult(true);
 56  
         } else {
 57  0
             List<HoldInfo> blockingHolds = new ArrayList<HoldInfo>();
 58  
 
 59  
             // Split the found holds into warning and blocking holds
 60  0
             for (HoldInfo hold : studentRegistrationHolds) {
 61  0
                     blockingHolds.add(hold);
 62  
             }
 63  
 
 64  
             // if there are no blocking holds, the result of the evaluation is true
 65  0
             result = new PropositionResult(blockingHolds.isEmpty());
 66  
         }
 67  
 
 68  0
         environment.getEngineResults().addResult(new BasicResult(ResultEvent.PROPOSITION_EVALUATED, this, environment, result.getResult()));
 69  
 
 70  0
         return result;
 71  
     }
 72  
 }