Search in sources :

Example 6 with AtlasRelationshipEdgeDirection

use of org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection in project incubator-atlas by apache.

the class EntityGraphRetriever method mapVertexToAttribute.

private Object mapVertexToAttribute(AtlasVertex entityVertex, AtlasAttribute attribute, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException {
    Object ret = null;
    AtlasType attrType = attribute.getAttributeType();
    String vertexPropertyName = attribute.getQualifiedName();
    String edgeLabel = EDGE_LABEL_PREFIX + vertexPropertyName;
    boolean isOwnedAttribute = attribute.isOwnedRef();
    AtlasRelationshipEdgeDirection edgeDirection = attribute.getRelationshipEdgeDirection();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Mapping vertex {} to atlas entity {}.{}", entityVertex, attribute.getDefinedInDef().getName(), attribute.getName());
    }
    switch(attrType.getTypeCategory()) {
        case PRIMITIVE:
            ret = mapVertexToPrimitive(entityVertex, vertexPropertyName, attribute.getAttributeDef());
            break;
        case ENUM:
            ret = GraphHelper.getProperty(entityVertex, vertexPropertyName);
            break;
        case STRUCT:
            ret = mapVertexToStruct(entityVertex, edgeLabel, null, entityExtInfo);
            break;
        case OBJECT_ID_TYPE:
            ret = mapVertexToObjectId(entityVertex, edgeLabel, null, entityExtInfo, isOwnedAttribute, edgeDirection);
            break;
        case ARRAY:
            ret = mapVertexToArray(entityVertex, (AtlasArrayType) attrType, vertexPropertyName, entityExtInfo, isOwnedAttribute, edgeDirection);
            break;
        case MAP:
            ret = mapVertexToMap(entityVertex, (AtlasMapType) attrType, vertexPropertyName, entityExtInfo, isOwnedAttribute, edgeDirection);
            break;
        case CLASSIFICATION:
            // do nothing
            break;
    }
    return ret;
}
Also used : AtlasRelationshipEdgeDirection(org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection)

Example 7 with AtlasRelationshipEdgeDirection

use of org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection in project atlas by apache.

the class AtlasRelationshipType method addRelationshipEdgeDirection.

private void addRelationshipEdgeDirection() {
    AtlasRelationshipEndDef endDef1 = relationshipDef.getEndDef1();
    AtlasRelationshipEndDef endDef2 = relationshipDef.getEndDef2();
    if (StringUtils.equals(endDef1.getType(), endDef2.getType()) && StringUtils.equals(endDef1.getName(), endDef2.getName())) {
        AtlasAttribute endAttribute = end1Type.getRelationshipAttribute(endDef1.getName());
        endAttribute.setRelationshipEdgeDirection(BOTH);
    } else {
        AtlasAttribute end1Attribute = end1Type.getRelationshipAttribute(endDef1.getName());
        AtlasAttribute end2Attribute = end2Type.getRelationshipAttribute(endDef2.getName());
        // default relationship edge direction is end1 (out) -> end2 (in)
        AtlasRelationshipEdgeDirection end1Direction = OUT;
        AtlasRelationshipEdgeDirection end2Direction = IN;
        if (endDef1.getIsLegacyAttribute() && endDef2.getIsLegacyAttribute()) {
            end2Direction = OUT;
        } else if (!endDef1.getIsLegacyAttribute() && endDef2.getIsLegacyAttribute()) {
            end1Direction = IN;
            end2Direction = OUT;
        }
        end1Attribute.setRelationshipEdgeDirection(end1Direction);
        end2Attribute.setRelationshipEdgeDirection(end2Direction);
    }
}
Also used : AtlasRelationshipEdgeDirection(org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection) AtlasRelationshipEndDef(org.apache.atlas.model.typedef.AtlasRelationshipEndDef)

Aggregations

AtlasRelationshipEdgeDirection (org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection)7 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)3 AtlasType (org.apache.atlas.type.AtlasType)3 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)2 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)2 AtlasRelationshipEndDef (org.apache.atlas.model.typedef.AtlasRelationshipEndDef)2 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)2 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)2 AtlasArrayType (org.apache.atlas.type.AtlasArrayType)1 AtlasMapType (org.apache.atlas.type.AtlasMapType)1