Java Code Examples for org.apache.atlas.model.instance.AtlasEntity#setUpdatedBy()

The following examples show how to use org.apache.atlas.model.instance.AtlasEntity#setUpdatedBy() . 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 incubator-atlas with Apache License 2.0 6 votes vote down vote up
private AtlasEntity mapSystemAttributes(AtlasVertex entityVertex, AtlasEntity entity) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Mapping system attributes for type {}", entity.getTypeName());
    }

    entity.setGuid(GraphHelper.getGuid(entityVertex));
    entity.setTypeName(GraphHelper.getTypeName(entityVertex));
    entity.setStatus(GraphHelper.getStatus(entityVertex));
    entity.setVersion(GraphHelper.getVersion(entityVertex).longValue());

    entity.setCreatedBy(GraphHelper.getCreatedByAsString(entityVertex));
    entity.setUpdatedBy(GraphHelper.getModifiedByAsString(entityVertex));

    entity.setCreateTime(new Date(GraphHelper.getCreatedTime(entityVertex)));
    entity.setUpdateTime(new Date(GraphHelper.getModifiedTime(entityVertex)));

    return entity;
}
 
Example 2
Source File: EntityGraphRetriever.java    From atlas with Apache License 2.0 5 votes vote down vote up
private AtlasEntity mapSystemAttributes(AtlasVertex entityVertex, AtlasEntity entity) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Mapping system attributes for type {}", entity.getTypeName());
    }

    entity.setGuid(getGuid(entityVertex));
    entity.setTypeName(getTypeName(entityVertex));
    entity.setStatus(GraphHelper.getStatus(entityVertex));
    entity.setVersion(GraphHelper.getVersion(entityVertex));

    entity.setCreatedBy(GraphHelper.getCreatedByAsString(entityVertex));
    entity.setUpdatedBy(GraphHelper.getModifiedByAsString(entityVertex));

    entity.setCreateTime(new Date(GraphHelper.getCreatedTime(entityVertex)));
    entity.setUpdateTime(new Date(GraphHelper.getModifiedTime(entityVertex)));

    entity.setHomeId(GraphHelper.getHomeId(entityVertex));

    entity.setIsProxy(GraphHelper.isProxy(entityVertex));
    entity.setIsIncomplete(isEntityIncomplete(entityVertex));

    entity.setProvenanceType(GraphHelper.getProvenanceType(entityVertex));
    entity.setCustomAttributes(getCustomAttributes(entityVertex));
    entity.setLabels(getLabels(entityVertex));

    return entity;
}
 
Example 3
Source File: EntityAuditListenerV2.java    From atlas with Apache License 2.0 4 votes vote down vote up
private String getAuditEventDetail(AtlasEntity entity, EntityAuditActionV2 action) {
    Map<String, Object> prunedAttributes = pruneEntityAttributesForAudit(entity);

    String auditPrefix  = getV2AuditPrefix(action);
    String auditString  = auditPrefix + AtlasType.toJson(entity);
    byte[] auditBytes   = auditString.getBytes(StandardCharsets.UTF_8);
    long   auditSize    = auditBytes != null ? auditBytes.length : 0;
    long   auditMaxSize = auditRepository.repositoryMaxSize();

    if (auditMaxSize >= 0 && auditSize > auditMaxSize) { // don't store attributes in audit
        LOG.warn("audit record too long: entityType={}, guid={}, size={}; maxSize={}. entity attribute values not stored in audit",
                entity.getTypeName(), entity.getGuid(), auditSize, auditMaxSize);

        Map<String, Object> attrValues    = entity.getAttributes();
        Map<String, Object> relAttrValues = entity.getRelationshipAttributes();

        entity.setAttributes(null);
        entity.setRelationshipAttributes(null);

        auditString = auditPrefix + AtlasType.toJson(entity);
        auditBytes  = auditString.getBytes(StandardCharsets.UTF_8); // recheck auditString size
        auditSize   = auditBytes != null ? auditBytes.length : 0;

        if (auditMaxSize >= 0 && auditSize > auditMaxSize) { // don't store classifications and meanings as well
            LOG.warn("audit record still too long: entityType={}, guid={}, size={}; maxSize={}. audit will have only summary details",
                    entity.getTypeName(), entity.getGuid(), auditSize, auditMaxSize);

            AtlasEntity shallowEntity = new AtlasEntity();

            shallowEntity.setGuid(entity.getGuid());
            shallowEntity.setTypeName(entity.getTypeName());
            shallowEntity.setCreateTime(entity.getCreateTime());
            shallowEntity.setUpdateTime(entity.getUpdateTime());
            shallowEntity.setCreatedBy(entity.getCreatedBy());
            shallowEntity.setUpdatedBy(entity.getUpdatedBy());
            shallowEntity.setStatus(entity.getStatus());
            shallowEntity.setVersion(entity.getVersion());

            auditString = auditPrefix + AtlasType.toJson(shallowEntity);
        }

        entity.setAttributes(attrValues);
        entity.setRelationshipAttributes(relAttrValues);
    }

    restoreEntityAttributes(entity, prunedAttributes);

    return auditString;
}