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.uif.RemotableAttributeError;
21  import org.kuali.rice.core.api.util.xml.XmlHelper;
22  import org.kuali.rice.kew.routeheader.DocumentContent;
23  
24  import java.io.StringReader;
25  import java.util.ArrayList;
26  import java.util.Collection;
27  import java.util.List;
28  import java.util.Map;
29  
30  
31  /**
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class MockWorkflowAttribute implements WorkflowRuleAttribute {
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              Collection<Element> elements = XmlHelper.findElements(doc.getRootElement(), MOCK_VALUE_ELEMENT);
56              Element mockValueElement = elements.iterator().next();
57              List attributes = new ArrayList();
58              if (mockValueElement != null) {
59                  attributes.add(new MockWorkflowAttribute(mockValueElement.getText()));
60              }
61              return attributes;
62          } catch (Exception e) {
63              throw new RuntimeException(e);
64          }
65      }
66      
67      public String getIdFieldName() {
68          return null;
69      }
70      public String getLockFieldName() {
71          return null;
72      }
73      public List getRoutingDataRows() {
74          return null;
75      }
76      public List getRuleExtensionValues() {
77          return null;
78      }
79      public List getRuleRows() {
80          return null;
81      }
82      public boolean isMatch(DocumentContent docContent, List ruleExtensions) {
83          return false;
84      }
85      public boolean isRequired() {
86          return false;
87      }
88      
89      public void setRequired(boolean required) {
90      }
91      public List<RemotableAttributeError> validateRoutingData(Map paramMap) {
92          return null;
93      }
94      public List<RemotableAttributeError> validateRuleData(Map paramMap) {
95          return null;
96      }
97      
98      public String getValue() {
99          return value;
100     }
101     
102     public void setValue(String value) {
103         this.value = value;
104     }
105     
106     
107 }