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