Commit 96a348a9 by Madhan Neethiraj

ATLAS-2556: fixed classification-def update to handle removal of all entity-type restrictions

parent 8ae61e0f
...@@ -384,6 +384,16 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore { ...@@ -384,6 +384,16 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
return atlasGraph.addEdge(outVertex, inVertex, edgeLabel); return atlasGraph.addEdge(outVertex, inVertex, edgeLabel);
} }
void removeEdge(AtlasVertex outVertex, AtlasVertex inVertex, String edgeLabel) {
Iterable<AtlasEdge> edges = outVertex.getEdges(AtlasEdgeDirection.OUT, edgeLabel);
for (AtlasEdge edge : edges) {
if (edge.getInVertex().getId().equals(inVertex.getId())) {
atlasGraph.removeEdge(edge);
}
}
}
void createSuperTypeEdges(AtlasVertex vertex, Set<String> superTypes, TypeCategory typeCategory) void createSuperTypeEdges(AtlasVertex vertex, Set<String> superTypes, TypeCategory typeCategory)
throws AtlasBaseException { throws AtlasBaseException {
Set<String> currentSuperTypes = getSuperTypeNames(vertex); Set<String> currentSuperTypes = getSuperTypeNames(vertex);
...@@ -420,6 +430,18 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore { ...@@ -420,6 +430,18 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
} }
getOrCreateEdge(classificationVertex, entityTypeVertex, AtlasGraphUtilsV1.ENTITYTYPE_EDGE_LABEL); getOrCreateEdge(classificationVertex, entityTypeVertex, AtlasGraphUtilsV1.ENTITYTYPE_EDGE_LABEL);
} }
} else if (CollectionUtils.isNotEmpty(currentEntityTypes)) { // remove the restrictions, if present
for (String entityType : currentEntityTypes) {
AtlasVertex entityTypeVertex = findTypeVertexByNameAndCategory(entityType, TypeCategory.CLASS);
if (entityTypeVertex == null) {
throw new AtlasBaseException(AtlasErrorCode.CLASSIFICATIONDEF_INVALID_ENTITYTYPES, classificationTypeName,entityType);
}
removeEdge(classificationVertex, entityTypeVertex, AtlasGraphUtilsV1.ENTITYTYPE_EDGE_LABEL);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment