1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.pm.workflow.krms;
17
18
19 import org.kuali.kpme.core.api.assignment.Assignable;
20 import org.kuali.kpme.core.api.namespace.KPMENamespace;
21 import org.kuali.kpme.core.krms.KPMERulesEngineExecuter;
22 import org.kuali.kpme.core.krms.KpmeKrmsFactBuilderService;
23 import org.kuali.kpme.core.service.HrServiceLocator;
24 import org.kuali.kpme.pm.api.common.krms.PmKrmsConstants;
25 import org.kuali.rice.kew.api.exception.WorkflowException;
26 import org.kuali.rice.kew.engine.RouteContext;
27 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
28 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
29 import org.kuali.rice.krms.api.engine.Engine;
30 import org.kuali.rice.krms.api.engine.EngineResults;
31 import org.kuali.rice.krms.api.engine.Facts;
32 import org.kuali.rice.krms.api.engine.SelectionCriteria;
33
34 import java.util.HashMap;
35 import java.util.Map;
36
37 public class PositionMaintDocRulesEngineExecutor extends KPMERulesEngineExecuter {
38
39
40 @Override
41 protected EngineResults performExecute(RouteContext routeContext, Engine engine) {
42 Map<String, String> contextQualifiers = new HashMap<String, String>();
43 contextQualifiers.put("namespaceCode", KPMENamespace.KPME_PM.getNamespaceCode());
44 contextQualifiers.put("name", PmKrmsConstants.Context.PM_CONTEXT_NAME);
45
46
47 String docContent = routeContext.getDocument().getDocContent();
48
49 SelectionCriteria selectionCriteria = SelectionCriteria.createCriteria(null, contextQualifiers,
50 new HashMap<String, String>());
51
52
53 String documentId = routeContext.getDocument().getDocumentId();
54 Object document = null;
55 try {
56 document = (MaintenanceDocument) KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(documentId);
57 } catch (WorkflowException e) {
58 e.printStackTrace();
59 }
60
61 KpmeKrmsFactBuilderService fbService = HrServiceLocator.getService("pmFactBuilderService");
62 Facts.Builder factsBuilder = Facts.Builder.create();
63
64 fbService.addFacts(factsBuilder, document, PmKrmsConstants.Context.PM_CONTEXT_NAME, KPMENamespace.KPME_PM.getNamespaceCode());
65 EngineResults results = engine.execute(selectionCriteria, factsBuilder.build(), null);
66 return results;
67 }
68 }