View Javadoc

1   /*
2    * Copyright 2005-2008 The Kuali Foundation
3    * 
4    * 
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    * http://www.opensource.org/licenses/ecl2.php
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.kuali.rice.kew.rule;
18  
19  import java.io.StringReader;
20  import java.util.ArrayList;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.jdom.Document;
25  import org.jdom.Element;
26  import org.kuali.rice.kew.routeheader.DocumentContent;
27  import org.kuali.rice.kew.rule.WorkflowAttribute;
28  import org.kuali.rice.kew.util.XmlHelper;
29  
30  
31  /**
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class MockWorkflowAttribute implements WorkflowAttribute {
35      
36      private static final String MOCK_VALUE_ELEMENT = "mockValue";
37      //private static final String VALUE_KEY = "value";
38      
39      private String value;
40      
41      public MockWorkflowAttribute() {}
42      
43      public MockWorkflowAttribute(String value) {
44          setValue(value);
45      }
46  
47      public String getDocContent() {
48          if (value == null) return "";
49          return "<"+MOCK_VALUE_ELEMENT+">"+value+"</"+MOCK_VALUE_ELEMENT+">";
50      }
51      
52      public List parseDocContent(String docContent) {
53          try {
54              Document doc = XmlHelper.buildJDocument(new StringReader(docContent));
55              Element mockValueElement = XmlHelper.findElement(doc.getRootElement(), MOCK_VALUE_ELEMENT);
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 }