final AtlasEntity.AtlasEntityWithExtInfo entityExt = searchEntityDef(id); final AtlasEntity entity = entityExt.getEntity(); if (AtlasEntity.Status.DELETED.equals(entity.getStatus())) { return null;
bindings.put("state", ACTIVE.toString());
states.remove(DELETED.toString());
Referenceable referenceable = new Referenceable(entity.getGuid(), entity.getTypeName(), status.name(), fromV2ToV1(entityType, entity.getAttributes(), context), new AtlasSystemAttributes(entity.getCreatedBy(), entity.getUpdatedBy(), entity.getCreateTime(), entity.getUpdateTime()));
put("$typeName$", entity.getTypeName()); put("version", entity.getVersion().intValue()); put("state", entity.getStatus().name()); }});
setStatus(Status.valueOf(status.toString()));
final AtlasEntity.AtlasEntityWithExtInfo entityExt = searchEntityDef(id); final AtlasEntity entity = entityExt.getEntity(); if (AtlasEntity.Status.DELETED.equals(entity.getStatus())) { return null;
public void updateSystemAttributes(AtlasVertex vertex, AtlasEntity entity) { if (entity.getStatus() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, STATE_PROPERTY_KEY, entity.getStatus().name()); } if (entity.getVersion() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, VERSION_PROPERTY_KEY, entity.getVersion()); } if (entity.getCreateTime() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, TIMESTAMP_PROPERTY_KEY, entity.getCreateTime().getTime()); } if (entity.getUpdateTime() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, entity.getUpdateTime().getTime()); } if (StringUtils.isNotEmpty(entity.getCreatedBy())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, CREATED_BY_KEY, entity.getCreatedBy()); } if (StringUtils.isNotEmpty(entity.getUpdatedBy())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, MODIFIED_BY_KEY, entity.getUpdatedBy()); } if (StringUtils.isNotEmpty(entity.getHomeId())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, HOME_ID_KEY, entity.getHomeId()); } if (entity.isProxy() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, IS_PROXY_KEY, entity.isProxy()); } if (entity.getProvenanceType() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, PROVENANCE_TYPE_KEY, entity.getProvenanceType()); } }
public void updateSystemAttributes(AtlasVertex vertex, AtlasEntity entity) { if (entity.getStatus() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, STATE_PROPERTY_KEY, entity.getStatus().name()); } if (entity.getCreateTime() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, TIMESTAMP_PROPERTY_KEY, entity.getCreateTime().getTime()); } if (entity.getUpdateTime() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, entity.getUpdateTime().getTime()); } if (StringUtils.isNotEmpty(entity.getCreatedBy())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, CREATED_BY_KEY, entity.getCreatedBy()); } if (StringUtils.isNotEmpty(entity.getUpdatedBy())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, MODIFIED_BY_KEY, entity.getUpdatedBy()); } if (StringUtils.isNotEmpty(entity.getHomeId())) { AtlasGraphUtilsV2.setEncodedProperty(vertex, HOME_ID_KEY, entity.getHomeId()); } if (entity.isProxy() != null) { AtlasGraphUtilsV2.setEncodedProperty(vertex, IS_PROXY_KEY, entity.isProxy()); } }
protected void deleteEdge(AtlasEdge edge, boolean updateInverseAttribute, boolean force) throws AtlasBaseException { //update inverse attribute if (updateInverseAttribute) { AtlasEdgeLabel atlasEdgeLabel = new AtlasEdgeLabel(edge.getLabel()); AtlasType parentType = typeRegistry.getType(atlasEdgeLabel.getTypeName()); if (parentType instanceof AtlasEntityType) { AtlasEntityType parentEntityType = (AtlasEntityType) parentType; AtlasStructType.AtlasAttribute attribute = parentEntityType.getAttribute(atlasEdgeLabel.getAttributeName()); if (attribute.getInverseRefAttribute() != null) { deleteEdgeBetweenVertices(edge.getInVertex(), edge.getOutVertex(), attribute.getInverseRefAttribute()); } } } if (isClassificationEdge(edge)) { AtlasVertex classificationVertex = edge.getInVertex(); AtlasGraphUtilsV2.setEncodedProperty(classificationVertex, CLASSIFICATION_ENTITY_STATUS, DELETED.name()); } deleteEdge(edge, force); }
@Override protected void deleteEdge(AtlasEdge edge, boolean force) { if (LOG.isDebugEnabled()) { LOG.debug("==> SoftDeleteHandlerV1.deleteEdge({}, {})",GraphHelper.string(edge), force); } if (force) { graphHelper.removeEdge(edge); } else { Status state = AtlasGraphUtilsV2.getState(edge); if (state != DELETED) { AtlasGraphUtilsV2.setEncodedProperty(edge, STATE_PROPERTY_KEY, DELETED.name()); AtlasGraphUtilsV2.setEncodedProperty(edge, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); AtlasGraphUtilsV2.setEncodedProperty(edge, MODIFIED_BY_KEY, RequestContext.get().getUser()); } } } }
public AtlasEdge addEdge(AtlasVertex fromVertex, AtlasVertex toVertex, String edgeLabel) { AtlasEdge ret; if (LOG.isDebugEnabled()) { LOG.debug("Adding edge for {} -> label {} -> {}", string(fromVertex), edgeLabel, string(toVertex)); } ret = graph.addEdge(fromVertex, toVertex, edgeLabel); if (ret != null) { AtlasGraphUtilsV2.setEncodedProperty(ret, STATE_PROPERTY_KEY, ACTIVE.name()); AtlasGraphUtilsV2.setEncodedProperty(ret, TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); AtlasGraphUtilsV2.setEncodedProperty(ret, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); AtlasGraphUtilsV2.setEncodedProperty(ret, CREATED_BY_KEY, RequestContext.get().getUser()); AtlasGraphUtilsV2.setEncodedProperty(ret, MODIFIED_BY_KEY, RequestContext.get().getUser()); if (LOG.isDebugEnabled()) { LOG.debug("Added {}", string(ret)); } } return ret; }
public AtlasVertex createVertexWithoutIdentity(String typeName, Id typedInstanceId, Set<String> superTypeNames) { if (LOG.isDebugEnabled()) { LOG.debug("Creating AtlasVertex for type {} id {}", typeName, typedInstanceId != null ? typedInstanceId._getId() : null); } final AtlasVertex ret = graph.addVertex(); AtlasGraphUtilsV2.setEncodedProperty(ret, ENTITY_TYPE_PROPERTY_KEY, typeName); AtlasGraphUtilsV2.setEncodedProperty(ret, STATE_PROPERTY_KEY, ACTIVE.name()); AtlasGraphUtilsV2.setEncodedProperty(ret, TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); AtlasGraphUtilsV2.setEncodedProperty(ret, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); AtlasGraphUtilsV2.setEncodedProperty(ret, CREATED_BY_KEY, RequestContext.get().getUser()); AtlasGraphUtilsV2.setEncodedProperty(ret, MODIFIED_BY_KEY, RequestContext.get().getUser()); for (String superTypeName : superTypeNames) { AtlasGraphUtilsV2.addEncodedProperty(ret, SUPER_TYPES_PROPERTY_KEY, superTypeName); } return ret; }
private AtlasEdge addEdge(AtlasVertex fromVertex, AtlasVertex toVertex, String edgeLabel) { if (LOG.isDebugEnabled()) { LOG.debug("Adding edge for {} -> label {} -> {}", string(fromVertex), edgeLabel, string(toVertex)); } AtlasEdge edge = graph.addEdge(fromVertex, toVertex, edgeLabel); setProperty(edge, Constants.STATE_PROPERTY_KEY, Id.EntityState.ACTIVE.name()); setProperty(edge, Constants.TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); setProperty(edge, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); setProperty(edge, Constants.CREATED_BY_KEY, RequestContext.get().getUser()); setProperty(edge, Constants.MODIFIED_BY_KEY, RequestContext.get().getUser()); if (LOG.isDebugEnabled()) { LOG.debug("Added {}", string(edge)); } return edge; }
private AtlasVertex createStructVertex(AtlasStruct struct) { if (LOG.isDebugEnabled()) { LOG.debug("==> createStructVertex({})", struct.getTypeName()); } final AtlasVertex ret = graph.addVertex(); AtlasGraphUtilsV2.setEncodedProperty(ret, ENTITY_TYPE_PROPERTY_KEY, struct.getTypeName()); AtlasGraphUtilsV2.setEncodedProperty(ret, STATE_PROPERTY_KEY, AtlasEntity.Status.ACTIVE.name()); AtlasGraphUtilsV2.setEncodedProperty(ret, TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); AtlasGraphUtilsV2.setEncodedProperty(ret, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); AtlasGraphUtilsV2.setEncodedProperty(ret, CREATED_BY_KEY, RequestContext.get().getUser()); AtlasGraphUtilsV2.setEncodedProperty(ret, MODIFIED_BY_KEY, RequestContext.get().getUser()); if (LOG.isDebugEnabled()) { LOG.debug("<== createStructVertex({})", struct.getTypeName()); } return ret; }
private AtlasVertex createStructVertex(AtlasStruct struct) { if (LOG.isDebugEnabled()) { LOG.debug("==> createStructVertex({})", struct.getTypeName()); } final AtlasVertex ret = graph.addVertex(); AtlasGraphUtilsV2.setEncodedProperty(ret, ENTITY_TYPE_PROPERTY_KEY, struct.getTypeName()); AtlasGraphUtilsV2.setEncodedProperty(ret, STATE_PROPERTY_KEY, AtlasEntity.Status.ACTIVE.name()); AtlasGraphUtilsV2.setEncodedProperty(ret, TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); AtlasGraphUtilsV2.setEncodedProperty(ret, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); AtlasGraphUtilsV2.setEncodedProperty(ret, CREATED_BY_KEY, RequestContext.get().getUser()); AtlasGraphUtilsV2.setEncodedProperty(ret, MODIFIED_BY_KEY, RequestContext.get().getUser()); if (LOG.isDebugEnabled()) { LOG.debug("<== createStructVertex({})", struct.getTypeName()); } return ret; }
@Override protected void _deleteVertex(AtlasVertex instanceVertex, boolean force) { if (LOG.isDebugEnabled()) { LOG.debug("==> SoftDeleteHandlerV1._deleteVertex({}, {})", GraphHelper.string(instanceVertex), force); } if (force) { graphHelper.removeVertex(instanceVertex); } else { Status state = AtlasGraphUtilsV2.getState(instanceVertex); if (state != DELETED) { AtlasGraphUtilsV2.setEncodedProperty(instanceVertex, STATE_PROPERTY_KEY, DELETED.name()); AtlasGraphUtilsV2.setEncodedProperty(instanceVertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime()); AtlasGraphUtilsV2.setEncodedProperty(instanceVertex, MODIFIED_BY_KEY, RequestContext.get().getUser()); } } }
@Override protected void deleteEdge(AtlasEdge edge, boolean force) throws AtlasBaseException { if (force) { graphHelper.removeEdge(edge); } else { AtlasEntity.Status state = AtlasGraphUtilsV1.getState(edge); if (state != AtlasEntity.Status.DELETED) { GraphHelper.setProperty(edge, STATE_PROPERTY_KEY, AtlasEntity.Status.DELETED.name()); GraphHelper .setProperty(edge, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); GraphHelper.setProperty(edge, MODIFIED_BY_KEY, RequestContextV1.get().getUser()); } } } }
@Override protected void _deleteVertex(AtlasVertex instanceVertex, boolean force) { if (force) { graphHelper.removeVertex(instanceVertex); } else { AtlasEntity.Status state = AtlasGraphUtilsV1.getState(instanceVertex); if (state != AtlasEntity.Status.DELETED) { GraphHelper.setProperty(instanceVertex, STATE_PROPERTY_KEY, AtlasEntity.Status.DELETED.name()); GraphHelper.setProperty(instanceVertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime()); GraphHelper.setProperty(instanceVertex, MODIFIED_BY_KEY, RequestContextV1.get().getUser()); } } }