Commit 45d3872b by Sarath Subramanian

ATLAS-2513: Notifications are not sent about impacted entities when…

ATLAS-2513: Notifications are not sent about impacted entities when classification is updated at source entity
parent 59673d48
...@@ -22,6 +22,7 @@ import org.apache.atlas.AtlasErrorCode; ...@@ -22,6 +22,7 @@ import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.RequestContextV1; import org.apache.atlas.RequestContextV1;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TimeBoundary;
import org.apache.atlas.model.TypeCategory; import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
...@@ -1483,6 +1484,7 @@ public class EntityGraphMapper { ...@@ -1483,6 +1484,7 @@ public class EntityGraphMapper {
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityTypeName); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityTypeName);
List<AtlasClassification> updatedClassifications = new ArrayList<>(); List<AtlasClassification> updatedClassifications = new ArrayList<>();
List<AtlasVertex> entitiesToPropagateTo = new ArrayList<>(); List<AtlasVertex> entitiesToPropagateTo = new ArrayList<>();
Map<AtlasVertex, List<AtlasClassification>> addedPropagations = null; Map<AtlasVertex, List<AtlasClassification>> addedPropagations = null;
Map<AtlasVertex, List<String>> removedPropagations = null; Map<AtlasVertex, List<String>> removedPropagations = null;
...@@ -1508,12 +1510,31 @@ public class EntityGraphMapper { ...@@ -1508,12 +1510,31 @@ public class EntityGraphMapper {
validateAndNormalizeForUpdate(classification); validateAndNormalizeForUpdate(classification);
Map<String, Object> classificationAttributes = classification.getAttributes(); boolean isClassificationUpdated = false;
// check for attribute update
Map<String, Object> updatedAttributes = classification.getAttributes();
if (MapUtils.isNotEmpty(updatedAttributes)) {
for (String attributeName : updatedAttributes.keySet()) {
currentClassification.setAttribute(attributeName, updatedAttributes.get(attributeName));
}
isClassificationUpdated = true;
}
// check for validity period update
List<TimeBoundary> currentValidityPeriods = currentClassification.getValidityPeriods();
List<TimeBoundary> updatedValidityPeriods = classification.getValidityPeriods();
if (!Objects.equals(currentValidityPeriods, updatedValidityPeriods)) {
currentClassification.setValidityPeriods(updatedValidityPeriods);
if (MapUtils.isNotEmpty(classificationAttributes)) { isClassificationUpdated = true;
for (String attributeName : classificationAttributes.keySet()) {
currentClassification.setAttribute(attributeName, classificationAttributes.get(attributeName));
} }
if (isClassificationUpdated && CollectionUtils.isEmpty(entitiesToPropagateTo)) {
entitiesToPropagateTo = graphHelper.getImpactedVertices(guid);
} }
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
package org.apache.atlas.repository.store.graph.v1; package org.apache.atlas.repository.store.graph.v1;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TimeBoundary; import org.apache.atlas.model.TimeBoundary;
...@@ -100,7 +101,7 @@ public final class EntityGraphRetriever { ...@@ -100,7 +101,7 @@ public final class EntityGraphRetriever {
private final String CREATE_TIME = "createTime"; private final String CREATE_TIME = "createTime";
private final String QUALIFIED_NAME = "qualifiedName"; private final String QUALIFIED_NAME = "qualifiedName";
private static final List<TimeBoundary> TIME_BOUNDARIES_LIST = new ArrayList<>(); private static final TypeReference<List<TimeBoundary>> TIME_BOUNDARIES_LIST_TYPE = new TypeReference<List<TimeBoundary>>() {};
private static final GraphHelper graphHelper = GraphHelper.getInstance(); private static final GraphHelper graphHelper = GraphHelper.getInstance();
private final AtlasTypeRegistry typeRegistry; private final AtlasTypeRegistry typeRegistry;
...@@ -249,7 +250,7 @@ public final class EntityGraphRetriever { ...@@ -249,7 +250,7 @@ public final class EntityGraphRetriever {
String strValidityPeriods = AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_VALIDITY_PERIODS_KEY, String.class); String strValidityPeriods = AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_VALIDITY_PERIODS_KEY, String.class);
if (strValidityPeriods != null) { if (strValidityPeriods != null) {
ret.setValidityPeriods(AtlasJson.fromJson(strValidityPeriods, TIME_BOUNDARIES_LIST.getClass())); ret.setValidityPeriods(AtlasJson.fromJson(strValidityPeriods, TIME_BOUNDARIES_LIST_TYPE));
} }
mapAttributes(classificationVertex, ret, null); mapAttributes(classificationVertex, ret, null);
......
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