You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2019/03/12 19:22:56 UTC

[atlas] branch branch-1.0 updated: ATLAS-3041: fix for failure in deleting relationship-def by name

This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch branch-1.0
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/branch-1.0 by this push:
     new 8c37961  ATLAS-3041: fix for failure in deleting relationship-def by name
8c37961 is described below

commit 8c379617f9a422081fa858e4e4f9458e67e77816
Author: jajodia <ja...@cloudera.com>
AuthorDate: Mon Mar 11 16:22:21 2019 -0700

    ATLAS-3041: fix for failure in deleting relationship-def by name
    
    Signed-off-by: Madhan Neethiraj <ma...@apache.org>
    (cherry picked from commit 50ff27c7e687670893f4f0320908de4c60d54adc)
---
 .../store/graph/AtlasTypeDefGraphStore.java        |  2 +
 .../store/graph/AtlasTypeDefGraphStoreTest.java    |  6 +++
 repository/src/test/resources/json/hiveDBv2.json   | 55 +++++++++++++++++++++-
 3 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
index 5cb57a4..2dac776 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
@@ -619,6 +619,8 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
             typesDef.setEntityDefs(Collections.singletonList((AtlasEntityDef) baseTypeDef));
         } else if (baseTypeDef instanceof AtlasEnumDef) {
             typesDef.setEnumDefs(Collections.singletonList((AtlasEnumDef) baseTypeDef));
+        } else if (baseTypeDef instanceof AtlasRelationshipDef) {
+            typesDef.setRelationshipDefs(Collections.singletonList((AtlasRelationshipDef) baseTypeDef));
         } else if (baseTypeDef instanceof AtlasStructDef) {
             typesDef.setStructDefs(Collections.singletonList((AtlasStructDef) baseTypeDef));
         }
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
index 493ad13..51dd16b 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
@@ -332,9 +332,15 @@ public class AtlasTypeDefGraphStoreTest {
         try {
             final String HIVEDB_v2_JSON = "hiveDBv2";
             final String hiveDB2 = "hive_db_v2";
+            final String relationshipDefName = "cluster_hosts_relationship";
+            final String hostEntityDef = "host";
+            final String clusterEntityDef = "cluster";
             AtlasTypesDef typesDef = TestResourceFileUtils.readObjectFromJson(".", HIVEDB_v2_JSON, AtlasTypesDef.class);
             typeDefStore.createTypesDef(typesDef);
             typeDefStore.deleteTypeByName(hiveDB2);
+            typeDefStore.deleteTypeByName(relationshipDefName);
+            typeDefStore.deleteTypeByName(hostEntityDef);
+            typeDefStore.deleteTypeByName(clusterEntityDef);
         } catch (AtlasBaseException e) {
             fail("Deletion should've succeeded");
         }
diff --git a/repository/src/test/resources/json/hiveDBv2.json b/repository/src/test/resources/json/hiveDBv2.json
index f46d5f7..bb0309d 100644
--- a/repository/src/test/resources/json/hiveDBv2.json
+++ b/repository/src/test/resources/json/hiveDBv2.json
@@ -52,5 +52,58 @@
       "isUnique": false,
       "isIndexable": false
     }]
-  }]
+  },
+    {
+      "name": "cluster",
+      "serviceType": "atlas_core",
+      "typeVersion": "1.0",
+      "attributeDefs": [
+        {
+          "name": "attr1",
+          "typeName": "string",
+          "cardinality": "SINGLE",
+          "isIndexable": true,
+          "isOptional": false,
+          "isUnique": false
+        }
+      ]
+    },
+    {
+      "name": "host",
+      "serviceType": "atlas_core",
+      "typeVersion": "1.0",
+      "attributeDefs": [
+        {
+          "name": "attr2",
+          "typeName": "string",
+          "cardinality": "SINGLE",
+          "isIndexable": true,
+          "isOptional": false,
+          "includeInNotification": true,
+          "isUnique": false
+        }
+      ]
+    }],
+  "relationshipDefs": [
+    {
+      "name": "cluster_hosts_relationship",
+      "relationshipLabel": "cluster_hosts_relationship_label",
+      "serviceType": "atlas_core",
+      "typeVersion": "1.0",
+      "relationshipCategory": "COMPOSITION",
+      "propagateTags": "NONE",
+      "endDef1": {
+        "type": "cluster",
+        "name": "host_list",
+        "isContainer": true,
+        "cardinality": "SET"
+      },
+      "endDef2": {
+        "type": "host",
+        "name": "cluster",
+        "isContainer": false,
+        "cardinality": "SINGLE"
+      }
+    }
+  ]
 }
\ No newline at end of file