org.kuali.rice.krad.service.impl
Class DataObjectMetaDataServiceImpl

java.lang.Object
  extended by org.kuali.rice.krad.service.impl.DataObjectMetaDataServiceImpl
All Implemented Interfaces:
DataObjectMetaDataService
Direct Known Subclasses:
BusinessObjectMetaDataServiceImpl

public class DataObjectMetaDataServiceImpl
extends Object
implements DataObjectMetaDataService

Author:
Kuali Rice Team (rice.collab@kuali.org)

Constructor Summary
DataObjectMetaDataServiceImpl()
           
 
Method Summary
 boolean areNotesSupported(Class dataObjectClass)
          Indicates whether notes are supported by the given data object class, currently this can only be true for business objects
protected  boolean classHasSupportedFeatures(Class relationshipClass, boolean supportsLookup, boolean supportsInquiry)
           
 boolean equalsByPrimaryKeys(Object do1, Object do2)
          Compares two dataObject instances for equality of type and key values using toString() of each value for comparison purposes.
protected  BusinessObjectEntry getBusinessObjectEntry(Class businessObjectClass)
           
protected  DataDictionaryService getDataDictionaryService()
          Protected method to allow subclasses to access the dataDictionaryService.
protected  DataObjectEntry getDataObjectEntry(Class<?> dataObjectClass)
           
 String getDataObjectIdentifierString(Object dataObject)
          Builds a string that uniquely identifiers the data object instance
 DataObjectRelationship getDataObjectRelationship(Object dataObject, Class<?> dataObjectClass, String attributeName, String attributePrefix, boolean keysOnly, boolean supportsLookup, boolean supportsInquiry)
          Attempts to find a relationship for the given attribute within the given data object
protected  DataObjectRelationship getDataObjectRelationship(RelationshipDefinition ddReference, Object dataObject, Class<?> dataObjectClass, String attributeName, String attributePrefix, boolean keysOnly, boolean supportsLookup, boolean supportsInquiry)
           
 List<DataObjectRelationship> getDataObjectRelationships(Class<?> dataObjectClass)
          Attempts to find relationships for the given data object class
 RelationshipDefinition getDictionaryRelationship(Class<?> c, String attributeName)
          Fetches the RelationshipDefinition for the attribute with the given name within the given class
protected  KualiModuleService getKualiModuleService()
          Protected method to allow subclasses to access the kualiModuleService.
protected  PersistenceStructureService getPersistenceStructureService()
          Protected method to allow subclasses to access the persistenceStructureService.
 Map<String,?> getPrimaryKeyFieldValues(Object dataObject)
          Determines the primary keys for the class of the given object, then for each key field retrieves the value from the object instance and populates the return map with the primary key name as the map key and the object value as the map value
 Map<String,?> getPrimaryKeyFieldValues(Object dataObject, boolean sortFieldNames)
          Determines the primary keys for the class of the given object, then for each key field retrieves the value from the object instance and populates the return map with the primary key name as the map key and the object value as the map value
protected  DataObjectRelationship getRelationshipMetadata(Class<?> dataObjectClass, String attributeName, String attributePrefix)
           
 String getTitleAttribute(Class<?> dataObjectClass)
          Returns the attribute to be associated with for object level markings.
protected  ViewDictionaryService getViewDictionaryService()
           
 List<String> listPrimaryKeyFieldNames(Class<?> clazz)
          Checks the DataDictionary and OJB Repository File to determine the primary fields names for a given class.
protected  DataObjectRelationship populateRelationshipFromDictionaryReference(Class<?> dataObjectClass, RelationshipDefinition ddReference, String attributePrefix, boolean keysOnly)
           
 void setDataDictionaryService(DataDictionaryService dataDictionaryService)
           
 void setKualiModuleService(KualiModuleService kualiModuleService)
           
 void setPersistenceStructureService(PersistenceStructureService persistenceStructureService)
           
 void setViewDictionaryService(ViewDictionaryService viewDictionaryService)
           
