Search in sources :

Example 6 with EdmNavigationProperty

use of org.apache.olingo.commons.api.edm.EdmNavigationProperty in project teiid by teiid.

the class TeiidServiceHandler method insertDepth.

private int insertDepth(EdmEntityType entityType, Entity entity) throws SQLException, TeiidException {
    int depth = 1;
    int childDepth = 0;
    for (String navigationName : entityType.getNavigationPropertyNames()) {
        EdmNavigationProperty navProperty = entityType.getNavigationProperty(navigationName);
        Link navLink = entity.getNavigationLink(navigationName);
        if (navLink != null && navLink.getInlineEntity() != null) {
            childDepth = Math.max(childDepth, insertDepth(navProperty.getType(), navLink.getInlineEntity()));
        } else if (navLink != null && navLink.getInlineEntitySet() != null && !navLink.getInlineEntitySet().getEntities().isEmpty()) {
            for (Entity inlineEntity : navLink.getInlineEntitySet().getEntities()) {
                childDepth = Math.max(childDepth, insertDepth(navProperty.getType(), inlineEntity));
            }
        }
    }
    return depth + childDepth;
}
Also used : Entity(org.apache.olingo.commons.api.data.Entity) EdmNavigationProperty(org.apache.olingo.commons.api.edm.EdmNavigationProperty) Link(org.apache.olingo.commons.api.data.Link)

Aggregations

EdmNavigationProperty (org.apache.olingo.commons.api.edm.EdmNavigationProperty)6 Entity (org.apache.olingo.commons.api.data.Entity)2 Link (org.apache.olingo.commons.api.data.Link)2 ExpandNode (org.teiid.olingo.service.TeiidServiceHandler.ExpandNode)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 EdmEntityType (org.apache.olingo.commons.api.edm.EdmEntityType)1 ExpandOptionImpl (org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl)1 TeiidException (org.teiid.core.TeiidException)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1 ForeignKey (org.teiid.metadata.ForeignKey)1 UpdateResponse (org.teiid.odata.api.UpdateResponse)1 SubqueryHint (org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint)1 Expression (org.teiid.query.sql.symbol.Expression)1