Coverage Report - org.kuali.rice.krms.framework.engine.BasicContext
 
Classes in this File Line Coverage Branch Coverage Complexity
BasicContext
93%
15/16
80%
8/10
2.25
 
 1  
 package org.kuali.rice.krms.framework.engine;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.Collections;
 5  
 import java.util.List;
 6  
 
 7  
 import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
 8  
 import org.kuali.rice.krms.api.engine.TermResolver;
 9  
 
 10  
 public final class BasicContext implements Context {
 11  
         
 12  
         private final List<Agenda> agendas;
 13  
         private final List<TermResolver<?>> termResolvers;
 14  
         
 15  29
         public BasicContext(List<Agenda> agendas, List<TermResolver<?>> termResolvers) {
 16  29
                 this.agendas = agendas;
 17  29
                 this.termResolvers = termResolvers;
 18  29
         }
 19  
         
 20  
         @Override
 21  
         public void execute(ExecutionEnvironment environment) {
 22  29
                 if (termResolvers != null) for (TermResolver<?> termResolver : termResolvers) {
 23  29
                         environment.addTermResolver(termResolver);
 24  
                 }
 25  29
                 List<Agenda> matchingAgendas = findMatchingAgendas(environment);
 26  29
                 for (Agenda matchingAgenda : matchingAgendas) {
 27  29
                         matchingAgenda.execute(environment);
 28  
                 }
 29  29
         }
 30  
         
 31  
         private List<Agenda> findMatchingAgendas(ExecutionEnvironment environment) {
 32  29
                 List<Agenda> matchingAgendas = new ArrayList<Agenda>();
 33  29
                 for (Agenda agenda : agendas) {
 34  29
                         if (agenda.appliesTo(environment)) {
 35  29
                                 matchingAgendas.add(agenda);
 36  
                         }
 37  
                 }
 38  29
                 return matchingAgendas;
 39  
         }
 40  
         
 41  
         public List<TermResolver<?>> getTermResolvers() {
 42  0
                 return Collections.unmodifiableList(termResolvers);
 43  
         }
 44  
 
 45  
 }