1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.routemodule.service.impl;
17
18 import org.kuali.rice.kew.engine.simulation.SimulationCriteria;
19 import org.kuali.rice.kew.engine.simulation.SimulationResults;
20 import org.kuali.rice.kew.engine.simulation.SimulationWorkflowEngine;
21 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
22 import org.kuali.rice.kew.routemodule.service.RoutingReportService;
23 import org.kuali.rice.kew.service.KEWServiceLocator;
24
25
26 public class RoutingReportServiceImpl implements RoutingReportService {
27
28 public DocumentRouteHeaderValue report(SimulationCriteria criteria) {
29 try {
30 SimulationWorkflowEngine simulationEngine = KEWServiceLocator.getSimulationEngine();
31 SimulationResults results = simulationEngine.runSimulation(criteria);
32 return materializeDocument(results);
33 } catch (Exception e) {
34 if (e instanceof RuntimeException) {
35 throw (RuntimeException)e;
36 }
37 throw new IllegalStateException("Problem running report: " + e.getMessage(), e);
38 }
39 }
40
41
42
43
44 private DocumentRouteHeaderValue materializeDocument(SimulationResults results) {
45 DocumentRouteHeaderValue document = results.getDocument();
46
47 document.getSimulatedActionRequests().addAll(results.getSimulatedActionRequests());
48 return document;
49
50 }
51 }