1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.engine.transition;
18
19 import org.jdom.Document;
20 import org.kuali.rice.kew.engine.RouteContext;
21 import org.kuali.rice.kew.engine.node.ProcessResult;
22 import org.kuali.rice.kew.engine.node.RouteNode;
23 import org.kuali.rice.kew.engine.node.RouteNodeInstance;
24 import org.kuali.rice.kew.engine.node.SimpleResult;
25 import org.kuali.rice.kew.exception.InvalidXmlException;
26 import org.kuali.rice.kew.exception.WorkflowRuntimeException;
27 import org.kuali.rice.kew.util.XmlHelper;
28
29 import java.io.StringReader;
30 import java.util.ArrayList;
31 import java.util.List;
32
33
34
35
36
37
38
39 public class LoopTransitionEngine extends TransitionEngine {
40
41 @Override
42 public ProcessResult isComplete(RouteContext context) throws Exception {
43 return new SimpleResult(true);
44 }
45
46
47
48
49
50
51 protected List<RouteNodeInstance> resolveNextNodeInstances(RouteNodeInstance nodeInstance, List<RouteNode> nextRouteNodes) {
52
53 try {
54 Document doc = XmlHelper.buildJDocument(new StringReader(nodeInstance.getRouteNode().getContentFragment()));
55
56
57 } catch (InvalidXmlException e) {
58 throw new WorkflowRuntimeException(e);
59 }
60
61
62 List<RouteNodeInstance> nextNodeInstances = new ArrayList<RouteNodeInstance>();
63 for (RouteNode nextRouteNode : nextRouteNodes)
64 {
65 RouteNodeInstance nextNodeInstance = getRouteHelper().getNodeFactory().createRouteNodeInstance(nodeInstance.getDocumentId(), nextRouteNode);
66 nextNodeInstance.setBranch(nodeInstance.getBranch());
67 nextNodeInstance.setProcess(nodeInstance.getProcess());
68 nextNodeInstances.add(nextNodeInstance);
69 }
70 return nextNodeInstances;
71 }
72
73 }