EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(nodeStateContext.getPersistenceDelegator().getKunderaMetadata(), nodeDataClass);
Object entityId = nodeStateContext.getEntityId();
Object nodeData = null; // Node data
EntityReader reader = client.getReader();
if (reader == null)
{
return;
}
EnhanceEntity ee = reader.findById(entityId, entityMetadata, client);
// Recursively retrieve relationship entities (if there are any)
if (ee != null && ee.getEntity() != null)
{
Object entity = ee.getEntity();
if ((entityMetadata.getRelationNames() == null || entityMetadata.getRelationNames().isEmpty())
&& !entityMetadata.isRelationViaJoinTable())
{
// There is no relation (not even via Join Table), Construct
// Node out of this enhance entity,
nodeData = entity;
}
else
{
// This entity has associated entities, find them recursively.
nodeData = reader.recursivelyFindEntities(ee.getEntity(), ee.getRelations(), entityMetadata,
nodeStateContext.getPersistenceDelegator(), false);
}
}
// Construct Node out of this entity and put into Persistence Cache