|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.kuali.rice.krad.data.provider.impl.MetadataProviderBase org.kuali.rice.krad.data.jpa.JpaMetadataProviderImpl
public abstract class JpaMetadataProviderImpl
A superclass which handles most of the JPA metadata extraction.
It handles everything which can be done via the standard javax.persistence annotations. Any implementation-specific annotations must be processed in the provided abstract hook methods.
Field Summary | |
---|---|
protected javax.persistence.EntityManager |
entityManager
The entity manager used in interacting with the database. |
Fields inherited from class org.kuali.rice.krad.data.provider.impl.MetadataProviderBase |
---|
masterMetadataMap |
Constructor Summary | |
---|---|
JpaMetadataProviderImpl()
|
Method Summary | |
---|---|
abstract DataObjectRelationship |
addExtensionRelationship(Class<?> entityClass,
String extensionPropertyName,
Class<?> extensionEntity)
Given the parameters, injects into the JPA repository a 1:1 relationship between the parent entity and the extension entity via the given property name (which must exist on the entityClass). |
protected DataObjectAttribute |
getAttributeMetadata(Class<?> persistableClass,
javax.persistence.metamodel.SingularAttribute<?,?> attr,
List<String> primaryKeyAttributes)
Gets a single field's metadata from the property descriptor. |
protected DataObjectCollection |
getCollectionMetadataFromCollectionAttribute(javax.persistence.metamodel.PluralAttribute cd)
Extracts the collection metadata from a single JPA PluralAttribute object. |
protected List<DataObjectCollection> |
getCollectionsFromMetadata(Set<javax.persistence.metamodel.PluralAttribute> collections)
Gets a collection's metadata from the property descriptor. |
javax.persistence.EntityManager |
getEntityManager()
Gets the entity manager for interacting with the database. |
DataObjectMetadata |
getMetadataForClass(Class<?> persistableClass)
Extracts the data from the JPA Persistence Unit. |
protected List<String> |
getPrimaryKeyAttributeNames(javax.persistence.metamodel.EntityType<?> entityType)
Gets the attribute names for the primary keys from the given entity type. |
protected DataObjectRelationship |
getRelationshipMetadata(javax.persistence.metamodel.SingularAttribute rd)
Gets a single field's relationship metadata. |
protected List<DataObjectRelationship> |
getRelationships(Set<?> references)
Gets the list of relationships for this data object. |
protected List<DataObjectAttribute> |
getSingularAttributes(Class<?> persistableClass,
Collection<?> fields,
List<String> primaryKeyAttributes)
Gets a list of attributes for this data object. |
protected void |
initializeMetadata(Collection<Class<?>> types)
Performs the initialization of the provider with the given set of types. |
boolean |
isClassPersistable(Class<?> type)
Determines whether the given class can be persisted. |
protected abstract void |
populateImplementationSpecificAttributeLevelMetadata(DataObjectAttributeImpl attribute,
javax.persistence.metamodel.SingularAttribute<?,?> attr)
Hook called after all "standard" attribute-level annotations are processed to perform any further extraction based on the internals of the JPA implementation. |
protected abstract void |
populateImplementationSpecificCollectionLevelMetadata(DataObjectCollectionImpl collection,
javax.persistence.metamodel.PluralAttribute<?,?,?> cd)
Hook called after all "standard" field-level annotations are processed on attributes identified as "plural" to perform any further extraction based on the internals of the JPA implementation. |
protected abstract void |
populateImplementationSpecificEntityLevelMetadata(DataObjectMetadataImpl metadata,
javax.persistence.metamodel.EntityType<?> entityType)
Hook called after all "standard" annotations are processed to perform any further extraction based on the internals of the JPA implementation. |
protected abstract void |
populateImplementationSpecificRelationshipLevelMetadata(DataObjectRelationshipImpl relationship,
javax.persistence.metamodel.SingularAttribute<?,?> rd)
Hook called after all "standard" field-level annotations are processed on attributes identified as "associations" to perform any further extraction based on the internals of the JPA implementation. |
void |
setEntityManager(javax.persistence.EntityManager entityManager)
Setter for the entity manager. |
Methods inherited from class org.kuali.rice.krad.data.provider.impl.MetadataProviderBase |
---|
getMetadataForType, getSupportedTypes, handles, provideMetadata, provideMetadataForTypes, requiresListOfExistingTypes |
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.data.provider.MetadataProvider |
---|
getMetadataForType, getSupportedTypes, handles, provideMetadata, provideMetadataForTypes, requiresListOfExistingTypes |
Field Detail |
---|
protected javax.persistence.EntityManager entityManager
Constructor Detail |
---|
public JpaMetadataProviderImpl()
Method Detail |
---|
protected abstract void populateImplementationSpecificEntityLevelMetadata(DataObjectMetadataImpl metadata, javax.persistence.metamodel.EntityType<?> entityType)
metadata
- The metadata for the data object.entityType
- The entity type of the data object.protected abstract void populateImplementationSpecificAttributeLevelMetadata(DataObjectAttributeImpl attribute, javax.persistence.metamodel.SingularAttribute<?,?> attr)
attribute
- The attribute metadata for the data object.attr
- The persistent single-valued property or field.protected abstract void populateImplementationSpecificCollectionLevelMetadata(DataObjectCollectionImpl collection, javax.persistence.metamodel.PluralAttribute<?,?,?> cd)
collection
- The collection metadata for the data object.cd
- The persistent collection-valued attribute.protected abstract void populateImplementationSpecificRelationshipLevelMetadata(DataObjectRelationshipImpl relationship, javax.persistence.metamodel.SingularAttribute<?,?> rd)
relationship
- The relationship metadata for the data object.rd
- The persistent single-valued property or field.public abstract DataObjectRelationship addExtensionRelationship(Class<?> entityClass, String extensionPropertyName, Class<?> extensionEntity)
addExtensionRelationship
in interface JpaMetadataProvider
entityClass
- The parent (owning) class which must be already known to the JPA persistence unit. This one's metadata
will be modified within the internals of the JPA metadata.extensionPropertyName
- The property on the parent class which will hold the extensionEntity. This property must be of the
type of the extension entity or a superclass. (Object will work.)extensionEntity
- The child/extension class which needs to be linked. It must also already be known to JPA.
protected void initializeMetadata(Collection<Class<?>> types)
If the list is null or empty, the provider is expected to discover the types via other means, or do nothing if the types cannot be discovered.
initializeMetadata
in class MetadataProviderBase
public DataObjectMetadata getMetadataForClass(Class<?> persistableClass)
persistableClass
- Class which will be looked up in OJB's static descriptor repository.
protected List<String> getPrimaryKeyAttributeNames(javax.persistence.metamodel.EntityType<?> entityType)
entityType
- The entity type of the data object.
protected List<DataObjectAttribute> getSingularAttributes(Class<?> persistableClass, Collection<?> fields, List<String> primaryKeyAttributes)
persistableClass
- The class of the data object.fields
- The collection of singular attributes to process.primaryKeyAttributes
- The list of primary key attribute names.
protected DataObjectAttribute getAttributeMetadata(Class<?> persistableClass, javax.persistence.metamodel.SingularAttribute<?,?> attr, List<String> primaryKeyAttributes)
persistableClass
- The class of the data object.attr
- The singular attribute to process.primaryKeyAttributes
- The list of primary key attribute names.
protected List<DataObjectCollection> getCollectionsFromMetadata(Set<javax.persistence.metamodel.PluralAttribute> collections)
collections
- The list of plural attributes to process.
protected DataObjectCollection getCollectionMetadataFromCollectionAttribute(javax.persistence.metamodel.PluralAttribute cd)
PluralAttribute
object.
cd
- The plural attribute to process.
PluralAttribute
object.protected List<DataObjectRelationship> getRelationships(Set<?> references)
references
- The list of singular attribute references.
protected DataObjectRelationship getRelationshipMetadata(javax.persistence.metamodel.SingularAttribute rd)
rd
- The singular attribute to process.
public boolean isClassPersistable(Class<?> type)
isClassPersistable
in class MetadataProviderBase
type
- the class to check for persistability.
public void setEntityManager(javax.persistence.EntityManager entityManager)
entityManager
- The entity manager to set.public javax.persistence.EntityManager getEntityManager()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |