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; } } }
private Referenceable toReferenceable(AtlasObjectId id) { return StringUtils.isEmpty(id.getGuid()) ? new Referenceable(id.getTypeName(), id.getUniqueAttributes()) : new Referenceable(id.getGuid(), id.getTypeName(), id.getUniqueAttributes()); }
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);
boolean isAssignableFrom(AtlasObjectId objId) { boolean ret = AtlasTypeUtil.isValid(objId) && (StringUtils.equals(objId.getTypeName(), getTypeName()) || isSuperTypeOf(objId.getTypeName())); return ret; } }
boolean isAssignableFrom(AtlasObjectId objId) { boolean ret = AtlasTypeUtil.isValid(objId) && (StringUtils.equals(objId.getTypeName(), getTypeName()) || isSuperTypeOf(objId.getTypeName())); 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; }
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 getTypeName(Object obj) { Object ret = null; if (obj instanceof AtlasObjectId) { ret = ((AtlasObjectId) obj).getTypeName(); } else if (obj instanceof Map) { ret = ((Map) obj).get(AtlasObjectId.KEY_TYPENAME); } else if (obj instanceof AtlasEntity) { ret = ((AtlasEntity) obj).getTypeName(); } else if (obj instanceof AtlasEntityWithExtInfo) { ret = ((AtlasEntityWithExtInfo) obj).getEntity().getTypeName(); } return ret != null ? ret.toString() : null; }
/** * Validate the fields in the the RelationshipType are consistent with respect to themselves. * @param relationship * @throws AtlasBaseException */ private boolean validateRelationship(AtlasRelationship relationship) { String end1TypeName = relationship.getEnd1() != null ? relationship.getEnd1().getTypeName() : null; String end2TypeName = relationship.getEnd2() != null ? relationship.getEnd2().getTypeName() : null; if (StringUtils.isNotEmpty(end1TypeName) && StringUtils.isNotEmpty(end2TypeName)) { return end1Type.isTypeOrSuperTypeOf(end1TypeName) && end2Type.isTypeOrSuperTypeOf(end2TypeName) && super.isValidValue(relationship); } return false; }
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; }
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 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 Referenceable toReferenceable(AtlasObjectId id) { return StringUtils.isEmpty(id.getGuid()) ? new Referenceable(id.getTypeName(), id.getUniqueAttributes()) : new Referenceable(id.getGuid(), id.getTypeName(), id.getUniqueAttributes()); }
private String mapSoftRefValue(AttributeMutationContext ctx, EntityMutationContext context) { String ret = null; if (ctx.getValue() instanceof AtlasObjectId) { AtlasObjectId objectId = (AtlasObjectId) ctx.getValue(); String typeName = objectId.getTypeName(); String guid = AtlasTypeUtil.isUnAssignedGuid(objectId.getGuid()) ? context.getGuidAssignments().get(objectId.getGuid()) : objectId.getGuid(); ret = AtlasEntityUtil.formatSoftRefValue(typeName, guid); } else { if (ctx.getValue() != null) { LOG.warn("mapSoftRefValue: Was expecting AtlasObjectId, but found: {}", ctx.getValue().getClass()); } } return ret; }
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()); }