Skip to content

Commit

Permalink
Expose method to fetch relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshi0301 committed Jan 11, 2024
1 parent d310444 commit d13bf10
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public interface AtlasRelationshipStore {

AtlasEdge getOrCreate(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship) throws AtlasBaseException;

AtlasEdge getRelationship(AtlasVertex fromVertex, AtlasVertex toVertex, AtlasRelationship relationship) throws AtlasBaseException;

/**
* Retrieve a relationship if it exists or creates a new relationship instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ public AtlasEdge getOrCreate(AtlasVertex end1Vertex, AtlasVertex end2Vertex, Atl
return ret;
}

private AtlasEdge getRelationship(AtlasVertex fromVertex, AtlasVertex toVertex, AtlasRelationship relationship) throws AtlasBaseException {
@Override
public AtlasEdge getRelationship(AtlasVertex fromVertex, AtlasVertex toVertex, AtlasRelationship relationship) throws AtlasBaseException {
String relationshipLabel = getRelationshipEdgeLabel(fromVertex, toVertex, relationship.getTypeName());

return getRelationshipEdge(fromVertex, toVertex, relationshipLabel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,7 @@ private AtlasEdge getEdgeUsingRelationship(AttributeMutationContext ctx, EntityM
}
}


if (attributeVertex == null) {
if(RequestContext.get().isImportInProgress()) {
return null;
Expand All @@ -1748,8 +1749,28 @@ private AtlasEdge getEdgeUsingRelationship(AttributeMutationContext ctx, EntityM
String attributeName = attribute.getName();

if (entityType.hasRelationshipAttribute(attributeName)) {
if (ctx.getCurrentEdge() != null && getStatus(ctx.getCurrentEdge()) != DELETED) {
ret = ctx.getCurrentEdge();
String relationshipName = attribute.getRelationshipName();
AtlasVertex fromVertex;
AtlasVertex toVertex;


if (StringUtils.isEmpty(relationshipName)) {
relationshipName = graphHelper.getRelationshipTypeName(entityVertex, entityType, attributeName);
}

if (attribute.getRelationshipEdgeDirection() == IN) {
fromVertex = attributeVertex;
toVertex = entityVertex;

} else {
fromVertex = entityVertex;
toVertex = attributeVertex;
}

AtlasEdge edge = relationshipStore.getRelationship(fromVertex, toVertex, new AtlasRelationship(relationshipName));

if (edge != null && getStatus(edge) != DELETED) {
return edge;
}
}
}
Expand Down

0 comments on commit d13bf10

Please sign in to comment.