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

java.lang.Object
  extended by org.kuali.rice.krad.service.impl.PersistenceServiceStructureImplBase
      extended by org.kuali.rice.krad.service.impl.PersistenceServiceImplBase
          extended by org.kuali.rice.krad.service.impl.PersistenceStructureServiceOjbImpl
All Implemented Interfaces:
PersistenceStructureService

public class PersistenceStructureServiceOjbImpl
extends PersistenceServiceImplBase
implements PersistenceStructureService


Field Summary
static Map<Class,Class> referenceConversionMap
          special case when the attributeClass passed in doesnt match the class of the reference-descriptor as defined in ojb-repository.
 
Fields inherited from class org.kuali.rice.krad.service.impl.PersistenceServiceStructureImplBase
LOG
 
Constructor Summary
PersistenceStructureServiceOjbImpl()
           
 
Method Summary
 Object clearPrimaryKeyFields(Object persistableObject)
           
 String getForeignKeyFieldName(Class persistableObjectClass, String attributeName, String pkName)
           
 ForeignKeyFieldsPopulationState getForeignKeyFieldsPopulationState(PersistableBusinessObject bo, String referenceName)
          This method checks the foreign keys for a reference on a given BO, and tests that all fk fields are populated if any are populated.
 Map getForeignKeysForReference(Class clazz, String attributeName)
          This method will return a Map of all the foreign key fields and the corresponding primary key fields for a given reference.
 Map<String,String> getInverseForeignKeysForCollection(Class boClass, String collectionName)
          Returns a listing of the FK field mappings between a BO and the elements in a collection.
 Map getNestedForeignKeyMap(Class persistableObjectClass)
          Builds a map of reference pk attributes back to the foreign key.
 PersistenceStructureService getPersistenceStructureServiceJpa()
           
 List getPrimaryKeys(Class clazz)
          This method returns a List of Strings, each containing the field name of one of the primary keys, as defined in the ORM layer.
 Map getReferencesForForeignKey(Class persistableObjectClass, String attributeName)
          Attempts to match the attribute name given for the class as a fk field to a reference class defined in the repository.
 Map<String,DataObjectRelationship> getRelationshipMetadata(Class persistableClass, String attributeName)
           
 Map<String,DataObjectRelationship> getRelationshipMetadata(Class persistableClass, String attributeName, String attributePrefix)
           
 String getTableName(Class<? extends PersistableBusinessObject> boClass)
          This overridden method ...
 boolean hasCollection(Class boClass, String collectionName)
          Returns whether BOs of the given class have a collection defined within them with the given collection name.
 boolean hasPrimaryKeyFieldValues(Object persistableObject)
           
 boolean hasReference(Class boClass, String referenceName)
          Returns whether there is a reference defined in the persistence layer with the given name.
 boolean isCollectionUpdatable(Class boClass, String collectionName)
           
 boolean isPersistable(Class clazz)
           
 boolean isReferenceUpdatable(Class boClass, String referenceName)
           
 Map<String,Class> listCollectionObjectTypes(Class boClass)
           
 Map<String,Class> listCollectionObjectTypes(PersistableBusinessObject bo)
           
 List listFieldNames(Class clazz)
           
 List listPersistableSubclasses(Class superclazz)
           
 Map<String,Class> listReferenceObjectFields(Class boClass)
          This method uses the persistence layer to determine the list of reference objects contained within this parent object.
 Map<String,Class> listReferenceObjectFields(PersistableBusinessObject bo)
          This method uses the persistence layer to determine the list of reference objects contained within this parent object.
 void setPersistenceStructureServiceJpa(PersistenceStructureService persistenceStructureServiceJpa)
           
 
Methods inherited from class org.kuali.rice.krad.service.impl.PersistenceServiceImplBase
getPrimaryKeyFieldValues, getPrimaryKeyFieldValues
 
Methods inherited from class org.kuali.rice.krad.service.impl.PersistenceServiceStructureImplBase
getBusinessObjectAttributeClass, getClassDescriptor, getDescriptorRepository, isJpaEnabledForKradClass, listPrimaryKeyFieldNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.kuali.rice.krad.service.PersistenceStructureService
getBusinessObjectAttributeClass, listPrimaryKeyFieldNames
 

