1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.workflow;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.kuali.ole.sys.context.SpringContext;
22 import org.kuali.ole.sys.document.FinancialSystemDocument;
23 import org.kuali.ole.sys.document.FinancialSystemMaintenanceDocument;
24 import org.kuali.ole.sys.document.FinancialSystemTransactionalDocument;
25 import org.kuali.rice.kew.engine.RouteContext;
26 import org.kuali.rice.kew.engine.RouteHelper;
27 import org.kuali.rice.kew.engine.node.SplitNode;
28 import org.kuali.rice.kew.engine.node.SplitResult;
29 import org.kuali.rice.krad.document.Document;
30 import org.kuali.rice.krad.service.DocumentService;
31
32 public class SimpleBooleanSplitNode implements SplitNode {
33
34
35
36
37 @Override
38 public SplitResult process(RouteContext context, RouteHelper helper) throws Exception {
39 SplitResult result = null;
40 String documentID = context.getDocument().getDocumentId();
41 Document document = SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(documentID);
42 if (document instanceof FinancialSystemDocument) {
43 String nodeName = context.getNodeInstance().getRouteNode().getRouteNodeName();
44 boolean ret = ((FinancialSystemDocument)document).answerSplitNodeQuestion(nodeName);
45 result = booleanToSplitResult(ret);
46 } else {
47 throw new IllegalArgumentException("Document "+document.getDocumentTitle() +" with id " + documentID + " is not an instance of " + FinancialSystemMaintenanceDocument.class + " or " + FinancialSystemTransactionalDocument.class);
48 }
49
50 return result;
51 }
52
53
54
55
56
57
58 protected SplitResult booleanToSplitResult(boolean b) {
59 List<String> branches = new ArrayList<String>();
60 final String branchName = b ? "True" : "False";
61 branches.add(branchName);
62 return new SplitResult(branches);
63 }
64
65 }