Coverage Report - org.kuali.student.process.poc.krms.termresolver.SummerOnlyStudentTermResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
SummerOnlyStudentTermResolver
0%
0/30
N/A
2.429
 
 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.process.poc.krms.termresolver;
 17  
 
 18  
 import org.kuali.rice.krms.api.engine.TermResolutionException;
 19  
 import org.kuali.rice.krms.api.engine.TermResolver;
 20  
 import org.kuali.student.common.util.krms.RulesExecutionConstants;
 21  
 import org.kuali.student.r2.common.dto.ContextInfo;
 22  
 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
 23  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 24  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 25  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 26  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 27  
 import org.kuali.student.r2.core.population.service.PopulationService;
 28  
 
 29  
 import java.util.Collections;
 30  
 import java.util.HashSet;
 31  
 import java.util.Map;
 32  
 import java.util.Set;
 33  
 
 34  
 /**
 35  
  * This class resolves the term of determining if the student is only registered in the summer term
 36  
  *
 37  
  * @author alubbers
 38  
  */
 39  0
 public class SummerOnlyStudentTermResolver implements TermResolver<Boolean> {
 40  
 
 41  
     private PopulationService populationService;
 42  
 
 43  0
     private final static Set<String> prerequisites = new HashSet<String>(2);
 44  
     private final String summerPopulationKey;
 45  
 
 46  
     static {
 47  0
         prerequisites.add(RulesExecutionConstants.STUDENT_ID_TERM_NAME);
 48  0
         prerequisites.add(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME);
 49  0
     }
 50  
 
 51  0
     public SummerOnlyStudentTermResolver(String summerPopulationKey) {
 52  0
         this.summerPopulationKey = summerPopulationKey;
 53  0
     }
 54  
 
 55  
     public void setPopulationService(PopulationService populationService) {
 56  0
         this.populationService = populationService;
 57  0
     }
 58  
 
 59  
     @Override
 60  
     public Set<String> getPrerequisites() {
 61  0
         return prerequisites;
 62  
     }
 63  
 
 64  
     @Override
 65  
     public String getOutput() {
 66  0
         return RulesExecutionConstants.SUMMER_ONLY_STUDENT_TERM_NAME;
 67  
     }
 68  
 
 69  
     @Override
 70  
     public Set<String> getParameterNames() {
 71  0
         return Collections.emptySet();
 72  
     }
 73  
 
 74  
     @Override
 75  
     public int getCost() {
 76  
         // TODO Analyze
 77  0
         return 0;
 78  
     }
 79  
 
 80  
     @Override
 81  
     public Boolean resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException {
 82  
 
 83  0
         Boolean result = false;
 84  
 
 85  0
         String studentId = (String) resolvedPrereqs.get(RulesExecutionConstants.STUDENT_ID_TERM_NAME);
 86  0
         ContextInfo context = (ContextInfo) resolvedPrereqs.get(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME);
 87  
 
 88  
         try {
 89  0
             result = populationService.isMember(studentId, summerPopulationKey, context);
 90  0
         } catch (DoesNotExistException e) {
 91  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 92  0
         } catch (InvalidParameterException e) {
 93  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 94  0
         } catch (MissingParameterException e) {
 95  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 96  0
         } catch (OperationFailedException e) {
 97  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 98  0
         } catch (PermissionDeniedException e) {
 99  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 100  0
         }
 101  
 
 102  0
         return result;
 103  
     }
 104  
 }