Field Detail

referenceConversionMap

public static Map<Class,Class> referenceConversionMap
special case when the attributeClass passed in doesnt match the class of the reference-descriptor as defined in ojb-repository. Currently the only case of this happening is ObjectCode vs. ObjectCodeCurrent. NOTE: This method makes no real sense and is a product of a hack introduced by KFS for an unknown reason. If you find yourself using this map stop and go do something else.

Constructor Detail

PersistenceStructureServiceOjbImpl

public PersistenceStructureServiceOjbImpl()
Method Detail

getPersistenceStructureServiceJpa

public PersistenceStructureService getPersistenceStructureServiceJpa()

setPersistenceStructureServiceJpa

public void setPersistenceStructureServiceJpa(PersistenceStructureService persistenceStructureServiceJpa)

isPersistable

public boolean isPersistable(Class clazz)
Specified by:
isPersistable in interface PersistenceStructureService
Returns:
true if the given Class is persistable (is known to OJB)
See Also:
org.kuali.rice.krad.service.PersistenceService#isPersistable(java.lang.Class)

getPrimaryKeys

public List getPrimaryKeys(Class clazz)
Description copied from interface: PersistenceStructureService
This method returns a List of Strings, each containing the field name of one of the primary keys, as defined in the ORM layer.

Specified by:
getPrimaryKeys in interface PersistenceStructureService
Parameters:
clazz - - Class whose primary key field names are requested
Returns:
A List of Strings, each containing the field name of the primary key
See Also:
org.kuali.rice.krad.service.PersistenceService#getPrimaryKeys(java.lang.Class)

listFieldNames

public List listFieldNames(Class clazz)
Specified by:
listFieldNames in interface PersistenceStructureService
Parameters:
clazz - Class whose field names you want to list
Returns:
a List of field names for the given class in the OJB repository file
See Also:
org.kuali.rice.krad.service.PersistenceMetadataExplorerService#listFieldNames(java.lang.Class)

clearPrimaryKeyFields

public Object clearPrimaryKeyFields(Object persistableObject)
Specified by:
clearPrimaryKeyFields in interface PersistenceStructureService
Parameters:
persistableObject - object whose primary key fields need to be cleared
Returns:
the object whose primary key fields have just been cleared
See Also:
org.kuali.rice.krad.service.PersistenceMetadataService#clearPrimaryKeyFields(java.lang.Object)

listPersistableSubclasses

public List listPersistableSubclasses(Class superclazz)
Specified by:
listPersistableSubclasses in interface PersistenceStructureService
Parameters:
superclazz - class whose persistable subclasses (or interface whose implementors) will be returned
Returns:
a List of persistable Classes which extend or implement the given Class
See Also:
org.kuali.rice.krad.service.PersistenceMetadataExplorerService#listPersistableSubclasses(java.lang.Class)

getRelationshipMetadata

public Map<String,DataObjectRelationship> getRelationshipMetadata(Class persistableClass,
                                                                  String attributeName,
                                                                  String attributePrefix)
Specified by:
getRelationshipMetadata in interface PersistenceStructureService
attributeName - Name of an attribute used in the relationship
Returns:
BusinessObjectRelationship object containing information about the object type related via the named relationship of the given class, or null if the persistence service can find no object type related via the named relationship
See Also:
org.kuali.rice.krad.service.PersistenceService#getRelationshipMetadata(java.lang.Class, java.lang.String)

getRelationshipMetadata

public Map<String,DataObjectRelationship> getRelationshipMetadata(Class persistableClass,
                                                                  String attributeName)
Specified by:
getRelationshipMetadata in interface PersistenceStructureService

getForeignKeyFieldName

public String getForeignKeyFieldName(Class persistableObjectClass,
                                     String attributeName,
                                     String pkName)
Specified by:
getForeignKeyFieldName in interface PersistenceStructureService
See Also:
org.kuali.rice.krad.service.PersistenceService#getForeignKeyFieldName(java.lang.Object, java.lang.String, java.lang.String)

