1 package org.kuali.ole.select.executor;
2
3 import org.kuali.ole.OLEConstants;
4 import org.kuali.rice.kew.engine.RouteContext;
5 import org.kuali.rice.kew.framework.support.krms.RulesEngineExecutor;
6 import org.kuali.rice.krms.api.engine.*;
7
8 import java.util.HashMap;
9 import java.util.Map;
10
11
12
13
14
15
16
17
18 public class OLEEResourceRulesEngineExecutor implements RulesEngineExecutor {
19 private static final String CONTEXT_NAMESPACE_CODE = OLEConstants.OLE_NAMESPACE;
20 private static final String CONTEXT_NAME = "EResource Approval";
21 private static final String EVENT_NAME = "EResource Approval";
22
23 @Override
24 public EngineResults execute(RouteContext routeContext, Engine engine) {
25
26 ExecutionOptions executionOptions = new ExecutionOptions();
27 executionOptions.setFlag(ExecutionFlag.LOG_EXECUTION, true);
28 Map<String, String> contextQualifiers = new HashMap<String, String>();
29 contextQualifiers.put("namespaceCode", CONTEXT_NAMESPACE_CODE);
30 contextQualifiers.put("name", "OLE-CONTEXT");
31 Facts.Builder factsBuilder = Facts.Builder.create();
32 SelectionCriteria sectionCriteria = SelectionCriteria.createCriteria(null, contextQualifiers,
33 getAgendaContext(CONTEXT_NAME));
34
35 factsBuilder.addFact("eresourceApproval", "true");
36 return engine.execute(sectionCriteria, factsBuilder.build(), executionOptions);
37 }
38
39
40
41
42
43
44
45 protected Map<String, String> getAgendaContext(String agendaName) {
46 Map<String, String> selector = new HashMap<String, String>();
47 selector.put(OLEConstants.NAME, agendaName);
48 return selector;
49 }
50 }