Coverage Report - org.kuali.student.r2.core.class1.process.krms.termresolver.RegistrationHoldsTermResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
RegistrationHoldsTermResolver
0%
0/25
N/A
2.333
 
 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.r2.core.class1.process.krms.termresolver;
 17  
 
 18  
 import java.util.Collections;
 19  
 import java.util.HashSet;
 20  
 import java.util.List;
 21  
 import java.util.Map;
 22  
 import java.util.Set;
 23  
 
 24  
 import org.kuali.rice.krms.api.engine.TermResolutionException;
 25  
 import org.kuali.rice.krms.api.engine.TermResolver;
 26  
 import org.kuali.student.common.util.krms.RulesExecutionConstants;
 27  
 import org.kuali.student.r2.common.dto.ContextInfo;
 28  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 29  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 30  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 31  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 32  
 import org.kuali.student.r2.core.hold.dto.HoldInfo;
 33  
 import org.kuali.student.r2.core.hold.service.HoldService;
 34  
 
 35  
 /**
 36  
  * Created by IntelliJ IDEA.
 37  
  * User: andy
 38  
  * Date: 12/13/11
 39  
  * Time: 4:01 PM
 40  
  * To change this template use File | Settings | File Templates.
 41  
  */
 42  0
 public class RegistrationHoldsTermResolver implements TermResolver<List<HoldInfo>> {
 43  
 
 44  
     private HoldService holdService;
 45  
 
 46  0
     private final static Set<String> prerequisites = new HashSet<String>(2);
 47  
 
 48  
     static {
 49  0
         prerequisites.add(RulesExecutionConstants.STUDENT_ID_TERM_NAME);
 50  0
         prerequisites.add(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME);
 51  0
     }
 52  
 
 53  
     public void setHoldService(HoldService holdService) {
 54  0
         this.holdService = holdService;
 55  0
     }
 56  
 
 57  
     @Override
 58  
     public Set<String> getPrerequisites() {
 59  0
         return prerequisites;
 60  
     }
 61  
 
 62  
     @Override
 63  
     public String getOutput() {
 64  0
         return RulesExecutionConstants.STUDENT_REGISTRATION_HOLDS_TERM_NAME;
 65  
     }
 66  
 
 67  
     @Override
 68  
     public Set<String> getParameterNames() {
 69  0
         return Collections.singleton(RulesExecutionConstants.ISSUE_KEY_TERM_PROPERTY);
 70  
     }
 71  
 
 72  
     @Override
 73  
     public int getCost() {
 74  
         // TODO Analyze
 75  0
         return 0;
 76  
     }
 77  
 
 78  
     @Override
 79  
     public List<HoldInfo> resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException {
 80  0
         String studentId = (String) resolvedPrereqs.get(RulesExecutionConstants.STUDENT_ID_TERM_NAME);
 81  0
         ContextInfo context = (ContextInfo) resolvedPrereqs.get(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME);
 82  0
         String issueId = parameters.get(RulesExecutionConstants.ISSUE_KEY_TERM_PROPERTY);
 83  
 
 84  
         List<HoldInfo> studentHolds;
 85  
 
 86  
         // get all the active holds for the student and the given issue
 87  
         try {
 88  0
             studentHolds = holdService.getActiveHoldsByIssueAndPerson(issueId, studentId, context);
 89  0
         } catch (InvalidParameterException e) {
 90  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 91  0
         } catch (MissingParameterException e) {
 92  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 93  0
         } catch (OperationFailedException e) {
 94  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 95  0
         } catch (PermissionDeniedException e) {
 96  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 97  0
         }
 98  
 
 99  0
         return studentHolds;
 100  
     }
 101  
 }