getReferencesForForeignKey

public Map getReferencesForForeignKey(Class persistableObjectClass,
                                      String attributeName)
Description copied from interface: PersistenceStructureService
Attempts to match the attribute name given for the class as a fk field to a reference class defined in the repository. Since a fk field can have references to many tables, this returns a list of all found.

Specified by:
getReferencesForForeignKey in interface PersistenceStructureService
Returns:
Map with attribue name as key of map and class as value
See Also:
org.kuali.rice.krad.service.PersistenceService#getReferencesForForeignKey(java.lang.Class, java.lang.String)

getForeignKeysForReference

public Map getForeignKeysForReference(Class clazz,
                                      String attributeName)
Description copied from interface: PersistenceStructureService
This method will return a Map of all the foreign key fields and the corresponding primary key fields for a given reference. The Map structure is: Key(String fkFieldName) => Value(String pkFieldName)

Specified by:
getForeignKeysForReference in interface PersistenceStructureService
Parameters:
clazz - - Class that contains the named reference
attributeName - - Name of the member that is the reference you want foreign keys for
Returns:
returns a Map populated as described above, with one entry per foreign key field
See Also:
The Map structure is: Key(String fkFieldName) => Value(String pkFieldName) NOTE that this implementation depends on the ordering of foreign-key elements in the ojb-repository matching the ordering of primary-key declarations of the class on the other side of the relationship. This is done because: 1. The current version of OJB requires you to declare all of these things in the correct (and matching) order in the ojb-repository file for it to work at all. 2. There is no other way to match a given foreign-key reference to its corresponding primary-key on the opposing side of the relationship. Yes, this is a crummy way to do it, but OJB doesnt provide explicit matches of foreign-keys to primary keys, and always assumes that foreign-keys map to primary keys on the other object, and never to a set of candidate keys, or any other column.

getInverseForeignKeysForCollection

public Map<String,String> getInverseForeignKeysForCollection(Class boClass,
                                                             String collectionName)
Description copied from interface: PersistenceStructureService
Returns a listing of the FK field mappings between a BO and the elements in a collection. Since this is in effect a 1:n relationship, only the complete primary key set of the parent BO will be returned. for example, assume Account BO has an "acctNbrForAcct" PK, and it has a list of subAccounts, each of which has a ("acctNbrForSubAcct", "subAcctNbr") PK pair. the Account PK will be mapped to some of the PK fields of the element list. When called on the Account BO class with the "subAccounts" collection name, his method should return a map with a mapping of "acctNbrForAcct" (key) => "acctNbrForSubAcct"

Specified by:
getInverseForeignKeysForCollection in interface PersistenceStructureService
Returns:

getNestedForeignKeyMap

public Map getNestedForeignKeyMap(Class persistableObjectClass)
Description copied from interface: PersistenceStructureService
Builds a map of reference pk attributes back to the foreign key.

Specified by:
getNestedForeignKeyMap in interface PersistenceStructureService
Returns:
See Also:
org.kuali.rice.krad.service.PersistenceService#getNestedForeignKeyMap(java.lang.Class)

hasPrimaryKeyFieldValues

public boolean hasPrimaryKeyFieldValues(Object persistableObject)
Specified by:
hasPrimaryKeyFieldValues in interface PersistenceStructureService
Returns:
true if all primary key fields of the string have a non-null (and non-empty, for Strings) value
See Also:
org.kuali.rice.krad.service.PersistenceMetadataService#hasPrimaryKeyFieldValues(java.lang.Object)

getForeignKeyFieldsPopulationState

public ForeignKeyFieldsPopulationState getForeignKeyFieldsPopulationState(PersistableBusinessObject bo,
                                                                          String referenceName)
Description copied from interface: PersistenceStructureService
This method checks the foreign keys for a reference on a given BO, and tests that all fk fields are populated if any are populated. In other words, for a given reference, it finds all the attributes of the BO that make up the foreign keys, and checks to see if they all have values. It also keeps a list of all the fieldNames that do not have values.

