1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krad.service.impl; |
17 | |
|
18 | |
import java.beans.IndexedPropertyDescriptor; |
19 | |
import java.beans.PropertyDescriptor; |
20 | |
import java.lang.reflect.InvocationTargetException; |
21 | |
import java.util.ArrayList; |
22 | |
import java.util.Collection; |
23 | |
import java.util.HashSet; |
24 | |
import java.util.Iterator; |
25 | |
import java.util.List; |
26 | |
import java.util.Set; |
27 | |
|
28 | |
import org.apache.commons.beanutils.PropertyUtils; |
29 | |
import org.apache.commons.lang.StringUtils; |
30 | |
import org.apache.log4j.Logger; |
31 | |
import org.kuali.rice.kew.api.KewApiServiceLocator; |
32 | |
import org.kuali.rice.kns.datadictionary.BusinessObjectEntry; |
33 | |
import org.kuali.rice.kns.datadictionary.FieldDefinition; |
34 | |
import org.kuali.rice.kns.datadictionary.InquiryDefinition; |
35 | |
import org.kuali.rice.kns.datadictionary.InquirySectionDefinition; |
36 | |
import org.kuali.rice.kns.datadictionary.LookupDefinition; |
37 | |
import org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry; |
38 | |
import org.kuali.rice.krad.bo.BusinessObject; |
39 | |
import org.kuali.rice.krad.bo.PersistableBusinessObject; |
40 | |
import org.kuali.rice.krad.exception.IntrospectionException; |
41 | |
import org.kuali.rice.krad.inquiry.InquiryAuthorizer; |
42 | |
import org.kuali.rice.krad.inquiry.InquiryAuthorizerBase; |
43 | |
import org.kuali.rice.krad.inquiry.InquiryPresentationController; |
44 | |
import org.kuali.rice.krad.inquiry.InquiryPresentationControllerBase; |
45 | |
import org.kuali.rice.krad.service.BusinessObjectDictionaryService; |
46 | |
import org.kuali.rice.krad.service.DataDictionaryService; |
47 | |
import org.kuali.rice.krad.service.PersistenceStructureService; |
48 | |
import org.kuali.rice.krad.util.ObjectUtils; |
49 | |
import org.kuali.rice.krad.valuefinder.ValueFinder; |
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
@Deprecated |
57 | 0 | public class BusinessObjectDictionaryServiceImpl implements |
58 | |
BusinessObjectDictionaryService { |
59 | 0 | private static Logger LOG = Logger |
60 | |
.getLogger(BusinessObjectDictionaryServiceImpl.class); |
61 | |
|
62 | |
private DataDictionaryService dataDictionaryService; |
63 | |
private PersistenceStructureService persistenceStructureService; |
64 | |
|
65 | |
public <T extends BusinessObject> InquiryAuthorizer getInquiryAuthorizer( |
66 | |
Class<T> businessObjectClass) { |
67 | 0 | Class inquiryAuthorizerClass = ((BusinessObjectEntry) getDataDictionaryService() |
68 | |
.getDataDictionary().getBusinessObjectEntry( |
69 | |
businessObjectClass.getName())).getInquiryDefinition() |
70 | |
.getAuthorizerClass(); |
71 | 0 | if (inquiryAuthorizerClass == null) { |
72 | 0 | inquiryAuthorizerClass = InquiryAuthorizerBase.class; |
73 | |
} |
74 | |
try { |
75 | 0 | return (InquiryAuthorizer) inquiryAuthorizerClass.newInstance(); |
76 | 0 | } catch (Exception e) { |
77 | 0 | throw new RuntimeException( |
78 | |
"Unable to instantiate InquiryAuthorizer class: " |
79 | |
+ inquiryAuthorizerClass, e); |
80 | |
} |
81 | |
} |
82 | |
|
83 | |
public <T extends BusinessObject> InquiryPresentationController getInquiryPresentationController( |
84 | |
Class<T> businessObjectClass) { |
85 | 0 | Class inquiryPresentationControllerClass = ((BusinessObjectEntry) getDataDictionaryService() |
86 | |
.getDataDictionary().getBusinessObjectEntry( |
87 | |
businessObjectClass.getName())).getInquiryDefinition() |
88 | |
.getPresentationControllerClass(); |
89 | 0 | if (inquiryPresentationControllerClass == null) { |
90 | 0 | inquiryPresentationControllerClass = InquiryPresentationControllerBase.class; |
91 | |
} |
92 | |
try { |
93 | 0 | return (InquiryPresentationController) inquiryPresentationControllerClass |
94 | |
.newInstance(); |
95 | 0 | } catch (Exception e) { |
96 | 0 | throw new RuntimeException( |
97 | |
"Unable to instantiate InquiryPresentationController class: " |
98 | |
+ inquiryPresentationControllerClass, e); |
99 | |
} |
100 | |
} |
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
public List getBusinessObjectClassnames() { |
108 | 0 | return getDataDictionaryService().getDataDictionary() |
109 | |
.getBusinessObjectClassNames(); |
110 | |
} |
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
public Boolean isLookupable(Class businessObjectClass) { |
116 | 0 | Boolean isLookupable = Boolean.FALSE; |
117 | |
|
118 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
119 | 0 | if (entry != null) { |
120 | 0 | isLookupable = Boolean.valueOf(entry.hasLookupDefinition()); |
121 | |
} |
122 | |
|
123 | 0 | return isLookupable; |
124 | |
} |
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public Boolean isInquirable(Class businessObjectClass) { |
130 | 0 | Boolean isInquirable = Boolean.FALSE; |
131 | |
|
132 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
133 | 0 | if (entry != null) { |
134 | 0 | isInquirable = Boolean.valueOf(entry.hasInquiryDefinition()); |
135 | |
} |
136 | |
|
137 | 0 | return isInquirable; |
138 | |
} |
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
public Boolean isMaintainable(Class businessObjectClass) { |
144 | 0 | Boolean isMaintainable = Boolean.FALSE; |
145 | |
|
146 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
147 | 0 | if (entry != null) { |
148 | 0 | isMaintainable = Boolean |
149 | |
.valueOf(getMaintenanceDocumentEntry(businessObjectClass) != null); |
150 | |
} |
151 | |
|
152 | 0 | return isMaintainable; |
153 | |
} |
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
public Boolean isExportable(Class businessObjectClass) { |
160 | 0 | Boolean isExportable = Boolean.FALSE; |
161 | |
|
162 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
163 | 0 | if (entry != null) { |
164 | 0 | isExportable = entry.getExporterClass() != null; |
165 | |
} |
166 | |
|
167 | 0 | return isExportable; |
168 | |
} |
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
public List getLookupFieldNames(Class businessObjectClass) { |
174 | 0 | List results = null; |
175 | |
|
176 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
177 | 0 | if (lookupDefinition != null) { |
178 | 0 | results = lookupDefinition.getLookupFieldNames(); |
179 | |
} |
180 | |
|
181 | 0 | return results; |
182 | |
} |
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
public String getLookupTitle(Class businessObjectClass) { |
189 | 0 | String lookupTitle = ""; |
190 | |
|
191 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
192 | 0 | if (lookupDefinition != null) { |
193 | 0 | lookupTitle = lookupDefinition.getTitle(); |
194 | |
} |
195 | |
|
196 | 0 | return lookupTitle; |
197 | |
} |
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
public String getLookupMenuBar(Class businessObjectClass) { |
203 | 0 | String menubar = ""; |
204 | |
|
205 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
206 | 0 | if (lookupDefinition != null) { |
207 | 0 | if (lookupDefinition.hasMenubar()) { |
208 | 0 | menubar = lookupDefinition.getMenubar(); |
209 | |
} |
210 | |
} |
211 | |
|
212 | 0 | return menubar; |
213 | |
} |
214 | |
|
215 | |
|
216 | |
|
217 | |
|
218 | |
|
219 | |
public String getExtraButtonSource(Class businessObjectClass) { |
220 | 0 | String buttonSource = ""; |
221 | |
|
222 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
223 | 0 | if (lookupDefinition != null) { |
224 | 0 | if (lookupDefinition.hasExtraButtonSource()) { |
225 | 0 | buttonSource = lookupDefinition.getExtraButtonSource(); |
226 | |
} |
227 | |
} |
228 | |
|
229 | 0 | return buttonSource; |
230 | |
} |
231 | |
|
232 | |
|
233 | |
|
234 | |
|
235 | |
public String getExtraButtonParams(Class businessObjectClass) { |
236 | 0 | String buttonParams = ""; |
237 | |
|
238 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
239 | 0 | if (lookupDefinition != null) { |
240 | 0 | if (lookupDefinition.hasExtraButtonParams()) { |
241 | 0 | buttonParams = lookupDefinition.getExtraButtonParams(); |
242 | |
} |
243 | |
} |
244 | |
|
245 | 0 | return buttonParams; |
246 | |
} |
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
public String getSearchIconOverride(Class businessObjectClass) { |
253 | 0 | String iconUrl = ""; |
254 | |
|
255 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
256 | 0 | if (lookupDefinition != null) { |
257 | 0 | if (lookupDefinition.hasSearchIconOverride()) { |
258 | 0 | iconUrl = lookupDefinition.getSearchIconOverride(); |
259 | |
} |
260 | |
} |
261 | |
|
262 | 0 | return iconUrl; |
263 | |
} |
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
public List getLookupDefaultSortFieldNames(Class businessObjectClass) { |
270 | 0 | List defaultSort = null; |
271 | |
|
272 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
273 | 0 | if (lookupDefinition != null) { |
274 | 0 | if (lookupDefinition.hasDefaultSort()) { |
275 | 0 | defaultSort = lookupDefinition.getDefaultSort() |
276 | |
.getAttributeNames(); |
277 | |
} |
278 | |
} |
279 | 0 | if (defaultSort == null) { |
280 | 0 | defaultSort = new ArrayList(); |
281 | |
} |
282 | |
|
283 | 0 | return defaultSort; |
284 | |
} |
285 | |
|
286 | |
|
287 | |
|
288 | |
|
289 | |
public List<String> getLookupResultFieldNames(Class businessObjectClass) { |
290 | 0 | List<String> results = null; |
291 | |
|
292 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
293 | 0 | if (lookupDefinition != null) { |
294 | 0 | results = lookupDefinition.getResultFieldNames(); |
295 | |
} |
296 | |
|
297 | 0 | return results; |
298 | |
} |
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
public Integer getLookupResultFieldMaxLength(Class businessObjectClass, |
305 | |
String resultFieldName) { |
306 | 0 | Integer resultFieldMaxLength = null; |
307 | |
|
308 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
309 | 0 | if (lookupDefinition != null) { |
310 | 0 | FieldDefinition field = lookupDefinition.getResultField(resultFieldName); |
311 | 0 | if (field != null) { |
312 | 0 | resultFieldMaxLength = field.getMaxLength(); |
313 | |
} |
314 | |
} |
315 | |
|
316 | 0 | return resultFieldMaxLength; |
317 | |
} |
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
public Integer getLookupResultSetLimit(Class businessObjectClass) { |
323 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
324 | 0 | if ( lookupDefinition != null ) { |
325 | 0 | return lookupDefinition.getResultSetLimit(); |
326 | |
|
327 | |
} else { |
328 | 0 | return null; |
329 | |
} |
330 | |
} |
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | |
public Integer getMultipleValueLookupResultSetLimit(Class businessObjectClass) { |
336 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
337 | 0 | if ( lookupDefinition != null ) { |
338 | 0 | return lookupDefinition.getMultipleValuesResultSetLimit(); |
339 | |
} else { |
340 | 0 | return null; |
341 | |
} |
342 | |
} |
343 | |
|
344 | |
|
345 | |
|
346 | |
|
347 | |
public Integer getLookupNumberOfColumns(Class businessObjectClass) { |
348 | |
|
349 | 0 | int numberOfColumns = 1; |
350 | |
|
351 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
352 | 0 | if (lookupDefinition != null) { |
353 | 0 | if (lookupDefinition.getNumOfColumns() > 1) { |
354 | 0 | numberOfColumns = lookupDefinition.getNumOfColumns(); |
355 | |
} |
356 | |
} |
357 | |
|
358 | 0 | return numberOfColumns; |
359 | |
} |
360 | |
|
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
public Boolean getLookupAttributeRequired(Class businessObjectClass, |
366 | |
String attributeName) { |
367 | 0 | Boolean isRequired = null; |
368 | |
|
369 | 0 | FieldDefinition definition = getLookupFieldDefinition( |
370 | |
businessObjectClass, attributeName); |
371 | 0 | if (definition != null) { |
372 | 0 | isRequired = Boolean.valueOf(definition.isRequired()); |
373 | |
} |
374 | |
|
375 | 0 | return isRequired; |
376 | |
} |
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
public Boolean getLookupAttributeReadOnly(Class businessObjectClass, String attributeName) { |
383 | 0 | Boolean readOnly = null; |
384 | |
|
385 | 0 | FieldDefinition definition = getLookupFieldDefinition(businessObjectClass, attributeName); |
386 | 0 | if (definition != null) { |
387 | 0 | readOnly = Boolean.valueOf(definition.isReadOnly()); |
388 | |
} |
389 | |
|
390 | 0 | return readOnly; |
391 | |
} |
392 | |
|
393 | |
|
394 | |
|
395 | |
|
396 | |
|
397 | |
public List getInquiryFieldNames(Class businessObjectClass, |
398 | |
String sectionTitle) { |
399 | 0 | List results = null; |
400 | |
|
401 | 0 | InquirySectionDefinition inquirySection = getInquiryDefinition( |
402 | |
businessObjectClass).getInquirySection(sectionTitle); |
403 | 0 | if (inquirySection != null) { |
404 | 0 | results = inquirySection.getInquiryFieldNames(); |
405 | |
} |
406 | |
|
407 | 0 | return results; |
408 | |
} |
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
public List<InquirySectionDefinition> getInquirySections(Class businessObjectClass) { |
414 | 0 | List<InquirySectionDefinition> results = null; |
415 | |
|
416 | 0 | results = getInquiryDefinition(businessObjectClass) |
417 | |
.getInquirySections(); |
418 | |
|
419 | 0 | return results; |
420 | |
} |
421 | |
|
422 | |
|
423 | |
|
424 | |
|
425 | |
public String getInquiryTitle(Class businessObjectClass) { |
426 | 0 | String title = ""; |
427 | |
|
428 | 0 | InquiryDefinition inquiryDefinition = getInquiryDefinition(businessObjectClass); |
429 | 0 | if (inquiryDefinition != null) { |
430 | 0 | title = inquiryDefinition.getTitle(); |
431 | |
} |
432 | |
|
433 | 0 | return title; |
434 | |
} |
435 | |
|
436 | |
|
437 | |
|
438 | |
|
439 | |
public Class getInquirableClass(Class businessObjectClass) { |
440 | 0 | Class clazz = null; |
441 | |
|
442 | 0 | InquiryDefinition inquiryDefinition = getInquiryDefinition(businessObjectClass); |
443 | 0 | if (inquiryDefinition != null) { |
444 | 0 | clazz = inquiryDefinition.getInquirableClass(); |
445 | |
} |
446 | |
|
447 | 0 | return clazz; |
448 | |
} |
449 | |
|
450 | |
|
451 | |
|
452 | |
|
453 | |
public String getMaintainableLabel(Class businessObjectClass) { |
454 | 0 | String label = ""; |
455 | |
|
456 | 0 | MaintenanceDocumentEntry entry = getMaintenanceDocumentEntry(businessObjectClass); |
457 | 0 | if (entry != null) { |
458 | 0 | label = KewApiServiceLocator.getDocumentTypeService().getDocumentTypeByName(entry.getDocumentTypeName()).getLabel(); |
459 | |
} |
460 | |
|
461 | 0 | return label; |
462 | |
} |
463 | |
|
464 | |
|
465 | |
|
466 | |
|
467 | |
|
468 | |
public String getLookupableID(Class businessObjectClass) { |
469 | 0 | String lookupableID = null; |
470 | |
|
471 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
472 | 0 | if (lookupDefinition != null) { |
473 | 0 | lookupableID = lookupDefinition.getLookupableID(); |
474 | |
} |
475 | |
|
476 | 0 | return lookupableID; |
477 | |
} |
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
|
486 | |
|
487 | |
|
488 | |
|
489 | |
|
490 | |
|
491 | |
|
492 | |
|
493 | |
public void performForceUppercase(BusinessObject bo) { |
494 | 0 | performForceUppercaseCycleSafe(bo, new HashSet<BusinessObject>()); |
495 | 0 | } |
496 | |
|
497 | |
|
498 | |
|
499 | |
|
500 | |
|
501 | |
protected void performForceUppercaseCycleSafe(BusinessObject bo, Set<BusinessObject> visited) { |
502 | 0 | if (visited.contains(bo)) { |
503 | 0 | return; |
504 | |
} else { |
505 | 0 | visited.add(bo); |
506 | |
} |
507 | 0 | PropertyDescriptor descriptors[] = PropertyUtils |
508 | |
.getPropertyDescriptors(bo); |
509 | 0 | for (int i = 0; i < descriptors.length; ++i) { |
510 | |
try { |
511 | 0 | if (descriptors[i] instanceof IndexedPropertyDescriptor) { |
512 | |
|
513 | |
|
514 | |
|
515 | |
|
516 | |
|
517 | |
|
518 | |
} else { |
519 | 0 | Object nestedObject = ObjectUtils.getPropertyValue(bo, |
520 | |
descriptors[i].getName()); |
521 | 0 | if (ObjectUtils.isNotNull(nestedObject) |
522 | |
&& nestedObject instanceof BusinessObject) { |
523 | 0 | if (persistenceStructureService |
524 | |
.isPersistable(nestedObject.getClass())) { |
525 | |
try { |
526 | 0 | if (persistenceStructureService.hasReference(bo |
527 | |
.getClass(), descriptors[i].getName())) { |
528 | 0 | if (persistenceStructureService |
529 | |
.isReferenceUpdatable( |
530 | |
bo.getClass(), |
531 | |
descriptors[i].getName())) { |
532 | 0 | if (persistenceStructureService |
533 | |
.getForeignKeyFieldsPopulationState( |
534 | |
(PersistableBusinessObject) bo, |
535 | |
descriptors[i] |
536 | |
.getName()) |
537 | |
.isAllFieldsPopulated()) { |
538 | |
|
539 | |
|
540 | 0 | performForceUppercaseCycleSafe((BusinessObject) nestedObject, visited); |
541 | |
} |
542 | |
} |
543 | |
} |
544 | 0 | } catch (org.kuali.rice.krad.exception.ReferenceAttributeNotAnOjbReferenceException ranaore) { |
545 | 0 | LOG.debug("Propery " + descriptors[i].getName() |
546 | |
+ " is not a foreign key reference."); |
547 | 0 | } |
548 | |
} |
549 | 0 | } else if (nestedObject instanceof String) { |
550 | 0 | if (dataDictionaryService.isAttributeDefined( |
551 | |
bo.getClass(), descriptors[i].getName()) |
552 | |
.booleanValue() |
553 | |
&& dataDictionaryService |
554 | |
.getAttributeForceUppercase( |
555 | |
bo.getClass(), |
556 | |
descriptors[i].getName()) |
557 | |
.booleanValue()) { |
558 | 0 | String curValue = (String) nestedObject; |
559 | 0 | PropertyUtils.setProperty(bo, descriptors[i] |
560 | |
.getName(), curValue.toUpperCase()); |
561 | 0 | } |
562 | |
} else { |
563 | 0 | if (ObjectUtils.isNotNull(nestedObject) |
564 | |
&& nestedObject instanceof Collection) { |
565 | 0 | if (persistenceStructureService.hasCollection(bo |
566 | |
.getClass(), descriptors[i].getName())) { |
567 | 0 | if (persistenceStructureService |
568 | |
.isCollectionUpdatable(bo.getClass(), |
569 | |
descriptors[i].getName())) { |
570 | 0 | Iterator iter = ((Collection) nestedObject) |
571 | |
.iterator(); |
572 | 0 | while (iter.hasNext()) { |
573 | 0 | Object collElem = iter.next(); |
574 | 0 | if (collElem instanceof BusinessObject) { |
575 | 0 | if (persistenceStructureService |
576 | |
.isPersistable(collElem |
577 | |
.getClass())) { |
578 | 0 | performForceUppercaseCycleSafe((BusinessObject) collElem, visited); |
579 | |
} |
580 | |
} |
581 | 0 | } |
582 | |
} |
583 | |
} |
584 | |
} |
585 | |
} |
586 | |
} |
587 | 0 | } catch (IllegalAccessException e) { |
588 | 0 | throw new IntrospectionException( |
589 | |
"unable to performForceUppercase", e); |
590 | 0 | } catch (InvocationTargetException e) { |
591 | 0 | throw new IntrospectionException( |
592 | |
"unable to performForceUppercase", e); |
593 | 0 | } catch (NoSuchMethodException e) { |
594 | |
|
595 | |
|
596 | |
|
597 | 0 | } |
598 | |
} |
599 | 0 | } |
600 | |
|
601 | |
|
602 | |
|
603 | |
|
604 | |
|
605 | |
|
606 | |
public void setDataDictionaryService( |
607 | |
DataDictionaryService dataDictionaryService) { |
608 | 0 | this.dataDictionaryService = dataDictionaryService; |
609 | 0 | } |
610 | |
|
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
|
616 | |
public DataDictionaryService getDataDictionaryService() { |
617 | 0 | return this.dataDictionaryService; |
618 | |
} |
619 | |
|
620 | |
|
621 | |
|
622 | |
|
623 | |
|
624 | |
|
625 | |
|
626 | |
|
627 | |
private BusinessObjectEntry getBusinessObjectEntry(Class businessObjectClass) { |
628 | 0 | validateBusinessObjectClass(businessObjectClass); |
629 | |
|
630 | 0 | BusinessObjectEntry entry = (BusinessObjectEntry) getDataDictionaryService() |
631 | |
.getDataDictionary().getBusinessObjectEntry( |
632 | |
businessObjectClass.getName()); |
633 | 0 | return entry; |
634 | |
} |
635 | |
|
636 | |
|
637 | |
|
638 | |
|
639 | |
|
640 | |
|
641 | |
|
642 | |
|
643 | |
private MaintenanceDocumentEntry getMaintenanceDocumentEntry( |
644 | |
Class businessObjectClass) { |
645 | 0 | validateBusinessObjectClass(businessObjectClass); |
646 | |
|
647 | 0 | MaintenanceDocumentEntry entry = (MaintenanceDocumentEntry) getDataDictionaryService() |
648 | |
.getDataDictionary() |
649 | |
.getMaintenanceDocumentEntryForBusinessObjectClass( |
650 | |
businessObjectClass); |
651 | 0 | return entry; |
652 | |
} |
653 | |
|
654 | |
|
655 | |
|
656 | |
|
657 | |
|
658 | |
|
659 | |
|
660 | |
|
661 | |
private LookupDefinition getLookupDefinition(Class businessObjectClass) { |
662 | 0 | LookupDefinition lookupDefinition = null; |
663 | |
|
664 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
665 | 0 | if (entry != null) { |
666 | 0 | if (entry.hasLookupDefinition()) { |
667 | 0 | lookupDefinition = entry.getLookupDefinition(); |
668 | |
} |
669 | |
} |
670 | |
|
671 | 0 | return lookupDefinition; |
672 | |
} |
673 | |
|
674 | |
|
675 | |
|
676 | |
|
677 | |
|
678 | |
|
679 | |
|
680 | |
|
681 | |
|
682 | |
private FieldDefinition getLookupFieldDefinition(Class businessObjectClass, |
683 | |
String lookupFieldName) { |
684 | 0 | if (StringUtils.isBlank(lookupFieldName)) { |
685 | 0 | throw new IllegalArgumentException( |
686 | |
"invalid (blank) lookupFieldName"); |
687 | |
} |
688 | |
|
689 | 0 | FieldDefinition fieldDefinition = null; |
690 | |
|
691 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
692 | 0 | if (lookupDefinition != null) { |
693 | 0 | fieldDefinition = lookupDefinition.getLookupField(lookupFieldName); |
694 | |
} |
695 | |
|
696 | 0 | return fieldDefinition; |
697 | |
} |
698 | |
|
699 | |
|
700 | |
|
701 | |
|
702 | |
|
703 | |
|
704 | |
|
705 | |
|
706 | |
|
707 | |
private FieldDefinition getLookupResultFieldDefinition( |
708 | |
Class businessObjectClass, String lookupFieldName) { |
709 | 0 | if (StringUtils.isBlank(lookupFieldName)) { |
710 | 0 | throw new IllegalArgumentException( |
711 | |
"invalid (blank) lookupFieldName"); |
712 | |
} |
713 | |
|
714 | 0 | FieldDefinition fieldDefinition = null; |
715 | |
|
716 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
717 | 0 | if (lookupDefinition != null) { |
718 | 0 | fieldDefinition = lookupDefinition.getResultField(lookupFieldName); |
719 | |
} |
720 | |
|
721 | 0 | return fieldDefinition; |
722 | |
} |
723 | |
|
724 | |
|
725 | |
|
726 | |
|
727 | |
|
728 | |
|
729 | |
|
730 | |
|
731 | |
private InquiryDefinition getInquiryDefinition(Class businessObjectClass) { |
732 | 0 | InquiryDefinition inquiryDefinition = null; |
733 | |
|
734 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
735 | 0 | if (entry != null) { |
736 | 0 | if (entry.hasInquiryDefinition()) { |
737 | 0 | inquiryDefinition = entry.getInquiryDefinition(); |
738 | |
} |
739 | |
} |
740 | |
|
741 | 0 | return inquiryDefinition; |
742 | |
} |
743 | |
|
744 | |
|
745 | |
|
746 | |
|
747 | |
|
748 | |
public String getTitleAttribute(Class businessObjectClass) { |
749 | 0 | String titleAttribute = null; |
750 | |
|
751 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
752 | 0 | if (entry != null) { |
753 | 0 | titleAttribute = entry.getTitleAttribute(); |
754 | |
} |
755 | |
|
756 | 0 | return titleAttribute; |
757 | |
} |
758 | |
|
759 | |
|
760 | |
|
761 | |
|
762 | |
|
763 | |
|
764 | |
|
765 | |
|
766 | |
|
767 | |
private FieldDefinition getInquiryFieldDefinition( |
768 | |
Class businessObjectClass, String fieldName) { |
769 | 0 | if (StringUtils.isBlank(fieldName)) { |
770 | 0 | throw new IllegalArgumentException("invalid (blank) fieldName"); |
771 | |
} |
772 | |
|
773 | 0 | FieldDefinition fieldDefinition = null; |
774 | |
|
775 | 0 | InquiryDefinition inquiryDefinition = getInquiryDefinition(businessObjectClass); |
776 | 0 | if (inquiryDefinition != null) { |
777 | 0 | fieldDefinition = inquiryDefinition.getFieldDefinition(fieldName); |
778 | |
} |
779 | |
|
780 | 0 | return fieldDefinition; |
781 | |
} |
782 | |
|
783 | |
|
784 | |
|
785 | |
|
786 | |
|
787 | |
|
788 | |
private void validateBusinessObjectClass(Class businessObjectClass) { |
789 | 0 | if (businessObjectClass == null) { |
790 | 0 | throw new IllegalArgumentException( |
791 | |
"invalid (null) dataObjectClass"); |
792 | |
} |
793 | 0 | if (!BusinessObject.class.isAssignableFrom(businessObjectClass)) { |
794 | 0 | throw new IllegalArgumentException("class '" |
795 | |
+ businessObjectClass.getName() |
796 | |
+ "' is not a descendent of BusinessObject"); |
797 | |
} |
798 | 0 | } |
799 | |
|
800 | |
|
801 | |
|
802 | |
|
803 | |
|
804 | |
public Boolean forceLookupResultFieldInquiry(Class businessObjectClass, |
805 | |
String attributeName) { |
806 | 0 | Boolean forceLookup = null; |
807 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
808 | 0 | forceLookup = Boolean.valueOf(getLookupResultFieldDefinition( |
809 | |
businessObjectClass, attributeName).isForceInquiry()); |
810 | |
} |
811 | |
|
812 | 0 | return forceLookup; |
813 | |
} |
814 | |
|
815 | |
|
816 | |
|
817 | |
|
818 | |
|
819 | |
public Boolean noLookupResultFieldInquiry(Class businessObjectClass, |
820 | |
String attributeName) { |
821 | 0 | Boolean noLookup = null; |
822 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
823 | 0 | noLookup = Boolean.valueOf(getLookupResultFieldDefinition( |
824 | |
businessObjectClass, attributeName).isNoInquiry()); |
825 | |
} |
826 | |
|
827 | 0 | return noLookup; |
828 | |
} |
829 | |
|
830 | |
|
831 | |
|
832 | |
|
833 | |
|
834 | |
public Boolean forceLookupFieldLookup(Class businessObjectClass, |
835 | |
String attributeName) { |
836 | 0 | Boolean forceLookup = null; |
837 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
838 | 0 | forceLookup = Boolean.valueOf(getLookupFieldDefinition( |
839 | |
businessObjectClass, attributeName).isForceLookup()); |
840 | |
} |
841 | |
|
842 | 0 | return forceLookup; |
843 | |
} |
844 | |
|
845 | |
public Boolean forceInquiryFieldLookup(Class businessObjectClass, |
846 | |
String attributeName) { |
847 | 0 | Boolean forceInquiry = null; |
848 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
849 | 0 | forceInquiry = Boolean.valueOf(getLookupFieldDefinition( |
850 | |
businessObjectClass, attributeName).isForceInquiry()); |
851 | |
} |
852 | |
|
853 | 0 | return forceInquiry; |
854 | |
} |
855 | |
|
856 | |
|
857 | |
|
858 | |
|
859 | |
|
860 | |
public Boolean noLookupFieldLookup(Class businessObjectClass, |
861 | |
String attributeName) { |
862 | 0 | Boolean noLookup = null; |
863 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
864 | 0 | noLookup = Boolean.valueOf(getLookupFieldDefinition( |
865 | |
businessObjectClass, attributeName).isNoLookup()); |
866 | |
} |
867 | |
|
868 | 0 | return noLookup; |
869 | |
} |
870 | |
|
871 | |
|
872 | |
|
873 | |
|
874 | |
|
875 | |
public Boolean noDirectInquiryFieldLookup(Class businessObjectClass, |
876 | |
String attributeName) { |
877 | 0 | Boolean noDirectInquiry = null; |
878 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
879 | 0 | noDirectInquiry = Boolean.valueOf(getLookupFieldDefinition( |
880 | |
businessObjectClass, attributeName).isNoDirectInquiry()); |
881 | |
} |
882 | |
|
883 | 0 | return noDirectInquiry; |
884 | |
} |
885 | |
|
886 | |
|
887 | |
|
888 | |
|
889 | |
|
890 | |
public Boolean getLookupResultFieldUseShortLabel(Class businessObjectClass, |
891 | |
String attributeName) { |
892 | 0 | Boolean useShortLabel = null; |
893 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
894 | 0 | useShortLabel = Boolean.valueOf(getLookupResultFieldDefinition( |
895 | |
businessObjectClass, attributeName).isUseShortLabel()); |
896 | |
} |
897 | |
|
898 | 0 | return useShortLabel; |
899 | |
} |
900 | |
|
901 | |
|
902 | |
|
903 | |
|
904 | |
|
905 | |
public Boolean getLookupResultFieldTotal(Class businessObjectClass, String attributeName) { |
906 | 0 | Boolean total = false; |
907 | |
|
908 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
909 | 0 | total = Boolean.valueOf(getLookupResultFieldDefinition( |
910 | |
businessObjectClass, attributeName).isTotal()); |
911 | |
} |
912 | |
|
913 | 0 | return total; |
914 | |
} |
915 | |
|
916 | |
|
917 | |
|
918 | |
|
919 | |
|
920 | |
public Boolean forceInquiryFieldInquiry(Class businessObjectClass, |
921 | |
String attributeName) { |
922 | 0 | Boolean forceInquiry = null; |
923 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
924 | 0 | forceInquiry = Boolean.valueOf(getInquiryFieldDefinition( |
925 | |
businessObjectClass, attributeName).isForceInquiry()); |
926 | |
} |
927 | |
|
928 | 0 | return forceInquiry; |
929 | |
} |
930 | |
|
931 | |
|
932 | |
|
933 | |
|
934 | |
|
935 | |
public Boolean noInquiryFieldInquiry(Class businessObjectClass, |
936 | |
String attributeName) { |
937 | 0 | Boolean noInquiry = null; |
938 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
939 | 0 | noInquiry = Boolean.valueOf(getInquiryFieldDefinition( |
940 | |
businessObjectClass, attributeName).isNoInquiry()); |
941 | |
} |
942 | |
|
943 | 0 | return noInquiry; |
944 | |
} |
945 | |
|
946 | |
|
947 | |
|
948 | |
|
949 | |
|
950 | |
public String getLookupFieldDefaultValue(Class businessObjectClass, |
951 | |
String attributeName) { |
952 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName) |
953 | |
.getDefaultValue(); |
954 | |
} |
955 | |
|
956 | |
|
957 | |
|
958 | |
|
959 | |
|
960 | |
public Class<? extends ValueFinder> getLookupFieldDefaultValueFinderClass( |
961 | |
Class businessObjectClass, String attributeName) { |
962 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName) |
963 | |
.getDefaultValueFinderClass(); |
964 | |
} |
965 | |
|
966 | |
|
967 | |
public String getLookupFieldQuickfinderParameterString(Class businessObjectClass, String attributeName) { |
968 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName).getQuickfinderParameterString(); |
969 | |
} |
970 | |
|
971 | |
|
972 | |
public Class<? extends ValueFinder> getLookupFieldQuickfinderParameterStringBuilderClass(Class businessObjectClass, String attributeName) { |
973 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName).getQuickfinderParameterStringBuilderClass(); |
974 | |
} |
975 | |
|
976 | |
public void setPersistenceStructureService( |
977 | |
PersistenceStructureService persistenceStructureService) { |
978 | 0 | this.persistenceStructureService = persistenceStructureService; |
979 | 0 | } |
980 | |
|
981 | |
|
982 | |
|
983 | |
|
984 | |
public boolean isLookupFieldTreatWildcardsAndOperatorsAsLiteral(Class businessObjectClass, String attributeName) { |
985 | 0 | FieldDefinition lookupFieldDefinition = getLookupFieldDefinition(businessObjectClass, attributeName); |
986 | 0 | return lookupFieldDefinition != null && lookupFieldDefinition.isTreatWildcardsAndOperatorsAsLiteral(); |
987 | |
} |
988 | |
|
989 | |
|
990 | |
|
991 | |
|
992 | |
|
993 | |
public String getInquiryFieldAdditionalDisplayAttributeName(Class businessObjectClass, String attributeName) { |
994 | 0 | String additionalDisplayAttributeName = null; |
995 | |
|
996 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
997 | 0 | additionalDisplayAttributeName = getInquiryFieldDefinition(businessObjectClass, attributeName) |
998 | |
.getAdditionalDisplayAttributeName(); |
999 | |
} |
1000 | |
|
1001 | 0 | return additionalDisplayAttributeName; |
1002 | |
} |
1003 | |
|
1004 | |
|
1005 | |
|
1006 | |
|
1007 | |
|
1008 | |
public String getInquiryFieldAlternateDisplayAttributeName(Class businessObjectClass, String attributeName) { |
1009 | 0 | String alternateDisplayAttributeName = null; |
1010 | |
|
1011 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
1012 | 0 | alternateDisplayAttributeName = getInquiryFieldDefinition(businessObjectClass, attributeName) |
1013 | |
.getAlternateDisplayAttributeName(); |
1014 | |
} |
1015 | |
|
1016 | 0 | return alternateDisplayAttributeName; |
1017 | |
} |
1018 | |
|
1019 | |
|
1020 | |
|
1021 | |
|
1022 | |
|
1023 | |
public String getLookupFieldAdditionalDisplayAttributeName(Class businessObjectClass, String attributeName) { |
1024 | 0 | String additionalDisplayAttributeName = null; |
1025 | |
|
1026 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
1027 | 0 | additionalDisplayAttributeName = getLookupResultFieldDefinition(businessObjectClass, attributeName) |
1028 | |
.getAdditionalDisplayAttributeName(); |
1029 | |
} |
1030 | |
|
1031 | 0 | return additionalDisplayAttributeName; |
1032 | |
} |
1033 | |
|
1034 | |
|
1035 | |
|
1036 | |
|
1037 | |
|
1038 | |
public String getLookupFieldAlternateDisplayAttributeName(Class businessObjectClass, String attributeName) { |
1039 | 0 | String alternateDisplayAttributeName = null; |
1040 | |
|
1041 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
1042 | 0 | alternateDisplayAttributeName = getLookupResultFieldDefinition(businessObjectClass, attributeName) |
1043 | |
.getAlternateDisplayAttributeName(); |
1044 | |
} |
1045 | |
|
1046 | 0 | return alternateDisplayAttributeName; |
1047 | |
} |
1048 | |
|
1049 | |
|
1050 | |
|
1051 | |
|
1052 | |
public Boolean tranlateCodesInLookup(Class businessObjectClass) { |
1053 | 0 | boolean translateCodes = false; |
1054 | |
|
1055 | 0 | if (getLookupDefinition(businessObjectClass) != null) { |
1056 | 0 | translateCodes = getLookupDefinition(businessObjectClass).isTranslateCodes(); |
1057 | |
} |
1058 | |
|
1059 | 0 | return translateCodes; |
1060 | |
} |
1061 | |
|
1062 | |
|
1063 | |
|
1064 | |
|
1065 | |
public Boolean tranlateCodesInInquiry(Class businessObjectClass) { |
1066 | 0 | boolean translateCodes = false; |
1067 | |
|
1068 | 0 | if (getInquiryDefinition(businessObjectClass) != null) { |
1069 | 0 | translateCodes = getInquiryDefinition(businessObjectClass).isTranslateCodes(); |
1070 | |
} |
1071 | |
|
1072 | 0 | return translateCodes; |
1073 | |
} |
1074 | |
|
1075 | |
|
1076 | |
|
1077 | |
|
1078 | |
|
1079 | |
public boolean isLookupFieldTriggerOnChange(Class businessObjectClass, String attributeName) { |
1080 | 0 | boolean triggerOnChange = false; |
1081 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
1082 | 0 | triggerOnChange = getLookupFieldDefinition(businessObjectClass, attributeName).isTriggerOnChange(); |
1083 | |
} |
1084 | |
|
1085 | 0 | return triggerOnChange; |
1086 | |
} |
1087 | |
|
1088 | |
|
1089 | |
|
1090 | |
|
1091 | |
public boolean disableSearchButtonsInLookup(Class businessObjectClass) { |
1092 | 0 | boolean disableSearchButtons = false; |
1093 | |
|
1094 | 0 | if (getLookupDefinition(businessObjectClass) != null) { |
1095 | 0 | disableSearchButtons = getLookupDefinition(businessObjectClass).isDisableSearchButtons(); |
1096 | |
} |
1097 | |
|
1098 | 0 | return disableSearchButtons; |
1099 | |
} |
1100 | |
|
1101 | |
|
1102 | |
|
1103 | |
} |