Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id ED37A200C20 for ; Sun, 19 Feb 2017 16:01:14 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id EBAF1160B58; Sun, 19 Feb 2017 15:01:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E60F2160B4F for ; Sun, 19 Feb 2017 16:01:12 +0100 (CET) Received: (qmail 43566 invoked by uid 500); 19 Feb 2017 15:01:11 -0000 Mailing-List: contact commits-help@atlas.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@atlas.incubator.apache.org Delivered-To: mailing list commits@atlas.incubator.apache.org Received: (qmail 43557 invoked by uid 99); 19 Feb 2017 15:01:11 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Feb 2017 15:01:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 08B5CC343C for ; Sun, 19 Feb 2017 15:01:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 9EzjLUsfEzgf for ; Sun, 19 Feb 2017 15:01:06 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id E64775F610 for ; Sun, 19 Feb 2017 15:01:04 +0000 (UTC) Received: (qmail 43511 invoked by uid 99); 19 Feb 2017 15:01:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Feb 2017 15:01:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E7865DFADC; Sun, 19 Feb 2017 15:01:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: madhan@apache.org To: commits@atlas.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-atlas git commit: ATLAS-1568: moved helper methods from org.apache.atlas.model package classes into an utility class Date: Sun, 19 Feb 2017 15:01:03 +0000 (UTC) archived-at: Sun, 19 Feb 2017 15:01:15 -0000 Repository: incubator-atlas Updated Branches: refs/heads/master 8cd6a6445 -> 7303a412e ATLAS-1568: moved helper methods from org.apache.atlas.model package classes into an utility class Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/7303a412 Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/7303a412 Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/7303a412 Branch: refs/heads/master Commit: 7303a412ef4812dec9bb0f3b65a10146ccfd8330 Parents: 8cd6a64 Author: Madhan Neethiraj Authored: Sat Feb 18 09:30:53 2017 -0800 Committer: Madhan Neethiraj Committed: Sun Feb 19 07:00:56 2017 -0800 ---------------------------------------------------------------------- .../atlas/CreateUpdateEntitiesResult.java | 3 +- .../atlas/model/instance/AtlasEntity.java | 33 ------------ .../atlas/model/instance/AtlasEntityHeader.java | 7 --- .../atlas/model/instance/AtlasObjectId.java | 34 ++---------- .../atlas/model/instance/GuidMapping.java | 34 ++++++------ .../org/apache/atlas/type/AtlasEntityType.java | 2 +- .../org/apache/atlas/type/AtlasTypeUtil.java | 56 +++++++++++++++++++- .../test/java/org/apache/atlas/TestUtilsV2.java | 20 +++---- release-log.txt | 5 +- .../graph/v1/AtlasEntityGraphDiscoveryV1.java | 10 ++-- .../store/graph/v1/AtlasEntityStoreV1.java | 3 +- .../store/graph/v1/EntityGraphMapper.java | 2 +- .../store/graph/v1/EntityGraphRetriever.java | 6 +-- .../store/graph/v1/IDBasedEntityResolver.java | 3 +- .../GraphBackedMetadataRepositoryTest.java | 2 - .../graph/v1/AtlasDeleteHandlerV1Test.java | 26 +++++---- .../store/graph/v1/AtlasEntityStoreV1Test.java | 46 ++++++++-------- .../org/apache/atlas/examples/QuickStartV2.java | 4 +- .../atlas/web/resources/EntityResource.java | 3 +- .../atlas/web/resources/ExportService.java | 8 +-- .../org/apache/atlas/web/rest/TypesREST.java | 2 - .../atlas/web/adapters/TestEntitiesREST.java | 5 +- .../atlas/web/adapters/TestEntityREST.java | 7 ++- .../web/resources/EntityJerseyResourceIT.java | 3 +- .../web/resources/EntityV2JerseyResourceIT.java | 4 +- 25 files changed, 166 insertions(+), 162 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/client/src/main/java/org/apache/atlas/CreateUpdateEntitiesResult.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/atlas/CreateUpdateEntitiesResult.java b/client/src/main/java/org/apache/atlas/CreateUpdateEntitiesResult.java index a1aef61..d31e0f5 100644 --- a/client/src/main/java/org/apache/atlas/CreateUpdateEntitiesResult.java +++ b/client/src/main/java/org/apache/atlas/CreateUpdateEntitiesResult.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.atlas.AtlasClient.EntityResult; import org.apache.atlas.model.instance.GuidMapping; +import org.apache.atlas.type.AtlasType; /** * Result from creating or updating entities. @@ -77,7 +78,7 @@ public class CreateUpdateEntitiesResult { */ public static CreateUpdateEntitiesResult fromJson(String json) throws AtlasServiceException { - GuidMapping guidMapping = GuidMapping.fromString(json); + GuidMapping guidMapping = AtlasType.fromJson(json, GuidMapping.class); EntityResult entityResult = EntityResult.fromString(json); CreateUpdateEntitiesResult result = new CreateUpdateEntitiesResult(); result.setEntityResult(entityResult); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java index e74813a..4e3895d 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java @@ -40,7 +40,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.UUID; import java.util.concurrent.atomic.AtomicLong; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; @@ -175,33 +174,6 @@ public class AtlasEntity extends AtlasStruct implements Serializable { public void setClassifications(List classifications) { this.classifications = classifications; } - @JsonIgnore - public boolean isUnassigned() { - return isUnAssigned(guid); - } - - @JsonIgnore - public boolean isAssigned() { - return isAssigned(guid); - } - - @JsonIgnore - public static boolean isAssigned(String guid) { - if (guid != null) { - try { - UUID.fromString(guid); - return true; - } catch (IllegalArgumentException e) { - // ignore - } - } - return false; - } - - @JsonIgnore - public static boolean isUnAssigned(String guid) { - return guid != null && guid.length() > 0 && guid.charAt(0) == '-'; - } private void init() { setGuid(nextInternalId()); @@ -217,11 +189,6 @@ public class AtlasEntity extends AtlasStruct implements Serializable { return "-" + Long.toString(s_nextId.getAndIncrement()); } - @JsonIgnore - public AtlasObjectId getAtlasObjectId() { - return new AtlasObjectId(getGuid(), getTypeName()); - } - @Override public StringBuilder toString(StringBuilder sb) { if (sb == null) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java index 94b3aa6..324946a 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java @@ -34,7 +34,6 @@ import org.codehaus.jackson.annotate.JsonAutoDetect; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; -import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.annotate.JsonSerialize; @@ -191,10 +190,4 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable { super(list, startIndex, pageSize, totalCount, sortType, sortBy); } } - - @JsonIgnore - public AtlasObjectId getAtlasObjectId() { - return new AtlasObjectId(getGuid(), getTypeName()); - } - } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java index dea3a93..5f0e093 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java @@ -31,13 +31,10 @@ import javax.xml.bind.annotation.XmlSeeAlso; import org.apache.atlas.model.PList; import org.apache.atlas.model.SearchFilter.SortType; import org.apache.atlas.model.typedef.AtlasBaseTypeDef; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang.StringUtils; import org.codehaus.jackson.annotate.JsonAutoDetect; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; -import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.annotate.JsonSerialize; @@ -139,32 +136,6 @@ public class AtlasObjectId implements Serializable { this.uniqueAttributes = uniqueAttributes; } - @JsonIgnore - public boolean isValidGuid() { - return isAssignedGuid() || isUnAssignedGuid(); - } - - @JsonIgnore - public boolean isAssignedGuid() { - return AtlasEntity.isAssigned(guid); - } - - @JsonIgnore - public boolean isUnAssignedGuid() { - return AtlasEntity.isUnAssigned(guid); - } - - @JsonIgnore - public boolean isValid() { - if (isAssignedGuid() || isUnAssignedGuid()) { - return true; - } else if (StringUtils.isNotEmpty(typeName) && MapUtils.isNotEmpty(uniqueAttributes)) { - return true; - } - - return false; - } - public StringBuilder toString(StringBuilder sb) { if (sb == null) { sb = new StringBuilder(); @@ -193,7 +164,8 @@ public class AtlasObjectId implements Serializable { AtlasObjectId that = (AtlasObjectId) o; - if (isValidGuid() && Objects.equals(guid, that.guid)) { + // if guid is null, equality should be based on typeName/uniqueAttributes + if (guid != null && Objects.equals(guid, that.guid)) { return true; } @@ -203,7 +175,7 @@ public class AtlasObjectId implements Serializable { @Override public int hashCode() { - return isValidGuid() ? Objects.hash(guid) : Objects.hash(typeName, uniqueAttributes); + return guid != null ? Objects.hash(guid) : Objects.hash(typeName, uniqueAttributes); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/intg/src/main/java/org/apache/atlas/model/instance/GuidMapping.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/instance/GuidMapping.java b/intg/src/main/java/org/apache/atlas/model/instance/GuidMapping.java index 43ce3b0..1dab56a 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/GuidMapping.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/GuidMapping.java @@ -26,13 +26,11 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; +import org.apache.atlas.model.typedef.AtlasBaseTypeDef; import org.codehaus.jackson.annotate.JsonAutoDetect; -import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.annotate.JsonSerialize; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; /** * This stores a mapping of guid assignments that were made during the processing @@ -45,15 +43,13 @@ import com.google.gson.GsonBuilder; @XmlRootElement @XmlAccessorType(XmlAccessType.PROPERTY) public class GuidMapping { + private static final long serialVersionUID = 1L; - @JsonIgnore - private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); private Map guidAssignments; public GuidMapping() { - } public GuidMapping(Map guidAssignments) { @@ -68,17 +64,23 @@ public class GuidMapping { public void setGuidAssignments(Map guidAssignments) { this.guidAssignments = guidAssignments; } - /** - * Converts the GuidMapping to json - */ - @Override - public String toString() { - return gson.toJson(this); - } - @JsonIgnore - public static GuidMapping fromString(String json) { - return gson.fromJson(json, GuidMapping.class); + public StringBuilder toString(StringBuilder sb) { + if (sb == null) { + sb = new StringBuilder(); + } + + sb.append("GuidMapping{"); + sb.append("guidAssignments={"); + AtlasBaseTypeDef.dumpObjects(guidAssignments, sb); + sb.append('}'); + sb.append('}'); + + return sb; } + @Override + public String toString() { + return toString(new StringBuilder()).toString(); + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java index 626f18e..c6be8f5 100644 --- a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java +++ b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java @@ -362,7 +362,7 @@ public class AtlasEntityType extends AtlasStructType { } boolean isAssignableFrom(AtlasObjectId objId) { - boolean ret = objId.isValid() && (StringUtils.equals(objId.getTypeName(), getTypeName()) || isSuperTypeOf(objId.getTypeName())); + boolean ret = AtlasTypeUtil.isValid(objId) && (StringUtils.equals(objId.getTypeName(), getTypeName()) || isSuperTypeOf(objId.getTypeName())); return ret; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java b/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java index 0a82f40..068fdba 100644 --- a/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java +++ b/intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java @@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableSet; import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasEntity; +import org.apache.atlas.model.instance.AtlasEntityHeader; import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.typedef.AtlasBaseTypeDef; import org.apache.atlas.model.typedef.AtlasClassificationDef; @@ -35,8 +36,10 @@ import org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef; import org.apache.atlas.model.typedef.AtlasTypeDefHeader; import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; + import java.util.Arrays; import java.util.ArrayList; import java.util.Collection; @@ -46,6 +49,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -309,7 +313,7 @@ public class AtlasTypeUtil { if (CollectionUtils.isNotEmpty(entities)) { for (AtlasEntity entity : entities) { if (entity != null) { - ret.add(entity.getAtlasObjectId()); + ret.add(AtlasTypeUtil.getAtlasObjectId(entity)); } } } @@ -324,4 +328,54 @@ public class AtlasTypeUtil { return map; } + + public static AtlasObjectId getAtlasObjectId(AtlasEntity entity) { + return new AtlasObjectId(entity.getGuid(), entity.getTypeName()); + } + + public static AtlasObjectId getAtlasObjectId(AtlasEntityHeader header) { + return new AtlasObjectId(header.getGuid(), header.getTypeName()); + } + + public static boolean isValidGuid(AtlasObjectId objId) { + return isValidGuid(objId.getGuid()); + } + + public static boolean isAssignedGuid(AtlasObjectId objId) { + return isAssignedGuid(objId.getGuid()); + } + + public static boolean isUnAssignedGuid(AtlasObjectId objId) { + return isUnAssignedGuid(objId.getGuid()); + } + + public static boolean isValidGuid(String guid) { + return isAssignedGuid(guid) || isUnAssignedGuid(guid); + } + + public static boolean isAssignedGuid(String guid) { + if (guid != null) { + try { + UUID.fromString(guid); + return true; + } catch (IllegalArgumentException e) { + // ignore + } + } + return false; + } + + public static boolean isUnAssignedGuid(String guid) { + return guid != null && guid.length() > 0 && guid.charAt(0) == '-'; + } + + public static boolean isValid(AtlasObjectId objId) { + if (isAssignedGuid(objId) || isUnAssignedGuid(objId)) { + return true; + } else if (StringUtils.isNotEmpty(objId.getTypeName()) && MapUtils.isNotEmpty(objId.getUniqueAttributes())) { + return true; + } + + return false; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/intg/src/test/java/org/apache/atlas/TestUtilsV2.java ---------------------------------------------------------------------- diff --git a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java index 6d85672..84e17cb 100755 --- a/intg/src/test/java/org/apache/atlas/TestUtilsV2.java +++ b/intg/src/test/java/org/apache/atlas/TestUtilsV2.java @@ -311,7 +311,7 @@ public final class TestUtilsV2 { /******* Department - HR *******/ AtlasEntity hrDept = new AtlasEntity(DEPARTMENT_TYPE, "name", "hr"); - AtlasObjectId hrDeptId = hrDept.getAtlasObjectId(); + AtlasObjectId hrDeptId = AtlasTypeUtil.getAtlasObjectId(hrDept); /******* Address Entities *******/ AtlasStruct janeAddr = new AtlasStruct(ADDRESS_TYPE); @@ -332,14 +332,14 @@ public final class TestUtilsV2 { /******* Manager - Jane (John and Max subordinates) *******/ AtlasEntity jane = new AtlasEntity(MANAGER_TYPE); - AtlasObjectId janeId = jane.getAtlasObjectId(); + AtlasObjectId janeId = AtlasTypeUtil.getAtlasObjectId(jane); jane.setAttribute("name", "Jane"); jane.setAttribute("department", hrDeptId); jane.setAttribute("address", janeAddr); /******* Manager - Julius (no subordinates) *******/ AtlasEntity julius = new AtlasEntity(MANAGER_TYPE); - AtlasObjectId juliusId = julius.getAtlasObjectId(); + AtlasObjectId juliusId = AtlasTypeUtil.getAtlasObjectId(julius); julius.setAttribute("name", "Julius"); julius.setAttribute("department", hrDeptId); julius.setAttribute("address", juliusAddr); @@ -347,7 +347,7 @@ public final class TestUtilsV2 { /******* Employee - Max (Manager: Jane, Mentor: Julius) *******/ AtlasEntity max = new AtlasEntity(EMPLOYEE_TYPE); - AtlasObjectId maxId = max.getAtlasObjectId(); + AtlasObjectId maxId = AtlasTypeUtil.getAtlasObjectId(max); max.setAttribute("name", "Max"); max.setAttribute("department", hrDeptId); max.setAttribute("address", maxAddr); @@ -366,7 +366,7 @@ public final class TestUtilsV2 { /******* Employee - John (Manager: Jane, Mentor: Max) *******/ AtlasEntity john = new AtlasEntity(EMPLOYEE_TYPE); - AtlasObjectId johnId = john.getAtlasObjectId(); + AtlasObjectId johnId = AtlasTypeUtil.getAtlasObjectId(john); john.setAttribute("name", "John"); john.setAttribute("department", hrDeptId); john.setAttribute("address", johnAddr); @@ -442,8 +442,8 @@ public final class TestUtilsV2 { julius.setAttribute("address", juliusAddr); julius.setAttribute("subordinates", ImmutableList.of()); - AtlasObjectId janeId = jane.getAtlasObjectId(); - AtlasObjectId johnId = john.getAtlasObjectId(); + AtlasObjectId janeId = AtlasTypeUtil.getAtlasObjectId(jane); + AtlasObjectId johnId = AtlasTypeUtil.getAtlasObjectId(john); //TODO - Change to MANAGER_TYPE for JULIUS AtlasObjectId maxId = new AtlasObjectId(max.getGuid(), EMPLOYEE_TYPE); @@ -797,7 +797,7 @@ public final class TestUtilsV2 { entity.setAttribute("description", "random table"); entity.setAttribute("type", "type"); entity.setAttribute("tableType", "MANAGED"); - entity.setAttribute("database", dbEntity.getAtlasObjectId()); + entity.setAttribute("database", AtlasTypeUtil.getAtlasObjectId(dbEntity)); entity.setAttribute("created", new Date()); Map partAttributes = new HashMap() {{ @@ -820,7 +820,7 @@ public final class TestUtilsV2 { tblEntity.setAttribute("description", "random table"); tblEntity.setAttribute("type", "type"); tblEntity.setAttribute("tableType", "MANAGED"); - tblEntity.setAttribute("database", dbEntity.getAtlasObjectId()); + tblEntity.setAttribute("database", AtlasTypeUtil.getAtlasObjectId(dbEntity)); tblEntity.setAttribute("created", new Date()); final AtlasStruct partitionStruct = new AtlasStruct("partition_struct_type", "name", "part0"); @@ -845,7 +845,7 @@ public final class TestUtilsV2 { AtlasEntity entity = new AtlasEntity(COLUMN_TYPE); entity.setAttribute(NAME, colName); entity.setAttribute("type", "VARCHAR(32)"); - entity.setAttribute("table", tableEntity.getAtlasObjectId()); + entity.setAttribute("table", AtlasTypeUtil.getAtlasObjectId(tableEntity)); return entity; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 582b71f..2c49879 100644 --- a/release-log.txt +++ b/release-log.txt @@ -9,14 +9,15 @@ 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-1568 moved helper methods from org.apache.atlas.model package classes into an utility class (mneethiraj) ATLAS-1566 replace GSON ser-de with ObjectMapper ser-de (svimal2016 via mneethiraj) ATLAS-1551 auto update of reverse references in V1 API (dkantor) ATLAS-1565 Create EntityREST endpoints for delete operations (sarathkumarsubramanian via svimal2106) -ATLAS-1547 Added tests for hard delete (mneethiraj) +ATLAS-1547 Added tests for hard delete (sumasai) ATLAS-1546 (ATLAS-1546.3.patch)Hive hook should choose appropriate JAAS config if host uses kerberos ticket-cache (nixonrodrigues via kevalbhat) ATLAS-1503 Export/import support to copy data between Atlas instances (ashutoshm via mneethiraj) ATLAS-1554 v2 EntityREST implementation for entity partial update (sarathkumarsubramanian via mneethiraj) -ATLAS-1547 Fix DeleteHandlerV1 for new model changes and add tests (mneethiraj) +ATLAS-1547 Fix DeleteHandlerV1 for new model changes and add tests (sumasai) ATLAS-1556 Edit entity button not working from search table of tag detail page. (kevalbhatt) ATLAS-1559 Regression - If a new tag is created then the earlier tags doesn't render properly (kevalbhatt) ATLAS-1508 Make AtlasADAuthenticationProvider like Ranger ADLdap Methods (gss2002 via mneethiraj) http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityGraphDiscoveryV1.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityGraphDiscoveryV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityGraphDiscoveryV1.java index 436de49..6c88510 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityGraphDiscoveryV1.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityGraphDiscoveryV1.java @@ -72,7 +72,7 @@ public class AtlasEntityGraphDiscoveryV1 implements EntityGraphDiscovery { public void validateAndNormalize(AtlasEntity entity) throws AtlasBaseException { List messages = new ArrayList<>(); - if (!AtlasEntity.isAssigned(entity.getGuid()) && !AtlasEntity.isUnAssigned(entity.getGuid())) { + if (! AtlasTypeUtil.isValidGuid(entity.getGuid())) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, "invalid guid " + entity.getGuid()); } @@ -95,7 +95,7 @@ public class AtlasEntityGraphDiscoveryV1 implements EntityGraphDiscovery { public void validateAndNormalizeForUpdate(AtlasEntity entity) throws AtlasBaseException { List messages = new ArrayList<>(); - if (!AtlasEntity.isAssigned(entity.getGuid()) && !AtlasEntity.isUnAssigned(entity.getGuid())) { + if (! AtlasTypeUtil.isValidGuid(entity.getGuid())) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, "invalid guid " + entity.getGuid()); } @@ -176,7 +176,7 @@ public class AtlasEntityGraphDiscoveryV1 implements EntityGraphDiscovery { if (val instanceof AtlasObjectId) { AtlasObjectId objId = (AtlasObjectId)val; - if (!objId.isValid()) { + if (!AtlasTypeUtil.isValid(objId)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, objId.toString()); } @@ -184,7 +184,7 @@ public class AtlasEntityGraphDiscoveryV1 implements EntityGraphDiscovery { } else if (val instanceof Map) { AtlasObjectId objId = new AtlasObjectId((Map)val); - if (!objId.isValid()) { + if (!AtlasTypeUtil.isValid(objId)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, objId.toString()); } @@ -323,7 +323,7 @@ public class AtlasEntityGraphDiscoveryV1 implements EntityGraphDiscovery { } private void recordObjectReference(AtlasObjectId objId) { - if (objId.isValidGuid()) { + if (AtlasTypeUtil.isValidGuid(objId)) { discoveryContext.addReferencedGuid(objId.getGuid()); } else { discoveryContext.addReferencedByUniqAttribs(objId); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java index 8a6501c..45b7c03 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java @@ -38,6 +38,7 @@ import org.apache.atlas.repository.store.graph.EntityGraphDiscovery; import org.apache.atlas.repository.store.graph.EntityGraphDiscoveryContext; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasTypeRegistry; +import org.apache.atlas.type.AtlasTypeUtil; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -378,7 +379,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); //Create vertices which do not exist in the repository - if ((entityStream instanceof EntityImportStream) && AtlasEntity.isAssigned(entity.getGuid())) { + if ((entityStream instanceof EntityImportStream) && AtlasTypeUtil.isAssignedGuid(entity.getGuid())) { vertex = entityGraphMapper.createVertexWithGuid(entity, entity.getGuid()); } else { vertex = entityGraphMapper.createVertex(entity); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/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 8c96c7b..09f69db 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 @@ -538,7 +538,7 @@ public class EntityGraphMapper { } else if (val instanceof Map) { AtlasObjectId ret = new AtlasObjectId((Map)val); - if (ret.isValid()) { + if (AtlasTypeUtil.isValid(ret)) { return ret; } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java index 527ce15..3ba2190 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java @@ -127,10 +127,10 @@ public final class EntityGraphRetriever { private AtlasVertex getEntityVertex(AtlasObjectId objId) throws AtlasBaseException { try { - if (! objId.isValid()) { + if (! AtlasTypeUtil.isValid(objId)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, objId.toString()); } - if (objId.isAssignedGuid()) { + if (AtlasTypeUtil.isAssignedGuid(objId)) { return graphHelper.getVertexForGUID(objId.getGuid()); } else { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(objId.getTypeName()); @@ -419,7 +419,7 @@ public final class EntityGraphRetriever { AtlasEntity entity = mapVertexToAtlasEntity(referenceVertex, entityExtInfo); if (entity != null) { - ret = entity.getAtlasObjectId(); + ret = AtlasTypeUtil.getAtlasObjectId(entity); } } else { ret = new AtlasObjectId(GraphHelper.getGuid(referenceVertex), GraphHelper.getTypeName(referenceVertex)); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/IDBasedEntityResolver.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/IDBasedEntityResolver.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/IDBasedEntityResolver.java index e773f02..f53efe6 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/IDBasedEntityResolver.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/IDBasedEntityResolver.java @@ -26,6 +26,7 @@ import org.apache.atlas.repository.store.graph.EntityGraphDiscoveryContext; import org.apache.atlas.repository.store.graph.EntityResolver; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasTypeRegistry; +import org.apache.atlas.type.AtlasTypeUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,7 +48,7 @@ public class IDBasedEntityResolver implements EntityResolver { EntityStream entityStream = context.getEntityStream(); for (String guid : context.getReferencedGuids()) { - boolean isAssignedGuid = AtlasEntity.isAssigned(guid); + boolean isAssignedGuid = AtlasTypeUtil.isAssignedGuid(guid); AtlasVertex vertex = isAssignedGuid ? AtlasGraphUtilsV1.findByGuid(guid) : null; if (vertex == null) { // if not found in the store, look if the entity is present in the stream http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java index 1ac9bd1..9f32b85 100755 --- a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java @@ -240,7 +240,6 @@ public class GraphBackedMetadataRepositoryTest { CreateUpdateEntitiesResult result = repositoryService.createEntities(deptInstance); - System.out.println(result.getGuidMapping().toString()); validateGuidMapping(toValidate, result); } @@ -362,7 +361,6 @@ public class GraphBackedMetadataRepositoryTest { CreateUpdateEntitiesResult result = repositoryService.createEntities(deptInstance); - System.out.println(result.getGuidMapping().toString()); assertEquals(result.getCreatedEntities().size(), toVerify.size()); validateGuidMapping(toVerify, result); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java index c55e3f7..555f0ac 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java @@ -198,7 +198,7 @@ public abstract class AtlasDeleteHandlerV1Test { final AtlasEntity tableEntity = TestUtilsV2.createTableEntity(dbEntity); final AtlasEntity columnEntity = TestUtilsV2.createColumnEntity(tableEntity); - tableEntity.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(columnEntity.getAtlasObjectId())); + tableEntity.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(AtlasTypeUtil.getAtlasObjectId(columnEntity))); AtlasEntity.AtlasEntityWithExtInfo input = new AtlasEntity.AtlasEntityWithExtInfo(tableEntity); input.addReferredEntity(columnEntity); @@ -220,7 +220,7 @@ public abstract class AtlasDeleteHandlerV1Test { assertColumnForTestDeleteReference(entityStore.getById(tableCreated.getGuid())); //Deleting table should update process - AtlasEntity process = TestUtilsV2.createProcessEntity(null, Arrays.asList(tableCreated.getAtlasObjectId())); + AtlasEntity process = TestUtilsV2.createProcessEntity(null, Arrays.asList(AtlasTypeUtil.getAtlasObjectId(tableCreated))); init(); final EntityMutationResponse processCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(process), false); @@ -249,7 +249,9 @@ public abstract class AtlasDeleteHandlerV1Test { final AtlasEntity columnEntity3 = TestUtilsV2.createColumnEntity(tableEntity); entitiesInfo.addReferredEntity(columnEntity3); - tableEntity.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(columnEntity1.getAtlasObjectId(), columnEntity2.getAtlasObjectId(), columnEntity3.getAtlasObjectId())); + tableEntity.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(AtlasTypeUtil.getAtlasObjectId(columnEntity1), + AtlasTypeUtil.getAtlasObjectId(columnEntity2), + AtlasTypeUtil.getAtlasObjectId(columnEntity3))); init(); @@ -287,7 +289,7 @@ public abstract class AtlasDeleteHandlerV1Test { AtlasEntity.AtlasEntitiesWithExtInfo entitiesInfo1 = new AtlasEntity.AtlasEntitiesWithExtInfo(tableEntity1); final AtlasEntity columnEntity3New = TestUtilsV2.createColumnEntity(tableEntity1, (String) column3Created.getAttribute(NAME)); - tableEntity1.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(columnEntity3New.getAtlasObjectId())); + tableEntity1.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(AtlasTypeUtil.getAtlasObjectId(columnEntity3New))); entitiesInfo1.addReferredEntity(columnEntity3New); init(); @@ -357,9 +359,9 @@ public abstract class AtlasDeleteHandlerV1Test { Assert.assertNotNull(modificationTimestampPreUpdate); AtlasEntity maxEmployee = getEmployeeByName(hrDept, "Max"); - maxEmployee.setAttribute("mentor", johnEmployeeCreated.getAtlasObjectId()); - maxEmployee.setAttribute("department", deptCreated.getAtlasObjectId()); - maxEmployee.setAttribute("manager", janeEmployeeCreated.getAtlasObjectId()); + maxEmployee.setAttribute("mentor", AtlasTypeUtil.getAtlasObjectId(johnEmployeeCreated)); + maxEmployee.setAttribute("department", AtlasTypeUtil.getAtlasObjectId(deptCreated)); + maxEmployee.setAttribute("manager", AtlasTypeUtil.getAtlasObjectId(janeEmployeeCreated)); init(); EntityMutationResponse entityResult = entityStore.createOrUpdate(new AtlasEntityStream(maxEmployee), false); @@ -379,7 +381,7 @@ public abstract class AtlasDeleteHandlerV1Test { Assert.assertTrue(creationTimestamp < modificationTimestampPostUpdate); // Update max's mentor reference to jane. - maxEmployee.setAttribute("mentor", janeEmployeeCreated.getAtlasObjectId()); + maxEmployee.setAttribute("mentor", AtlasTypeUtil.getAtlasObjectId(janeEmployeeCreated)); init(); entityResult = entityStore.createOrUpdate(new AtlasEntityStream(maxEmployee), false); assertEquals(entityResult.getUpdatedEntities().size(), 1); @@ -400,7 +402,7 @@ public abstract class AtlasDeleteHandlerV1Test { Id juliusGuid = julius.getId(); init(); - maxEmployee.setAttribute("manager", juliusEmployeeCreated.getAtlasObjectId()); + maxEmployee.setAttribute("manager", AtlasTypeUtil.getAtlasObjectId(juliusEmployeeCreated)); entityResult = entityStore.createOrUpdate(new AtlasEntityStream(maxEmployee), false); //TODO ATLAS-499 should have updated julius' subordinates assertEquals(entityResult.getUpdatedEntities().size(), 2); @@ -625,7 +627,7 @@ public abstract class AtlasDeleteHandlerV1Test { AtlasStruct nestedStructInstance = new AtlasStruct("NestedStruct"); Struct traitInstance = new Struct("TestTrait"); structContainerEntity.setAttribute("struct", structInstance); - structInstance.setAttribute("target", ImmutableList.of(structTargetEntity.getAtlasObjectId())); + structInstance.setAttribute("target", ImmutableList.of(AtlasTypeUtil.getAtlasObjectId(structTargetEntity))); structInstance.setAttribute("nestedStructs", ImmutableList.of(nestedStructInstance)); AtlasEntity.AtlasEntitiesWithExtInfo structCreationObj = new AtlasEntity.AtlasEntitiesWithExtInfo(); @@ -728,7 +730,9 @@ public abstract class AtlasDeleteHandlerV1Test { final AtlasEntity columnEntity3 = TestUtilsV2.createColumnEntity(tableEntity); entitiesInfo.addReferredEntity(columnEntity3); - tableEntity.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(columnEntity1.getAtlasObjectId(), columnEntity2.getAtlasObjectId(), columnEntity3.getAtlasObjectId())); + tableEntity.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(AtlasTypeUtil.getAtlasObjectId(columnEntity1), + AtlasTypeUtil.getAtlasObjectId(columnEntity2), + AtlasTypeUtil.getAtlasObjectId(columnEntity3))); init(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/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 7f76236..845bbb4 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 @@ -191,8 +191,8 @@ public class AtlasEntityStoreV1Test { AtlasEntity col2 = TestUtilsV2.createColumnEntity(tableEntity); col2.setAttribute(TestUtilsV2.NAME, "col2"); - columns.add(col1.getAtlasObjectId()); - columns.add(col2.getAtlasObjectId()); + columns.add(AtlasTypeUtil.getAtlasObjectId(col1)); + columns.add(AtlasTypeUtil.getAtlasObjectId(col2)); tableEntity.setAttribute(TestUtilsV2.COLUMNS_ATTR_NAME, columns); @@ -213,8 +213,8 @@ public class AtlasEntityStoreV1Test { AtlasEntity col4 = TestUtilsV2.createColumnEntity(tableEntity); col4.setAttribute(TestUtilsV2.NAME, "col4"); - columns.add(col3.getAtlasObjectId()); - columns.add(col4.getAtlasObjectId()); + columns.add(AtlasTypeUtil.getAtlasObjectId(col3)); + columns.add(AtlasTypeUtil.getAtlasObjectId(col4)); tableEntity.setAttribute(TestUtilsV2.COLUMNS_ATTR_NAME, columns); entitiesInfo.addReferredEntity(col3); @@ -228,8 +228,8 @@ public class AtlasEntityStoreV1Test { //Swap elements columns.clear(); - columns.add(col4.getAtlasObjectId()); - columns.add(col3.getAtlasObjectId()); + columns.add(AtlasTypeUtil.getAtlasObjectId(col4)); + columns.add(AtlasTypeUtil.getAtlasObjectId(col3)); tableEntity.setAttribute(TestUtilsV2.COLUMNS_ATTR_NAME, columns); init(); @@ -321,7 +321,7 @@ public class AtlasEntityStoreV1Test { AtlasEntity col0 = new AtlasEntity(TestUtilsV2.COLUMN_TYPE, TestUtilsV2.NAME, "test1"); col0.setAttribute("type", "string"); - col0.setAttribute("table", tableEntity.getAtlasObjectId()); + col0.setAttribute("table", AtlasTypeUtil.getAtlasObjectId(tableEntity)); AtlasEntityWithExtInfo col0WithExtendedInfo = new AtlasEntityWithExtInfo(col0); col0WithExtendedInfo.addReferredEntity(tableEntity); @@ -332,7 +332,7 @@ public class AtlasEntityStoreV1Test { AtlasEntity col1 = new AtlasEntity(TestUtils.COLUMN_TYPE, TestUtilsV2.NAME, "test2"); col1.setAttribute("type", "string"); - col1.setAttribute("table", tableEntity.getAtlasObjectId()); + col1.setAttribute("table", AtlasTypeUtil.getAtlasObjectId(tableEntity)); AtlasEntityWithExtInfo col1WithExtendedInfo = new AtlasEntityWithExtInfo(col1); col1WithExtendedInfo.addReferredEntity(tableEntity); @@ -342,8 +342,8 @@ public class AtlasEntityStoreV1Test { entityStore.createOrUpdate(new AtlasEntityStream(col1WithExtendedInfo), false); Map columnsMap = new HashMap(); - columnsMap.put("col0", col0.getAtlasObjectId()); - columnsMap.put("col1", col1.getAtlasObjectId()); + columnsMap.put("col0", AtlasTypeUtil.getAtlasObjectId(col0)); + columnsMap.put("col1", AtlasTypeUtil.getAtlasObjectId(col1)); tableEntity.setAttribute(TestUtils.COLUMNS_MAP, columnsMap); @@ -356,8 +356,8 @@ public class AtlasEntityStoreV1Test { //Swap elements columnsMap.clear(); - columnsMap.put("col0", col1.getAtlasObjectId()); - columnsMap.put("col1", col0.getAtlasObjectId()); + columnsMap.put("col0", AtlasTypeUtil.getAtlasObjectId(col1)); + columnsMap.put("col1", AtlasTypeUtil.getAtlasObjectId(col0)); tableEntity.setAttribute(TestUtils.COLUMNS_MAP, columnsMap); init(); @@ -367,7 +367,7 @@ public class AtlasEntityStoreV1Test { //Drop the first key and change the class type as well to col0 columnsMap.clear(); - columnsMap.put("col0", col0.getAtlasObjectId()); + columnsMap.put("col0", AtlasTypeUtil.getAtlasObjectId(col0)); init(); response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false); AtlasEntityHeader tableDefinition7 = response.getFirstUpdatedEntityByTypeName(TABLE_TYPE); @@ -695,7 +695,7 @@ public class AtlasEntityStoreV1Test { tblEntity.setAttribute("name", RandomStringUtils.randomAlphanumeric(10)); tblEntity.setAttribute("type", "type"); tblEntity.setAttribute("tableType", "MANAGED"); - tblEntity.setAttribute("database", updatedDbEntity.getAtlasObjectId()); + tblEntity.setAttribute("database", AtlasTypeUtil.getAtlasObjectId(updatedDbEntity)); // create new column entity AtlasEntity col1 = TestUtilsV2.createColumnEntity(tblEntity); @@ -704,8 +704,8 @@ public class AtlasEntityStoreV1Test { col2.setAttribute(TestUtilsV2.NAME, "col2"); List columns = new ArrayList<>(); - columns.add(col1.getAtlasObjectId()); - columns.add(col2.getAtlasObjectId()); + columns.add(AtlasTypeUtil.getAtlasObjectId(col1)); + columns.add(AtlasTypeUtil.getAtlasObjectId(col2)); tblEntity.setAttribute(TestUtilsV2.COLUMNS_ATTR_NAME, columns); @@ -731,8 +731,8 @@ public class AtlasEntityStoreV1Test { col4.setAttribute("description", "description col4"); columns.clear(); - columns.add(col3.getAtlasObjectId()); - columns.add(col4.getAtlasObjectId()); + columns.add(AtlasTypeUtil.getAtlasObjectId(col3)); + columns.add(AtlasTypeUtil.getAtlasObjectId(col4)); tblEntity = new AtlasEntity(TABLE_TYPE); tblEntity.setGuid(createdTblEntity.getGuid()); @@ -774,7 +774,9 @@ public class AtlasEntityStoreV1Test { columnEntity3.setAttribute("description", "desc for col3"); entitiesInfo.addReferredEntity(columnEntity3); - tableEntity.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(columnEntity1.getAtlasObjectId(), columnEntity2.getAtlasObjectId(), columnEntity3.getAtlasObjectId())); + tableEntity.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(AtlasTypeUtil.getAtlasObjectId(columnEntity1), + AtlasTypeUtil.getAtlasObjectId(columnEntity2), + AtlasTypeUtil.getAtlasObjectId(columnEntity3))); init(); @@ -801,7 +803,9 @@ public class AtlasEntityStoreV1Test { final AtlasEntity tableEntity1 = new AtlasEntity(TABLE_TYPE); tableEntity1.setGuid(createdTblHeader.getGuid()); - tableEntity1.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(col1.getAtlasObjectId(), col2.getAtlasObjectId(), col3.getAtlasObjectId())); + tableEntity1.setAttribute(COLUMNS_ATTR_NAME, Arrays.asList(AtlasTypeUtil.getAtlasObjectId(col1), + AtlasTypeUtil.getAtlasObjectId(col2), + AtlasTypeUtil.getAtlasObjectId(col3))); AtlasEntitiesWithExtInfo tableInfo = new AtlasEntitiesWithExtInfo(tableEntity1); tableInfo.addReferredEntity(col1.getGuid(), col1); tableInfo.addReferredEntity(col2.getGuid(), col2); @@ -862,7 +866,7 @@ public class AtlasEntityStoreV1Test { case OBJECT_ID_TYPE: Assert.assertTrue(actual instanceof AtlasObjectId); String guid = ((AtlasObjectId) actual).getGuid(); - Assert.assertTrue(AtlasEntity.isAssigned(guid), "expected assigned guid. found " + guid); + Assert.assertTrue(AtlasTypeUtil.isAssignedGuid(guid), "expected assigned guid. found " + guid); break; case PRIMITIVE: http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java b/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java index 26bf496..f593d0c 100755 --- a/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java +++ b/webapp/src/main/java/org/apache/atlas/examples/QuickStartV2.java @@ -420,8 +420,8 @@ public class QuickStartV2 { entity.setAttribute("createTime", System.currentTimeMillis()); entity.setAttribute("lastAccessTime", System.currentTimeMillis()); entity.setAttribute("retention", System.currentTimeMillis()); - entity.setAttribute("db", db.getAtlasObjectId()); - entity.setAttribute("sd", sd.getAtlasObjectId()); + entity.setAttribute("db", AtlasTypeUtil.getAtlasObjectId(db)); + entity.setAttribute("sd", AtlasTypeUtil.getAtlasObjectId(sd)); entity.setAttribute("columns", AtlasTypeUtil.toObjectIds(columns)); return createInstance(entity, traitNames); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java index b90627f..f59cd9d 100755 --- a/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java +++ b/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java @@ -28,6 +28,7 @@ import org.apache.atlas.EntityAuditEvent; import org.apache.atlas.AtlasClient.EntityResult; import org.apache.atlas.model.instance.GuidMapping; import org.apache.atlas.services.MetadataService; +import org.apache.atlas.type.AtlasType; import org.apache.atlas.typesystem.IStruct; import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.typesystem.exception.EntityExistsException; @@ -201,7 +202,7 @@ public class EntityResource { } } if(mapping != null) { - response.put(AtlasClient.GUID_ASSIGNMENTS, new JSONObject(mapping.toString()).get(AtlasClient.GUID_ASSIGNMENTS)); + response.put(AtlasClient.GUID_ASSIGNMENTS, new JSONObject(AtlasType.toJson(mapping)).get(AtlasClient.GUID_ASSIGNMENTS)); } return response; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/webapp/src/main/java/org/apache/atlas/web/resources/ExportService.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/ExportService.java b/webapp/src/main/java/org/apache/atlas/web/resources/ExportService.java index 04bb4d3..bbd48bc 100644 --- a/webapp/src/main/java/org/apache/atlas/web/resources/ExportService.java +++ b/webapp/src/main/java/org/apache/atlas/web/resources/ExportService.java @@ -23,7 +23,6 @@ import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever; -import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasServiceException; @@ -32,6 +31,7 @@ import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.impexp.*; import org.apache.atlas.model.typedef.AtlasClassificationDef; import org.apache.atlas.model.typedef.AtlasEntityDef; +import org.apache.atlas.type.AtlasTypeUtil; import org.apache.commons.collections.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -133,7 +133,7 @@ public class ExportService { private void processEntity(AtlasEntity entity, ExportContext context) throws AtlasBaseException { if (LOG.isDebugEnabled()) { - LOG.debug("==> processEntity({})", entity.getAtlasObjectId()); + LOG.debug("==> processEntity({})", AtlasTypeUtil.getAtlasObjectId(entity)); } if (!context.guidsProcessed.contains(entity.getGuid())) { @@ -148,7 +148,7 @@ public class ExportService { } if (LOG.isDebugEnabled()) { - LOG.debug("<== processEntity({})", entity.getAtlasObjectId()); + LOG.debug("<== processEntity({})", AtlasTypeUtil.getAtlasObjectId(entity)); } } @@ -156,7 +156,7 @@ public class ExportService { try { if (LOG.isDebugEnabled()) { - LOG.debug("==> getConnectedEntityGuids({}): guidsToProcess {}", entity.getAtlasObjectId(), context.guidsToProcess.size()); + LOG.debug("==> getConnectedEntityGuids({}): guidsToProcess {}", AtlasTypeUtil.getAtlasObjectId(entity), context.guidsToProcess.size()); } List result = executeGremlinScriptFor(entity.getGuid()); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java index 2d48770..f2d97b3 100644 --- a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java +++ b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java @@ -18,8 +18,6 @@ package org.apache.atlas.web.rest; import com.google.inject.Inject; -import com.webcohesion.enunciate.metadata.rs.ResponseCode; -import com.webcohesion.enunciate.metadata.rs.StatusCodes; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.SearchFilter; import org.apache.atlas.model.typedef.AtlasBaseTypeDef; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java index 861e15f..7badd1e 100644 --- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java +++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java @@ -18,6 +18,7 @@ package org.apache.atlas.web.adapters; import org.apache.atlas.AtlasClient; +import org.apache.atlas.RequestContextV1; import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.RequestContext; import org.apache.atlas.TestUtilsV2; @@ -37,6 +38,7 @@ import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasTypeRegistry; +import org.apache.atlas.type.AtlasTypeUtil; import org.apache.atlas.web.rest.EntityREST; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -101,6 +103,7 @@ public class TestEntitiesREST { @AfterMethod public void cleanup() throws Exception { RequestContext.clear(); + RequestContextV1.clear(); } @AfterClass @@ -263,7 +266,7 @@ public class TestEntitiesREST { List ret = new ArrayList<>(); for (AtlasEntity entity : entities) { - ret.add(entity.getAtlasObjectId()); + ret.add(AtlasTypeUtil.getAtlasObjectId(entity)); } return ret; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java index 5e57518..0c1ffd3 100644 --- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java +++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java @@ -19,6 +19,7 @@ package org.apache.atlas.web.adapters; import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.RequestContext; +import org.apache.atlas.RequestContextV1; import org.apache.atlas.TestUtilsV2; import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasEntity; @@ -30,6 +31,7 @@ import org.apache.atlas.model.instance.EntityMutations; import org.apache.atlas.model.typedef.AtlasTypesDef; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.store.AtlasTypeDefStore; +import org.apache.atlas.type.AtlasTypeUtil; import org.apache.atlas.web.rest.EntityREST; import org.mockito.Mockito; import org.testng.Assert; @@ -73,6 +75,7 @@ public class TestEntityREST { @AfterMethod public void cleanup() throws Exception { RequestContext.clear(); + RequestContextV1.clear(); } private void createTestEntity() throws Exception { @@ -158,7 +161,7 @@ public class TestEntityREST { EntityMutationResponse response = entityREST.createOrUpdate(new AtlasEntitiesWithExtInfo(dbEntity)); String dbGuid = response.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).get(0).getGuid(); - Assert.assertTrue(AtlasEntity.isAssigned(dbGuid)); + Assert.assertTrue(AtlasTypeUtil.isAssignedGuid(dbGuid)); final String prevDBName = (String) dbEntity.getAttribute(TestUtilsV2.NAME); final String updatedDBName = prevDBName + ":updated"; @@ -189,7 +192,7 @@ public class TestEntityREST { EntityMutationResponse response = entityREST.createOrUpdate(new AtlasEntitiesWithExtInfo(dbEntity)); String dbGuid = response.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).get(0).getGuid(); - Assert.assertTrue(AtlasEntity.isAssigned(dbGuid)); + Assert.assertTrue(AtlasTypeUtil.isAssignedGuid(dbGuid)); final String prevDBName = (String) dbEntity.getAttribute(TestUtilsV2.NAME); final String updatedDBName = prevDBName + ":updated"; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java index 96e6f9b..b37dbca 100755 --- a/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/resources/EntityJerseyResourceIT.java @@ -40,6 +40,7 @@ import org.apache.atlas.notification.NotificationConsumer; import org.apache.atlas.notification.NotificationInterface; import org.apache.atlas.notification.NotificationModule; import org.apache.atlas.notification.entity.EntityNotification; +import org.apache.atlas.type.AtlasType; import org.apache.atlas.typesystem.IStruct; import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.typesystem.Struct; @@ -158,7 +159,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT { JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.CREATE_ENTITY, json); - GuidMapping guidMapping = GuidMapping.fromString(response.toString()); + GuidMapping guidMapping = AtlasType.fromJson(response.toString(), GuidMapping.class); Map guidsCreated = guidMapping.getGuidAssignments(); assertEquals(guidsCreated.size(), nTables * colsPerTable + nTables + 1); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/7303a412/webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java index 639d581..ae5cd46 100755 --- a/webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java @@ -126,7 +126,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT { AtlasEntity tableInstance = new AtlasEntity(HIVE_TABLE_TYPE_V2, "name", tableName); tableInstance.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName); - tableInstance.setAttribute("db", databaseInstance.getAtlasObjectId()); + tableInstance.setAttribute("db", AtlasTypeUtil.getAtlasObjectId(databaseInstance)); tableInstance.setAttribute("description", tableName + " table"); entities.addEntity(tableInstance); @@ -137,7 +137,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT { columnInstance.setAttribute("dataType", "String"); columnInstance.setAttribute("comment", "column " + j + " for table " + i); - columns.add(columnInstance.getAtlasObjectId()); + columns.add(AtlasTypeUtil.getAtlasObjectId(columnInstance)); entities.addReferredEntity(columnInstance); }