Commit 5b406348 by Graham Wallis

ATLAS-2808: Add proxy support

ATLAS-2808: further updates Signed-off-by: 's avatarGraham Wallis <graham_wallis@uk.ibm.com>
parent 69fe4ab7
......@@ -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 =
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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 {
......
......@@ -522,6 +522,8 @@ public final class EntityGraphRetriever {
entity.setHomeId(GraphHelper.getHomeId(entityVertex));
entity.setIsProxy(GraphHelper.isProxy(entityVertex));
return entity;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment