1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.time.timesheet.rules;
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.core.service.HrServiceLocator;
22 import org.kuali.kpme.tklm.common.krms.TklmKrmsConstants;
23 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
24 import org.kuali.kpme.tklm.time.timesheet.TimesheetDocument;
25 import org.kuali.rice.kew.engine.RouteContext;
26 import org.kuali.rice.krms.api.engine.Engine;
27 import org.kuali.rice.krms.api.engine.EngineResults;
28 import org.kuali.rice.krms.api.engine.Facts;
29 import org.kuali.rice.krms.api.engine.SelectionCriteria;
30
31 import java.util.HashMap;
32 import java.util.Map;
33
34
35 public class TimesheetRulesEngineExecutor extends KPMERulesEngineExecuter {
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", TklmKrmsConstants.Calendar.KPME_TIMESHEET_CONTEXT_NAME);
41
42
43 String docContent = routeContext.getDocument().getDocContent();
44
45 SelectionCriteria selectionCriteria = SelectionCriteria.createCriteria(null, contextQualifiers,
46 new HashMap<String, String>());
47
48
49 TimesheetDocument td = TkServiceLocator.getTimesheetService().getTimesheetDocument(routeContext.getDocument().getDocumentId());
50 KpmeKrmsFactBuilderService fbService = HrServiceLocator.getService("calendarDocumentFactBuilderService");
51 Facts.Builder factsBuilder = Facts.Builder.create();
52 fbService.addFacts(factsBuilder, td, TklmKrmsConstants.Calendar.KPME_TIMESHEET_CONTEXT_NAME, KPMENamespace.KPME_TK.getNamespaceCode());
53 EngineResults results = engine.execute(selectionCriteria, factsBuilder.build(), null);
54 return results;
55 }
56 }