1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.time.krms;
17
18 import org.kuali.kpme.core.KPMENamespace;
19 import org.kuali.kpme.core.krms.KPMERulesEngineExecuter;
20 import org.kuali.kpme.core.krms.KpmeKrmsFactBuilderService;
21 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
22 import org.kuali.rice.kew.engine.RouteContext;
23 import org.kuali.rice.krms.api.engine.Engine;
24 import org.kuali.rice.krms.api.engine.EngineResults;
25 import org.kuali.rice.krms.api.engine.Facts;
26 import org.kuali.rice.krms.api.engine.SelectionCriteria;
27
28 import java.util.Collections;
29 import java.util.HashMap;
30 import java.util.Map;
31
32
33 public class TkRulesEngineExecutor extends KPMERulesEngineExecuter {
34 private final static String TK_TIMESHEET_CONTEXT = "KPME-TK-Context";
35
36 @Override
37 protected EngineResults performExecute(RouteContext routeContext, Engine engine) {
38 Map<String, String> contextQualifiers = new HashMap<String, String>();
39 contextQualifiers.put("namespaceCode", KPMENamespace.KPME_TK.getNamespaceCode());
40 contextQualifiers.put("name", TK_TIMESHEET_CONTEXT);
41
42
43 String docContent = routeContext.getDocument().getDocContent();
44 String unitNumber = getElementValue(docContent, "//document/coiDisclosureList[1]/org.kuali.kra.coi.CoiDisclosure[1]/disclosurePersons[1]/org.kuali.kra.coi.disclosure.DisclosurePerson[1]/disclosurePersonUnits[1]/org.kuali.kra.coi.disclosure.DisclosurePersonUnit[1]/unitNumber[1]");
45
46 SelectionCriteria selectionCriteria = SelectionCriteria.createCriteria(null, contextQualifiers,
47 Collections.singletonMap("Unit Number", unitNumber));
48
49
50 Facts.Builder factsBuilder = Facts.Builder.create();
51
52 EngineResults results = engine.execute(selectionCriteria, factsBuilder.build(), null);
53 return results;
54 }
55 }