Coverage Report - org.kuali.student.enrollment.class1.lu.termresolver.CourseSetResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseSetResolver
0%
0/23
0%
0/2
3.4
 
 1  
 package org.kuali.student.enrollment.class1.lu.termresolver;
 2  
 
 3  
 import org.kuali.rice.krms.api.engine.TermResolutionException;
 4  
 import org.kuali.rice.krms.api.engine.TermResolver;
 5  
 
 6  
 import org.kuali.student.common.util.krms.RulesExecutionConstants;
 7  
 import org.kuali.student.r2.common.dto.ContextInfo;
 8  
 import org.kuali.student.r2.lum.clu.service.CluService;
 9  
 
 10  
 import javax.annotation.Resource;
 11  
 import java.util.Collection;
 12  
 import java.util.Collections;
 13  
 import java.util.List;
 14  
 import java.util.Map;
 15  
 import java.util.Set;
 16  
 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
 17  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 18  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 19  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 20  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 21  
 
 22  0
 public class CourseSetResolver implements TermResolver<Collection<String>> {
 23  
 
 24  
     @Resource
 25  
     private CluService luService;
 26  
 
 27  
     @Override
 28  
     public Set<String> getPrerequisites() {
 29  0
         return Collections.singleton(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME);
 30  
     }
 31  
 
 32  
     @Override
 33  
     public String getOutput() {
 34  0
         return RulesExecutionConstants.COURSE_SET_TERM_NAME;
 35  
     }
 36  
 
 37  
     @Override
 38  
     public Set<String> getParameterNames() {
 39  0
         return Collections.singleton(RulesExecutionConstants.COURSE_SET_ID_TERM_PROPERTY);
 40  
     }
 41  
 
 42  
     @Override
 43  
     public int getCost() {
 44  
         // TODO analyze for a relevant cost
 45  0
         return 0;
 46  
     }
 47  
 
 48  
     @Override
 49  
     public Collection<String> resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException {
 50  0
         String courseSetId = parameters.get(RulesExecutionConstants.COURSE_SET_ID_TERM_PROPERTY);
 51  0
         ContextInfo context = (ContextInfo) resolvedPrereqs.get(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME);
 52  
         
 53  0
         if(courseSetId == null) {
 54  0
             throw new TermResolutionException("No parameter found with name: " + RulesExecutionConstants.COURSE_SET_ID_TERM_PROPERTY, this, parameters);
 55  
         }
 56  
 
 57  0
         List<String> results = null;
 58  
         try {
 59  0
             results = luService.getCluIdsFromCluSet(courseSetId, context);
 60  0
         } catch (DoesNotExistException e) {
 61  0
             throw new TermResolutionException("", this, parameters, e);
 62  0
         } catch (InvalidParameterException e) {
 63  0
             throw new TermResolutionException("", this, parameters, e);
 64  0
         } catch (MissingParameterException e) {
 65  0
             throw new TermResolutionException("", this, parameters, e);
 66  0
         } catch (OperationFailedException e) {
 67  0
             throw new TermResolutionException("", this, parameters, e);
 68  0
         } catch (PermissionDeniedException e) {
 69  0
             throw new TermResolutionException("", this, parameters, e);
 70  0
         }
 71  
 
 72  0
         return results;
 73  
         
 74  
     }
 75  
 
 76  
 }