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;
}
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);
}
}
Aggregations