| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |   | 
  | 17 |  |  package org.kuali.rice.kns.datadictionary; | 
  | 18 |  |   | 
  | 19 |  |  import java.beans.IntrospectionException; | 
  | 20 |  |  import java.beans.PropertyDescriptor; | 
  | 21 |  |  import java.io.File; | 
  | 22 |  |  import java.io.IOException; | 
  | 23 |  |  import java.util.ArrayList; | 
  | 24 |  |  import java.util.Collection; | 
  | 25 |  |  import java.util.HashMap; | 
  | 26 |  |  import java.util.List; | 
  | 27 |  |  import java.util.Map; | 
  | 28 |  |  import java.util.Set; | 
  | 29 |  |  import java.util.TreeMap; | 
  | 30 |  |   | 
  | 31 |  |  import org.apache.commons.lang.StringUtils; | 
  | 32 |  |  import org.apache.commons.logging.Log; | 
  | 33 |  |  import org.apache.commons.logging.LogFactory; | 
  | 34 |  |  import org.kuali.rice.core.util.ClassLoaderUtils; | 
  | 35 |  |  import org.kuali.rice.kns.bo.BusinessObject; | 
  | 36 |  |  import org.kuali.rice.kns.bo.PersistableBusinessObjectExtension; | 
  | 37 |  |  import org.kuali.rice.kns.datadictionary.exception.AttributeValidationException; | 
  | 38 |  |  import org.kuali.rice.kns.datadictionary.exception.CompletionException; | 
  | 39 |  |  import org.kuali.rice.kns.service.KNSServiceLocator; | 
  | 40 |  |  import org.kuali.rice.kns.service.PersistenceStructureService; | 
  | 41 |  |  import org.kuali.rice.kns.util.ObjectUtils; | 
  | 42 |  |  import org.springframework.beans.factory.support.DefaultListableBeanFactory; | 
  | 43 |  |  import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; | 
  | 44 |  |  import org.springframework.core.io.DefaultResourceLoader; | 
  | 45 |  |  import org.springframework.core.io.Resource; | 
  | 46 |  |   | 
  | 47 |  |   | 
  | 48 |  |   | 
  | 49 |  |   | 
  | 50 |  |   | 
  | 51 |  |   | 
  | 52 |  |   | 
  | 53 |  |   | 
  | 54 |  |  public class DataDictionary { | 
  | 55 |  |   | 
  | 56 | 0 |      private DefaultListableBeanFactory ddBeans = new DefaultListableBeanFactory(); | 
  | 57 | 0 |      private XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ddBeans); | 
  | 58 |  |   | 
  | 59 |  |           | 
  | 60 | 0 |          private static final Log LOG = LogFactory.getLog(DataDictionary.class); | 
  | 61 |  |   | 
  | 62 |  |           | 
  | 63 |  |   | 
  | 64 |  |   | 
  | 65 | 0 |          private DataDictionaryIndex ddIndex = new DataDictionaryIndex(ddBeans); | 
  | 66 |  |   | 
  | 67 |  |           | 
  | 68 |  |   | 
  | 69 |  |   | 
  | 70 |  |   | 
  | 71 |  |   | 
  | 72 | 0 |          private DataDictionaryMapper ddMapper = new DataDictionaryIndexMapper(); | 
  | 73 |  |   | 
  | 74 | 0 |          private List<String> configFileLocations = new ArrayList<String>(); | 
  | 75 |  |   | 
  | 76 | 0 |      public DataDictionary() { } | 
  | 77 |  |       | 
  | 78 |  |          public List<String> getConfigFileLocations() { | 
  | 79 | 0 |          return this.configFileLocations; | 
  | 80 |  |      } | 
  | 81 |  |   | 
  | 82 |  |      public void setConfigFileLocations(List<String> configFileLocations) { | 
  | 83 | 0 |          this.configFileLocations = configFileLocations; | 
  | 84 | 0 |      } | 
  | 85 |  |       | 
  | 86 |  |      public void addConfigFileLocation( String location ) throws IOException { | 
  | 87 | 0 |          indexSource( location ); | 
  | 88 | 0 |      } | 
  | 89 |  |   | 
  | 90 |  |       | 
  | 91 |  |   | 
  | 92 |  |   | 
  | 93 |  |   | 
  | 94 |  |      public void setDataDictionaryMapper(DataDictionaryMapper mapper) { | 
  | 95 | 0 |              this.ddMapper = mapper; | 
  | 96 | 0 |      } | 
  | 97 |  |       | 
  | 98 |  |      private void indexSource(String sourceName) throws IOException {         | 
  | 99 | 0 |          if (sourceName == null) { | 
  | 100 | 0 |              throw new DataDictionaryException("Source Name given is null"); | 
  | 101 |  |          } | 
  | 102 |  |   | 
  | 103 | 0 |          if (!sourceName.endsWith(".xml") ) { | 
  | 104 | 0 |              Resource resource = getFileResource(sourceName); | 
  | 105 | 0 |              if (resource.exists()) { | 
  | 106 | 0 |                  indexSource(resource.getFile()); | 
  | 107 |  |              } else { | 
  | 108 | 0 |                  LOG.warn("Could not find " + sourceName); | 
  | 109 | 0 |                  throw new DataDictionaryException("DD Resource " + sourceName + " not found"); | 
  | 110 |  |              } | 
  | 111 | 0 |          } else { | 
  | 112 | 0 |              if ( LOG.isDebugEnabled() ) { | 
  | 113 | 0 |                  LOG.debug("adding sourceName " + sourceName + " "); | 
  | 114 |  |              } | 
  | 115 | 0 |              Resource resource = getFileResource(sourceName); | 
  | 116 | 0 |              if (! resource.exists()) { | 
  | 117 | 0 |                  throw new DataDictionaryException("DD Resource " + sourceName + " not found");   | 
  | 118 |  |              } | 
  | 119 | 0 |              String indexName = sourceName.substring(sourceName.lastIndexOf("/") + 1, sourceName.indexOf(".xml")); | 
  | 120 | 0 |              configFileLocations.add( sourceName ); | 
  | 121 |  |          } | 
  | 122 | 0 |      }     | 
  | 123 |  |   | 
  | 124 |  |      private Resource getFileResource(String sourceName) { | 
  | 125 | 0 |          DefaultResourceLoader resourceLoader = new DefaultResourceLoader(ClassLoaderUtils.getDefaultClassLoader()); | 
  | 126 | 0 |          return resourceLoader.getResource(sourceName); | 
  | 127 |  |      } | 
  | 128 |  |   | 
  | 129 |  |      private void indexSource(File dir) { | 
  | 130 | 0 |          for (File file : dir.listFiles()) { | 
  | 131 | 0 |              if (file.isDirectory()) { | 
  | 132 | 0 |                  indexSource(file); | 
  | 133 | 0 |              } else if (file.getName().endsWith(".xml") ) { | 
  | 134 | 0 |                  configFileLocations.add( "file:" + file.getAbsolutePath()); | 
  | 135 |  |              } else { | 
  | 136 | 0 |                  if ( LOG.isDebugEnabled() ) { | 
  | 137 | 0 |                      LOG.debug("Skipping non xml file " + file.getAbsolutePath() + " in DD load"); | 
  | 138 |  |                  } | 
  | 139 |  |              } | 
  | 140 |  |          } | 
  | 141 | 0 |      } | 
  | 142 |  |       | 
  | 143 |  |      public void parseDataDictionaryConfigurationFiles( boolean allowConcurrentValidation ) { | 
  | 144 |  |           | 
  | 145 |  |   | 
  | 146 | 0 |          LOG.info( "Starting DD XML File Load" ); | 
  | 147 | 0 |          String[] configFileLocationsArray = new String[configFileLocations.size()]; | 
  | 148 | 0 |          configFileLocationsArray = configFileLocations.toArray( configFileLocationsArray ); | 
  | 149 | 0 |          configFileLocations.clear();  | 
  | 150 |  |          try { | 
  | 151 | 0 |              xmlReader.loadBeanDefinitions( configFileLocationsArray ); | 
  | 152 | 0 |          } catch (Exception e) { | 
  | 153 | 0 |              LOG.error("Error loading bean definitions", e); | 
  | 154 | 0 |              throw new DataDictionaryException("Error loading bean definitions: " + e.getLocalizedMessage()); | 
  | 155 | 0 |          } | 
  | 156 | 0 |          LOG.info( "Completed DD XML File Load" ); | 
  | 157 | 0 |          if ( allowConcurrentValidation ) { | 
  | 158 | 0 |              Thread t = new Thread(ddIndex); | 
  | 159 | 0 |              t.start(); | 
  | 160 | 0 |          } else { | 
  | 161 | 0 |              ddIndex.run(); | 
  | 162 |  |          } | 
  | 163 | 0 |      } | 
  | 164 |  |               | 
  | 165 | 0 |      static boolean validateEBOs = true; | 
  | 166 |  |       | 
  | 167 |  |      public void validateDD( boolean validateEbos ) { | 
  | 168 | 0 |              DataDictionary.validateEBOs = validateEbos; | 
  | 169 | 0 |          Map<String,BusinessObjectEntry> boBeans = ddBeans.getBeansOfType(BusinessObjectEntry.class); | 
  | 170 | 0 |          for ( BusinessObjectEntry entry : boBeans.values() ) { | 
  | 171 | 0 |              entry.completeValidation(); | 
  | 172 |  |          } | 
  | 173 | 0 |          Map<String,DocumentEntry> docBeans = ddBeans.getBeansOfType(DocumentEntry.class); | 
  | 174 | 0 |          for ( DocumentEntry entry : docBeans.values() ) { | 
  | 175 | 0 |              entry.completeValidation(); | 
  | 176 |  |          } | 
  | 177 | 0 |      } | 
  | 178 |  |       | 
  | 179 |  |      public void validateDD() { | 
  | 180 | 0 |              DataDictionary.validateEBOs = true; | 
  | 181 | 0 |          Map<String,BusinessObjectEntry> boBeans = ddBeans.getBeansOfType(BusinessObjectEntry.class); | 
  | 182 | 0 |          for ( BusinessObjectEntry entry : boBeans.values() ) { | 
  | 183 | 0 |              entry.completeValidation(); | 
  | 184 |  |          } | 
  | 185 | 0 |          Map<String,DocumentEntry> docBeans = ddBeans.getBeansOfType(DocumentEntry.class); | 
  | 186 | 0 |          for ( DocumentEntry entry : docBeans.values() ) { | 
  | 187 | 0 |              entry.completeValidation(); | 
  | 188 |  |          } | 
  | 189 | 0 |      } | 
  | 190 |  |   | 
  | 191 |  |           | 
  | 192 |  |   | 
  | 193 |  |   | 
  | 194 |  |   | 
  | 195 |  |          public BusinessObjectEntry getBusinessObjectEntry(String className ) { | 
  | 196 | 0 |                  return ddMapper.getBusinessObjectEntry(ddIndex, className); | 
  | 197 |  |          } | 
  | 198 |  |   | 
  | 199 |  |           | 
  | 200 |  |   | 
  | 201 |  |   | 
  | 202 |  |   | 
  | 203 |  |   | 
  | 204 |  |   | 
  | 205 |  |          public BusinessObjectEntry getBusinessObjectEntryForConcreteClass(String className){ | 
  | 206 | 0 |                  return ddMapper.getBusinessObjectEntryForConcreteClass(ddIndex, className); | 
  | 207 |  |          } | 
  | 208 |  |           | 
  | 209 |  |           | 
  | 210 |  |   | 
  | 211 |  |   | 
  | 212 |  |          public List<String> getBusinessObjectClassNames() { | 
  | 213 | 0 |                  return ddMapper.getBusinessObjectClassNames(ddIndex); | 
  | 214 |  |          } | 
  | 215 |  |   | 
  | 216 |  |           | 
  | 217 |  |   | 
  | 218 |  |   | 
  | 219 |  |          public Map<String, BusinessObjectEntry> getBusinessObjectEntries() { | 
  | 220 | 0 |                  return ddMapper.getBusinessObjectEntries(ddIndex); | 
  | 221 |  |          } | 
  | 222 |  |   | 
  | 223 |  |           | 
  | 224 |  |   | 
  | 225 |  |   | 
  | 226 |  |   | 
  | 227 |  |   | 
  | 228 |  |          public DataDictionaryEntry getDictionaryObjectEntry(String className) { | 
  | 229 | 0 |                  return ddMapper.getDictionaryObjectEntry(ddIndex, className); | 
  | 230 |  |          } | 
  | 231 |  |   | 
  | 232 |  |           | 
  | 233 |  |   | 
  | 234 |  |   | 
  | 235 |  |   | 
  | 236 |  |   | 
  | 237 |  |   | 
  | 238 |  |   | 
  | 239 |  |   | 
  | 240 |  |   | 
  | 241 |  |   | 
  | 242 |  |   | 
  | 243 |  |   | 
  | 244 |  |   | 
  | 245 |  |   | 
  | 246 |  |   | 
  | 247 |  |          public DocumentEntry getDocumentEntry(String documentTypeDDKey ) { | 
  | 248 | 0 |                  return ddMapper.getDocumentEntry(ddIndex, documentTypeDDKey); | 
  | 249 |  |          } | 
  | 250 |  |   | 
  | 251 |  |           | 
  | 252 |  |   | 
  | 253 |  |   | 
  | 254 |  |   | 
  | 255 |  |   | 
  | 256 |  |   | 
  | 257 |  |   | 
  | 258 |  |   | 
  | 259 |  |   | 
  | 260 |  |   | 
  | 261 |  |          public MaintenanceDocumentEntry getMaintenanceDocumentEntryForBusinessObjectClass(Class businessObjectClass) { | 
  | 262 | 0 |                  return ddMapper.getMaintenanceDocumentEntryForBusinessObjectClass(ddIndex, businessObjectClass); | 
  | 263 |  |          } | 
  | 264 |  |   | 
  | 265 |  |          public Map<String, DocumentEntry> getDocumentEntries() { | 
  | 266 | 0 |                  return ddMapper.getDocumentEntries(ddIndex); | 
  | 267 |  |          } | 
  | 268 |  |   | 
  | 269 |  |       | 
  | 270 |  |   | 
  | 271 |  |   | 
  | 272 |  |   | 
  | 273 |  |   | 
  | 274 |  |   | 
  | 275 |  |      public static boolean isPropertyOf(Class targetClass, String propertyName) { | 
  | 276 | 0 |          if (targetClass == null) { | 
  | 277 | 0 |              throw new IllegalArgumentException("invalid (null) targetClass"); | 
  | 278 |  |          } | 
  | 279 | 0 |          if (StringUtils.isBlank(propertyName)) { | 
  | 280 | 0 |              throw new IllegalArgumentException("invalid (blank) propertyName"); | 
  | 281 |  |          } | 
  | 282 |  |   | 
  | 283 | 0 |          PropertyDescriptor propertyDescriptor = buildReadDescriptor(targetClass, propertyName); | 
  | 284 |  |   | 
  | 285 | 0 |          boolean isPropertyOf = (propertyDescriptor != null); | 
  | 286 | 0 |          return isPropertyOf; | 
  | 287 |  |      } | 
  | 288 |  |   | 
  | 289 |  |       | 
  | 290 |  |   | 
  | 291 |  |   | 
  | 292 |  |   | 
  | 293 |  |   | 
  | 294 |  |   | 
  | 295 |  |      public static boolean isCollectionPropertyOf(Class targetClass, String propertyName) { | 
  | 296 | 0 |          boolean isCollectionPropertyOf = false; | 
  | 297 |  |   | 
  | 298 | 0 |          PropertyDescriptor propertyDescriptor = buildReadDescriptor(targetClass, propertyName); | 
  | 299 | 0 |          if (propertyDescriptor != null) { | 
  | 300 | 0 |              Class clazz = propertyDescriptor.getPropertyType(); | 
  | 301 |  |   | 
  | 302 | 0 |              if ((clazz != null) && Collection.class.isAssignableFrom(clazz)) { | 
  | 303 | 0 |                  isCollectionPropertyOf = true; | 
  | 304 |  |              } | 
  | 305 |  |          } | 
  | 306 |  |   | 
  | 307 | 0 |          return isCollectionPropertyOf; | 
  | 308 |  |      } | 
  | 309 |  |   | 
  | 310 |  |      public static PersistenceStructureService persistenceStructureService; | 
  | 311 |  |       | 
  | 312 |  |       | 
  | 313 |  |   | 
  | 314 |  |   | 
  | 315 |  |      public static PersistenceStructureService getPersistenceStructureService() { | 
  | 316 | 0 |          if ( persistenceStructureService == null ) { | 
  | 317 | 0 |              persistenceStructureService = KNSServiceLocator.getPersistenceStructureService(); | 
  | 318 |  |          } | 
  | 319 | 0 |          return persistenceStructureService; | 
  | 320 |  |      } | 
  | 321 |  |       | 
  | 322 |  |       | 
  | 323 |  |   | 
  | 324 |  |   | 
  | 325 |  |   | 
  | 326 |  |   | 
  | 327 |  |   | 
  | 328 |  |   | 
  | 329 |  |   | 
  | 330 |  |      public static Class getAttributeClass(Class boClass, String attributeName) { | 
  | 331 |  |   | 
  | 332 |  |           | 
  | 333 | 0 |          if (!isPropertyOf(boClass, attributeName)) { | 
  | 334 | 0 |              throw new AttributeValidationException("unable to find attribute '" + attributeName + "' in rootClass '" + boClass.getName() + "'"); | 
  | 335 |  |          } | 
  | 336 |  |   | 
  | 337 |  |               | 
  | 338 |  |           | 
  | 339 |  |           | 
  | 340 | 0 |          if(boClass.isInterface()) | 
  | 341 | 0 |                  return getAttributeClassWhenBOIsInterface(boClass, attributeName); | 
  | 342 |  |          else | 
  | 343 | 0 |                  return getAttributeClassWhenBOIsClass(boClass, attributeName);                 | 
  | 344 |  |   | 
  | 345 |  |      } | 
  | 346 |  |   | 
  | 347 |  |       | 
  | 348 |  |   | 
  | 349 |  |   | 
  | 350 |  |   | 
  | 351 |  |   | 
  | 352 |  |   | 
  | 353 |  |   | 
  | 354 |  |   | 
  | 355 |  |      private static Class getAttributeClassWhenBOIsClass(Class boClass, String attributeName){ | 
  | 356 |  |              BusinessObject boInstance; | 
  | 357 |  |          try { | 
  | 358 | 0 |              boInstance = (BusinessObject) boClass.newInstance(); | 
  | 359 | 0 |          } catch (Exception e) { | 
  | 360 | 0 |                  throw new RuntimeException("Unable to instantiate BO: " + boClass, e); | 
  | 361 | 0 |          } | 
  | 362 |  |   | 
  | 363 |  |           | 
  | 364 |  |          try { | 
  | 365 | 0 |              return ObjectUtils.getPropertyType(boInstance, attributeName, getPersistenceStructureService()); | 
  | 366 | 0 |          } catch (Exception e) { | 
  | 367 | 0 |              throw new RuntimeException("Unable to determine property type for: " + boClass.getName() + "." + attributeName, e); | 
  | 368 |  |          } | 
  | 369 |  |      } | 
  | 370 |  |   | 
  | 371 |  |       | 
  | 372 |  |   | 
  | 373 |  |   | 
  | 374 |  |   | 
  | 375 |  |   | 
  | 376 |  |   | 
  | 377 |  |   | 
  | 378 |  |   | 
  | 379 |  |   | 
  | 380 |  |   | 
  | 381 |  |      private static Class getAttributeClassWhenBOIsInterface(Class boClass, String attributeName){ | 
  | 382 | 0 |          if (boClass == null) { | 
  | 383 | 0 |              throw new IllegalArgumentException("invalid (null) boClass"); | 
  | 384 |  |          } | 
  | 385 | 0 |          if (StringUtils.isBlank(attributeName)) { | 
  | 386 | 0 |              throw new IllegalArgumentException("invalid (blank) attributeName"); | 
  | 387 |  |          } | 
  | 388 |  |   | 
  | 389 | 0 |          PropertyDescriptor propertyDescriptor = null; | 
  | 390 |  |   | 
  | 391 | 0 |          String[] intermediateProperties = attributeName.split("\\."); | 
  | 392 | 0 |          int lastLevel = intermediateProperties.length - 1; | 
  | 393 | 0 |          Class currentClass = boClass; | 
  | 394 |  |   | 
  | 395 | 0 |          for (int i = 0; i <= lastLevel; ++i) { | 
  | 396 |  |   | 
  | 397 | 0 |              String currentPropertyName = intermediateProperties[i]; | 
  | 398 | 0 |              propertyDescriptor = buildSimpleReadDescriptor(currentClass, currentPropertyName); | 
  | 399 |  |   | 
  | 400 | 0 |              if (propertyDescriptor != null) { | 
  | 401 |  |   | 
  | 402 | 0 |                  Class propertyType = propertyDescriptor.getPropertyType(); | 
  | 403 | 0 |                  if ( propertyType.equals( PersistableBusinessObjectExtension.class ) ) { | 
  | 404 | 0 |                      propertyType = getPersistenceStructureService().getBusinessObjectAttributeClass( currentClass, currentPropertyName );                     | 
  | 405 |  |                  } | 
  | 406 | 0 |                  if (Collection.class.isAssignableFrom(propertyType)) { | 
  | 407 |  |                           | 
  | 408 | 0 |                          throw new AttributeValidationException("Can't determine the Class of Collection elements because when the business object is an (possibly ExternalizableBusinessObject) interface."); | 
  | 409 |  |                  } | 
  | 410 |  |                  else { | 
  | 411 | 0 |                      currentClass = propertyType; | 
  | 412 |  |                  } | 
  | 413 | 0 |              } | 
  | 414 |  |              else { | 
  | 415 | 0 |                      throw new AttributeValidationException("Can't find getter method of " + boClass.getName() + " for property " + attributeName); | 
  | 416 |  |              } | 
  | 417 |  |          } | 
  | 418 | 0 |          return currentClass; | 
  | 419 |  |      } | 
  | 420 |  |       | 
  | 421 |  |       | 
  | 422 |  |   | 
  | 423 |  |   | 
  | 424 |  |   | 
  | 425 |  |   | 
  | 426 |  |   | 
  | 427 |  |   | 
  | 428 |  |      public static Class getCollectionElementClass(Class boClass, String collectionName) { | 
  | 429 | 0 |          if (boClass == null) { | 
  | 430 | 0 |              throw new IllegalArgumentException("invalid (null) boClass"); | 
  | 431 |  |          } | 
  | 432 | 0 |          if (StringUtils.isBlank(collectionName)) { | 
  | 433 | 0 |              throw new IllegalArgumentException("invalid (blank) collectionName"); | 
  | 434 |  |          } | 
  | 435 |  |   | 
  | 436 | 0 |          PropertyDescriptor propertyDescriptor = null; | 
  | 437 |  |   | 
  | 438 | 0 |          String[] intermediateProperties = collectionName.split("\\."); | 
  | 439 | 0 |          Class currentClass = boClass; | 
  | 440 |  |   | 
  | 441 | 0 |          for (int i = 0; i <intermediateProperties.length; ++i) { | 
  | 442 |  |   | 
  | 443 | 0 |              String currentPropertyName = intermediateProperties[i]; | 
  | 444 | 0 |              propertyDescriptor = buildSimpleReadDescriptor(currentClass, currentPropertyName); | 
  | 445 |  |   | 
  | 446 |  |   | 
  | 447 | 0 |                  if (propertyDescriptor != null) { | 
  | 448 |  |   | 
  | 449 | 0 |                      Class type = propertyDescriptor.getPropertyType(); | 
  | 450 | 0 |                      if (Collection.class.isAssignableFrom(type)) { | 
  | 451 |  |   | 
  | 452 | 0 |                          if (getPersistenceStructureService().isPersistable(currentClass)) { | 
  | 453 |  |   | 
  | 454 | 0 |                              Map<String, Class> collectionClasses = new HashMap<String, Class>(); | 
  | 455 | 0 |                              collectionClasses = getPersistenceStructureService().listCollectionObjectTypes(currentClass); | 
  | 456 | 0 |                              currentClass = collectionClasses.get(currentPropertyName); | 
  | 457 |  |   | 
  | 458 | 0 |                          } | 
  | 459 |  |                          else { | 
  | 460 | 0 |                              throw new RuntimeException("Can't determine the Class of Collection elements because persistenceStructureService.isPersistable(" + currentClass.getName() + ") returns false."); | 
  | 461 |  |                          } | 
  | 462 |  |   | 
  | 463 |  |                      } | 
  | 464 |  |                      else { | 
  | 465 |  |   | 
  | 466 | 0 |                          currentClass = propertyDescriptor.getPropertyType(); | 
  | 467 |  |   | 
  | 468 |  |                      } | 
  | 469 |  |                  } | 
  | 470 |  |              } | 
  | 471 |  |   | 
  | 472 | 0 |          return currentClass; | 
  | 473 |  |      } | 
  | 474 |  |   | 
  | 475 | 0 |      static private Map<String, Map<String, PropertyDescriptor>> cache = new TreeMap<String, Map<String, PropertyDescriptor>>(); | 
  | 476 |  |   | 
  | 477 |  |       | 
  | 478 |  |   | 
  | 479 |  |   | 
  | 480 |  |   | 
  | 481 |  |   | 
  | 482 |  |      public static PropertyDescriptor buildReadDescriptor(Class propertyClass, String propertyName) { | 
  | 483 | 0 |          if (propertyClass == null) { | 
  | 484 | 0 |              throw new IllegalArgumentException("invalid (null) propertyClass"); | 
  | 485 |  |          } | 
  | 486 | 0 |          if (StringUtils.isBlank(propertyName)) { | 
  | 487 | 0 |              throw new IllegalArgumentException("invalid (blank) propertyName"); | 
  | 488 |  |          } | 
  | 489 |  |   | 
  | 490 | 0 |          PropertyDescriptor propertyDescriptor = null; | 
  | 491 |  |   | 
  | 492 | 0 |          String[] intermediateProperties = propertyName.split("\\."); | 
  | 493 | 0 |          int lastLevel = intermediateProperties.length - 1; | 
  | 494 | 0 |          Class currentClass = propertyClass; | 
  | 495 |  |   | 
  | 496 | 0 |          for (int i = 0; i <= lastLevel; ++i) { | 
  | 497 |  |   | 
  | 498 | 0 |              String currentPropertyName = intermediateProperties[i]; | 
  | 499 | 0 |              propertyDescriptor = buildSimpleReadDescriptor(currentClass, currentPropertyName); | 
  | 500 |  |   | 
  | 501 | 0 |              if (i < lastLevel) { | 
  | 502 |  |   | 
  | 503 | 0 |                  if (propertyDescriptor != null) { | 
  | 504 |  |   | 
  | 505 | 0 |                      Class propertyType = propertyDescriptor.getPropertyType(); | 
  | 506 | 0 |                      if ( propertyType.equals( PersistableBusinessObjectExtension.class ) ) { | 
  | 507 | 0 |                          propertyType = getPersistenceStructureService().getBusinessObjectAttributeClass( currentClass, currentPropertyName );                     | 
  | 508 |  |                      } | 
  | 509 | 0 |                      if (Collection.class.isAssignableFrom(propertyType)) { | 
  | 510 |  |   | 
  | 511 | 0 |                          if (getPersistenceStructureService().isPersistable(currentClass)) { | 
  | 512 |  |   | 
  | 513 | 0 |                              Map<String, Class> collectionClasses = new HashMap<String, Class>(); | 
  | 514 | 0 |                              collectionClasses = getPersistenceStructureService().listCollectionObjectTypes(currentClass); | 
  | 515 | 0 |                              currentClass = collectionClasses.get(currentPropertyName); | 
  | 516 |  |   | 
  | 517 | 0 |                          } | 
  | 518 |  |                          else { | 
  | 519 |  |   | 
  | 520 | 0 |                              throw new RuntimeException("Can't determine the Class of Collection elements because persistenceStructureService.isPersistable(" + currentClass.getName() + ") returns false."); | 
  | 521 |  |   | 
  | 522 |  |                          } | 
  | 523 |  |   | 
  | 524 |  |                      } | 
  | 525 |  |                      else { | 
  | 526 |  |   | 
  | 527 | 0 |                          currentClass = propertyType; | 
  | 528 |  |   | 
  | 529 |  |                      } | 
  | 530 |  |   | 
  | 531 |  |                  } | 
  | 532 |  |   | 
  | 533 |  |              } | 
  | 534 |  |   | 
  | 535 |  |          } | 
  | 536 |  |   | 
  | 537 | 0 |          return propertyDescriptor; | 
  | 538 |  |      } | 
  | 539 |  |   | 
  | 540 |  |       | 
  | 541 |  |   | 
  | 542 |  |   | 
  | 543 |  |   | 
  | 544 |  |   | 
  | 545 |  |      public static PropertyDescriptor buildSimpleReadDescriptor(Class propertyClass, String propertyName) { | 
  | 546 | 0 |          if (propertyClass == null) { | 
  | 547 | 0 |              throw new IllegalArgumentException("invalid (null) propertyClass"); | 
  | 548 |  |          } | 
  | 549 | 0 |          if (StringUtils.isBlank(propertyName)) { | 
  | 550 | 0 |              throw new IllegalArgumentException("invalid (blank) propertyName"); | 
  | 551 |  |          } | 
  | 552 |  |   | 
  | 553 | 0 |          PropertyDescriptor p = null; | 
  | 554 |  |   | 
  | 555 |  |           | 
  | 556 | 0 |          String propertyClassName = propertyClass.getName(); | 
  | 557 | 0 |          Map<String, PropertyDescriptor> m = cache.get(propertyClassName); | 
  | 558 | 0 |          if (null != m) { | 
  | 559 | 0 |              p = m.get(propertyName); | 
  | 560 | 0 |              if (null != p) { | 
  | 561 | 0 |                  return p; | 
  | 562 |  |              } | 
  | 563 |  |          } | 
  | 564 |  |   | 
  | 565 | 0 |          String prefix = StringUtils.capitalize(propertyName); | 
  | 566 | 0 |          String getName = "get" + prefix; | 
  | 567 | 0 |          String isName = "is" + prefix; | 
  | 568 |  |   | 
  | 569 |  |          try { | 
  | 570 |  |   | 
  | 571 | 0 |              p = new PropertyDescriptor(propertyName, propertyClass, getName, null); | 
  | 572 |  |   | 
  | 573 |  |          } | 
  | 574 | 0 |          catch (IntrospectionException e) { | 
  | 575 |  |              try { | 
  | 576 |  |   | 
  | 577 | 0 |                  p = new PropertyDescriptor(propertyName, propertyClass, isName, null); | 
  | 578 |  |   | 
  | 579 |  |              } | 
  | 580 | 0 |              catch (IntrospectionException f) { | 
  | 581 |  |                   | 
  | 582 | 0 |              } | 
  | 583 | 0 |          } | 
  | 584 |  |   | 
  | 585 |  |           | 
  | 586 | 0 |          if (null != p) { | 
  | 587 |  |   | 
  | 588 | 0 |              if (null == m) { | 
  | 589 |  |   | 
  | 590 | 0 |                  m = new TreeMap<String, PropertyDescriptor>(); | 
  | 591 | 0 |                  cache.put(propertyClassName, m); | 
  | 592 |  |   | 
  | 593 |  |              } | 
  | 594 |  |   | 
  | 595 | 0 |              m.put(propertyName, p); | 
  | 596 |  |   | 
  | 597 |  |          } | 
  | 598 |  |   | 
  | 599 | 0 |          return p; | 
  | 600 |  |      } | 
  | 601 |  |   | 
  | 602 |  |      public Set<InactivationBlockingMetadata> getAllInactivationBlockingMetadatas(Class blockedClass) { | 
  | 603 | 0 |              return ddMapper.getAllInactivationBlockingMetadatas(ddIndex, blockedClass); | 
  | 604 |  |      } | 
  | 605 |  |       | 
  | 606 |  |       | 
  | 607 |  |   | 
  | 608 |  |   | 
  | 609 |  |       | 
  | 610 |  |      public void performBeanOverrides() | 
  | 611 |  |      { | 
  | 612 | 0 |              Collection<BeanOverride> beanOverrides = ddBeans.getBeansOfType(BeanOverride.class).values(); | 
  | 613 |  |               | 
  | 614 | 0 |              if (beanOverrides.isEmpty()){ | 
  | 615 | 0 |                      LOG.info("DataDictionary.performOverrides(): No beans to override"); | 
  | 616 |  |              } | 
  | 617 | 0 |                  for (BeanOverride beanOverride : beanOverrides) { | 
  | 618 |  |                           | 
  | 619 | 0 |                          Object bean = ddBeans.getBean(beanOverride.getBeanName()); | 
  | 620 | 0 |                          beanOverride.performOverride(bean); | 
  | 621 | 0 |                          LOG.info("DataDictionary.performOverrides(): Performing override on bean: " + bean.toString()); | 
  | 622 | 0 |                  } | 
  | 623 | 0 |      } | 
  | 624 |  |  } |