View Javadoc

1   package org.kuali.rice.krms.framework.engine;
2   
3   import java.util.Map;
4   
5   import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
6   import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition;
7   
8   public class BasicAgenda implements Agenda {
9   
10  	private String eventName;
11  	private Map<String, String> qualifiers;
12  	private AgendaTree agendaTree;
13  	
14  	public BasicAgenda(String eventName, Map<String, String> qualifiers, AgendaTree agendaTree) {
15  		this.eventName = eventName;
16  		this.qualifiers = qualifiers;
17  		this.agendaTree = agendaTree;
18  	}
19  	
20  	@Override
21  	public void execute(ExecutionEnvironment environment) {
22  		agendaTree.execute(environment);
23  	}
24  
25  	@Override
26  	public boolean appliesTo(ExecutionEnvironment environment) {
27  		if (eventName.equals(environment.getSelectionCriteria().getEventName())) {
28  			for (String agendaQualifierName : qualifiers.keySet()) {
29  			    // ignore the eventName qualifier, we've already matched it
30  			    if (agendaQualifierName.equals(AgendaDefinition.Constants.EVENT)) continue;
31  			    
32  				String qualifierValue = qualifiers.get(agendaQualifierName);
33  				String environmentQualifierValue = environment.getSelectionCriteria().getAgendaQualifiers().get(agendaQualifierName);
34  				if (!qualifierValue.equals(environmentQualifierValue)) {
35  					return false;
36  				}
37  			}
38  		} else {
39  			return false;
40  		}
41  		return true;
42  	}
43  
44  }