Java Code Examples for org.apache.atlas.model.instance.AtlasObjectId#toString()

The following examples show how to use org.apache.atlas.model.instance.AtlasObjectId#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityGraphRetriever.java    From atlas with Apache License 2.0 6 votes vote down vote up
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(this.graph, objId.getGuid());
    } else {
        AtlasEntityType     entityType     = typeRegistry.getEntityTypeByName(objId.getTypeName());
        Map<String, Object> uniqAttributes = objId.getUniqueAttributes();

        ret = AtlasGraphUtilsV2.getVertexByUniqueAttributes(this.graph, entityType, uniqAttributes);
    }

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, objId.toString());
    }

    return ret;
}
 
Example 2
Source File: EntityGraphRetriever.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
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 = AtlasGraphUtilsV1.findByGuid(objId.getGuid());
    } else {
        AtlasEntityType     entityType     = typeRegistry.getEntityTypeByName(objId.getTypeName());
        Map<String, Object> uniqAttributes = objId.getUniqueAttributes();

        ret = AtlasGraphUtilsV1.getVertexByUniqueAttributes(entityType, uniqAttributes);
    }

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, objId.toString());
    }

    return ret;
}
 
Example 3
Source File: UniqAttrBasedEntityResolver.java    From atlas with Apache License 2.0 5 votes vote down vote up
@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(this.graph, entityType, objId.getUniqueAttributes());

        if (vertex == null && RequestContext.get().isCreateShellEntityForNonExistingReference()) {
            vertex = entityGraphMapper.createShellEntityVertex(objId, context);
        }

        if (vertex != null) {
            context.addResolvedIdByUniqAttribs(objId, vertex);
            resolvedReferences.add(objId);
        } else {
            throw new AtlasBaseException(AtlasErrorCode.REFERENCED_ENTITY_NOT_FOUND, objId.toString());
        }
    }

    return context;
}
 
Example 4
Source File: UniqAttrBasedEntityResolver.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@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 = AtlasGraphUtilsV1.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;
}