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