use of org.apache.atlas.model.instance.AtlasClassification.PropagationState in project atlas by apache.
the class EntityGraphRetriever method mapClassifications.
private void mapClassifications(AtlasVertex entityVertex, AtlasEntity entity) throws AtlasBaseException {
List<AtlasEdge> edges = getAllClassificationEdges(entityVertex);
if (CollectionUtils.isNotEmpty(edges)) {
List<AtlasClassification> allClassifications = new ArrayList<>();
List<AtlasClassification> propagationDisabledClassifications = new ArrayList<>();
for (AtlasEdge edge : edges) {
PropagationState edgeState = getClassificationEdgeState(edge);
AtlasVertex classificationVertex = edge.getInVertex();
if (edgeState == ACTIVE) {
allClassifications.add(toAtlasClassification(classificationVertex));
} else if (edgeState == DELETED && isPropagatedClassificationEdge(edge)) {
propagationDisabledClassifications.add(toAtlasClassification(classificationVertex));
}
}
entity.setClassifications(allClassifications);
entity.setPropagationDisabledClassifications(propagationDisabledClassifications);
}
}
use of org.apache.atlas.model.instance.AtlasClassification.PropagationState in project atlas by apache.
the class EntityGraphMapper method setPropagatedClassificationState.
public void setPropagatedClassificationState(String entityGuid, String classificationName, String sourceEntityGuid, boolean disablePropagation) throws AtlasBaseException {
AtlasVertex entityVertex = AtlasGraphUtilsV1.findByGuid(entityGuid);
if (entityVertex == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, entityGuid);
}
AtlasEdge propagatedEdge = getPropagatedClassificationEdge(entityVertex, classificationName, sourceEntityGuid);
if (propagatedEdge == null) {
throw new AtlasBaseException(AtlasErrorCode.PROPAGATED_CLASSIFICATION_NOT_ASSOCIATED_WITH_ENTITY, classificationName);
}
PropagationState currentState = getClassificationEdgeState(propagatedEdge);
PropagationState updatedState = (disablePropagation) ? PropagationState.DELETED : PropagationState.ACTIVE;
if (currentState != updatedState) {
AtlasGraphUtilsV1.setProperty(propagatedEdge, CLASSIFICATION_EDGE_STATE_PROPERTY_KEY, updatedState);
if (disablePropagation) {
removeFromPropagatedTraitNames(entityVertex, classificationName);
} else {
addToPropagatedTraitNames(entityVertex, classificationName);
}
updateModificationMetadata(entityVertex);
AtlasEntityWithExtInfo entityWithExtInfo = instanceConverter.getAndCacheEntity(entityGuid);
AtlasEntity entity = (entityWithExtInfo != null) ? entityWithExtInfo.getEntity() : null;
if (updatedState == PropagationState.DELETED) {
entityChangeNotifier.onClassificationDeletedFromEntity(entity, Collections.singletonList(classificationName));
} else {
AtlasClassification classification = entityRetriever.toAtlasClassification(propagatedEdge.getInVertex());
entityChangeNotifier.onClassificationAddedToEntity(entity, Collections.singletonList(classification));
}
}
}
Aggregations