1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.framework.document.search; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.core.api.CoreConstants; |
20 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
21 | |
import org.kuali.rice.core.api.uif.RemotableAttributeField; |
22 | |
import org.w3c.dom.Element; |
23 | |
|
24 | |
import javax.xml.bind.annotation.XmlAccessType; |
25 | |
import javax.xml.bind.annotation.XmlAccessorType; |
26 | |
import javax.xml.bind.annotation.XmlAnyElement; |
27 | |
import javax.xml.bind.annotation.XmlElement; |
28 | |
import javax.xml.bind.annotation.XmlElementWrapper; |
29 | |
import javax.xml.bind.annotation.XmlRootElement; |
30 | |
import javax.xml.bind.annotation.XmlType; |
31 | |
import java.util.ArrayList; |
32 | |
import java.util.Collection; |
33 | |
import java.util.Collections; |
34 | |
import java.util.List; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
@XmlRootElement(name = AttributeFields.Constants.ROOT_ELEMENT_NAME) |
47 | |
@XmlAccessorType(XmlAccessType.NONE) |
48 | |
@XmlType(name = AttributeFields.Constants.TYPE_NAME, propOrder = { |
49 | |
AttributeFields.Elements.ATTRIBUTE_NAME, |
50 | |
AttributeFields.Elements.REMOTABLE_ATTRIBUTE_FIELDS, |
51 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
52 | |
}) |
53 | |
public final class AttributeFields extends AbstractDataTransferObject { |
54 | |
|
55 | |
@XmlElement(name = Elements.ATTRIBUTE_NAME, required = true) |
56 | |
private final String attributeName; |
57 | |
|
58 | |
@XmlElementWrapper(name = Elements.REMOTABLE_ATTRIBUTE_FIELDS, required = true) |
59 | |
@XmlElement(name = Elements.REMOTABLE_ATTRIBUTE_FIELD, required = false) |
60 | |
private final List<RemotableAttributeField> remotableAttributeFields; |
61 | |
|
62 | 0 | @SuppressWarnings("unused") |
63 | |
@XmlAnyElement |
64 | |
private final Collection<Element> _futureElements = null; |
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
@SuppressWarnings("unused") |
70 | 0 | private AttributeFields() { |
71 | 0 | this.attributeName = null; |
72 | 0 | this.remotableAttributeFields = null; |
73 | 0 | } |
74 | |
|
75 | 0 | private AttributeFields(String attributeName, List<RemotableAttributeField> remotableAttributeFields) { |
76 | 0 | if (StringUtils.isBlank(attributeName)) { |
77 | 0 | throw new IllegalArgumentException("attributeName was blank or null"); |
78 | |
} |
79 | 0 | if (remotableAttributeFields == null) { |
80 | 0 | throw new IllegalArgumentException("attributeFields was blank or null"); |
81 | |
} |
82 | 0 | this.attributeName = attributeName; |
83 | 0 | this.remotableAttributeFields = Collections.unmodifiableList(new ArrayList<RemotableAttributeField>(remotableAttributeFields)); |
84 | 0 | } |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
public static AttributeFields create(String attributeName, List<RemotableAttributeField> attributeFields) { |
97 | 0 | if (attributeFields == null) { |
98 | 0 | attributeFields = Collections.emptyList(); |
99 | |
} |
100 | 0 | return new AttributeFields(attributeName, attributeFields); |
101 | |
} |
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
public String getAttributeName() { |
110 | 0 | return attributeName; |
111 | |
} |
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
public List<RemotableAttributeField> getRemotableAttributeFields() { |
120 | 0 | return remotableAttributeFields; |
121 | |
} |
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | 0 | static class Constants { |
127 | |
final static String ROOT_ELEMENT_NAME = "attributeFields"; |
128 | |
final static String TYPE_NAME = "AttributeFieldsType"; |
129 | |
} |
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | 0 | static class Elements { |
135 | |
final static String ATTRIBUTE_NAME = "attributeName"; |
136 | |
final static String REMOTABLE_ATTRIBUTE_FIELDS = "remotableAttributeFields"; |
137 | |
final static String REMOTABLE_ATTRIBUTE_FIELD = "remotableAttributeField"; |
138 | |
} |
139 | |
|
140 | |
} |