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