ATLAS-4614 : Deferred Actions : Add classification name in response

Signed-off-by: Pinal Shah <pinal.shah@freestoneinfotech.com>
This commit is contained in:
pareshD 2022-05-06 17:11:25 +05:30 committed by Pinal Shah
parent bc49b631e9
commit eaa6d1645e
3 changed files with 12 additions and 13 deletions

View File

@ -405,7 +405,7 @@ public abstract class DeleteHandlerV1 {
if (taskManagement != null && DEFERRED_ACTION_ENABLED) {
for (AtlasVertex classificationVertex : classificationVertices) {
createAndQueueTask(CLASSIFICATION_PROPAGATION_ADD, toVertex, classificationVertex.getIdForDisplay(), relationshipGuid);
createAndQueueTask(CLASSIFICATION_PROPAGATION_ADD, toVertex, classificationVertex.getIdForDisplay(), relationshipGuid, GraphHelper.getClassificationName(classificationVertex));
}
} else {
final List<AtlasVertex> propagatedEntityVertices = CollectionUtils.isNotEmpty(classificationVertices) ? entityRetriever.getIncludedImpactedVerticesV2(toVertex, relationshipGuid) : null;
@ -1016,7 +1016,7 @@ public abstract class DeleteHandlerV1 {
if (isClassificationEdge && removePropagations) {
if (taskManagement != null && DEFERRED_ACTION_ENABLED) {
createAndQueueTask(CLASSIFICATION_PROPAGATION_DELETE, instanceVertex, classificationVertex.getIdForDisplay(), null);
createAndQueueTask(CLASSIFICATION_PROPAGATION_DELETE, instanceVertex, classificationVertex.getIdForDisplay(), null, GraphHelper.getClassificationName(classificationVertex));
} else {
removeTagPropagation(classificationVertex);
}
@ -1190,17 +1190,16 @@ public abstract class DeleteHandlerV1 {
}
}
public void createAndQueueTask(String taskType, AtlasVertex entityVertex, String classificationVertexId, String relationshipGuid) {
public void createAndQueueTask(String taskType, AtlasVertex entityVertex, String classificationVertexId, String relationshipGuid, String classificationName) {
String currentUser = RequestContext.getCurrentUser();
String entityGuid = GraphHelper.getGuid(entityVertex);
Map<String, Object> taskParams = ClassificationTask.toParameters(entityGuid, classificationVertexId, relationshipGuid);
Map<String, Object> taskParams = ClassificationTask.toParameters(entityGuid, classificationVertexId, relationshipGuid, classificationName);
AtlasTask task = taskManagement.createTask(taskType, currentUser, taskParams);
AtlasGraphUtilsV2.addEncodedProperty(entityVertex, PENDING_TASKS_PROPERTY_KEY, task.getGuid());
RequestContext.get().queueTask(task);
}
public void createAndQueueTask(String taskType, AtlasEdge relationshipEdge, AtlasRelationship relationship) {
String currentUser = RequestContext.getCurrentUser();
String relationshipEdgeId = relationshipEdge.getIdForDisplay();

View File

@ -2011,7 +2011,7 @@ public class EntityGraphMapper {
if (propagateTags && taskManagement != null && DEFERRED_ACTION_ENABLED) {
propagateTags = false;
createAndQueueTask(CLASSIFICATION_PROPAGATION_ADD, entityVertex, classificationVertex.getIdForDisplay());
createAndQueueTask(CLASSIFICATION_PROPAGATION_ADD, entityVertex, classificationVertex.getIdForDisplay(), classificationName);
}
// add the attributes for the trait instance
@ -2193,7 +2193,7 @@ public class EntityGraphMapper {
throw new AtlasBaseException(AtlasErrorCode.DELETE_TAG_PROPAGATION_NOT_ALLOWED, classificationVertexId, entityGuid);
}
createAndQueueTask(CLASSIFICATION_PROPAGATION_DELETE, entityVertex, classificationVertexId);
createAndQueueTask(CLASSIFICATION_PROPAGATION_DELETE, entityVertex, classificationVertexId, classificationName);
entityVertices = new ArrayList<>();
} else {
@ -2428,7 +2428,7 @@ public class EntityGraphMapper {
if (updatedTagPropagation != null && taskManagement != null && DEFERRED_ACTION_ENABLED) {
String propagationType = updatedTagPropagation ? CLASSIFICATION_PROPAGATION_ADD : CLASSIFICATION_PROPAGATION_DELETE;
createAndQueueTask(propagationType, entityVertex, classificationVertex.getIdForDisplay());
createAndQueueTask(propagationType, entityVertex, classificationVertex.getIdForDisplay(), classificationName);
updatedTagPropagation = null;
}
@ -2823,10 +2823,9 @@ public class EntityGraphMapper {
attributes.put(bmAttribute.getName(), attrValue);
}
private void createAndQueueTask(String taskType, AtlasVertex entityVertex, String classificationVertexId) {
deleteDelegate.getHandler().createAndQueueTask(taskType, entityVertex, classificationVertexId, null);
private void createAndQueueTask(String taskType, AtlasVertex entityVertex, String classificationVertexId, String classificationName) {
deleteDelegate.getHandler().createAndQueueTask(taskType, entityVertex, classificationVertexId, null, classificationName);
}
public void removePendingTaskFromEntity(String entityGuid, String taskGuid) throws EntityNotFoundException {
if (StringUtils.isEmpty(entityGuid) || StringUtils.isEmpty(taskGuid)) {
return;

View File

@ -49,6 +49,7 @@ public abstract class ClassificationTask extends AbstractTask {
public static final String PARAM_ENTITY_GUID = "entityGuid";
public static final String PARAM_CLASSIFICATION_VERTEX_ID = "classificationVertexId";
public static final String PARAM_CLASSIFICATION_NAME = "classificationName";
public static final String PARAM_RELATIONSHIP_GUID = "relationshipGuid";
public static final String PARAM_RELATIONSHIP_OBJECT = "relationshipObject";
public static final String PARAM_RELATIONSHIP_EDGE_ID = "relationshipEdgeId";
@ -108,14 +109,14 @@ public abstract class ClassificationTask extends AbstractTask {
return getStatus();
}
public static Map<String, Object> toParameters(String entityGuid, String classificationVertexId, String relationshipGuid) {
public static Map<String, Object> toParameters(String entityGuid, String classificationVertexId, String relationshipGuid, String classificationName) {
return new HashMap<String, Object>() {{
put(PARAM_ENTITY_GUID, entityGuid);
put(PARAM_CLASSIFICATION_VERTEX_ID, classificationVertexId);
put(PARAM_CLASSIFICATION_NAME, classificationName);
put(PARAM_RELATIONSHIP_GUID, relationshipGuid);
}};
}
public static Map<String, Object> toParameters(String relationshipEdgeId, AtlasRelationship relationship) {
return new HashMap<String, Object>() {{
put(PARAM_RELATIONSHIP_EDGE_ID, relationshipEdgeId);