Repository: incubator-atlas
Updated Branches:
  refs/heads/master 0feb60a2f -> 88ca02c62


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


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/88ca02c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/88ca02c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/88ca02c6

Branch: refs/heads/master
Commit: 88ca02c623345890e42bab300602f8f733949012
Parents: 0feb60a
Author: Madhan Neethiraj <[email protected]>
Authored: Wed Mar 1 00:43:30 2017 -0800
Committer: kevalbhatt <[email protected]>
Committed: Wed Mar 1 15:51:19 2017 +0530

----------------------------------------------------------------------
 release-log.txt                                 |  4 ++++
 .../store/graph/v1/EntityGraphMapper.java       | 25 +++++++++++++-------
 .../store/graph/v1/AtlasEntityStoreV1Test.java  | 20 ++++++++++++++++
 3 files changed, 40 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/88ca02c6/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 4f59f57..3148c70 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -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)
 
 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-1589 DSL queries return wrong object when filter traverses an edge 
(jnhagelberg)
 ATLAS-1590 UI : Edit Button is enabled for Deleted entities. (kevalbhatt)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/88ca02c6/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
----------------------------------------------------------------------
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
index e6a7f41..e2b82cc 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
@@ -282,15 +282,19 @@ public class EntityGraphMapper {
             }
 
             case OBJECT_ID_TYPE: {
-                String          edgeLabel    = 
AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty());
-                AtlasEdge       currentEdge  = 
graphHelper.getEdgeForLabel(ctx.getReferringVertex(), edgeLabel);
-                AtlasEntityType instanceType = getInstanceType(ctx.getValue());
-                AtlasEdge       edge         = currentEdge != null ? 
currentEdge : null;
+                String    edgeLabel    = 
AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty());
+                AtlasEdge currentEdge  = 
graphHelper.getEdgeForLabel(ctx.getReferringVertex(), edgeLabel);
+                AtlasEdge newEdge      = null;
 
-                ctx.setElementType(instanceType);
-                ctx.setExistingEdge(edge);
+                if (ctx.getValue() != null) {
+                    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)) {
                     deleteHandler.deleteEdgeReference(currentEdge, 
ctx.getAttrType().getTypeCategory(), ctx.getAttribute().isOwnedRef(), true);
@@ -371,11 +375,14 @@ public class EntityGraphMapper {
 
         if (entityVertex == null) {
             AtlasObjectId objId = getObjectId(ctx.getValue());
-            entityVertex = 
context.getDiscoveryContext().getResolvedEntityVertex(objId);
+
+            if (objId != null) {
+                entityVertex = 
context.getDiscoveryContext().getResolvedEntityVertex(objId);
+            }
         }
 
         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) {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/88ca02c6/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
----------------------------------------------------------------------
diff --git 
a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
 
b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
index 94d313f..47c9fc9 100644
--- 
a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
+++ 
b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1Test.java
@@ -75,6 +75,7 @@ import static org.apache.atlas.TestUtils.randomString;
 import static org.apache.atlas.TestUtilsV2.TABLE_TYPE;
 import static org.mockito.Mockito.mock;
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 
 @Guice(modules = RepositoryMetadataModule.class)
@@ -811,6 +812,25 @@ public class AtlasEntityStoreV1Test {
         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() {
         return randomString() + "\"${}%";

Reply via email to