001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.routetemplate;
018:
019: import java.io.StringReader;
020: import java.util.ArrayList;
021: import java.util.List;
022: import java.util.Map;
023:
024: import org.jdom.Document;
025: import org.jdom.Element;
026:
027: import edu.iu.uis.eden.plugin.attributes.WorkflowAttribute;
028: import edu.iu.uis.eden.routeheader.DocumentContent;
029: import edu.iu.uis.eden.util.XmlHelper;
030:
031: /**
032: * @author ewestfal
033: */
034: public class MockWorkflowAttribute implements WorkflowAttribute {
035:
036: private static final String MOCK_VALUE_ELEMENT = "mockValue";
037: //private static final String VALUE_KEY = "value";
038:
039: private String value;
040:
041: public MockWorkflowAttribute() {
042: }
043:
044: public MockWorkflowAttribute(String value) {
045: setValue(value);
046: }
047:
048: public String getDocContent() {
049: if (value == null)
050: return "";
051: return "<" + MOCK_VALUE_ELEMENT + ">" + value + "</"
052: + MOCK_VALUE_ELEMENT + ">";
053: }
054:
055: public List parseDocContent(String docContent) {
056: try {
057: Document doc = XmlHelper.buildJDocument(new StringReader(
058: docContent));
059: Element mockValueElement = XmlHelper.findElement(doc
060: .getRootElement(), MOCK_VALUE_ELEMENT);
061: List attributes = new ArrayList();
062: if (mockValueElement != null) {
063: attributes.add(new MockWorkflowAttribute(
064: mockValueElement.getText()));
065: }
066: return attributes;
067: } catch (Exception e) {
068: throw new RuntimeException(e);
069: }
070: }
071:
072: public String getIdFieldName() {
073: return null;
074: }
075:
076: public String getLockFieldName() {
077: return null;
078: }
079:
080: public List getRoutingDataRows() {
081: return null;
082: }
083:
084: public List getRuleExtensionValues() {
085: return null;
086: }
087:
088: public List getRuleRows() {
089: return null;
090: }
091:
092: public boolean isMatch(DocumentContent docContent,
093: List ruleExtensions) {
094: return false;
095: }
096:
097: public boolean isRequired() {
098: return false;
099: }
100:
101: public void setRequired(boolean required) {
102: }
103:
104: public List validateRoutingData(Map paramMap) {
105: return null;
106: }
107:
108: public List validateRuleData(Map paramMap) {
109: return null;
110: }
111:
112: public String getValue() {
113: return value;
114: }
115:
116: public void setValue(String value) {
117: this.value = value;
118: }
119:
120: }
|