1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.field;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.uif.component.BindingInfo;
20 import org.kuali.rice.krad.uif.component.MethodInvokerConfig;
21
22 import java.io.Serializable;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.Map;
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 public class AttributeQuery implements Serializable {
44 private static final long serialVersionUID = -4569905665441735255L;
45
46 private String dataObjectClassName;
47
48 private boolean renderNotFoundMessage;
49 private String returnMessageText;
50 private String returnMessageStyleClasses;
51
52 private Map<String, String> queryFieldMapping;
53 private Map<String, String> returnFieldMapping;
54 private Map<String, String> additionalCriteria;
55
56 private List<String> sortPropertyNames;
57
58 private String queryMethodToCall;
59 private List<String> queryMethodArgumentFieldList;
60 private MethodInvokerConfig queryMethodInvokerConfig;
61
62 public AttributeQuery() {
63 renderNotFoundMessage = true;
64 queryFieldMapping = new HashMap<String, String>();
65 returnFieldMapping = new HashMap<String, String>();
66 additionalCriteria = new HashMap<String, String>();
67 sortPropertyNames = new ArrayList<String>();
68 queryMethodArgumentFieldList = new ArrayList<String>();
69 }
70
71
72
73
74
75
76
77 public void updateQueryFieldMapping(BindingInfo bindingInfo) {
78 Map<String, String> adjustedQueryFieldMapping = new HashMap<String, String>();
79 for (String fromFieldPath : getQueryFieldMapping().keySet()) {
80 String toField = getQueryFieldMapping().get(fromFieldPath);
81 String adjustedFromFieldPath = bindingInfo.getPropertyAdjustedBindingPath(fromFieldPath);
82
83 adjustedQueryFieldMapping.put(adjustedFromFieldPath, toField);
84 }
85
86 this.queryFieldMapping = adjustedQueryFieldMapping;
87 }
88
89
90
91
92
93
94
95 public void updateReturnFieldMapping(BindingInfo bindingInfo) {
96 Map<String, String> adjustedReturnFieldMapping = new HashMap<String, String>();
97 for (String fromFieldPath : getReturnFieldMapping().keySet()) {
98 String toFieldPath = getReturnFieldMapping().get(fromFieldPath);
99 String adjustedToFieldPath = bindingInfo.getPropertyAdjustedBindingPath(toFieldPath);
100
101 adjustedReturnFieldMapping.put(fromFieldPath, adjustedToFieldPath);
102 }
103
104 this.returnFieldMapping = adjustedReturnFieldMapping;
105 }
106
107
108
109
110
111
112
113 public void updateQueryMethodArgumentFieldList(BindingInfo bindingInfo) {
114 List<String> adjustedArgumentFieldList = new ArrayList<String>();
115 for (String argumentFieldPath : getQueryMethodArgumentFieldList()) {
116 String adjustedFieldPath = bindingInfo.getPropertyAdjustedBindingPath(argumentFieldPath);
117 adjustedArgumentFieldList.add(adjustedFieldPath);
118 }
119
120 this.queryMethodArgumentFieldList = adjustedArgumentFieldList;
121 }
122
123
124
125
126
127
128
129 public String getQueryFieldMappingJsString() {
130 String queryFieldMappingJs = "{";
131
132 for (String queryField : queryFieldMapping.keySet()) {
133 if (!StringUtils.equals(queryFieldMappingJs, "{")) {
134 queryFieldMappingJs += ",";
135 }
136
137 queryFieldMappingJs += "\"" + queryField + "\":\"" + queryFieldMapping.get(queryField) + "\"";
138 }
139
140 queryFieldMappingJs += "}";
141
142 return queryFieldMappingJs;
143 }
144
145
146
147
148
149
150
151 public String getReturnFieldMappingJsString() {
152 String returnFieldMappingJs = "{";
153
154 for (String fromField : returnFieldMapping.keySet()) {
155 if (!StringUtils.equals(returnFieldMappingJs, "{")) {
156 returnFieldMappingJs += ",";
157 }
158
159 returnFieldMappingJs += "\"" + returnFieldMapping.get(fromField) + "\":\"" + fromField + "\"";
160 }
161
162 returnFieldMappingJs += "}";
163
164 return returnFieldMappingJs;
165 }
166
167
168
169
170
171
172 public String getQueryMethodArgumentFieldsJsString() {
173 String queryMethodArgsJs = "[";
174
175 for (String methodArg : queryMethodArgumentFieldList) {
176 if (!StringUtils.equals(queryMethodArgsJs, "{")) {
177 queryMethodArgsJs += ",";
178 }
179 queryMethodArgsJs += "\"" + methodArg + "\"";
180 }
181
182 queryMethodArgsJs += "]";
183
184 return queryMethodArgsJs;
185 }
186
187
188
189
190
191
192
193
194
195 public boolean hasConfiguredMethod() {
196 boolean configuredMethod = false;
197
198 if (StringUtils.isNotBlank(getQueryMethodToCall())) {
199 configuredMethod = true;
200 } else if (getQueryMethodInvokerConfig() != null) {
201 configuredMethod = true;
202 }
203
204 return configuredMethod;
205 }
206
207
208
209
210
211
212 public String getDataObjectClassName() {
213 return dataObjectClassName;
214 }
215
216
217
218
219
220
221 public void setDataObjectClassName(String dataObjectClassName) {
222 this.dataObjectClassName = dataObjectClassName;
223 }
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238 public Map<String, String> getQueryFieldMapping() {
239 return queryFieldMapping;
240 }
241
242
243
244
245
246
247 public void setQueryFieldMapping(Map<String, String> queryFieldMapping) {
248 this.queryFieldMapping = queryFieldMapping;
249 }
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264 public Map<String, String> getReturnFieldMapping() {
265 return returnFieldMapping;
266 }
267
268
269
270
271
272
273 public void setReturnFieldMapping(Map<String, String> returnFieldMapping) {
274 this.returnFieldMapping = returnFieldMapping;
275 }
276
277
278
279
280
281
282
283
284
285 public Map<String, String> getAdditionalCriteria() {
286 return additionalCriteria;
287 }
288
289
290
291
292
293
294 public void setAdditionalCriteria(Map<String, String> additionalCriteria) {
295 this.additionalCriteria = additionalCriteria;
296 }
297
298
299
300
301
302
303
304
305
306 public List<String> getSortPropertyNames() {
307 return sortPropertyNames;
308 }
309
310
311
312
313
314
315 public void setSortPropertyNames(List<String> sortPropertyNames) {
316 this.sortPropertyNames = sortPropertyNames;
317 }
318
319
320
321
322
323
324
325 public boolean isRenderNotFoundMessage() {
326 return renderNotFoundMessage;
327 }
328
329
330
331
332
333
334 public void setRenderNotFoundMessage(boolean renderNotFoundMessage) {
335 this.renderNotFoundMessage = renderNotFoundMessage;
336 }
337
338
339
340
341
342
343 public String getReturnMessageText() {
344 return returnMessageText;
345 }
346
347
348
349
350
351
352 public void setReturnMessageText(String returnMessageText) {
353 this.returnMessageText = returnMessageText;
354 }
355
356
357
358
359
360
361
362 public String getReturnMessageStyleClasses() {
363 return returnMessageStyleClasses;
364 }
365
366
367
368
369
370
371 public void setReturnMessageStyleClasses(String returnMessageStyleClasses) {
372 this.returnMessageStyleClasses = returnMessageStyleClasses;
373 }
374
375
376
377
378
379
380
381
382
383
384
385
386
387 public String getQueryMethodToCall() {
388 return queryMethodToCall;
389 }
390
391
392
393
394
395
396 public void setQueryMethodToCall(String queryMethodToCall) {
397 this.queryMethodToCall = queryMethodToCall;
398 }
399
400
401
402
403
404
405
406
407
408
409
410
411 public List<String> getQueryMethodArgumentFieldList() {
412 return queryMethodArgumentFieldList;
413 }
414
415
416
417
418
419
420 public void setQueryMethodArgumentFieldList(List<String> queryMethodArgumentFieldList) {
421 this.queryMethodArgumentFieldList = queryMethodArgumentFieldList;
422 }
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437 public MethodInvokerConfig getQueryMethodInvokerConfig() {
438 return queryMethodInvokerConfig;
439 }
440
441
442
443
444
445
446 public void setQueryMethodInvokerConfig(MethodInvokerConfig queryMethodInvokerConfig) {
447 this.queryMethodInvokerConfig = queryMethodInvokerConfig;
448 }
449 }