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.kuali.rice.core.api.CoreConstants;
19 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
20 import org.kuali.rice.core.api.mo.ModelBuilder;
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.io.Serializable;
32 import java.util.ArrayList;
33 import java.util.Collection;
34 import java.util.Collections;
35 import java.util.List;
36
37
38
39
40
41
42
43 @XmlRootElement(name = DocumentSearchCriteriaConfiguration.Constants.ROOT_ELEMENT_NAME)
44 @XmlAccessorType(XmlAccessType.NONE)
45 @XmlType(name = DocumentSearchCriteriaConfiguration.Constants.TYPE_NAME, propOrder = {
46 DocumentSearchCriteriaConfiguration.Elements.SEARCH_ATTRIBUTE_FIELDS,
47 CoreConstants.CommonElements.FUTURE_ELEMENTS
48 })
49 public final class DocumentSearchCriteriaConfiguration extends AbstractDataTransferObject implements DocumentSearchCriteriaConfigurationContract {
50
51 private static final long serialVersionUID = -5764134034667636217L;
52
53 @XmlElementWrapper(name = Elements.SEARCH_ATTRIBUTE_FIELDS, required = false)
54 @XmlElement(name = Elements.ATTRIBUTE_FIELDS, required = false)
55 private final List<AttributeFields> searchAttributeFields;
56
57 @SuppressWarnings("unused")
58 @XmlAnyElement
59 private final Collection<Element> _futureElements = null;
60
61
62
63
64 @SuppressWarnings("unused")
65 private DocumentSearchCriteriaConfiguration() {
66 this.searchAttributeFields = null;
67 }
68
69 private DocumentSearchCriteriaConfiguration(Builder builder) {
70 if (builder.getSearchAttributeFields() == null) {
71 this.searchAttributeFields = Collections.emptyList();
72 } else {
73 this.searchAttributeFields = Collections.unmodifiableList(new ArrayList<AttributeFields>(builder.getSearchAttributeFields()));
74 }
75 }
76
77 @Override
78 public List<AttributeFields> getSearchAttributeFields() {
79 return this.searchAttributeFields;
80 }
81
82 public List<RemotableAttributeField> getFlattenedSearchAttributeFields() {
83 List<RemotableAttributeField> searchAttributeFields = new ArrayList<RemotableAttributeField>();
84 for (AttributeFields attributeFields : getSearchAttributeFields()) {
85 searchAttributeFields.addAll(attributeFields.getRemotableAttributeFields());
86 }
87 return searchAttributeFields;
88 }
89
90
91
92
93
94 public final static class Builder implements Serializable, ModelBuilder, DocumentSearchCriteriaConfigurationContract {
95
96 private List<AttributeFields> searchAttributeFields;
97
98 private Builder() {
99 setSearchAttributeFields(new ArrayList<AttributeFields>());
100 }
101
102
103
104
105
106
107
108 public static Builder create() {
109 return new Builder();
110 }
111
112
113
114
115
116
117
118
119
120
121 public static Builder create(DocumentSearchCriteriaConfigurationContract contract) {
122 if (contract == null) {
123 throw new IllegalArgumentException("contract was null");
124 }
125 Builder builder = create();
126 builder.setSearchAttributeFields(contract.getSearchAttributeFields());
127 return builder;
128 }
129
130 @Override
131 public DocumentSearchCriteriaConfiguration build() {
132 return new DocumentSearchCriteriaConfiguration(this);
133 }
134
135 @Override
136 public List<AttributeFields> getSearchAttributeFields() {
137 return this.searchAttributeFields;
138 }
139
140
141
142
143
144
145 public void setSearchAttributeFields(List<AttributeFields> searchAttributeFields) {
146 this.searchAttributeFields = searchAttributeFields;
147 }
148
149 }
150
151
152
153
154 static class Constants {
155 final static String ROOT_ELEMENT_NAME = "documentSearchCriteriaConfiguration";
156 final static String TYPE_NAME = "DocumentSearchCriteriaConfigurationType";
157 }
158
159
160
161
162
163 static class Elements {
164 final static String SEARCH_ATTRIBUTE_FIELDS = "searchAttributeFields";
165 final static String ATTRIBUTE_FIELDS = "attributeFields";
166 }
167
168 }