protected  void validateBusinessObjectClass(Class businessObjectClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataObjectMetaDataServiceImpl

public DataObjectMetaDataServiceImpl()
Method Detail

listPrimaryKeyFieldNames

public List<String> listPrimaryKeyFieldNames(Class<?> clazz)
Description copied from interface: DataObjectMetaDataService
Checks the DataDictionary and OJB Repository File to determine the primary fields names for a given class.

Specified by:
listPrimaryKeyFieldNames in interface DataObjectMetaDataService
Parameters:
clazz - - the Class to check for primary keys
Returns:
a list of the primary key field names or an empty list if none are found
See Also:
DataObjectMetaDataService.listPrimaryKeyFieldNames(java.lang.Class)

getPrimaryKeyFieldValues

public Map<String,?> getPrimaryKeyFieldValues(Object dataObject)
Description copied from interface: DataObjectMetaDataService
Determines the primary keys for the class of the given object, then for each key field retrieves the value from the object instance and populates the return map with the primary key name as the map key and the object value as the map value

Specified by:
getPrimaryKeyFieldValues in interface DataObjectMetaDataService
Parameters:
dataObject - - object whose primary key field name,value pairs you want
Returns:
a Map containing the names and values of fields for the given class which are designated as key fields in the OJB repository file or DataDictionary
See Also:
DataObjectMetaDataService.getPrimaryKeyFieldValues(java.lang.Object)

getPrimaryKeyFieldValues

public Map<String,?> getPrimaryKeyFieldValues(Object dataObject,
                                              boolean sortFieldNames)
Description copied from interface: DataObjectMetaDataService
Determines the primary keys for the class of the given object, then for each key field retrieves the value from the object instance and populates the return map with the primary key name as the map key and the object value as the map value

Specified by:
getPrimaryKeyFieldValues in interface DataObjectMetaDataService
Parameters:
dataObject - - object whose primary key field name,value pairs you want
sortFieldNames - - if true, the returned Map will iterate through its entries sorted by fieldName
Returns:
a Map containing the names and values of fields for the given class which are designated as key fields in the OJB repository file or DataDictionary
See Also:
DataObjectMetaDataService.getPrimaryKeyFieldValues(java.lang.Object, boolean)

equalsByPrimaryKeys

public boolean equalsByPrimaryKeys(Object do1,
                                   Object do2)
Description copied from interface: DataObjectMetaDataService
Compares two dataObject instances for equality of type and key values using toString() of each value for comparison purposes.

Specified by:
equalsByPrimaryKeys in interface DataObjectMetaDataService
Returns:
boolean indicating whether the two objects are equal.
See Also:
DataObjectMetaDataService.equalsByPrimaryKeys(java.lang.Object, java.lang.Object)

getDataObjectRelationship

public DataObjectRelationship getDataObjectRelationship(Object dataObject,
                                                        Class<?> dataObjectClass,
                                                        String attributeName,
                                                        String attributePrefix,
                                                        boolean keysOnly,
                                                        boolean supportsLookup,
                                                        boolean supportsInquiry)
Description copied from interface: DataObjectMetaDataService
Attempts to find a relationship for the given attribute within the given data object

First the data dictionary is queried to find any relationship definitions setup that include the attribute, if found the BusinessObjectRetationship is build from that. If not and the data object class is persistent, relationships are retrieved from the persistence service. Nested attributes are handled in addition to external business objects. If multiple relationships are found, the one that contains the least amount of joining keys is returned

Specified by:
getDataObjectRelationship in interface DataObjectMetaDataService
Parameters:
dataObject - - data object instance that contains the attribute
dataObjectClass - - class for the data object that contains the attribute
attributeName - - property name for the attribute
attributePrefix - - property prefix for the attribute
keysOnly - - indicates whether only primary key fields should be returned in the relationship
supportsLookup - - indicates whether the relationship should support lookup
Returns:
BusinessObjectRelationship for the attribute, or null if not found
See Also:
DataObjectMetaDataService.getDataObjectRelationship(java.lang.Object, java.lang.Class, java.lang.String, java.lang.String, boolean, boolean, boolean)

getDataObjectRelationship

protected DataObjectRelationship getDataObjectRelationship(RelationshipDefinition ddReference,
                                                           Object dataObject,
                                                           Class<?> dataObjectClass,
                                                           String attributeName,
                                                           String attributePrefix,
                                                           boolean keysOnly,
                                                           boolean supportsLookup,
                                                           boolean supportsInquiry)

classHasSupportedFeatures

protected boolean classHasSupportedFeatures(Class relationshipClass,
                                            boolean supportsLookup,
                                            boolean supportsInquiry)

getDictionaryRelationship

public RelationshipDefinition getDictionaryRelationship(Class<?> c,
                                                        String attributeName)
Description copied from interface: DataObjectMetaDataService
Fetches the RelationshipDefinition for the attribute with the given name within the given class

Specified by:
getDictionaryRelationship in interface DataObjectMetaDataService
Parameters:
c - - data object class that contains the attribute
attributeName - - property name for the attribute
Returns:
RelationshipDefinition for the attribute, or null if not found

populateRelationshipFromDictionaryReference

protected DataObjectRelationship populateRelationshipFromDictionaryReference(Class<?> dataObjectClass,
                                                                             RelationshipDefinition ddReference,
                                                                             String attributePrefix,
                                                                             boolean keysOnly)

getRelationshipMetadata

protected DataObjectRelationship getRelationshipMetadata(Class<?> dataObjectClass,
                                                         String attributeName,
                                                         String attributePrefix)

getTitleAttribute

public String getTitleAttribute(Class<?> dataObjectClass)
Description copied from interface: DataObjectMetaDataService
Returns the attribute to be associated with for object level markings. This would be the field chosen for inquiry links etc.

Specified by:
getTitleAttribute in interface DataObjectMetaDataService
Parameters:
dataObjectClass - - data object class to obtain title attribute of
Returns:
property name of title attribute or null if data object entry not found
See Also:
DataObjectMetaDataService.getTitleAttribute(java.lang.Class)

areNotesSupported

public boolean areNotesSupported(Class dataObjectClass)
Description copied from interface: DataObjectMetaDataService
Indicates whether notes are supported by the given data object class, currently this can only be true for business objects

Specified by:
areNotesSupported in interface DataObjectMetaDataService
Parameters:
dataObjectClass - - class for data object to check
Returns:
boolean true if notes are supported for data object, false if notes are not supported
See Also:
DataObjectMetaDataService.areNotesSupported(java.lang.Class)

getDataObjectIdentifierString

public String getDataObjectIdentifierString(Object dataObject)
Description copied from interface: DataObjectMetaDataService
Builds a string that uniquely identifiers the data object instance

Based on the metadata available for the class of the data object, the values for fields that uniquely identify an instance are concatenated together into one string. For general data objects these fields will be the primary key fields defined in the data dictionary. For the case of objects with type PersistableBusinessObject, the object id field will be used.

Specified by:
getDataObjectIdentifierString in interface DataObjectMetaDataService
Parameters:
dataObject - - data object instance to build identifier string for
Returns:
String identifier string for data object
See Also:
DataObjectMetaDataService.getDataObjectIdentifierString(java.lang.Object)

getDataObjectEntry

protected DataObjectEntry getDataObjectEntry(Class<?> dataObjectClass)
Parameters:
dataObjectClass -
Returns:
DataObjectEntry for the given dataObjectClass, or null if there is none
Throws:
IllegalArgumentException - if the given Class is null

getDataObjectRelationships

public List<DataObjectRelationship> getDataObjectRelationships(Class<?> dataObjectClass)
Description copied from interface: DataObjectMetaDataService
Attempts to find relationships for the given data object class

First the data dictionary is queried to find any relationship definitions BusinessObjectRetationship is build from that. If not and the data object class is persistent, relationships are retrieved from the persistence service. Nested attributes are handled in addition to external business objects. If multiple relationships are found, the one that contains the least amount of joining keys is returned

Specified by:
getDataObjectRelationships in interface DataObjectMetaDataService
Parameters:
dataObjectClass - - class for the data object that contains the attribute
Returns:
List of DataObjectRelationship for the class

getBusinessObjectEntry

protected BusinessObjectEntry getBusinessObjectEntry(Class businessObjectClass)
Parameters:
businessObjectClass - - class of business object to return entry for
Returns:
BusinessObjectEntry for the given dataObjectClass, or null if there is none

validateBusinessObjectClass

protected void validateBusinessObjectClass(Class businessObjectClass)
Parameters:
businessObjectClass -
Throws:
IllegalArgumentException - if the given Class is null or is not a BusinessObject class

getDataDictionaryService

protected DataDictionaryService getDataDictionaryService()
Protected method to allow subclasses to access the dataDictionaryService.

Returns:
Returns the dataDictionaryService.

setDataDictionaryService

public void setDataDictionaryService(DataDictionaryService dataDictionaryService)

getKualiModuleService

protected KualiModuleService getKualiModuleService()
Protected method to allow subclasses to access the kualiModuleService.

Returns:
Returns the persistenceStructureService.

setKualiModuleService

public void setKualiModuleService(KualiModuleService kualiModuleService)

getPersistenceStructureService

protected PersistenceStructureService getPersistenceStructureService()
Protected method to allow subclasses to access the persistenceStructureService.

Returns:
Returns the persistenceStructureService.

setPersistenceStructureService

public void setPersistenceStructureService(PersistenceStructureService persistenceStructureService)

getViewDictionaryService

protected ViewDictionaryService getViewDictionaryService()

setViewDictionaryService

public void setViewDictionaryService(ViewDictionaryService viewDictionaryService)


Copyright © 2005-2011 The Kuali Foundation. All Rights Reserved.