Coverage Report - org.kuali.student.r2.core.class1.process.krms.termresolver.MilestoneResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
MilestoneResolver
0%
0/21
N/A
3
 
 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.Map;
 20  
 import java.util.Set;
 21  
 
 22  
 import org.kuali.rice.krms.api.engine.TermResolutionException;
 23  
 import org.kuali.rice.krms.api.engine.TermResolver;
 24  
 import org.kuali.student.common.util.krms.RulesExecutionConstants;
 25  
 import org.kuali.student.r2.common.dto.ContextInfo;
 26  
 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
 27  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 28  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 29  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 30  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 31  
 import org.kuali.student.r2.core.atp.dto.MilestoneInfo;
 32  
 import org.kuali.student.r2.core.atp.service.AtpService;
 33  
 
 34  
 /**
 35  
  * Created by IntelliJ IDEA.
 36  
  * User: andy
 37  
  * Date: 12/21/11
 38  
  * Time: 12:12 PM
 39  
  * To change this template use File | Settings | File Templates.
 40  
  */
 41  0
 public class MilestoneResolver implements TermResolver<MilestoneInfo> {
 42  
     private AtpService atpService;
 43  
 
 44  
     @Override
 45  
     public Set<String> getPrerequisites() {
 46  0
         return Collections.singleton(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME);
 47  
     }
 48  
 
 49  
     @Override
 50  
     public String getOutput() {
 51  0
         return RulesExecutionConstants.MILESTONE_TERM_NAME;
 52  
     }
 53  
 
 54  
     @Override
 55  
     public Set<String> getParameterNames() {
 56  0
         return Collections.singleton(RulesExecutionConstants.MILESTONE_ID_TERM_PROPERTY);
 57  
     }
 58  
 
 59  
     @Override
 60  
     public int getCost() {
 61  
         // TODO Analyze
 62  0
         return 0;
 63  
     }
 64  
 
 65  
     @Override
 66  
     public MilestoneInfo resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException {
 67  
 
 68  0
         String milestoneId = parameters.get(RulesExecutionConstants.MILESTONE_ID_TERM_PROPERTY);
 69  0
         ContextInfo context = (ContextInfo) resolvedPrereqs.get(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME);
 70  
 
 71  0
         MilestoneInfo result = null;
 72  
         try {
 73  0
             result = atpService.getMilestone(milestoneId, context);
 74  0
         } catch (DoesNotExistException e) {
 75  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 76  0
         } catch (InvalidParameterException e) {
 77  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 78  0
         } catch (MissingParameterException e) {
 79  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 80  0
         } catch (OperationFailedException e) {
 81  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 82  0
         } catch (PermissionDeniedException e) {
 83  0
             throw new TermResolutionException(e.getMessage(), this, parameters);
 84  0
         }
 85  
 
 86  0
         return result;
 87  
     }
 88  
 }