Skip to content

Commit

Permalink
Merge pull request #2356 from atlanhq/plt-1891-struct-diff
Browse files Browse the repository at this point in the history
fix: fix for array and the maps
  • Loading branch information
sumandas0 authored Sep 7, 2023
2 parents 115c16d + 45c1708 commit 0eb0644
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.atlas.repository.store.graph.v2;

import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.repository.graphdb.AtlasVertex;
Expand All @@ -28,6 +29,7 @@
import org.apache.atlas.utils.AtlasEntityUtil;
import org.apache.commons.collections.MapUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -81,7 +83,28 @@ private AtlasEntityDiffResult getDiffResult(AtlasEntity updatedEntity, AtlasEnti
continue;
}

Object newVal = entry.getValue();
TypeCategory category = attribute.getAttributeType().getTypeCategory();
boolean isDefaultValueNotNull = !attribute.getAttributeDef().getIsDefaultValueNull();
Object newVal;

if (entry.getValue() == null && isDefaultValueNotNull) {
switch (category) {
case PRIMITIVE:
newVal = attribute.getAttributeType().createDefaultValue();
break;
case ARRAY:
newVal = new ArrayList<>();
break;
case MAP:
newVal = MapUtils.EMPTY_MAP;
break;
default:
newVal = entry.getValue();
}
} else {
newVal = entry.getValue();
}

Object currVal = (storedEntity != null) ? storedEntity.getAttribute(attrName) : entityRetriever.getEntityAttribute(storedVertex, attribute);

if (!attribute.getAttributeType().areEqualValues(currVal, newVal, guidRefMap)) {
Expand Down

0 comments on commit 0eb0644

Please sign in to comment.