public AtlasEntity.AtlasEntityWithExtInfo searchEntityDef(AtlasObjectId id) throws AtlasServiceException { final String guid = id.getGuid(); if (!StringUtils.isEmpty(guid)) { return atlasClient.getEntityByGuid(guid); } final Map<String, String> attributes = new HashMap<>(); id.getUniqueAttributes().entrySet().stream().filter(entry -> entry.getValue() != null) .forEach(entry -> attributes.put(entry.getKey(), entry.getValue().toString())); return atlasClient.getEntityByAttribute(id.getTypeName(), attributes); }
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);
private static String getGuid(Object val) throws AtlasBaseException { if (val != null) { if ( val instanceof AtlasObjectId) { return ((AtlasObjectId) val).getGuid(); } else if (val instanceof Map) { Object guidVal = ((Map)val).get(AtlasObjectId.KEY_GUID); return guidVal != null ? guidVal.toString() : null; } } return null; }
private List<String> getColumnIds(AtlasEntity entity) { List<String> ret = new ArrayList<>(); Object columnObjs = entity.getAttribute(COLUMNS); if (columnObjs instanceof List) { for (Object pkObj : (List) columnObjs) { if (pkObj instanceof AtlasObjectId) { ret.add(((AtlasObjectId) pkObj).getGuid()); } } } return ret; }
private String getTypeNameFromObjectId(AtlasObjectId objectId) { String typeName = objectId.getTypeName(); if (StringUtils.isBlank(typeName)) { typeName = AtlasGraphUtilsV2.getTypeNameFromGuid(objectId.getGuid()); } return typeName; }
private String getTypeNameFromObjectId(AtlasObjectId objectId) { String typeName = objectId.getTypeName(); if (StringUtils.isBlank(typeName)) { typeName = AtlasGraphUtilsV2.getTypeNameFromGuid(objectId.getGuid()); } return typeName; }
private AtlasVertex getVertexFromEndPoint(AtlasObjectId endPoint) { AtlasVertex ret = null; if (StringUtils.isNotEmpty(endPoint.getGuid())) { ret = AtlasGraphUtilsV2.findByGuid(endPoint.getGuid()); } else if (StringUtils.isNotEmpty(endPoint.getTypeName()) && MapUtils.isNotEmpty(endPoint.getUniqueAttributes())) { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(endPoint.getTypeName()); ret = AtlasGraphUtilsV2.findByUniqueAttributes(entityType, endPoint.getUniqueAttributes()); } return ret; }
private void recordObjectReference(AtlasObjectId objId) { if (AtlasTypeUtil.isValidGuid(objId)) { discoveryContext.addReferencedGuid(objId.getGuid()); } else { discoveryContext.addReferencedByUniqAttribs(objId); } } }
private AtlasVertex getVertexFromEndPoint(AtlasObjectId endPoint) { AtlasVertex ret = null; if (StringUtils.isNotEmpty(endPoint.getGuid())) { ret = AtlasGraphUtilsV2.findByGuid(endPoint.getGuid()); } else if (StringUtils.isNotEmpty(endPoint.getTypeName()) && MapUtils.isNotEmpty(endPoint.getUniqueAttributes())) { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(endPoint.getTypeName()); ret = AtlasGraphUtilsV2.findByUniqueAttributes(entityType, endPoint.getUniqueAttributes()); } return ret; }
protected void verifyReferenceValue(AtlasEntity entity, String refName, String expectedGuid) { Object refValue = entity.getAttribute(refName); if (expectedGuid == null) { assertNull(refValue); } else { assertTrue(refValue instanceof AtlasObjectId); AtlasObjectId referencedObjectId = (AtlasObjectId) refValue; assertEquals(referencedObjectId.getGuid(), expectedGuid); } }
protected void verifyReferenceValue(AtlasEntity entity, String refName, String expectedGuid) { Object refValue = entity.getAttribute(refName); if (expectedGuid == null) { assertNull(refValue); } else { assertTrue(refValue instanceof AtlasObjectId); AtlasObjectId referencedObjectId = (AtlasObjectId) refValue; assertEquals(referencedObjectId.getGuid(), expectedGuid); } }
private void recordObjectReference(AtlasObjectId objId) { if (AtlasTypeUtil.isValidGuid(objId)) { discoveryContext.addReferencedGuid(objId.getGuid()); } else { discoveryContext.addReferencedByUniqAttribs(objId); } } }
protected static void verifyRelationshipAttributeValue(AtlasEntity entity, String relationshipAttrName, String expectedGuid) { Object refValue = entity.getRelationshipAttribute(relationshipAttrName); if (expectedGuid == null) { assertNull(refValue); } else { assertTrue(refValue instanceof AtlasObjectId); AtlasObjectId referencedObjectId = (AtlasObjectId) refValue; assertEquals(referencedObjectId.getGuid(), expectedGuid); } } }
public AtlasObjectId(AtlasObjectId other) { if (other != null) { setGuid(other.getGuid()); setTypeName(other.getTypeName()); setUniqueAttributes(other.getUniqueAttributes()); } }
public AtlasObjectId(AtlasObjectId other) { if (other != null) { setGuid(other.getGuid()); setTypeName(other.getTypeName()); setUniqueAttributes(other.getUniqueAttributes()); } }
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))); } } }