Java Code Examples for org.apache.atlas.model.instance.AtlasEntityHeader#getClassifications()

The following examples show how to use org.apache.atlas.model.instance.AtlasEntityHeader#getClassifications() . 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: AtlasAuthorizer.java    From atlas with Apache License 2.0 6 votes vote down vote up
default
void scrubEntityHeader(AtlasEntityHeader entity) {
    entity.setGuid("-1");

    if(entity.getAttributes() != null) {
        entity.getAttributes().clear();
    }

    if(entity.getClassifications() != null) {
        entity.getClassifications().clear();
    }

    if(entity.getClassificationNames() != null) {
        entity.getClassificationNames().clear();
    }

    if(entity.getMeanings() != null) {
        entity.getMeanings().clear();
    }

    if(entity.getMeaningNames() != null) {
        entity.getMeaningNames().clear();
    }
}
 
Example 2
Source File: BulkFetchAndUpdate.java    From atlas with Apache License 2.0 6 votes vote down vote up
private void updateClassificationsForHeader(AtlasEntityHeader header, AtlasEntityHeader currentHeader, boolean keyFound) {
    for (AtlasClassification c : header.getClassifications()) {
        c.setEntityGuid(null);

        if (keyFound) {
            boolean found =
                    currentHeader.getClassifications().stream().anyMatch(ox -> ox.getTypeName().equals(c.getTypeName()));
            if (!found) {
                currentHeader.getClassifications().add(c);
            } else {
                displayCrLf("Ignoring: " + c.toString());
                LOG.warn("Ignoring: {}", AtlasJson.toJson(c));
            }
        }
    }
}
 
Example 3
Source File: AtlasEntityStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
@GraphTransaction
public List<AtlasClassification> retrieveClassifications(String guid) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Retriving classifications for entity={}", guid);
    }

    AtlasEntityHeader entityHeader = entityRetriever.toAtlasEntityHeaderWithClassifications(guid);

    return entityHeader.getClassifications();
}
 
Example 4
Source File: AtlasEntityStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
@GraphTransaction
public List<AtlasClassification> getClassifications(String guid) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Getting classifications for entity={}", guid);
    }

    AtlasEntityHeader entityHeader = entityRetriever.toAtlasEntityHeaderWithClassifications(guid);

    AtlasAuthorizationUtils.verifyAccess(new AtlasEntityAccessRequest(typeRegistry, AtlasPrivilege.ENTITY_READ, entityHeader), "get classifications: guid=", guid);

    return entityHeader.getClassifications();
}
 
Example 5
Source File: AtlasEntityStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
@GraphTransaction
public AtlasClassification getClassification(String guid, String classificationName) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Getting classifications for entities={}", guid);
    }

    AtlasClassification ret          = null;
    AtlasEntityHeader   entityHeader = entityRetriever.toAtlasEntityHeaderWithClassifications(guid);

    if (CollectionUtils.isNotEmpty(entityHeader.getClassifications())) {
        AtlasAuthorizationUtils.verifyAccess(new AtlasEntityAccessRequest(typeRegistry, AtlasPrivilege.ENTITY_READ, entityHeader), "get classification: guid=", guid, ", classification=", classificationName);

        for (AtlasClassification classification : entityHeader.getClassifications()) {
            if (!StringUtils.equalsIgnoreCase(classification.getTypeName(), classificationName)) {
                continue;
            }

            if (StringUtils.isEmpty(classification.getEntityGuid()) || StringUtils.equalsIgnoreCase(classification.getEntityGuid(), guid)) {
                ret = classification;
                break;
            } else if (ret == null) {
                ret = classification;
            }
        }
    }

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.CLASSIFICATION_NOT_FOUND, classificationName);
    }

    return ret;
}
 
Example 6
Source File: AtlasAccessRequest.java    From atlas with Apache License 2.0 5 votes vote down vote up
public Set<String> getClassificationNames(AtlasEntityHeader entity) {
    final Set<String> ret;

    if (entity == null || entity.getClassifications() == null) {
        ret = Collections.emptySet();
    } else {
        ret = new HashSet<>();

        for (AtlasClassification classify : entity.getClassifications()) {
            ret.add(classify.getTypeName());
        }
    }

    return ret;
}