This is an automated email from the ASF dual-hosted git repository. nixon pushed a commit to branch branch-1.0 in repository https://gitbox.apache.org/repos/asf/atlas.git
commit 6f3aa81452000e432a1b9a4b4abbae88cd172f63 Author: Ashutosh Mestry <ames...@hortonworks.com> AuthorDate: Mon Jan 21 22:31:13 2019 -0800 ATLAS-3029, ATLAS-3020: Audit APIs for classification updates. Part-2. --- .../store/graph/v2/ClassificationAssociator.java | 4 ++- .../graph/v2/ClassificationAssociatorTest.java | 5 +++ .../col-entity-T1-prop-Tn-No-Guid.json | 31 +++++++++++++++++ .../header-Tx-prop-T1-No-Guid.json | 39 ++++++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/ClassificationAssociator.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/ClassificationAssociator.java index 057598c..628c1cc 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/ClassificationAssociator.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/ClassificationAssociator.java @@ -310,7 +310,9 @@ public class ClassificationAssociator { return list; } - return list.stream().filter(x -> x.getEntityGuid().equals(guid)).collect(Collectors.toList()); + return list.stream().filter(x -> x != null && + (StringUtils.isEmpty(guid) || StringUtils.isEmpty(x.getEntityGuid())) + || x.getEntityGuid().equals(guid)).collect(Collectors.toList()); } } } diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/ClassificationAssociatorTest.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/ClassificationAssociatorTest.java index ab5bb2b..16074b6 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/ClassificationAssociatorTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/ClassificationAssociatorTest.java @@ -163,6 +163,7 @@ public class ClassificationAssociatorTest { @Test public void updaterTests() throws IOException { + updaterAssert("header-None", "col-entity-None"); updaterAssert("header-PII", "col-entity-None", PROCESS_ADD + ":PII"); updaterAssert("header-PII", "col-entity-PII", new String[]{PROCESS_UPDATE + ":PII"}); updaterAssert("header-None", "col-entity-PII", new String[]{PROCESS_DELETE + ":PII"}); @@ -181,6 +182,10 @@ public class ClassificationAssociatorTest { updaterAssert("header-Tx-prop-T1", "col-entity-T1-prop-Tn", PROCESS_DELETE + ":T1", PROCESS_ADD + ":Tx"); + updaterAssert("header-Tx-prop-T1-No-Guid", "col-entity-T1-prop-Tn-No-Guid", + PROCESS_DELETE + ":Tn", + PROCESS_UPDATE + ":T1", + PROCESS_ADD + ":Tx"); } diff --git a/repository/src/test/resources/json/classification-association/col-entity-T1-prop-Tn-No-Guid.json b/repository/src/test/resources/json/classification-association/col-entity-T1-prop-Tn-No-Guid.json new file mode 100644 index 0000000..4a6fa80 --- /dev/null +++ b/repository/src/test/resources/json/classification-association/col-entity-T1-prop-Tn-No-Guid.json @@ -0,0 +1,31 @@ +{ + "typeName": "hive_column", + "attributes": { + "owner": "hive", + "createTime": 1547071410000, + "qualifiedName": "stocks.daily@cl1", + "name": "daily" + }, + "status": "ACTIVE", + "displayText": "daily", + "classifications": [ + { + "typeName": "T1", + "attributes": {}, + "entityStatus": "ACTIVE", + "propagate": false, + "validityPeriods": [], + "removePropagationsOnEntityDelete": false + }, + { + "typeName": "Tn", + "attributes": {}, + "entityStatus": "ACTIVE", + "propagate": false, + "validityPeriods": [], + "removePropagationsOnEntityDelete": false + } + ], + "meaningNames": [], + "meanings": [] +} diff --git a/repository/src/test/resources/json/classification-association/header-Tx-prop-T1-No-Guid.json b/repository/src/test/resources/json/classification-association/header-Tx-prop-T1-No-Guid.json new file mode 100644 index 0000000..0771851 --- /dev/null +++ b/repository/src/test/resources/json/classification-association/header-Tx-prop-T1-No-Guid.json @@ -0,0 +1,39 @@ +{ + "guidHeaderMap": { + "0ce68113-77fe-4ed1-9585-69371202bd74": { + "typeName": "hive_column", + "attributes": { + "owner": "hive", + "qualifiedName": "hortoniabank.us_customers.nationalid@cl1", + "name": "nationalid" + }, + "status": "ACTIVE", + "displayText": "nationalid", + "classificationNames": [ + "T1", "Tx" + ], + "classifications": [ + { + "typeName": "Tx", + "attributes": { + "type": "ssn" + }, + "entityStatus": "ACTIVE", + "propagate": true, + "removePropagationsOnEntityDelete": false + }, + { + "typeName": "T1", + "attributes": { + "type": "ssn" + }, + "entityStatus": "ACTIVE", + "propagate": true, + "removePropagationsOnEntityDelete": false + } + ], + "meaningNames": [], + "meanings": [] + } + } +}