Search in sources :

Example 11 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class EntityAuditListener method onTraitsUpdated.

@Override
public void onTraitsUpdated(Referenceable entity, Collection<? extends Struct> traits) throws AtlasException {
    if (traits != null) {
        for (Struct trait : traits) {
            EntityAuditEvent event = createEvent(entity, EntityAuditAction.TAG_UPDATE, "Updated trait: " + AtlasType.toV1Json(trait));
            auditRepository.putEventsV1(event);
        }
    }
}
Also used : EntityAuditEvent(org.apache.atlas.EntityAuditEvent) Struct(org.apache.atlas.v1.model.instance.Struct)

Example 12 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class EntityAuditListener method pruneAttributes.

private Map<String, Object> pruneAttributes(Map<String, Object> ret, Referenceable attribute) throws AtlasException {
    Referenceable attrInstance = attribute;
    Map<String, Object> prunedAttrs = pruneEntityAttributesForAudit(attrInstance);
    if (MapUtils.isNotEmpty(prunedAttrs)) {
        if (ret == null) {
            ret = new HashMap<>();
        }
        ret.put(attrInstance.getId()._getId(), prunedAttrs);
    }
    return ret;
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable)

Example 13 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class EntityAuditListener method onTraitsAdded.

@Override
public void onTraitsAdded(Referenceable entity, Collection<? extends Struct> traits) throws AtlasException {
    if (traits != null) {
        for (Struct trait : traits) {
            EntityAuditEvent event = createEvent(entity, EntityAuditAction.TAG_ADD, "Added trait: " + AtlasType.toV1Json(trait));
            auditRepository.putEventsV1(event);
        }
    }
}
Also used : EntityAuditEvent(org.apache.atlas.EntityAuditEvent) Struct(org.apache.atlas.v1.model.instance.Struct)

Example 14 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class EntityAuditListener method onEntitiesAdded.

@Override
public void onEntitiesAdded(Collection<Referenceable> entities, boolean isImport) throws AtlasException {
    List<EntityAuditEvent> events = new ArrayList<>();
    for (Referenceable entity : entities) {
        EntityAuditEvent event = createEvent(entity, isImport ? EntityAuditAction.ENTITY_IMPORT_CREATE : EntityAuditAction.ENTITY_CREATE);
        events.add(event);
    }
    auditRepository.putEventsV1(events);
}
Also used : EntityAuditEvent(org.apache.atlas.EntityAuditEvent) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) ArrayList(java.util.ArrayList)

Example 15 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class EntityAuditListener method onEntitiesDeleted.

@Override
public void onEntitiesDeleted(Collection<Referenceable> entities, boolean isImport) throws AtlasException {
    List<EntityAuditEvent> events = new ArrayList<>();
    for (Referenceable entity : entities) {
        EntityAuditEvent event = createEvent(entity, isImport ? EntityAuditAction.ENTITY_IMPORT_DELETE : EntityAuditAction.ENTITY_DELETE, "Deleted entity");
        events.add(event);
    }
    auditRepository.putEventsV1(events);
}
Also used : EntityAuditEvent(org.apache.atlas.EntityAuditEvent) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) ArrayList(java.util.ArrayList)

Aggregations

Referenceable (org.apache.atlas.v1.model.instance.Referenceable)143 Test (org.testng.annotations.Test)64 Id (org.apache.atlas.v1.model.instance.Id)37 Struct (org.apache.atlas.v1.model.instance.Struct)23 ArrayList (java.util.ArrayList)20 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)15 HashMap (java.util.HashMap)12 List (java.util.List)10 AtlasException (org.apache.atlas.AtlasException)10 HookNotification (org.apache.atlas.model.notification.HookNotification)10 Map (java.util.Map)9 EntityUpdateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest)9 AtlasServiceException (org.apache.atlas.AtlasServiceException)8 EntityAuditEvent (org.apache.atlas.EntityAuditEvent)8 EntityNotificationV1 (org.apache.atlas.v1.model.notification.EntityNotificationV1)7 EntityCreateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest)7 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)6 EntityResult (org.apache.atlas.model.legacy.EntityResult)6 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)6 EntityNotificationTest (org.apache.atlas.notification.entity.EntityNotificationTest)5