1 /**
2 * Copyright 2005-2012 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.krms.framework.engine;
17
18 import java.util.Map;
19
20 import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
21 import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition;
22
23 /**
24 * An implementation of {@link Agenda} that executes over an {@link AgendaTree}.
25 *
26 * @author Kuali Rice Team (rice.collab@kuali.org)
27 */
28
29 public class BasicAgenda implements Agenda {
30
31 private Map<String, String> qualifiers;
32 private AgendaTree agendaTree;
33
34 /**
35 * Create a BasicAgenda with the given qualifiers and {@link AgendaTree}
36 * @param qualifiers to determine if a given {@link ExecutionEnvironment} applies.
37 * @param agendaTree {@link AgendaTree} to be executed
38 */
39 public BasicAgenda(Map<String, String> qualifiers, AgendaTree agendaTree) {
40 this.qualifiers = qualifiers;
41 this.agendaTree = agendaTree;
42 }
43
44 @Override
45 public void execute(ExecutionEnvironment environment) {
46 agendaTree.execute(environment);
47 }
48
49 @Override
50 public boolean appliesTo(ExecutionEnvironment environment) {
51
52 for (Map.Entry<String, String> agendaQualifier : environment.getSelectionCriteria().getAgendaQualifiers().entrySet()) {
53 String agendaQualifierValue = qualifiers.get(agendaQualifier.getKey());
54 String environmentQualifierValue = agendaQualifier.getValue();
55 if (!environmentQualifierValue.equals(agendaQualifierValue)) {
56 return false;
57 }
58 }
59 return true;
60 }
61
62 }