1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.rule;
17
18 import org.jdom.Document;
19 import org.jdom.Element;
20 import org.kuali.rice.core.api.util.xml.XmlHelper;
21 import org.kuali.rice.kew.routeheader.DocumentContent;
22
23 import java.io.StringReader;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.List;
27 import java.util.Map;
28
29
30
31
32
33 public class MockWorkflowAttribute implements WorkflowRuleAttribute {
34
35 private static final String MOCK_VALUE_ELEMENT = "mockValue";
36
37
38 private String value;
39
40 public MockWorkflowAttribute() {}
41
42 public MockWorkflowAttribute(String value) {
43 setValue(value);
44 }
45
46 public String getDocContent() {
47 if (value == null) return "";
48 return "<"+MOCK_VALUE_ELEMENT+">"+value+"</"+MOCK_VALUE_ELEMENT+">";
49 }
50
51 public List parseDocContent(String docContent) {
52 try {
53 Document doc = XmlHelper.buildJDocument(new StringReader(docContent));
54 Collection<Element> elements = XmlHelper.findElements(doc.getRootElement(), MOCK_VALUE_ELEMENT);
55 Element mockValueElement = elements.iterator().next();
56 List attributes = new ArrayList();
57 if (mockValueElement != null) {
58 attributes.add(new MockWorkflowAttribute(mockValueElement.getText()));
59 }
60 return attributes;
61 } catch (Exception e) {
62 throw new RuntimeException(e);
63 }
64 }
65
66 public String getIdFieldName() {
67 return null;
68 }
69 public String getLockFieldName() {
70 return null;
71 }
72 public List getRoutingDataRows() {
73 return null;
74 }
75 public List getRuleExtensionValues() {
76 return null;
77 }
78 public List getRuleRows() {
79 return null;
80 }
81 public boolean isMatch(DocumentContent docContent, List ruleExtensions) {
82 return false;
83 }
84 public boolean isRequired() {
85 return false;
86 }
87
88 public void setRequired(boolean required) {
89 }
90 public List validateRoutingData(Map paramMap) {
91 return null;
92 }
93 public List validateRuleData(Map paramMap) {
94 return null;
95 }
96
97 public String getValue() {
98 return value;
99 }
100
101 public void setValue(String value) {
102 this.value = value;
103 }
104
105
106 }