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 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 Referenceable toReferenceable(AtlasObjectId id) { return StringUtils.isEmpty(id.getGuid()) ? new Referenceable(id.getTypeName(), id.getUniqueAttributes()) : new Referenceable(id.getGuid(), id.getTypeName(), id.getUniqueAttributes()); }
public AtlasEntity.AtlasEntityWithExtInfo getCreateEntity(AtlasObjectId item) throws AtlasBaseException { if(!item.getUniqueAttributes().containsKey(HDFS_PATH_ATTRIBUTE_NAME_PATH)) { return null; } return getCreateEntity((String) item.getUniqueAttributes().get(HDFS_PATH_ATTRIBUTE_NAME_PATH)); }
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 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); }
public String getQualifiedName(Object obj) { Map<String, Object> attributes = null; if (obj instanceof AtlasObjectId) { attributes = ((AtlasObjectId) obj).getUniqueAttributes(); } else if (obj instanceof Map) { attributes = (Map) ((Map) obj).get(AtlasObjectId.KEY_UNIQUE_ATTRIBUTES); } else if (obj instanceof AtlasEntity) { attributes = ((AtlasEntity) obj).getAttributes(); } else if (obj instanceof AtlasEntityWithExtInfo) { attributes = ((AtlasEntityWithExtInfo) obj).getEntity().getAttributes(); } Object ret = attributes != null ? attributes.get(ATTRIBUTE_QUALIFIED_NAME) : null; return ret != null ? ret.toString() : null; }
private void tamperEmployeeRequest(AtlasExportRequest request) { AtlasObjectId objectId = request.getItemsToExport().get(0); objectId.getUniqueAttributes().remove("name"); objectId.getUniqueAttributes().put("qualifiedName", "XXX@121"); }
private boolean isMatch(AtlasObjectId objectId, AtlasEntity entity) { if (!StringUtils.isEmpty(objectId.getGuid())) { return Objects.equals(objectId.getGuid(), entity.getGuid()); } boolean ret = Objects.equals(objectId.getTypeName(), entity.getTypeName()); if (ret) { for (Map.Entry<String, Object> entry : objectId.getUniqueAttributes().entrySet()) { ret = ret && Objects.equals(entity.getAttribute(entry.getKey()), entry.getValue()); if (!ret) { break; } } } return ret; } }
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 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; }
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; }
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; }
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; }
public static AtlasEntityHeader constructHeader(AtlasObjectId id) { return new AtlasEntityHeader(id.getTypeName(), id.getGuid(), id.getUniqueAttributes()); }
public static AtlasEntityHeader constructHeader(AtlasObjectId id) { return new AtlasEntityHeader(id.getTypeName(), id.getGuid(), id.getUniqueAttributes()); }
private Referenceable toReferenceable(AtlasObjectId id) { return StringUtils.isEmpty(id.getGuid()) ? new Referenceable(id.getTypeName(), id.getUniqueAttributes()) : new Referenceable(id.getGuid(), id.getTypeName(), id.getUniqueAttributes()); }
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 assertClusterAdditionalInfo(AtlasServer cluster, AtlasImportResult importResult) throws AtlasBaseException { AtlasExportRequest request = importResult.getExportResult().getRequest(); AtlasEntityType type = (AtlasEntityType) typeRegistry.getType(request.getItemsToExport().get(0).getTypeName()); AtlasEntity.AtlasEntityWithExtInfo entity = entityStore.getByUniqueAttributes(type, request.getItemsToExport().get(0).getUniqueAttributes()); long actualLastModifiedTimestamp = (long) cluster.getAdditionalInfoRepl(entity.getEntity().getGuid()); assertTrue(cluster.getAdditionalInfo().size() > 0); assertEquals(actualLastModifiedTimestamp, importResult.getExportResult().getChangeMarker()); }