Repository: atlas Updated Branches: refs/heads/master 69fe4ab73 -> 5b406348c
ATLAS-2808: Add proxy support ATLAS-2808: further updates Signed-off-by: Graham Wallis <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/5b406348 Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/5b406348 Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/5b406348 Branch: refs/heads/master Commit: 5b406348cb51a871fdf388f676c68102f647afac Parents: 69fe4ab Author: Graham Wallis <[email protected]> Authored: Thu Aug 16 14:50:17 2018 +0100 Committer: Graham Wallis <[email protected]> Committed: Fri Aug 17 16:45:54 2018 +0100 ---------------------------------------------------------------------- .../org/apache/atlas/repository/Constants.java | 8 ++++ .../atlas/model/instance/AtlasEntity.java | 40 +++++++++++++++----- .../atlas/repository/graph/GraphHelper.java | 4 ++ .../store/graph/v2/EntityGraphMapper.java | 6 ++- .../store/graph/v2/EntityGraphRetriever.java | 2 + 5 files changed, 50 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/atlas/blob/5b406348/common/src/main/java/org/apache/atlas/repository/Constants.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/atlas/repository/Constants.java b/common/src/main/java/org/apache/atlas/repository/Constants.java index a892551..e4772d1 100644 --- a/common/src/main/java/org/apache/atlas/repository/Constants.java +++ b/common/src/main/java/org/apache/atlas/repository/Constants.java @@ -93,6 +93,14 @@ public final class Constants { */ public static final String HOME_ID_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "homeId"; + /** + * The isProxy field is used when saving into Atlas a proxy of an entity - i.e. it is not a whole entity, but + * a partial representation of an entity that is referred to by a relationship end. + * The isProxy field will be set to true if the entity is a proxy. The field is used during retrieval of an + * entity (proxy) from Atlas to indicate that the entity does not contain full entity detail. + */ + public static final String IS_PROXY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "isProxy"; + public static final String TIMESTAMP_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "timestamp"; public static final String MODIFICATION_TIMESTAMP_PROPERTY_KEY = http://git-wip-us.apache.org/repos/asf/atlas/blob/5b406348/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 dc2be41..066b0d0 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 @@ -61,6 +61,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable { public static final String KEY_GUID = "guid"; public static final String KEY_HOME_ID = "homeId"; + public static final String KEY_IS_PROXY = "isProxy"; public static final String KEY_STATUS = "status"; public static final String KEY_CREATED_BY = "createdBy"; public static final String KEY_UPDATED_BY = "updatedBy"; @@ -73,14 +74,15 @@ public class AtlasEntity extends AtlasStruct implements Serializable { */ public enum Status { ACTIVE, DELETED } - private String guid = null; - private String homeId = null; - private Status status = Status.ACTIVE; - private String createdBy = null; - private String updatedBy = null; - private Date createTime = null; - private Date updateTime = null; - private Long version = 0L; + private String guid = null; + private String homeId = null; + private Boolean isProxy = Boolean.FALSE; + private Status status = Status.ACTIVE; + private String createdBy = null; + private String updatedBy = null; + private Date createTime = null; + private Date updateTime = null; + private Long version = 0L; private Map<String, Object> relationshipAttributes; private List<AtlasClassification> classifications; @@ -119,6 +121,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable { if (map != null) { Object oGuid = map.get(KEY_GUID); Object homeId = map.get(KEY_HOME_ID); + Object isProxy = map.get(KEY_IS_PROXY); Object status = map.get(KEY_STATUS); Object createdBy = map.get(KEY_CREATED_BY); Object updatedBy = map.get(KEY_UPDATED_BY); @@ -134,6 +137,13 @@ public class AtlasEntity extends AtlasStruct implements Serializable { setHomeId(homeId.toString()); } + if (isProxy != null) { + setIsProxy((Boolean)isProxy); + } + else { + setIsProxy(Boolean.FALSE); + } + if (status != null) { setStatus(Status.valueOf(status.toString())); } @@ -166,6 +176,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable { if (other != null) { setGuid(other.getGuid()); setHomeId(other.getHomeId()); + setIsProxy(other.isProxy()); setStatus(other.getStatus()); setCreatedBy(other.getCreatedBy()); setUpdatedBy(other.getUpdatedBy()); @@ -192,6 +203,14 @@ public class AtlasEntity extends AtlasStruct implements Serializable { this.homeId = homeId; } + public Boolean isProxy() { + return isProxy; + } + + public void setIsProxy(Boolean isProxy) { + this.isProxy = isProxy; + } + public Status getStatus() { return status; } @@ -308,6 +327,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable { private void init() { setGuid(nextInternalId()); setHomeId(null); + setIsProxy(Boolean.FALSE); setStatus(null); setCreatedBy(null); setUpdatedBy(null); @@ -331,6 +351,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable { super.toString(sb); sb.append("guid='").append(guid).append('\''); sb.append(", homeId='").append(homeId).append('\''); + sb.append(", isProxy='").append(isProxy).append('\''); sb.append(", status=").append(status); sb.append(", createdBy='").append(createdBy).append('\''); sb.append(", updatedBy='").append(updatedBy).append('\''); @@ -360,6 +381,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable { AtlasEntity that = (AtlasEntity) o; return Objects.equals(guid, that.guid) && Objects.equals(homeId, that.homeId) && + Objects.equals(isProxy, that.isProxy) && status == that.status && Objects.equals(createdBy, that.createdBy) && Objects.equals(updatedBy, that.updatedBy) && @@ -372,7 +394,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable { @Override public int hashCode() { - return Objects.hash(super.hashCode(), guid, homeId, status, createdBy, updatedBy, createTime, updateTime, version, + return Objects.hash(super.hashCode(), guid, homeId, isProxy, status, createdBy, updatedBy, createTime, updateTime, version, relationshipAttributes, classifications); } http://git-wip-us.apache.org/repos/asf/atlas/blob/5b406348/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java index 9c4b9f2..78ed74d 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java @@ -1185,6 +1185,10 @@ public final class GraphHelper { return element.getProperty(Constants.HOME_ID_KEY, String.class); } + public static Boolean isProxy(AtlasElement element) { + return element.getProperty(Constants.IS_PROXY_KEY, Boolean.class); + } + public static String getTypeName(AtlasElement element) { return element.getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY, String.class); } http://git-wip-us.apache.org/repos/asf/atlas/blob/5b406348/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java index 386ebb6..7eb3214 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java @@ -91,7 +91,7 @@ public class EntityGraphMapper { private final GraphHelper graphHelper = GraphHelper.getInstance(); private final AtlasGraph graph; - private final DeleteHandlerV1 deleteHandler; + private final DeleteHandlerV1 deleteHandler; private final AtlasTypeRegistry typeRegistry; private final AtlasRelationshipStore relationshipStore; private final AtlasEntityChangeNotifier entityChangeNotifier; @@ -159,6 +159,10 @@ public class EntityGraphMapper { if (StringUtils.isNotEmpty(entity.getHomeId())) { AtlasGraphUtilsV2.setProperty(vertex, Constants.HOME_ID_KEY, entity.getHomeId()); } + + if (entity.isProxy() != null) { + AtlasGraphUtilsV2.setProperty(vertex, Constants.IS_PROXY_KEY, entity.isProxy()); + } } public EntityMutationResponse mapAttributesAndClassifications(EntityMutationContext context, final boolean isPartialUpdate, final boolean replaceClassifications) throws AtlasBaseException { http://git-wip-us.apache.org/repos/asf/atlas/blob/5b406348/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java index 52c3745..8a25689 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java @@ -522,6 +522,8 @@ public final class EntityGraphRetriever { entity.setHomeId(GraphHelper.getHomeId(entityVertex)); + entity.setIsProxy(GraphHelper.isProxy(entityVertex)); + return entity; }
