Search in sources :

Example 6 with EntityInheritanceTree

use of org.apache.cayenne.map.EntityInheritanceTree in project cayenne by apache.

the class ObjectContextQueryAction method polymorphicObjectFromCache.

private Object polymorphicObjectFromCache(EntityInheritanceTree superNode, Map<String, ?> idSnapshot) {
    for (EntityInheritanceTree child : superNode.getChildren()) {
        ObjectId id = new ObjectId(child.getEntity().getName(), idSnapshot);
        Object object = actingContext.getGraphManager().getNode(id);
        if (object != null) {
            return object;
        }
        object = polymorphicObjectFromCache(child, idSnapshot);
        if (object != null) {
            return object;
        }
    }
    return null;
}
Also used : EntityInheritanceTree(org.apache.cayenne.map.EntityInheritanceTree) ObjectId(org.apache.cayenne.ObjectId)

Example 7 with EntityInheritanceTree

use of org.apache.cayenne.map.EntityInheritanceTree in project cayenne by apache.

the class DataDomainQueryAction method polymorphicRowFromCache.

private DataRow polymorphicRowFromCache(ObjectId superOid) {
    DataRow row = cache.getCachedSnapshot(superOid);
    if (row != null) {
        return row;
    }
    EntityInheritanceTree inheritanceTree = domain.getEntityResolver().getInheritanceTree(superOid.getEntityName());
    if (!inheritanceTree.getChildren().isEmpty()) {
        row = polymorphicRowFromCache(inheritanceTree, superOid.getIdSnapshot());
    }
    return row;
}
Also used : EntityInheritanceTree(org.apache.cayenne.map.EntityInheritanceTree) DataRow(org.apache.cayenne.DataRow)

Example 8 with EntityInheritanceTree

use of org.apache.cayenne.map.EntityInheritanceTree in project cayenne by apache.

the class ObjGraphBuilder method isIsolated.

@Override
protected boolean isIsolated(DataChannelDescriptor domain, Entity entity) {
    if (!super.isIsolated(domain, entity)) {
        return false;
    }
    if (((ObjEntity) entity).getSuperEntity() != null) {
        return false;
    }
    // TODO: andrus 05/30/2010 - reindexing all DataMaps every time may be VERY slow on large projects
    EntityResolver resolver = new EntityResolver(domain.getDataMaps());
    EntityInheritanceTree inheritanceTree = resolver.getInheritanceTree(entity.getName());
    return inheritanceTree == null || inheritanceTree.getChildren().isEmpty();
}
Also used : EntityInheritanceTree(org.apache.cayenne.map.EntityInheritanceTree) EntityResolver(org.apache.cayenne.map.EntityResolver)

Aggregations

EntityInheritanceTree (org.apache.cayenne.map.EntityInheritanceTree)8 DataRow (org.apache.cayenne.DataRow)2 ObjectId (org.apache.cayenne.ObjectId)2 ObjEntity (org.apache.cayenne.map.ObjEntity)2 EmbeddedAttribute (org.apache.cayenne.map.EmbeddedAttribute)1 EntityResolver (org.apache.cayenne.map.EntityResolver)1 ObjAttribute (org.apache.cayenne.map.ObjAttribute)1 ObjRelationship (org.apache.cayenne.map.ObjRelationship)1