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