private Referenceable toReferenceable(AtlasObjectId id) { return StringUtils.isEmpty(id.getGuid()) ? new Referenceable(id.getTypeName(), id.getUniqueAttributes()) : new Referenceable(id.getGuid(), id.getTypeName(), id.getUniqueAttributes()); }
private AtlasObjectId createAtlasObjectId() { return new AtlasObjectId(atlasGuid, TYPE_NIFI_FLOW, Collections.singletonMap(ATTR_QUALIFIED_NAME, getQualifiedName())); }
private EntityChangeType getFlowPathIOChangeType(AtlasObjectId id) { final String guid = id.getGuid(); if (!isGuidAssigned(guid)) { return EntityChangeType.CREATED; } else { if (TYPE_NIFI_QUEUE.equals(id.getTypeName()) && queues.containsKey(id)) { // If an input/output is a queue, and it is owned by this NiFiFlow, then check if it's still needed. NiFiFlow knows active queues. if (stillExistingEntityGuids.contains(guid)) { return EntityChangeType.AS_IS; } else { return EntityChangeType.DELETED; } } else { // Otherwise, do not need to delete. return EntityChangeType.AS_IS; } } }
return new Tuple<>(new AtlasObjectId(id.getGuid(), id.getTypeName(), uniqueAttrs), entity); } catch (AtlasServiceException e) { logger.warn("Failed to search entity by id {}, due to {}", id, e);
public AtlasVertex getResolvedEntityVertex(AtlasObjectId objId) { AtlasVertex vertex = resolvedIdsByUniqAttribs.get(objId); // check also for sub-types; ref={typeName=Asset; guid=abcd} should match {typeName=hive_table; guid=abcd} if (vertex == null) { final AtlasEntityType entityType = typeRegistry.getEntityTypeByName(objId.getTypeName()); final Set<String> allSubTypes = entityType.getAllSubTypes(); for (String subType : allSubTypes) { AtlasObjectId subTypeObjId = new AtlasObjectId(objId.getGuid(), subType, objId.getUniqueAttributes()); vertex = resolvedIdsByUniqAttribs.get(subTypeObjId); if (vertex != null) { resolvedIdsByUniqAttribs.put(objId, vertex); break; } } } return vertex; }
public AtlasObjectId(AtlasObjectId other) { if (other != null) { setGuid(other.getGuid()); setTypeName(other.getTypeName()); setUniqueAttributes(other.getUniqueAttributes()); } }
private AtlasVertex getEntityVertex(AtlasObjectId objId) throws AtlasBaseException { AtlasVertex ret = null; if (! AtlasTypeUtil.isValid(objId)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, objId.toString()); } if (AtlasTypeUtil.isAssignedGuid(objId)) { ret = AtlasGraphUtilsV2.findByGuid(objId.getGuid()); } else { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(objId.getTypeName()); Map<String, Object> uniqAttributes = objId.getUniqueAttributes(); ret = AtlasGraphUtilsV2.getVertexByUniqueAttributes(entityType, uniqAttributes); } if (ret == null) { throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, objId.toString()); } return ret; }
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; }
@Override public EntityGraphDiscoveryContext resolveEntityReferences(EntityGraphDiscoveryContext context) throws AtlasBaseException { if (context == null) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "UniqAttrBasedEntityResolver.resolveEntityReferences(): context is null"); } //Resolve attribute references List<AtlasObjectId> resolvedReferences = new ArrayList<>(); for (AtlasObjectId objId : context.getReferencedByUniqAttribs()) { //query in graph repo that given unique attribute - check for deleted also? AtlasEntityType entityType = typeRegistry.getEntityTypeByName(objId.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), objId.getTypeName()); } AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(entityType, objId.getUniqueAttributes()); if (vertex != null) { context.addResolvedIdByUniqAttribs(objId, vertex); resolvedReferences.add(objId); } else { throw new AtlasBaseException(AtlasErrorCode.REFERENCED_ENTITY_NOT_FOUND, objId.toString()); } } return context; } }
private void renameColumns(List<AtlasObjectId> columns, AtlasEntityExtInfo oldEntityExtInfo, String newTableQualifiedName, List<HookNotification> notifications) { if (CollectionUtils.isNotEmpty(columns)) { for (AtlasObjectId columnId : columns) { AtlasEntity oldColumn = oldEntityExtInfo.getEntity(columnId.getGuid()); AtlasObjectId oldColumnId = new AtlasObjectId(oldColumn.getTypeName(), ATTRIBUTE_QUALIFIED_NAME, oldColumn.getAttribute(ATTRIBUTE_QUALIFIED_NAME)); AtlasEntity newColumn = new AtlasEntity(oldColumn.getTypeName(), ATTRIBUTE_QUALIFIED_NAME, getColumnQualifiedName(newTableQualifiedName, (String) oldColumn.getAttribute(ATTRIBUTE_NAME))); notifications.add(new EntityPartialUpdateRequestV2(getUserName(), oldColumnId, new AtlasEntityWithExtInfo(newColumn))); } } }
public static Optional<AtlasObjectId> findIdByQualifiedName(Set<AtlasObjectId> ids, String qualifiedName) { return ids.stream().filter(id -> qualifiedName.equals(id.getUniqueAttributes().get(ATTR_QUALIFIED_NAME))).findFirst(); }
public String getTypeName() { return entity.getTypeName(); }
private void visitReference(AtlasObjectIdType type, Object val) throws AtlasBaseException { if (type == null || val == null) { return; } if (val instanceof AtlasObjectId) { AtlasObjectId objId = (AtlasObjectId)val; if (!AtlasTypeUtil.isValid(objId)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, objId.toString()); } recordObjectReference(objId); } else if (val instanceof Map) { AtlasObjectId objId = new AtlasObjectId((Map)val); if (!AtlasTypeUtil.isValid(objId)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, objId.toString()); } recordObjectReference(objId); } else { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, val.toString()); } }
public AtlasObjectId(String guid, String typeName, Map<String, Object> uniqueAttributes) { setGuid(guid); setTypeName(typeName); setUniqueAttributes(uniqueAttributes); }
private AtlasObjectId getAtlasObjectId(AtlasEntity entity) { AtlasObjectId ret = entityRetriever.toAtlasObjectId(entity); if (ret != null && MapUtils.isNotEmpty(ret.getUniqueAttributes())) { // if uniqueAttributes is not empty, reset guid to null. ret.setGuid(null); } return ret; }
dbObjectId.setGuid(db1.getGuid()); tblEntity.addReferredEntity(dbEntity.getEntity());
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } AtlasRelatedObjectId that = (AtlasRelatedObjectId) o; return Objects.equals(entityStatus, that.entityStatus) && Objects.equals(displayText, that.displayText) && Objects.equals(relationshipGuid, that.relationshipGuid) && Objects.equals(relationshipStatus, that.relationshipStatus) && Objects.equals(relationshipAttributes, that.relationshipAttributes); }
@Override public String toString() { return toString(new StringBuilder()).toString(); }
public AtlasVertex getResolvedEntityVertex(AtlasObjectId objId) { AtlasVertex vertex = resolvedIdsByUniqAttribs.get(objId); // check also for sub-types; ref={typeName=Asset; guid=abcd} should match {typeName=hive_table; guid=abcd} if (vertex == null) { final AtlasEntityType entityType = typeRegistry.getEntityTypeByName(objId.getTypeName()); final Set<String> allSubTypes = entityType.getAllSubTypes(); for (String subType : allSubTypes) { AtlasObjectId subTypeObjId = new AtlasObjectId(objId.getGuid(), subType, objId.getUniqueAttributes()); vertex = resolvedIdsByUniqAttribs.get(subTypeObjId); if (vertex != null) { resolvedIdsByUniqAttribs.put(objId, vertex); break; } } } return vertex; }