Commit 88ca02c6 by Madhan Neethiraj Committed by kevalbhatt

ATLAS-1603: fix to handle null value for object_id type attributes

parent 0feb60a2
...@@ -9,6 +9,10 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al ...@@ -9,6 +9,10 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai) ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES: ALL CHANGES:
ATLAS-1603: fix to handle null value for object_id type attributes (mneethiraj via kevalbhatt)
ATLAS 1607: notify listeners on classification addition/deletion (sarathkumarsubramanian via mneethiraj)
ATLAS-1606: introduced query provider to handle Gremlin version specific queries (apoorvnaik via mneethiraj)
ATLAS-1602 fixed IT failures in QuickStart and issues identified in coverity scan (sarathkumarsubramanian via mneethiraj)
ATLAS-1584 Fix issues with owned map reference and add tests (sumasai) ATLAS-1584 Fix issues with owned map reference and add tests (sumasai)
ATLAS-1589 DSL queries return wrong object when filter traverses an edge (jnhagelberg) ATLAS-1589 DSL queries return wrong object when filter traverses an edge (jnhagelberg)
ATLAS-1590 UI : Edit Button is enabled for Deleted entities. (kevalbhatt) ATLAS-1590 UI : Edit Button is enabled for Deleted entities. (kevalbhatt)
......
...@@ -282,15 +282,19 @@ public class EntityGraphMapper { ...@@ -282,15 +282,19 @@ public class EntityGraphMapper {
} }
case OBJECT_ID_TYPE: { case OBJECT_ID_TYPE: {
String edgeLabel = AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty()); String edgeLabel = AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty());
AtlasEdge currentEdge = graphHelper.getEdgeForLabel(ctx.getReferringVertex(), edgeLabel); AtlasEdge currentEdge = graphHelper.getEdgeForLabel(ctx.getReferringVertex(), edgeLabel);
AtlasEntityType instanceType = getInstanceType(ctx.getValue()); AtlasEdge newEdge = null;
AtlasEdge edge = currentEdge != null ? currentEdge : null;
ctx.setElementType(instanceType); if (ctx.getValue() != null) {
ctx.setExistingEdge(edge); AtlasEntityType instanceType = getInstanceType(ctx.getValue());
AtlasEdge edge = currentEdge != null ? currentEdge : null;
ctx.setElementType(instanceType);
ctx.setExistingEdge(edge);
AtlasEdge newEdge = mapObjectIdValue(ctx, context); newEdge = mapObjectIdValue(ctx, context);
}
if (currentEdge != null && !currentEdge.equals(newEdge)) { if (currentEdge != null && !currentEdge.equals(newEdge)) {
deleteHandler.deleteEdgeReference(currentEdge, ctx.getAttrType().getTypeCategory(), ctx.getAttribute().isOwnedRef(), true); deleteHandler.deleteEdgeReference(currentEdge, ctx.getAttrType().getTypeCategory(), ctx.getAttribute().isOwnedRef(), true);
...@@ -371,11 +375,14 @@ public class EntityGraphMapper { ...@@ -371,11 +375,14 @@ public class EntityGraphMapper {
if (entityVertex == null) { if (entityVertex == null) {
AtlasObjectId objId = getObjectId(ctx.getValue()); AtlasObjectId objId = getObjectId(ctx.getValue());
entityVertex = context.getDiscoveryContext().getResolvedEntityVertex(objId);
if (objId != null) {
entityVertex = context.getDiscoveryContext().getResolvedEntityVertex(objId);
}
} }
if (entityVertex == null) { if (entityVertex == null) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, ctx.getValue().toString()); throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, (ctx.getValue() == null ? null : ctx.getValue().toString()));
} }
if (ctx.getCurrentEdge() != null) { if (ctx.getCurrentEdge() != null) {
......
...@@ -75,6 +75,7 @@ import static org.apache.atlas.TestUtils.randomString; ...@@ -75,6 +75,7 @@ import static org.apache.atlas.TestUtils.randomString;
import static org.apache.atlas.TestUtilsV2.TABLE_TYPE; import static org.apache.atlas.TestUtilsV2.TABLE_TYPE;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
@Guice(modules = RepositoryMetadataModule.class) @Guice(modules = RepositoryMetadataModule.class)
...@@ -811,6 +812,25 @@ public class AtlasEntityStoreV1Test { ...@@ -811,6 +812,25 @@ public class AtlasEntityStoreV1Test {
assertEquals(col3.getAttribute("description"), updatedCol3Entity.getAttribute("description")); assertEquals(col3.getAttribute("description"), updatedCol3Entity.getAttribute("description"));
} }
@Test
public void testSetObjectIdAttrToNull() throws Exception {
final AtlasEntity dbEntity = TestUtilsV2.createDBEntity();
EntityMutationResponse dbCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(dbEntity), false);
final AtlasEntity tableEntity = TestUtilsV2.createTableEntity(dbEntity);
final EntityMutationResponse tblCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(tableEntity), false);
final AtlasEntityHeader createdTblHeader = tblCreationResponse.getCreatedEntityByTypeNameAndAttribute(TABLE_TYPE, NAME, (String) tableEntity.getAttribute(NAME));
final AtlasEntity createdTblEntity = getEntityFromStore(createdTblHeader);
init();
createdTblEntity.setAttribute("database", null);
final EntityMutationResponse tblUpdateResponse = entityStore.createOrUpdate(new AtlasEntityStream(createdTblEntity), true);
final AtlasEntityHeader updatedTblHeader = tblUpdateResponse.getFirstEntityPartialUpdated();
final AtlasEntity updatedTblEntity = getEntityFromStore(updatedTblHeader);
assertNull(updatedTblEntity.getAttribute("database"));
}
private String randomStrWithReservedChars() { private String randomStrWithReservedChars() {
return randomString() + "\"${}%"; return randomString() + "\"${}%";
......
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