use of org.apache.atlas.model.instance.AtlasRelatedObjectId in project atlas by apache.
the class EntityGraphRetriever method mapRelationshipArrayAttribute.
private List<AtlasRelatedObjectId> mapRelationshipArrayAttribute(AtlasVertex entityVertex, AtlasAttribute attribute) throws AtlasBaseException {
List<AtlasRelatedObjectId> ret = new ArrayList<>();
Iterator<AtlasEdge> edges = null;
if (attribute.getRelationshipEdgeDirection() == IN) {
edges = getIncomingEdgesByLabel(entityVertex, attribute.getRelationshipEdgeLabel());
} else if (attribute.getRelationshipEdgeDirection() == OUT) {
edges = getOutGoingEdgesByLabel(entityVertex, attribute.getRelationshipEdgeLabel());
} else if (attribute.getRelationshipEdgeDirection() == BOTH) {
edges = getAdjacentEdgesByLabel(entityVertex, AtlasEdgeDirection.BOTH, attribute.getRelationshipEdgeLabel());
}
if (edges != null) {
while (edges.hasNext()) {
AtlasEdge relationshipEdge = edges.next();
AtlasRelatedObjectId relatedObjectId = mapVertexToRelatedObjectId(entityVertex, relationshipEdge);
ret.add(relatedObjectId);
}
}
return ret;
}
use of org.apache.atlas.model.instance.AtlasRelatedObjectId in project atlas by apache.
the class AtlasRelationshipStoreV1Test method toAtlasObjectIds.
protected static List<AtlasObjectId> toAtlasObjectIds(Object object) {
List<AtlasObjectId> ret = new ArrayList<>();
if (object instanceof List) {
List<?> objectIds = (List) object;
if (CollectionUtils.isNotEmpty(objectIds)) {
for (Object obj : objectIds) {
if (obj instanceof AtlasRelatedObjectId) {
AtlasRelatedObjectId relatedObjectId = (AtlasRelatedObjectId) obj;
ret.add(new AtlasObjectId(relatedObjectId.getGuid(), relatedObjectId.getTypeName(), relatedObjectId.getUniqueAttributes()));
}
}
}
}
return ret;
}
use of org.apache.atlas.model.instance.AtlasRelatedObjectId in project atlas by apache.
the class EntityGraphRetriever method mapVertexToRelatedObjectId.
private AtlasRelatedObjectId mapVertexToRelatedObjectId(AtlasVertex entityVertex, AtlasEdge edge) throws AtlasBaseException {
AtlasRelatedObjectId ret = null;
if (GraphHelper.elementExists(edge)) {
AtlasVertex referenceVertex = edge.getInVertex();
if (StringUtils.equals(getIdFromVertex(referenceVertex), getIdFromVertex(entityVertex))) {
referenceVertex = edge.getOutVertex();
}
if (referenceVertex != null) {
String entityTypeName = getTypeName(referenceVertex);
String entityGuid = getGuid(referenceVertex);
AtlasRelationship relationship = mapEdgeToAtlasRelationship(edge);
ret = new AtlasRelatedObjectId(entityGuid, entityTypeName, relationship.getGuid(), new AtlasStruct(relationship.getTypeName(), relationship.getAttributes()));
Object displayText = getDisplayText(referenceVertex, entityTypeName);
if (displayText != null) {
ret.setDisplayText(displayText.toString());
}
}
}
return ret;
}
Aggregations