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.BusinessObjectDictionaryService; |
47 | |
import org.kuali.rice.kns.service.DataDictionaryService; |
48 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
49 | |
import org.kuali.rice.kns.service.PersistenceStructureService; |
50 | |
import org.kuali.rice.kns.util.ObjectUtils; |
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
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 = 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 = 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 | |
|
305 | |
public Integer getLookupResultFieldMaxLength(Class businessObjectClass, |
306 | |
String resultFieldName) { |
307 | 0 | Integer resultFieldMaxLength = null; |
308 | |
|
309 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
310 | 0 | if (lookupDefinition != null) { |
311 | 0 | FieldDefinition field = lookupDefinition.getResultField(resultFieldName); |
312 | 0 | if (field != null) { |
313 | 0 | resultFieldMaxLength = field.getMaxLength(); |
314 | |
} |
315 | |
} |
316 | |
|
317 | 0 | return resultFieldMaxLength; |
318 | |
} |
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
public Integer getLookupResultSetLimit(Class businessObjectClass) { |
324 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
325 | 0 | if ( lookupDefinition != null ) { |
326 | 0 | return lookupDefinition.getResultSetLimit(); |
327 | |
|
328 | |
} else { |
329 | 0 | return null; |
330 | |
} |
331 | |
} |
332 | |
|
333 | |
|
334 | |
|
335 | |
|
336 | |
public Integer getLookupNumberOfColumns(Class businessObjectClass) { |
337 | |
|
338 | 0 | int numberOfColumns = 1; |
339 | |
|
340 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
341 | 0 | if (lookupDefinition != null) { |
342 | 0 | if (lookupDefinition.getNumOfColumns() > 1) { |
343 | 0 | numberOfColumns = lookupDefinition.getNumOfColumns(); |
344 | |
} |
345 | |
} |
346 | |
|
347 | 0 | return numberOfColumns; |
348 | |
} |
349 | |
|
350 | |
|
351 | |
|
352 | |
|
353 | |
|
354 | |
public Boolean getLookupAttributeRequired(Class businessObjectClass, |
355 | |
String attributeName) { |
356 | 0 | Boolean isRequired = null; |
357 | |
|
358 | 0 | FieldDefinition definition = getLookupFieldDefinition( |
359 | |
businessObjectClass, attributeName); |
360 | 0 | if (definition != null) { |
361 | 0 | isRequired = Boolean.valueOf(definition.isRequired()); |
362 | |
} |
363 | |
|
364 | 0 | return isRequired; |
365 | |
} |
366 | |
|
367 | |
|
368 | |
|
369 | |
|
370 | |
|
371 | |
public Boolean getLookupAttributeReadOnly(Class businessObjectClass, String attributeName) { |
372 | 0 | Boolean readOnly = null; |
373 | |
|
374 | 0 | FieldDefinition definition = getLookupFieldDefinition(businessObjectClass, attributeName); |
375 | 0 | if (definition != null) { |
376 | 0 | readOnly = Boolean.valueOf(definition.isReadOnly()); |
377 | |
} |
378 | |
|
379 | 0 | return readOnly; |
380 | |
} |
381 | |
|
382 | |
|
383 | |
|
384 | |
|
385 | |
|
386 | |
public List getInquiryFieldNames(Class businessObjectClass, |
387 | |
String sectionTitle) { |
388 | 0 | List results = null; |
389 | |
|
390 | 0 | InquirySectionDefinition inquirySection = getInquiryDefinition( |
391 | |
businessObjectClass).getInquirySection(sectionTitle); |
392 | 0 | if (inquirySection != null) { |
393 | 0 | results = inquirySection.getInquiryFieldNames(); |
394 | |
} |
395 | |
|
396 | 0 | return results; |
397 | |
} |
398 | |
|
399 | |
|
400 | |
|
401 | |
|
402 | |
public List<InquirySectionDefinition> getInquirySections(Class businessObjectClass) { |
403 | 0 | List<InquirySectionDefinition> results = null; |
404 | |
|
405 | 0 | results = getInquiryDefinition(businessObjectClass) |
406 | |
.getInquirySections(); |
407 | |
|
408 | 0 | return results; |
409 | |
} |
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
public String getInquiryTitle(Class businessObjectClass) { |
415 | 0 | String title = ""; |
416 | |
|
417 | 0 | InquiryDefinition inquiryDefinition = getInquiryDefinition(businessObjectClass); |
418 | 0 | if (inquiryDefinition != null) { |
419 | 0 | title = inquiryDefinition.getTitle(); |
420 | |
} |
421 | |
|
422 | 0 | return title; |
423 | |
} |
424 | |
|
425 | |
|
426 | |
|
427 | |
|
428 | |
public Class getInquirableClass(Class businessObjectClass) { |
429 | 0 | Class clazz = null; |
430 | |
|
431 | 0 | InquiryDefinition inquiryDefinition = getInquiryDefinition(businessObjectClass); |
432 | 0 | if (inquiryDefinition != null) { |
433 | 0 | clazz = inquiryDefinition.getInquirableClass(); |
434 | |
} |
435 | |
|
436 | 0 | return clazz; |
437 | |
} |
438 | |
|
439 | |
|
440 | |
|
441 | |
|
442 | |
public String getMaintainableLabel(Class businessObjectClass) { |
443 | 0 | String label = ""; |
444 | |
|
445 | |
try { |
446 | 0 | MaintenanceDocumentEntry entry = getMaintenanceDocumentEntry(businessObjectClass); |
447 | 0 | if (entry != null) { |
448 | 0 | label = KNSServiceLocator.getWorkflowInfoService().getDocType(entry.getDocumentTypeName()).getDocTypeLabel(); |
449 | |
} |
450 | |
|
451 | 0 | } catch (WorkflowException e) { |
452 | 0 | throw new RuntimeException("Caught Exception trying to get the document type", e); |
453 | 0 | } |
454 | |
|
455 | 0 | return label; |
456 | |
} |
457 | |
|
458 | |
|
459 | |
|
460 | |
|
461 | |
|
462 | |
public String getLookupableID(Class businessObjectClass) { |
463 | 0 | String lookupableID = null; |
464 | |
|
465 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
466 | 0 | if (lookupDefinition != null) { |
467 | 0 | lookupableID = lookupDefinition.getLookupableID(); |
468 | |
} |
469 | |
|
470 | 0 | return lookupableID; |
471 | |
} |
472 | |
|
473 | |
|
474 | |
|
475 | |
|
476 | |
|
477 | |
|
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
|
486 | |
|
487 | |
public void performForceUppercase(BusinessObject bo) { |
488 | 0 | performForceUppercaseCycleSafe(bo, new HashSet<BusinessObject>()); |
489 | 0 | } |
490 | |
|
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
protected void performForceUppercaseCycleSafe(BusinessObject bo, Set<BusinessObject> visited) { |
496 | 0 | if (visited.contains(bo)) { |
497 | 0 | return; |
498 | |
} else { |
499 | 0 | visited.add(bo); |
500 | |
} |
501 | 0 | PropertyDescriptor descriptors[] = PropertyUtils |
502 | |
.getPropertyDescriptors(bo); |
503 | 0 | for (int i = 0; i < descriptors.length; ++i) { |
504 | |
try { |
505 | 0 | if (descriptors[i] instanceof IndexedPropertyDescriptor) { |
506 | |
|
507 | |
|
508 | |
|
509 | |
|
510 | |
|
511 | |
|
512 | |
} else { |
513 | 0 | Object nestedObject = ObjectUtils.getPropertyValue(bo, |
514 | |
descriptors[i].getName()); |
515 | 0 | if (ObjectUtils.isNotNull(nestedObject) |
516 | |
&& nestedObject instanceof BusinessObject) { |
517 | 0 | if (persistenceStructureService |
518 | |
.isPersistable(nestedObject.getClass())) { |
519 | |
try { |
520 | 0 | if (persistenceStructureService.hasReference(bo |
521 | |
.getClass(), descriptors[i].getName())) { |
522 | 0 | if (persistenceStructureService |
523 | |
.isReferenceUpdatable( |
524 | |
bo.getClass(), |
525 | |
descriptors[i].getName())) { |
526 | 0 | if (persistenceStructureService |
527 | |
.getForeignKeyFieldsPopulationState( |
528 | |
(PersistableBusinessObject) bo, |
529 | |
descriptors[i] |
530 | |
.getName()) |
531 | |
.isAllFieldsPopulated()) { |
532 | |
|
533 | |
|
534 | 0 | performForceUppercaseCycleSafe((BusinessObject) nestedObject, visited); |
535 | |
} |
536 | |
} |
537 | |
} |
538 | 0 | } catch (org.kuali.rice.kns.exception.ReferenceAttributeNotAnOjbReferenceException ranaore) { |
539 | 0 | LOG.debug("Propery " + descriptors[i].getName() |
540 | |
+ " is not a foreign key reference."); |
541 | 0 | } |
542 | |
} |
543 | 0 | } else if (nestedObject instanceof String) { |
544 | 0 | if (dataDictionaryService.isAttributeDefined( |
545 | |
bo.getClass(), descriptors[i].getName()) |
546 | |
.booleanValue() |
547 | |
&& dataDictionaryService |
548 | |
.getAttributeForceUppercase( |
549 | |
bo.getClass(), |
550 | |
descriptors[i].getName()) |
551 | |
.booleanValue()) { |
552 | 0 | String curValue = (String) nestedObject; |
553 | 0 | PropertyUtils.setProperty(bo, descriptors[i] |
554 | |
.getName(), curValue.toUpperCase()); |
555 | 0 | } |
556 | |
} else { |
557 | 0 | if (ObjectUtils.isNotNull(nestedObject) |
558 | |
&& nestedObject instanceof Collection) { |
559 | 0 | if (persistenceStructureService.hasCollection(bo |
560 | |
.getClass(), descriptors[i].getName())) { |
561 | 0 | if (persistenceStructureService |
562 | |
.isCollectionUpdatable(bo.getClass(), |
563 | |
descriptors[i].getName())) { |
564 | 0 | Iterator iter = ((Collection) nestedObject) |
565 | |
.iterator(); |
566 | 0 | while (iter.hasNext()) { |
567 | 0 | Object collElem = iter.next(); |
568 | 0 | if (collElem instanceof BusinessObject) { |
569 | 0 | if (persistenceStructureService |
570 | |
.isPersistable(collElem |
571 | |
.getClass())) { |
572 | 0 | performForceUppercaseCycleSafe((BusinessObject) collElem, visited); |
573 | |
} |
574 | |
} |
575 | 0 | } |
576 | |
} |
577 | |
} |
578 | |
} |
579 | |
} |
580 | |
} |
581 | 0 | } catch (IllegalAccessException e) { |
582 | 0 | throw new IntrospectionException( |
583 | |
"unable to performForceUppercase", e); |
584 | 0 | } catch (InvocationTargetException e) { |
585 | 0 | throw new IntrospectionException( |
586 | |
"unable to performForceUppercase", e); |
587 | 0 | } catch (NoSuchMethodException e) { |
588 | |
|
589 | |
|
590 | |
|
591 | 0 | } |
592 | |
} |
593 | 0 | } |
594 | |
|
595 | |
|
596 | |
|
597 | |
|
598 | |
|
599 | |
|
600 | |
public void setDataDictionaryService( |
601 | |
DataDictionaryService dataDictionaryService) { |
602 | 0 | this.dataDictionaryService = dataDictionaryService; |
603 | 0 | } |
604 | |
|
605 | |
|
606 | |
|
607 | |
|
608 | |
|
609 | |
|
610 | |
public DataDictionaryService getDataDictionaryService() { |
611 | 0 | return this.dataDictionaryService; |
612 | |
} |
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
|
621 | |
private BusinessObjectEntry getBusinessObjectEntry(Class businessObjectClass) { |
622 | 0 | validateBusinessObjectClass(businessObjectClass); |
623 | |
|
624 | 0 | BusinessObjectEntry entry = getDataDictionaryService() |
625 | |
.getDataDictionary().getBusinessObjectEntry( |
626 | |
businessObjectClass.getName()); |
627 | 0 | return entry; |
628 | |
} |
629 | |
|
630 | |
|
631 | |
|
632 | |
|
633 | |
|
634 | |
|
635 | |
|
636 | |
|
637 | |
private MaintenanceDocumentEntry getMaintenanceDocumentEntry( |
638 | |
Class businessObjectClass) { |
639 | 0 | validateBusinessObjectClass(businessObjectClass); |
640 | |
|
641 | 0 | MaintenanceDocumentEntry entry = getDataDictionaryService() |
642 | |
.getDataDictionary() |
643 | |
.getMaintenanceDocumentEntryForBusinessObjectClass( |
644 | |
businessObjectClass); |
645 | 0 | return entry; |
646 | |
} |
647 | |
|
648 | |
|
649 | |
|
650 | |
|
651 | |
|
652 | |
|
653 | |
|
654 | |
|
655 | |
private LookupDefinition getLookupDefinition(Class businessObjectClass) { |
656 | 0 | LookupDefinition lookupDefinition = null; |
657 | |
|
658 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
659 | 0 | if (entry != null) { |
660 | 0 | if (entry.hasLookupDefinition()) { |
661 | 0 | lookupDefinition = entry.getLookupDefinition(); |
662 | |
} |
663 | |
} |
664 | |
|
665 | 0 | return lookupDefinition; |
666 | |
} |
667 | |
|
668 | |
|
669 | |
|
670 | |
|
671 | |
|
672 | |
|
673 | |
|
674 | |
|
675 | |
|
676 | |
private FieldDefinition getLookupFieldDefinition(Class businessObjectClass, |
677 | |
String lookupFieldName) { |
678 | 0 | if (StringUtils.isBlank(lookupFieldName)) { |
679 | 0 | throw new IllegalArgumentException( |
680 | |
"invalid (blank) lookupFieldName"); |
681 | |
} |
682 | |
|
683 | 0 | FieldDefinition fieldDefinition = null; |
684 | |
|
685 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
686 | 0 | if (lookupDefinition != null) { |
687 | 0 | fieldDefinition = lookupDefinition.getLookupField(lookupFieldName); |
688 | |
} |
689 | |
|
690 | 0 | return fieldDefinition; |
691 | |
} |
692 | |
|
693 | |
|
694 | |
|
695 | |
|
696 | |
|
697 | |
|
698 | |
|
699 | |
|
700 | |
|
701 | |
private FieldDefinition getLookupResultFieldDefinition( |
702 | |
Class businessObjectClass, String lookupFieldName) { |
703 | 0 | if (StringUtils.isBlank(lookupFieldName)) { |
704 | 0 | throw new IllegalArgumentException( |
705 | |
"invalid (blank) lookupFieldName"); |
706 | |
} |
707 | |
|
708 | 0 | FieldDefinition fieldDefinition = null; |
709 | |
|
710 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
711 | 0 | if (lookupDefinition != null) { |
712 | 0 | fieldDefinition = lookupDefinition.getResultField(lookupFieldName); |
713 | |
} |
714 | |
|
715 | 0 | return fieldDefinition; |
716 | |
} |
717 | |
|
718 | |
|
719 | |
|
720 | |
|
721 | |
|
722 | |
|
723 | |
|
724 | |
|
725 | |
private InquiryDefinition getInquiryDefinition(Class businessObjectClass) { |
726 | 0 | InquiryDefinition inquiryDefinition = null; |
727 | |
|
728 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
729 | 0 | if (entry != null) { |
730 | 0 | if (entry.hasInquiryDefinition()) { |
731 | 0 | inquiryDefinition = entry.getInquiryDefinition(); |
732 | |
} |
733 | |
} |
734 | |
|
735 | 0 | return inquiryDefinition; |
736 | |
} |
737 | |
|
738 | |
|
739 | |
|
740 | |
|
741 | |
|
742 | |
public String getTitleAttribute(Class businessObjectClass) { |
743 | 0 | String titleAttribute = null; |
744 | |
|
745 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
746 | 0 | if (entry != null) { |
747 | 0 | titleAttribute = entry.getTitleAttribute(); |
748 | |
} |
749 | |
|
750 | 0 | return titleAttribute; |
751 | |
} |
752 | |
|
753 | |
|
754 | |
|
755 | |
|
756 | |
|
757 | |
|
758 | |
|
759 | |
|
760 | |
|
761 | |
private FieldDefinition getInquiryFieldDefinition( |
762 | |
Class businessObjectClass, String fieldName) { |
763 | 0 | if (StringUtils.isBlank(fieldName)) { |
764 | 0 | throw new IllegalArgumentException("invalid (blank) fieldName"); |
765 | |
} |
766 | |
|
767 | 0 | FieldDefinition fieldDefinition = null; |
768 | |
|
769 | 0 | InquiryDefinition inquiryDefinition = getInquiryDefinition(businessObjectClass); |
770 | 0 | if (inquiryDefinition != null) { |
771 | 0 | fieldDefinition = inquiryDefinition.getFieldDefinition(fieldName); |
772 | |
} |
773 | |
|
774 | 0 | return fieldDefinition; |
775 | |
} |
776 | |
|
777 | |
|
778 | |
|
779 | |
|
780 | |
|
781 | |
|
782 | |
private void validateBusinessObjectClass(Class businessObjectClass) { |
783 | 0 | if (businessObjectClass == null) { |
784 | 0 | throw new IllegalArgumentException( |
785 | |
"invalid (null) businessObjectClass"); |
786 | |
} |
787 | 0 | if (!BusinessObject.class.isAssignableFrom(businessObjectClass)) { |
788 | 0 | throw new IllegalArgumentException("class '" |
789 | |
+ businessObjectClass.getName() |
790 | |
+ "' is not a descendent of BusinessObject"); |
791 | |
} |
792 | 0 | } |
793 | |
|
794 | |
|
795 | |
|
796 | |
|
797 | |
|
798 | |
public Boolean forceLookupResultFieldInquiry(Class businessObjectClass, |
799 | |
String attributeName) { |
800 | 0 | Boolean forceLookup = null; |
801 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
802 | 0 | forceLookup = Boolean.valueOf(getLookupResultFieldDefinition( |
803 | |
businessObjectClass, attributeName).isForceInquiry()); |
804 | |
} |
805 | |
|
806 | 0 | return forceLookup; |
807 | |
} |
808 | |
|
809 | |
|
810 | |
|
811 | |
|
812 | |
|
813 | |
public Boolean noLookupResultFieldInquiry(Class businessObjectClass, |
814 | |
String attributeName) { |
815 | 0 | Boolean noLookup = null; |
816 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
817 | 0 | noLookup = Boolean.valueOf(getLookupResultFieldDefinition( |
818 | |
businessObjectClass, attributeName).isNoInquiry()); |
819 | |
} |
820 | |
|
821 | 0 | return noLookup; |
822 | |
} |
823 | |
|
824 | |
|
825 | |
|
826 | |
|
827 | |
|
828 | |
public Boolean forceLookupFieldLookup(Class businessObjectClass, |
829 | |
String attributeName) { |
830 | 0 | Boolean forceLookup = null; |
831 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
832 | 0 | forceLookup = Boolean.valueOf(getLookupFieldDefinition( |
833 | |
businessObjectClass, attributeName).isForceLookup()); |
834 | |
} |
835 | |
|
836 | 0 | return forceLookup; |
837 | |
} |
838 | |
|
839 | |
public Boolean forceInquiryFieldLookup(Class businessObjectClass, |
840 | |
String attributeName) { |
841 | 0 | Boolean forceInquiry = null; |
842 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
843 | 0 | forceInquiry = Boolean.valueOf(getLookupFieldDefinition( |
844 | |
businessObjectClass, attributeName).isForceInquiry()); |
845 | |
} |
846 | |
|
847 | 0 | return forceInquiry; |
848 | |
} |
849 | |
|
850 | |
|
851 | |
|
852 | |
|
853 | |
|
854 | |
public Boolean noLookupFieldLookup(Class businessObjectClass, |
855 | |
String attributeName) { |
856 | 0 | Boolean noLookup = null; |
857 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
858 | 0 | noLookup = Boolean.valueOf(getLookupFieldDefinition( |
859 | |
businessObjectClass, attributeName).isNoLookup()); |
860 | |
} |
861 | |
|
862 | 0 | return noLookup; |
863 | |
} |
864 | |
|
865 | |
|
866 | |
|
867 | |
|
868 | |
|
869 | |
public Boolean noDirectInquiryFieldLookup(Class businessObjectClass, |
870 | |
String attributeName) { |
871 | 0 | Boolean noDirectInquiry = null; |
872 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
873 | 0 | noDirectInquiry = Boolean.valueOf(getLookupFieldDefinition( |
874 | |
businessObjectClass, attributeName).isNoDirectInquiry()); |
875 | |
} |
876 | |
|
877 | 0 | return noDirectInquiry; |
878 | |
} |
879 | |
|
880 | |
|
881 | |
|
882 | |
|
883 | |
|
884 | |
public Boolean getLookupResultFieldUseShortLabel(Class businessObjectClass, |
885 | |
String attributeName) { |
886 | 0 | Boolean useShortLabel = null; |
887 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
888 | 0 | useShortLabel = Boolean.valueOf(getLookupResultFieldDefinition( |
889 | |
businessObjectClass, attributeName).isUseShortLabel()); |
890 | |
} |
891 | |
|
892 | 0 | return useShortLabel; |
893 | |
} |
894 | |
|
895 | |
|
896 | |
|
897 | |
|
898 | |
|
899 | |
public Boolean getLookupResultFieldTotal(Class businessObjectClass, String attributeName) { |
900 | 0 | Boolean total = false; |
901 | |
|
902 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
903 | 0 | total = Boolean.valueOf(getLookupResultFieldDefinition( |
904 | |
businessObjectClass, attributeName).isTotal()); |
905 | |
} |
906 | |
|
907 | 0 | return total; |
908 | |
} |
909 | |
|
910 | |
|
911 | |
|
912 | |
|
913 | |
|
914 | |
public Boolean forceInquiryFieldInquiry(Class businessObjectClass, |
915 | |
String attributeName) { |
916 | 0 | Boolean forceInquiry = null; |
917 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
918 | 0 | forceInquiry = Boolean.valueOf(getInquiryFieldDefinition( |
919 | |
businessObjectClass, attributeName).isForceInquiry()); |
920 | |
} |
921 | |
|
922 | 0 | return forceInquiry; |
923 | |
} |
924 | |
|
925 | |
|
926 | |
|
927 | |
|
928 | |
|
929 | |
public Boolean noInquiryFieldInquiry(Class businessObjectClass, |
930 | |
String attributeName) { |
931 | 0 | Boolean noInquiry = null; |
932 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
933 | 0 | noInquiry = Boolean.valueOf(getInquiryFieldDefinition( |
934 | |
businessObjectClass, attributeName).isNoInquiry()); |
935 | |
} |
936 | |
|
937 | 0 | return noInquiry; |
938 | |
} |
939 | |
|
940 | |
|
941 | |
|
942 | |
|
943 | |
|
944 | |
public String getLookupFieldDefaultValue(Class businessObjectClass, |
945 | |
String attributeName) { |
946 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName) |
947 | |
.getDefaultValue(); |
948 | |
} |
949 | |
|
950 | |
|
951 | |
|
952 | |
|
953 | |
|
954 | |
public Class<? extends ValueFinder> getLookupFieldDefaultValueFinderClass( |
955 | |
Class businessObjectClass, String attributeName) { |
956 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName) |
957 | |
.getDefaultValueFinderClass(); |
958 | |
} |
959 | |
|
960 | |
|
961 | |
public String getLookupFieldQuickfinderParameterString(Class businessObjectClass, String attributeName) { |
962 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName).getQuickfinderParameterString(); |
963 | |
} |
964 | |
|
965 | |
|
966 | |
public Class<? extends ValueFinder> getLookupFieldQuickfinderParameterStringBuilderClass(Class businessObjectClass, String attributeName) { |
967 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName).getQuickfinderParameterStringBuilderClass(); |
968 | |
} |
969 | |
|
970 | |
public void setPersistenceStructureService( |
971 | |
PersistenceStructureService persistenceStructureService) { |
972 | 0 | this.persistenceStructureService = persistenceStructureService; |
973 | 0 | } |
974 | |
|
975 | |
public Boolean areNotesSupported(Class businessObjectClass) { |
976 | 0 | Boolean hasNotesSupport = Boolean.FALSE; |
977 | |
|
978 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
979 | 0 | if (entry != null) { |
980 | 0 | hasNotesSupport = entry.isBoNotesEnabled(); |
981 | |
} |
982 | |
|
983 | 0 | return hasNotesSupport; |
984 | |
} |
985 | |
|
986 | |
|
987 | |
|
988 | |
|
989 | |
public boolean isLookupFieldTreatWildcardsAndOperatorsAsLiteral(Class businessObjectClass, String attributeName) { |
990 | 0 | FieldDefinition lookupFieldDefinition = getLookupFieldDefinition(businessObjectClass, attributeName); |
991 | 0 | return lookupFieldDefinition != null && lookupFieldDefinition.isTreatWildcardsAndOperatorsAsLiteral(); |
992 | |
} |
993 | |
|
994 | |
|
995 | |
|
996 | |
|
997 | |
|
998 | |
public String getInquiryFieldAdditionalDisplayAttributeName(Class businessObjectClass, String attributeName) { |
999 | 0 | String additionalDisplayAttributeName = null; |
1000 | |
|
1001 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
1002 | 0 | additionalDisplayAttributeName = getInquiryFieldDefinition(businessObjectClass, attributeName) |
1003 | |
.getAdditionalDisplayAttributeName(); |
1004 | |
} |
1005 | |
|
1006 | 0 | return additionalDisplayAttributeName; |
1007 | |
} |
1008 | |
|
1009 | |
|
1010 | |
|
1011 | |
|
1012 | |
|
1013 | |
public String getInquiryFieldAlternateDisplayAttributeName(Class businessObjectClass, String attributeName) { |
1014 | 0 | String alternateDisplayAttributeName = null; |
1015 | |
|
1016 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
1017 | 0 | alternateDisplayAttributeName = getInquiryFieldDefinition(businessObjectClass, attributeName) |
1018 | |
.getAlternateDisplayAttributeName(); |
1019 | |
} |
1020 | |
|
1021 | 0 | return alternateDisplayAttributeName; |
1022 | |
} |
1023 | |
|
1024 | |
|
1025 | |
|
1026 | |
|
1027 | |
|
1028 | |
public String getLookupFieldAdditionalDisplayAttributeName(Class businessObjectClass, String attributeName) { |
1029 | 0 | String additionalDisplayAttributeName = null; |
1030 | |
|
1031 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
1032 | 0 | additionalDisplayAttributeName = getLookupResultFieldDefinition(businessObjectClass, attributeName) |
1033 | |
.getAdditionalDisplayAttributeName(); |
1034 | |
} |
1035 | |
|
1036 | 0 | return additionalDisplayAttributeName; |
1037 | |
} |
1038 | |
|
1039 | |
|
1040 | |
|
1041 | |
|
1042 | |
|
1043 | |
public String getLookupFieldAlternateDisplayAttributeName(Class businessObjectClass, String attributeName) { |
1044 | 0 | String alternateDisplayAttributeName = null; |
1045 | |
|
1046 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
1047 | 0 | alternateDisplayAttributeName = getLookupResultFieldDefinition(businessObjectClass, attributeName) |
1048 | |
.getAlternateDisplayAttributeName(); |
1049 | |
} |
1050 | |
|
1051 | 0 | return alternateDisplayAttributeName; |
1052 | |
} |
1053 | |
|
1054 | |
|
1055 | |
|
1056 | |
|
1057 | |
public Boolean tranlateCodesInLookup(Class businessObjectClass) { |
1058 | 0 | boolean translateCodes = false; |
1059 | |
|
1060 | 0 | if (getLookupDefinition(businessObjectClass) != null) { |
1061 | 0 | translateCodes = getLookupDefinition(businessObjectClass).isTranslateCodes(); |
1062 | |
} |
1063 | |
|
1064 | 0 | return translateCodes; |
1065 | |
} |
1066 | |
|
1067 | |
|
1068 | |
|
1069 | |
|
1070 | |
public Boolean tranlateCodesInInquiry(Class businessObjectClass) { |
1071 | 0 | boolean translateCodes = false; |
1072 | |
|
1073 | 0 | if (getInquiryDefinition(businessObjectClass) != null) { |
1074 | 0 | translateCodes = getInquiryDefinition(businessObjectClass).isTranslateCodes(); |
1075 | |
} |
1076 | |
|
1077 | 0 | return translateCodes; |
1078 | |
} |
1079 | |
|
1080 | |
|
1081 | |
|
1082 | |
|
1083 | |
|
1084 | |
public boolean isLookupFieldTriggerOnChange(Class businessObjectClass, String attributeName) { |
1085 | 0 | boolean triggerOnChange = false; |
1086 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
1087 | 0 | triggerOnChange = getLookupFieldDefinition(businessObjectClass, attributeName).isTriggerOnChange(); |
1088 | |
} |
1089 | |
|
1090 | 0 | return triggerOnChange; |
1091 | |
} |
1092 | |
|
1093 | |
|
1094 | |
|
1095 | |
|
1096 | |
public boolean disableSearchButtonsInLookup(Class businessObjectClass) { |
1097 | 0 | boolean disableSearchButtons = false; |
1098 | |
|
1099 | 0 | if (getLookupDefinition(businessObjectClass) != null) { |
1100 | 0 | disableSearchButtons = getLookupDefinition(businessObjectClass).isDisableSearchButtons(); |
1101 | |
} |
1102 | |
|
1103 | 0 | return disableSearchButtons; |
1104 | |
} |
1105 | |
|
1106 | |
|
1107 | |
|
1108 | |
|
1109 | |
public List<String> getGroupByAttributesForEffectiveDating(Class businessObjectClass) { |
1110 | 0 | List<String> groupByList = null; |
1111 | |
|
1112 | 0 | if (getBusinessObjectEntry(businessObjectClass) != null) { |
1113 | 0 | groupByList = getBusinessObjectEntry(businessObjectClass).getGroupByAttributesForEffectiveDating(); |
1114 | |
} |
1115 | |
|
1116 | 0 | return groupByList; |
1117 | |
} |
1118 | |
|
1119 | |
} |