1 package org.kuali.rice.core.api.uif;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.rice.core.api.CoreConstants;
5 import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter;
6 import org.w3c.dom.Element;
7
8 import javax.xml.bind.annotation.XmlAccessType;
9 import javax.xml.bind.annotation.XmlAccessorType;
10 import javax.xml.bind.annotation.XmlAnyElement;
11 import javax.xml.bind.annotation.XmlElement;
12 import javax.xml.bind.annotation.XmlRootElement;
13 import javax.xml.bind.annotation.XmlType;
14 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.HashMap;
18 import java.util.Map;
19
20
21
22
23 @XmlRootElement(name = RemotableQuickFinder.Constants.ROOT_ELEMENT_NAME)
24 @XmlAccessorType(XmlAccessType.NONE)
25 @XmlType(name = RemotableQuickFinder.Constants.TYPE_NAME, propOrder = {
26 RemotableQuickFinder.Elements.BASE_LOOKUP_URL,
27 RemotableQuickFinder.Elements.DATA_OBJECT_CLASS,
28 RemotableQuickFinder.Elements.LOOKUP_PARAMETERS,
29 RemotableQuickFinder.Elements.FIELD_CONVERSIONS,
30 CoreConstants.CommonElements.FUTURE_ELEMENTS })
31 public final class RemotableQuickFinder extends RemotableAbstractWidget {
32
33 @XmlElement(name = Elements.BASE_LOOKUP_URL, required = false)
34 private final String baseLookupUrl;
35
36 @XmlElement(name = Elements.DATA_OBJECT_CLASS, required = true)
37 private final String dataObjectClass;
38
39 @XmlElement(name = Elements.LOOKUP_PARAMETERS, required = false)
40 @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
41 private final Map<String, String> lookupParameters;
42
43 @XmlElement(name = Elements.FIELD_CONVERSIONS, required = false)
44 @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
45 private final Map<String, String> fieldConversions;
46
47 @SuppressWarnings("unused")
48 @XmlAnyElement
49 private final Collection<Element> _futureElements = null;
50
51
52
53
54 @SuppressWarnings("unused")
55 private RemotableQuickFinder() {
56 baseLookupUrl = null;
57 dataObjectClass = null;
58 lookupParameters = null;
59 fieldConversions = null;
60 }
61
62 private RemotableQuickFinder(Builder b) {
63 baseLookupUrl = b.baseLookupUrl;
64 dataObjectClass = b.dataObjectClass;
65 lookupParameters = b.lookupParameters;
66 fieldConversions = b.fieldConversions;
67 }
68
69 public String getBaseLookupUrl() {
70 return baseLookupUrl;
71 }
72
73 public String getDataObjectClass() {
74 return dataObjectClass;
75 }
76
77 public Map<String, String> getLookupParameters() {
78 return Collections.unmodifiableMap(lookupParameters);
79 }
80
81 public Map<String, String> getFieldConversions() {
82 return Collections.unmodifiableMap(fieldConversions);
83 }
84
85 public static final class Builder extends RemotableAbstractWidget.Builder {
86 private String baseLookupUrl;
87 private String dataObjectClass;
88 private Map<String, String> lookupParameters = Collections.emptyMap();
89 private Map<String, String> fieldConversions = Collections.emptyMap();
90
91 private Builder(String baseLookupUrl, String dataObjectClass) {
92 setBaseLookupUrl(baseLookupUrl);
93 setDataObjectClass(dataObjectClass);
94 }
95
96 public static Builder create(String baseLookupUrl, String dataObjectClass) {
97 return new Builder(baseLookupUrl, dataObjectClass);
98 }
99
100 public String getBaseLookupUrl() {
101 return baseLookupUrl;
102 }
103
104 public void setBaseLookupUrl(String baseLookupUrl) {
105
106
107
108
109 this.baseLookupUrl = baseLookupUrl;
110 }
111
112 public String getDataObjectClass() {
113 return dataObjectClass;
114 }
115
116 public void setDataObjectClass(String dataObjectClass) {
117 if (StringUtils.isBlank(dataObjectClass)) {
118 throw new IllegalArgumentException("dataObjectClass is blank");
119 }
120
121 this.dataObjectClass = dataObjectClass;
122 }
123
124 public Map<String, String> getLookupParameters() {
125 return Collections.unmodifiableMap(lookupParameters);
126 }
127
128 public void setLookupParameters(Map<String, String> lookupParameters) {
129 if (lookupParameters != null) {
130 this.lookupParameters = new HashMap<String, String>(lookupParameters);
131 }
132 }
133
134 public Map<String, String> getFieldConversions() {
135 return Collections.unmodifiableMap(fieldConversions);
136 }
137
138 public void setFieldConversions(Map<String, String> fieldConversions) {
139 if (fieldConversions != null) {
140 this.fieldConversions = new HashMap<String, String>(fieldConversions);
141 }
142 }
143
144 @Override
145 public RemotableQuickFinder build() {
146 return new RemotableQuickFinder(this);
147 }
148 }
149
150
151
152
153 static final class Constants {
154 static final String TYPE_NAME = "QuickFinderType";
155 final static String ROOT_ELEMENT_NAME = "quickFinder";
156 }
157
158 static final class Elements {
159 static final String BASE_LOOKUP_URL = "baseLookupUrl";
160 static final String DATA_OBJECT_CLASS = "dataObjectClass";
161 static final String LOOKUP_PARAMETERS = "lookupParameters";
162 static final String FIELD_CONVERSIONS = "fieldConversions";
163 }
164 }