| 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 | |
|
| 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 | 0 | MaintenanceDocumentEntry entry = getMaintenanceDocumentEntry(businessObjectClass); |
| 446 | 0 | if (entry != null) { |
| 447 | 0 | label = KewApiServiceLocator.getDocumentTypeService().getDocumentTypeByName(entry.getDocumentTypeName()).getLabel(); |
| 448 | |
} |
| 449 | |
|
| 450 | 0 | return label; |
| 451 | |
} |
| 452 | |
|
| 453 | |
|
| 454 | |
|
| 455 | |
|
| 456 | |
|
| 457 | |
public String getLookupableID(Class businessObjectClass) { |
| 458 | 0 | String lookupableID = null; |
| 459 | |
|
| 460 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
| 461 | 0 | if (lookupDefinition != null) { |
| 462 | 0 | lookupableID = lookupDefinition.getLookupableID(); |
| 463 | |
} |
| 464 | |
|
| 465 | 0 | return lookupableID; |
| 466 | |
} |
| 467 | |
|
| 468 | |
|
| 469 | |
|
| 470 | |
|
| 471 | |
|
| 472 | |
|
| 473 | |
|
| 474 | |
|
| 475 | |
|
| 476 | |
|
| 477 | |
|
| 478 | |
|
| 479 | |
|
| 480 | |
|
| 481 | |
|
| 482 | |
public void performForceUppercase(BusinessObject bo) { |
| 483 | 0 | performForceUppercaseCycleSafe(bo, new HashSet<BusinessObject>()); |
| 484 | 0 | } |
| 485 | |
|
| 486 | |
|
| 487 | |
|
| 488 | |
|
| 489 | |
|
| 490 | |
protected void performForceUppercaseCycleSafe(BusinessObject bo, Set<BusinessObject> visited) { |
| 491 | 0 | if (visited.contains(bo)) { |
| 492 | 0 | return; |
| 493 | |
} else { |
| 494 | 0 | visited.add(bo); |
| 495 | |
} |
| 496 | 0 | PropertyDescriptor descriptors[] = PropertyUtils |
| 497 | |
.getPropertyDescriptors(bo); |
| 498 | 0 | for (int i = 0; i < descriptors.length; ++i) { |
| 499 | |
try { |
| 500 | 0 | if (descriptors[i] instanceof IndexedPropertyDescriptor) { |
| 501 | |
|
| 502 | |
|
| 503 | |
|
| 504 | |
|
| 505 | |
|
| 506 | |
|
| 507 | |
} else { |
| 508 | 0 | Object nestedObject = ObjectUtils.getPropertyValue(bo, |
| 509 | |
descriptors[i].getName()); |
| 510 | 0 | if (ObjectUtils.isNotNull(nestedObject) |
| 511 | |
&& nestedObject instanceof BusinessObject) { |
| 512 | 0 | if (persistenceStructureService |
| 513 | |
.isPersistable(nestedObject.getClass())) { |
| 514 | |
try { |
| 515 | 0 | if (persistenceStructureService.hasReference(bo |
| 516 | |
.getClass(), descriptors[i].getName())) { |
| 517 | 0 | if (persistenceStructureService |
| 518 | |
.isReferenceUpdatable( |
| 519 | |
bo.getClass(), |
| 520 | |
descriptors[i].getName())) { |
| 521 | 0 | if (persistenceStructureService |
| 522 | |
.getForeignKeyFieldsPopulationState( |
| 523 | |
(PersistableBusinessObject) bo, |
| 524 | |
descriptors[i] |
| 525 | |
.getName()) |
| 526 | |
.isAllFieldsPopulated()) { |
| 527 | |
|
| 528 | |
|
| 529 | 0 | performForceUppercaseCycleSafe((BusinessObject) nestedObject, visited); |
| 530 | |
} |
| 531 | |
} |
| 532 | |
} |
| 533 | 0 | } catch (org.kuali.rice.krad.exception.ReferenceAttributeNotAnOjbReferenceException ranaore) { |
| 534 | 0 | LOG.debug("Propery " + descriptors[i].getName() |
| 535 | |
+ " is not a foreign key reference."); |
| 536 | 0 | } |
| 537 | |
} |
| 538 | 0 | } else if (nestedObject instanceof String) { |
| 539 | 0 | if (dataDictionaryService.isAttributeDefined( |
| 540 | |
bo.getClass(), descriptors[i].getName()) |
| 541 | |
.booleanValue() |
| 542 | |
&& dataDictionaryService |
| 543 | |
.getAttributeForceUppercase( |
| 544 | |
bo.getClass(), |
| 545 | |
descriptors[i].getName()) |
| 546 | |
.booleanValue()) { |
| 547 | 0 | String curValue = (String) nestedObject; |
| 548 | 0 | PropertyUtils.setProperty(bo, descriptors[i] |
| 549 | |
.getName(), curValue.toUpperCase()); |
| 550 | 0 | } |
| 551 | |
} else { |
| 552 | 0 | if (ObjectUtils.isNotNull(nestedObject) |
| 553 | |
&& nestedObject instanceof Collection) { |
| 554 | 0 | if (persistenceStructureService.hasCollection(bo |
| 555 | |
.getClass(), descriptors[i].getName())) { |
| 556 | 0 | if (persistenceStructureService |
| 557 | |
.isCollectionUpdatable(bo.getClass(), |
| 558 | |
descriptors[i].getName())) { |
| 559 | 0 | Iterator iter = ((Collection) nestedObject) |
| 560 | |
.iterator(); |
| 561 | 0 | while (iter.hasNext()) { |
| 562 | 0 | Object collElem = iter.next(); |
| 563 | 0 | if (collElem instanceof BusinessObject) { |
| 564 | 0 | if (persistenceStructureService |
| 565 | |
.isPersistable(collElem |
| 566 | |
.getClass())) { |
| 567 | 0 | performForceUppercaseCycleSafe((BusinessObject) collElem, visited); |
| 568 | |
} |
| 569 | |
} |
| 570 | 0 | } |
| 571 | |
} |
| 572 | |
} |
| 573 | |
} |
| 574 | |
} |
| 575 | |
} |
| 576 | 0 | } catch (IllegalAccessException e) { |
| 577 | 0 | throw new IntrospectionException( |
| 578 | |
"unable to performForceUppercase", e); |
| 579 | 0 | } catch (InvocationTargetException e) { |
| 580 | 0 | throw new IntrospectionException( |
| 581 | |
"unable to performForceUppercase", e); |
| 582 | 0 | } catch (NoSuchMethodException e) { |
| 583 | |
|
| 584 | |
|
| 585 | |
|
| 586 | 0 | } |
| 587 | |
} |
| 588 | 0 | } |
| 589 | |
|
| 590 | |
|
| 591 | |
|
| 592 | |
|
| 593 | |
|
| 594 | |
|
| 595 | |
public void setDataDictionaryService( |
| 596 | |
DataDictionaryService dataDictionaryService) { |
| 597 | 0 | this.dataDictionaryService = dataDictionaryService; |
| 598 | 0 | } |
| 599 | |
|
| 600 | |
|
| 601 | |
|
| 602 | |
|
| 603 | |
|
| 604 | |
|
| 605 | |
public DataDictionaryService getDataDictionaryService() { |
| 606 | 0 | return this.dataDictionaryService; |
| 607 | |
} |
| 608 | |
|
| 609 | |
|
| 610 | |
|
| 611 | |
|
| 612 | |
|
| 613 | |
|
| 614 | |
|
| 615 | |
|
| 616 | |
private BusinessObjectEntry getBusinessObjectEntry(Class businessObjectClass) { |
| 617 | 0 | validateBusinessObjectClass(businessObjectClass); |
| 618 | |
|
| 619 | 0 | BusinessObjectEntry entry = (BusinessObjectEntry) getDataDictionaryService() |
| 620 | |
.getDataDictionary().getBusinessObjectEntry( |
| 621 | |
businessObjectClass.getName()); |
| 622 | 0 | return entry; |
| 623 | |
} |
| 624 | |
|
| 625 | |
|
| 626 | |
|
| 627 | |
|
| 628 | |
|
| 629 | |
|
| 630 | |
|
| 631 | |
|
| 632 | |
private MaintenanceDocumentEntry getMaintenanceDocumentEntry( |
| 633 | |
Class businessObjectClass) { |
| 634 | 0 | validateBusinessObjectClass(businessObjectClass); |
| 635 | |
|
| 636 | 0 | MaintenanceDocumentEntry entry = (MaintenanceDocumentEntry) getDataDictionaryService() |
| 637 | |
.getDataDictionary() |
| 638 | |
.getMaintenanceDocumentEntryForBusinessObjectClass( |
| 639 | |
businessObjectClass); |
| 640 | 0 | return entry; |
| 641 | |
} |
| 642 | |
|
| 643 | |
|
| 644 | |
|
| 645 | |
|
| 646 | |
|
| 647 | |
|
| 648 | |
|
| 649 | |
|
| 650 | |
private LookupDefinition getLookupDefinition(Class businessObjectClass) { |
| 651 | 0 | LookupDefinition lookupDefinition = null; |
| 652 | |
|
| 653 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
| 654 | 0 | if (entry != null) { |
| 655 | 0 | if (entry.hasLookupDefinition()) { |
| 656 | 0 | lookupDefinition = entry.getLookupDefinition(); |
| 657 | |
} |
| 658 | |
} |
| 659 | |
|
| 660 | 0 | return lookupDefinition; |
| 661 | |
} |
| 662 | |
|
| 663 | |
|
| 664 | |
|
| 665 | |
|
| 666 | |
|
| 667 | |
|
| 668 | |
|
| 669 | |
|
| 670 | |
|
| 671 | |
private FieldDefinition getLookupFieldDefinition(Class businessObjectClass, |
| 672 | |
String lookupFieldName) { |
| 673 | 0 | if (StringUtils.isBlank(lookupFieldName)) { |
| 674 | 0 | throw new IllegalArgumentException( |
| 675 | |
"invalid (blank) lookupFieldName"); |
| 676 | |
} |
| 677 | |
|
| 678 | 0 | FieldDefinition fieldDefinition = null; |
| 679 | |
|
| 680 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
| 681 | 0 | if (lookupDefinition != null) { |
| 682 | 0 | fieldDefinition = lookupDefinition.getLookupField(lookupFieldName); |
| 683 | |
} |
| 684 | |
|
| 685 | 0 | return fieldDefinition; |
| 686 | |
} |
| 687 | |
|
| 688 | |
|
| 689 | |
|
| 690 | |
|
| 691 | |
|
| 692 | |
|
| 693 | |
|
| 694 | |
|
| 695 | |
|
| 696 | |
private FieldDefinition getLookupResultFieldDefinition( |
| 697 | |
Class businessObjectClass, String lookupFieldName) { |
| 698 | 0 | if (StringUtils.isBlank(lookupFieldName)) { |
| 699 | 0 | throw new IllegalArgumentException( |
| 700 | |
"invalid (blank) lookupFieldName"); |
| 701 | |
} |
| 702 | |
|
| 703 | 0 | FieldDefinition fieldDefinition = null; |
| 704 | |
|
| 705 | 0 | LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass); |
| 706 | 0 | if (lookupDefinition != null) { |
| 707 | 0 | fieldDefinition = lookupDefinition.getResultField(lookupFieldName); |
| 708 | |
} |
| 709 | |
|
| 710 | 0 | return fieldDefinition; |
| 711 | |
} |
| 712 | |
|
| 713 | |
|
| 714 | |
|
| 715 | |
|
| 716 | |
|
| 717 | |
|
| 718 | |
|
| 719 | |
|
| 720 | |
private InquiryDefinition getInquiryDefinition(Class businessObjectClass) { |
| 721 | 0 | InquiryDefinition inquiryDefinition = null; |
| 722 | |
|
| 723 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
| 724 | 0 | if (entry != null) { |
| 725 | 0 | if (entry.hasInquiryDefinition()) { |
| 726 | 0 | inquiryDefinition = entry.getInquiryDefinition(); |
| 727 | |
} |
| 728 | |
} |
| 729 | |
|
| 730 | 0 | return inquiryDefinition; |
| 731 | |
} |
| 732 | |
|
| 733 | |
|
| 734 | |
|
| 735 | |
|
| 736 | |
|
| 737 | |
public String getTitleAttribute(Class businessObjectClass) { |
| 738 | 0 | String titleAttribute = null; |
| 739 | |
|
| 740 | 0 | BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass); |
| 741 | 0 | if (entry != null) { |
| 742 | 0 | titleAttribute = entry.getTitleAttribute(); |
| 743 | |
} |
| 744 | |
|
| 745 | 0 | return titleAttribute; |
| 746 | |
} |
| 747 | |
|
| 748 | |
|
| 749 | |
|
| 750 | |
|
| 751 | |
|
| 752 | |
|
| 753 | |
|
| 754 | |
|
| 755 | |
|
| 756 | |
private FieldDefinition getInquiryFieldDefinition( |
| 757 | |
Class businessObjectClass, String fieldName) { |
| 758 | 0 | if (StringUtils.isBlank(fieldName)) { |
| 759 | 0 | throw new IllegalArgumentException("invalid (blank) fieldName"); |
| 760 | |
} |
| 761 | |
|
| 762 | 0 | FieldDefinition fieldDefinition = null; |
| 763 | |
|
| 764 | 0 | InquiryDefinition inquiryDefinition = getInquiryDefinition(businessObjectClass); |
| 765 | 0 | if (inquiryDefinition != null) { |
| 766 | 0 | fieldDefinition = inquiryDefinition.getFieldDefinition(fieldName); |
| 767 | |
} |
| 768 | |
|
| 769 | 0 | return fieldDefinition; |
| 770 | |
} |
| 771 | |
|
| 772 | |
|
| 773 | |
|
| 774 | |
|
| 775 | |
|
| 776 | |
|
| 777 | |
private void validateBusinessObjectClass(Class businessObjectClass) { |
| 778 | 0 | if (businessObjectClass == null) { |
| 779 | 0 | throw new IllegalArgumentException( |
| 780 | |
"invalid (null) dataObjectClass"); |
| 781 | |
} |
| 782 | 0 | if (!BusinessObject.class.isAssignableFrom(businessObjectClass)) { |
| 783 | 0 | throw new IllegalArgumentException("class '" |
| 784 | |
+ businessObjectClass.getName() |
| 785 | |
+ "' is not a descendent of BusinessObject"); |
| 786 | |
} |
| 787 | 0 | } |
| 788 | |
|
| 789 | |
|
| 790 | |
|
| 791 | |
|
| 792 | |
|
| 793 | |
public Boolean forceLookupResultFieldInquiry(Class businessObjectClass, |
| 794 | |
String attributeName) { |
| 795 | 0 | Boolean forceLookup = null; |
| 796 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
| 797 | 0 | forceLookup = Boolean.valueOf(getLookupResultFieldDefinition( |
| 798 | |
businessObjectClass, attributeName).isForceInquiry()); |
| 799 | |
} |
| 800 | |
|
| 801 | 0 | return forceLookup; |
| 802 | |
} |
| 803 | |
|
| 804 | |
|
| 805 | |
|
| 806 | |
|
| 807 | |
|
| 808 | |
public Boolean noLookupResultFieldInquiry(Class businessObjectClass, |
| 809 | |
String attributeName) { |
| 810 | 0 | Boolean noLookup = null; |
| 811 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
| 812 | 0 | noLookup = Boolean.valueOf(getLookupResultFieldDefinition( |
| 813 | |
businessObjectClass, attributeName).isNoInquiry()); |
| 814 | |
} |
| 815 | |
|
| 816 | 0 | return noLookup; |
| 817 | |
} |
| 818 | |
|
| 819 | |
|
| 820 | |
|
| 821 | |
|
| 822 | |
|
| 823 | |
public Boolean forceLookupFieldLookup(Class businessObjectClass, |
| 824 | |
String attributeName) { |
| 825 | 0 | Boolean forceLookup = null; |
| 826 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
| 827 | 0 | forceLookup = Boolean.valueOf(getLookupFieldDefinition( |
| 828 | |
businessObjectClass, attributeName).isForceLookup()); |
| 829 | |
} |
| 830 | |
|
| 831 | 0 | return forceLookup; |
| 832 | |
} |
| 833 | |
|
| 834 | |
public Boolean forceInquiryFieldLookup(Class businessObjectClass, |
| 835 | |
String attributeName) { |
| 836 | 0 | Boolean forceInquiry = null; |
| 837 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
| 838 | 0 | forceInquiry = Boolean.valueOf(getLookupFieldDefinition( |
| 839 | |
businessObjectClass, attributeName).isForceInquiry()); |
| 840 | |
} |
| 841 | |
|
| 842 | 0 | return forceInquiry; |
| 843 | |
} |
| 844 | |
|
| 845 | |
|
| 846 | |
|
| 847 | |
|
| 848 | |
|
| 849 | |
public Boolean noLookupFieldLookup(Class businessObjectClass, |
| 850 | |
String attributeName) { |
| 851 | 0 | Boolean noLookup = null; |
| 852 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
| 853 | 0 | noLookup = Boolean.valueOf(getLookupFieldDefinition( |
| 854 | |
businessObjectClass, attributeName).isNoLookup()); |
| 855 | |
} |
| 856 | |
|
| 857 | 0 | return noLookup; |
| 858 | |
} |
| 859 | |
|
| 860 | |
|
| 861 | |
|
| 862 | |
|
| 863 | |
|
| 864 | |
public Boolean noDirectInquiryFieldLookup(Class businessObjectClass, |
| 865 | |
String attributeName) { |
| 866 | 0 | Boolean noDirectInquiry = null; |
| 867 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
| 868 | 0 | noDirectInquiry = Boolean.valueOf(getLookupFieldDefinition( |
| 869 | |
businessObjectClass, attributeName).isNoDirectInquiry()); |
| 870 | |
} |
| 871 | |
|
| 872 | 0 | return noDirectInquiry; |
| 873 | |
} |
| 874 | |
|
| 875 | |
|
| 876 | |
|
| 877 | |
|
| 878 | |
|
| 879 | |
public Boolean getLookupResultFieldUseShortLabel(Class businessObjectClass, |
| 880 | |
String attributeName) { |
| 881 | 0 | Boolean useShortLabel = null; |
| 882 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
| 883 | 0 | useShortLabel = Boolean.valueOf(getLookupResultFieldDefinition( |
| 884 | |
businessObjectClass, attributeName).isUseShortLabel()); |
| 885 | |
} |
| 886 | |
|
| 887 | 0 | return useShortLabel; |
| 888 | |
} |
| 889 | |
|
| 890 | |
|
| 891 | |
|
| 892 | |
|
| 893 | |
|
| 894 | |
public Boolean getLookupResultFieldTotal(Class businessObjectClass, String attributeName) { |
| 895 | 0 | Boolean total = false; |
| 896 | |
|
| 897 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
| 898 | 0 | total = Boolean.valueOf(getLookupResultFieldDefinition( |
| 899 | |
businessObjectClass, attributeName).isTotal()); |
| 900 | |
} |
| 901 | |
|
| 902 | 0 | return total; |
| 903 | |
} |
| 904 | |
|
| 905 | |
|
| 906 | |
|
| 907 | |
|
| 908 | |
|
| 909 | |
public Boolean forceInquiryFieldInquiry(Class businessObjectClass, |
| 910 | |
String attributeName) { |
| 911 | 0 | Boolean forceInquiry = null; |
| 912 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
| 913 | 0 | forceInquiry = Boolean.valueOf(getInquiryFieldDefinition( |
| 914 | |
businessObjectClass, attributeName).isForceInquiry()); |
| 915 | |
} |
| 916 | |
|
| 917 | 0 | return forceInquiry; |
| 918 | |
} |
| 919 | |
|
| 920 | |
|
| 921 | |
|
| 922 | |
|
| 923 | |
|
| 924 | |
public Boolean noInquiryFieldInquiry(Class businessObjectClass, |
| 925 | |
String attributeName) { |
| 926 | 0 | Boolean noInquiry = null; |
| 927 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
| 928 | 0 | noInquiry = Boolean.valueOf(getInquiryFieldDefinition( |
| 929 | |
businessObjectClass, attributeName).isNoInquiry()); |
| 930 | |
} |
| 931 | |
|
| 932 | 0 | return noInquiry; |
| 933 | |
} |
| 934 | |
|
| 935 | |
|
| 936 | |
|
| 937 | |
|
| 938 | |
|
| 939 | |
public String getLookupFieldDefaultValue(Class businessObjectClass, |
| 940 | |
String attributeName) { |
| 941 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName) |
| 942 | |
.getDefaultValue(); |
| 943 | |
} |
| 944 | |
|
| 945 | |
|
| 946 | |
|
| 947 | |
|
| 948 | |
|
| 949 | |
public Class<? extends ValueFinder> getLookupFieldDefaultValueFinderClass( |
| 950 | |
Class businessObjectClass, String attributeName) { |
| 951 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName) |
| 952 | |
.getDefaultValueFinderClass(); |
| 953 | |
} |
| 954 | |
|
| 955 | |
|
| 956 | |
public String getLookupFieldQuickfinderParameterString(Class businessObjectClass, String attributeName) { |
| 957 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName).getQuickfinderParameterString(); |
| 958 | |
} |
| 959 | |
|
| 960 | |
|
| 961 | |
public Class<? extends ValueFinder> getLookupFieldQuickfinderParameterStringBuilderClass(Class businessObjectClass, String attributeName) { |
| 962 | 0 | return getLookupFieldDefinition(businessObjectClass, attributeName).getQuickfinderParameterStringBuilderClass(); |
| 963 | |
} |
| 964 | |
|
| 965 | |
public void setPersistenceStructureService( |
| 966 | |
PersistenceStructureService persistenceStructureService) { |
| 967 | 0 | this.persistenceStructureService = persistenceStructureService; |
| 968 | 0 | } |
| 969 | |
|
| 970 | |
|
| 971 | |
|
| 972 | |
|
| 973 | |
public boolean isLookupFieldTreatWildcardsAndOperatorsAsLiteral(Class businessObjectClass, String attributeName) { |
| 974 | 0 | FieldDefinition lookupFieldDefinition = getLookupFieldDefinition(businessObjectClass, attributeName); |
| 975 | 0 | return lookupFieldDefinition != null && lookupFieldDefinition.isTreatWildcardsAndOperatorsAsLiteral(); |
| 976 | |
} |
| 977 | |
|
| 978 | |
|
| 979 | |
|
| 980 | |
|
| 981 | |
|
| 982 | |
public String getInquiryFieldAdditionalDisplayAttributeName(Class businessObjectClass, String attributeName) { |
| 983 | 0 | String additionalDisplayAttributeName = null; |
| 984 | |
|
| 985 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
| 986 | 0 | additionalDisplayAttributeName = getInquiryFieldDefinition(businessObjectClass, attributeName) |
| 987 | |
.getAdditionalDisplayAttributeName(); |
| 988 | |
} |
| 989 | |
|
| 990 | 0 | return additionalDisplayAttributeName; |
| 991 | |
} |
| 992 | |
|
| 993 | |
|
| 994 | |
|
| 995 | |
|
| 996 | |
|
| 997 | |
public String getInquiryFieldAlternateDisplayAttributeName(Class businessObjectClass, String attributeName) { |
| 998 | 0 | String alternateDisplayAttributeName = null; |
| 999 | |
|
| 1000 | 0 | if (getInquiryFieldDefinition(businessObjectClass, attributeName) != null) { |
| 1001 | 0 | alternateDisplayAttributeName = getInquiryFieldDefinition(businessObjectClass, attributeName) |
| 1002 | |
.getAlternateDisplayAttributeName(); |
| 1003 | |
} |
| 1004 | |
|
| 1005 | 0 | return alternateDisplayAttributeName; |
| 1006 | |
} |
| 1007 | |
|
| 1008 | |
|
| 1009 | |
|
| 1010 | |
|
| 1011 | |
|
| 1012 | |
public String getLookupFieldAdditionalDisplayAttributeName(Class businessObjectClass, String attributeName) { |
| 1013 | 0 | String additionalDisplayAttributeName = null; |
| 1014 | |
|
| 1015 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
| 1016 | 0 | additionalDisplayAttributeName = getLookupResultFieldDefinition(businessObjectClass, attributeName) |
| 1017 | |
.getAdditionalDisplayAttributeName(); |
| 1018 | |
} |
| 1019 | |
|
| 1020 | 0 | return additionalDisplayAttributeName; |
| 1021 | |
} |
| 1022 | |
|
| 1023 | |
|
| 1024 | |
|
| 1025 | |
|
| 1026 | |
|
| 1027 | |
public String getLookupFieldAlternateDisplayAttributeName(Class businessObjectClass, String attributeName) { |
| 1028 | 0 | String alternateDisplayAttributeName = null; |
| 1029 | |
|
| 1030 | 0 | if (getLookupResultFieldDefinition(businessObjectClass, attributeName) != null) { |
| 1031 | 0 | alternateDisplayAttributeName = getLookupResultFieldDefinition(businessObjectClass, attributeName) |
| 1032 | |
.getAlternateDisplayAttributeName(); |
| 1033 | |
} |
| 1034 | |
|
| 1035 | 0 | return alternateDisplayAttributeName; |
| 1036 | |
} |
| 1037 | |
|
| 1038 | |
|
| 1039 | |
|
| 1040 | |
|
| 1041 | |
public Boolean tranlateCodesInLookup(Class businessObjectClass) { |
| 1042 | 0 | boolean translateCodes = false; |
| 1043 | |
|
| 1044 | 0 | if (getLookupDefinition(businessObjectClass) != null) { |
| 1045 | 0 | translateCodes = getLookupDefinition(businessObjectClass).isTranslateCodes(); |
| 1046 | |
} |
| 1047 | |
|
| 1048 | 0 | return translateCodes; |
| 1049 | |
} |
| 1050 | |
|
| 1051 | |
|
| 1052 | |
|
| 1053 | |
|
| 1054 | |
public Boolean tranlateCodesInInquiry(Class businessObjectClass) { |
| 1055 | 0 | boolean translateCodes = false; |
| 1056 | |
|
| 1057 | 0 | if (getInquiryDefinition(businessObjectClass) != null) { |
| 1058 | 0 | translateCodes = getInquiryDefinition(businessObjectClass).isTranslateCodes(); |
| 1059 | |
} |
| 1060 | |
|
| 1061 | 0 | return translateCodes; |
| 1062 | |
} |
| 1063 | |
|
| 1064 | |
|
| 1065 | |
|
| 1066 | |
|
| 1067 | |
|
| 1068 | |
public boolean isLookupFieldTriggerOnChange(Class businessObjectClass, String attributeName) { |
| 1069 | 0 | boolean triggerOnChange = false; |
| 1070 | 0 | if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) { |
| 1071 | 0 | triggerOnChange = getLookupFieldDefinition(businessObjectClass, attributeName).isTriggerOnChange(); |
| 1072 | |
} |
| 1073 | |
|
| 1074 | 0 | return triggerOnChange; |
| 1075 | |
} |
| 1076 | |
|
| 1077 | |
|
| 1078 | |
|
| 1079 | |
|
| 1080 | |
public boolean disableSearchButtonsInLookup(Class businessObjectClass) { |
| 1081 | 0 | boolean disableSearchButtons = false; |
| 1082 | |
|
| 1083 | 0 | if (getLookupDefinition(businessObjectClass) != null) { |
| 1084 | 0 | disableSearchButtons = getLookupDefinition(businessObjectClass).isDisableSearchButtons(); |
| 1085 | |
} |
| 1086 | |
|
| 1087 | 0 | return disableSearchButtons; |
| 1088 | |
} |
| 1089 | |
|
| 1090 | |
|
| 1091 | |
|
| 1092 | |
} |