Specified by:
getForeignKeyFieldsPopulationState in interface PersistenceStructureService
Parameters:
bo - - A populated BusinessObject descendent. Must contain an attributed named referenceName.
referenceName - - The name of the field that is a reference we are analyzing.
Returns:
A populated ForeignKeyFieldsPopulation object which represents the state of population for the foreign key fields.
See Also:
org.kuali.rice.krad.service.PersistenceService#getForeignKeyFieldsPopulationState(org.kuali.rice.krad.bo.BusinessObject, java.lang.String)

listReferenceObjectFields

public Map<String,Class> listReferenceObjectFields(Class boClass)
Description copied from interface: PersistenceStructureService
This method uses the persistence layer to determine the list of reference objects contained within this parent object. For example, an Account object contains sub-objects such as Chart, as well as the key that connects the two, String chartOfAccountsCode. The return structure is: Map. As an example, an Account object passed into this would return: 0:['chartOfAccounts', org.kuali.module.chart.bo.Chart] 1:['organization', org.kuali.module.chart.bo.Org] etc.

Specified by:
listReferenceObjectFields in interface PersistenceStructureService
Parameters:
boClass - Class that would like to be analyzed for reference names
Returns:
Map containing the reference name for the key as a string, and the class of the reference as the value. If the object contains no references, then this Map will be empty.
See Also:
org.kuali.rice.krad.service.PersistenceStructureService#listReferenceObjectFieldNames(java.lang.Class)

listCollectionObjectTypes

public Map<String,Class> listCollectionObjectTypes(Class boClass)
Specified by:
listCollectionObjectTypes in interface PersistenceStructureService

listCollectionObjectTypes

public Map<String,Class> listCollectionObjectTypes(PersistableBusinessObject bo)
Specified by:
listCollectionObjectTypes in interface PersistenceStructureService

listReferenceObjectFields

public Map<String,Class> listReferenceObjectFields(PersistableBusinessObject bo)
Description copied from interface: PersistenceStructureService
This method uses the persistence layer to determine the list of reference objects contained within this parent object. For example, an Account object contains sub-objects such as Chart, as well as the key that connects the two, String chartOfAccountsCode. The return structure is: Map. As an example, an Account object passed into this would return: 0:['chartOfAccounts', org.kuali.module.chart.bo.Chart] 1:['organization', org.kuali.module.chart.bo.Org] etc.

Specified by:
listReferenceObjectFields in interface PersistenceStructureService
Parameters:
bo - BusinessObject (or subclass) instance that would like to be analyzed for reference names
Returns:
Map containing the reference name for the key as a string, and the class of the reference as the value. If the object contains no references, then this Map will be empty.
See Also:
org.kuali.rice.krad.service.PersistenceStructureService#listReferenceObjectFieldNames(org.kuali.rice.krad.bo.BusinessObject)

isReferenceUpdatable

public boolean isReferenceUpdatable(Class boClass,
                                    String referenceName)
Specified by:
isReferenceUpdatable in interface PersistenceStructureService

isCollectionUpdatable

public boolean isCollectionUpdatable(Class boClass,
                                     String collectionName)
Specified by:
isCollectionUpdatable in interface PersistenceStructureService

hasCollection

public boolean hasCollection(Class boClass,
                             String collectionName)
Description copied from interface: PersistenceStructureService
Returns whether BOs of the given class have a collection defined within them with the given collection name.

Specified by:
hasCollection in interface PersistenceStructureService
Returns:

hasReference

public boolean hasReference(Class boClass,
                            String referenceName)
Description copied from interface: PersistenceStructureService
Returns whether there is a reference defined in the persistence layer with the given name. Depending on the type of underlying persistence mechanism, this method may or may not return true when the referenceName really refers to a collection type. To determine whether a reference is a collection, use the hasCollection method instead. In OJB, this method will return false for collection references.

Specified by:
hasReference in interface PersistenceStructureService
Returns:

getTableName

public String getTableName(Class<? extends PersistableBusinessObject> boClass)
This overridden method ...

Specified by:
getTableName in interface PersistenceStructureService
Returns:
See Also:
PersistenceStructureService.getTableName(java.lang.Class)


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