Search in sources :

Example 1 with EntityNotificationImpl

use of org.apache.atlas.notification.entity.EntityNotificationImpl in project incubator-atlas by apache.

the class NotificationEntityChangeListener method notifyOfEntityEvent.

// send notification of entity change
private void notifyOfEntityEvent(Collection<ITypedReferenceableInstance> entityDefinitions, EntityNotification.OperationType operationType) throws AtlasException {
    List<EntityNotification> messages = new LinkedList<>();
    for (IReferenceableInstance entityDefinition : entityDefinitions) {
        Referenceable entity = new Referenceable(entityDefinition);
        Map<String, Object> attributesMap = entity.getValuesMap();
        List<String> entityNotificationAttrs = getNotificationAttributes(entity.getTypeName());
        if (MapUtils.isNotEmpty(attributesMap) && CollectionUtils.isNotEmpty(entityNotificationAttrs)) {
            for (String entityAttr : attributesMap.keySet()) {
                if (!entityNotificationAttrs.contains(entityAttr)) {
                    entity.setNull(entityAttr);
                }
            }
        }
        EntityNotificationImpl notification = new EntityNotificationImpl(entity, operationType, getAllTraits(entity, typeSystem));
        messages.add(notification);
    }
    notificationInterface.send(NotificationInterface.NotificationType.ENTITIES, messages);
}
Also used : IReferenceableInstance(org.apache.atlas.typesystem.IReferenceableInstance) EntityNotificationImpl(org.apache.atlas.notification.entity.EntityNotificationImpl) Referenceable(org.apache.atlas.typesystem.Referenceable) EntityNotification(org.apache.atlas.notification.entity.EntityNotification) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 EntityNotification (org.apache.atlas.notification.entity.EntityNotification)1 EntityNotificationImpl (org.apache.atlas.notification.entity.EntityNotificationImpl)1 IReferenceableInstance (org.apache.atlas.typesystem.IReferenceableInstance)1 Referenceable (org.apache.atlas.typesystem.Referenceable)1