001: /*
002: * Copyright 2005-2006 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.clientapp.vo;
018:
019: import java.util.ArrayList;
020: import java.util.Arrays;
021: import java.util.HashMap;
022: import java.util.List;
023: import java.util.Map;
024:
025: /**
026: * Defines a remote WorkflowAttribute and how to construct it. This is to be used when
027: * the attributes are being hosted remotely inside the Workflow runtime.
028: *
029: * The attribute definition must be constructed with the fully qualified class name of the
030: * target attribute. It can be constructed one of two ways, through the constructor of the
031: * attribute or by setting java bean properties. If both are specified, then the attribute
032: * will be constructed using both the constructor and properties. If no constructor
033: * parameters are specified the target attribute must have a no-argument public constructor.
034: *
035: * The "properties" represented by the PropertyDefinitionVOs will be set as bean properties
036: * (setters) on the target attribute class. The standard KSB resource/object-definition loading
037: * mechanism implements this functionality. If the attribute is a GenericXMLRuleAttribute
038: * or GenerixXMLSearchableAttribute, then the properties will also be set explicitly in the <code>paramMap</code>
039: * by the workflow server.
040: *
041: * @author ewestfal
042: *
043: * @workflow.webservice-object
044: */
045: public class WorkflowAttributeDefinitionVO implements
046: java.io.Serializable {
047:
048: static final long serialVersionUID = 1000;
049: private String attributeName;
050: private List<String> constructorParameters = new ArrayList<String>();
051: private Map<String, PropertyDefinitionVO> properties = new HashMap<String, PropertyDefinitionVO>();
052:
053: public WorkflowAttributeDefinitionVO() {
054: }
055:
056: public WorkflowAttributeDefinitionVO(String attributeName) {
057: setAttributeName(attributeName);
058: }
059:
060: public String getAttributeName() {
061: return attributeName;
062: }
063:
064: public void setAttributeName(String attributeName) {
065: if (attributeName == null)
066: throw new IllegalArgumentException(
067: "Attribute name cannot be null");
068: this .attributeName = attributeName;
069: }
070:
071: public void addConstructorParameter(String parameter) {
072: constructorParameters.add(parameter);
073: }
074:
075: public void removeConstructorParameter(String parameter) {
076: constructorParameters.remove(parameter);
077: }
078:
079: public void setConstructorParameters(String[] parameters) {
080: constructorParameters = Arrays.asList(parameters);
081: }
082:
083: public String[] getConstructorParameters() {
084: return (String[]) constructorParameters.toArray(new String[0]);
085: }
086:
087: public void addProperty(PropertyDefinitionVO property) {
088: if (property == null)
089: return;
090: if (property.getName() == null) {
091: throw new IllegalArgumentException(
092: "PropertyDefinition cannot have a null name.");
093: }
094: properties.put(property.getName(), property);
095: }
096:
097: public PropertyDefinitionVO getProperty(String name) {
098: return (PropertyDefinitionVO) properties.get(name);
099: }
100:
101: public PropertyDefinitionVO[] getProperties() {
102: return (PropertyDefinitionVO[]) properties.values().toArray(
103: new PropertyDefinitionVO[0]);
104: }
105:
106: public void setProperties(PropertyDefinitionVO[] properties) {
107: this .properties.clear();
108: if (properties == null)
109: return;
110: for (int index = 0; index < properties.length; index++) {
111: addProperty(properties[index]);
112: }
113: }
114:
115: public void addProperty(String name, String value) {
116: addProperty(new PropertyDefinitionVO(name, value));
117: }
118: }
|