View Javadoc

1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  public class MockWorkflowAttribute implements WorkflowRuleAttribute {
34      
35      private static final String MOCK_VALUE_ELEMENT = "mockValue";
36      //private static final String VALUE_KEY = "value";
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 }