1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.dto;
18
19 import java.io.Serializable;
20 import java.util.ArrayList;
21 import java.util.Arrays;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 public class WorkflowAttributeDefinitionDTO implements Serializable {
45
46 static final long serialVersionUID = 1000;
47 private String attributeName;
48 private List<String> constructorParameters = new ArrayList<String>();
49 private Map<String, PropertyDefinitionDTO> properties = new HashMap<String, PropertyDefinitionDTO>();
50
51 public WorkflowAttributeDefinitionDTO() {}
52
53 public WorkflowAttributeDefinitionDTO(String attributeName) {
54 setAttributeName(attributeName);
55 }
56
57 public String getAttributeName() {
58 return attributeName;
59 }
60
61 public void setAttributeName(String attributeName) {
62 if (attributeName == null) throw new IllegalArgumentException("Attribute name cannot be null");
63 this.attributeName = attributeName;
64 }
65
66 public void addConstructorParameter(String parameter) {
67 constructorParameters.add(parameter);
68 }
69
70 public void removeConstructorParameter(String parameter) {
71 constructorParameters.remove(parameter);
72 }
73
74 public void setConstructorParameters(String[] parameters) {
75 constructorParameters = Arrays.asList(parameters);
76 }
77
78 public String[] getConstructorParameters() {
79 return (String[])constructorParameters.toArray(new String[0]);
80 }
81
82 public void addProperty(PropertyDefinitionDTO property) {
83 if (property == null) return;
84 if (property.getName() == null) {
85 throw new IllegalArgumentException("PropertyDefinition cannot have a null name.");
86 }
87 properties.put(property.getName(), property);
88 }
89
90 public PropertyDefinitionDTO getProperty(String name) {
91 return (PropertyDefinitionDTO)properties.get(name);
92 }
93
94 public PropertyDefinitionDTO[] getProperties() {
95 return (PropertyDefinitionDTO[])properties.values().toArray(new PropertyDefinitionDTO[0]);
96 }
97
98 public void setProperties(PropertyDefinitionDTO[] properties) {
99 this.properties.clear();
100 if (properties == null) return;
101 for (int index = 0; index < properties.length; index++) {
102 addProperty(properties[index]);
103 }
104 }
105
106 public void addProperty(String name, String value) {
107 addProperty(new PropertyDefinitionDTO(name, value));
108 }
109 }