Search in sources :

Example 1 with EntityChangeListenerV2

use of org.apache.atlas.listener.EntityChangeListenerV2 in project atlas by apache.

the class AtlasEntityChangeNotifier method onClassificationDeletedFromEntity.

public void onClassificationDeletedFromEntity(AtlasEntity entity, List<String> deletedClassificationNames) throws AtlasBaseException {
    if (isV2EntityNotificationEnabled()) {
        doFullTextMapping(entity.getGuid());
        for (EntityChangeListenerV2 listener : entityChangeListenersV2) {
            listener.onClassificationsDeleted(entity, deletedClassificationNames);
        }
    } else {
        doFullTextMapping(entity.getGuid());
        Referenceable entityRef = toReferenceable(entity.getGuid());
        if (entityRef == null || CollectionUtils.isEmpty(deletedClassificationNames)) {
            return;
        }
        for (EntityChangeListener listener : entityChangeListeners) {
            try {
                listener.onTraitsDeleted(entityRef, deletedClassificationNames);
            } catch (AtlasException e) {
                throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e, getListenerName(listener), "TraitDelete");
            }
        }
    }
}
Also used : EntityChangeListener(org.apache.atlas.listener.EntityChangeListener) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) EntityChangeListenerV2(org.apache.atlas.listener.EntityChangeListenerV2) AtlasException(org.apache.atlas.AtlasException)

Example 2 with EntityChangeListenerV2

use of org.apache.atlas.listener.EntityChangeListenerV2 in project atlas by apache.

the class AtlasEntityChangeNotifier method onClassificationAddedToEntity.

public void onClassificationAddedToEntity(AtlasEntity entity, List<AtlasClassification> addedClassifications) throws AtlasBaseException {
    if (isV2EntityNotificationEnabled()) {
        doFullTextMapping(entity.getGuid());
        for (EntityChangeListenerV2 listener : entityChangeListenersV2) {
            listener.onClassificationsAdded(entity, addedClassifications);
        }
    } else {
        updateFullTextMapping(entity.getGuid(), addedClassifications);
        Referenceable entityRef = toReferenceable(entity.getGuid());
        List<Struct> traits = toStruct(addedClassifications);
        if (entity == null || CollectionUtils.isEmpty(traits)) {
            return;
        }
        for (EntityChangeListener listener : entityChangeListeners) {
            try {
                listener.onTraitsAdded(entityRef, traits);
            } catch (AtlasException e) {
                throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e, getListenerName(listener), "TraitAdd");
            }
        }
    }
}
Also used : EntityChangeListener(org.apache.atlas.listener.EntityChangeListener) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) EntityChangeListenerV2(org.apache.atlas.listener.EntityChangeListenerV2) AtlasException(org.apache.atlas.AtlasException) Struct(org.apache.atlas.v1.model.instance.Struct)

Example 3 with EntityChangeListenerV2

use of org.apache.atlas.listener.EntityChangeListenerV2 in project atlas by apache.

the class AtlasEntityChangeNotifier method onClassificationUpdatedToEntity.

public void onClassificationUpdatedToEntity(AtlasEntity entity, List<AtlasClassification> updatedClassifications) throws AtlasBaseException {
    if (isV2EntityNotificationEnabled()) {
        doFullTextMapping(entity.getGuid());
        for (EntityChangeListenerV2 listener : entityChangeListenersV2) {
            listener.onClassificationsUpdated(entity, updatedClassifications);
        }
    } else {
        doFullTextMapping(entity.getGuid());
        Referenceable entityRef = toReferenceable(entity.getGuid());
        List<Struct> traits = toStruct(updatedClassifications);
        if (entityRef == null || CollectionUtils.isEmpty(traits)) {
            return;
        }
        for (EntityChangeListener listener : entityChangeListeners) {
            try {
                listener.onTraitsUpdated(entityRef, traits);
            } catch (AtlasException e) {
                throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e, getListenerName(listener), "TraitUpdate");
            }
        }
    }
}
Also used : EntityChangeListener(org.apache.atlas.listener.EntityChangeListener) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) EntityChangeListenerV2(org.apache.atlas.listener.EntityChangeListenerV2) AtlasException(org.apache.atlas.AtlasException) Struct(org.apache.atlas.v1.model.instance.Struct)

Aggregations

AtlasException (org.apache.atlas.AtlasException)3 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)3 EntityChangeListener (org.apache.atlas.listener.EntityChangeListener)3 EntityChangeListenerV2 (org.apache.atlas.listener.EntityChangeListenerV2)3 Referenceable (org.apache.atlas.v1.model.instance.Referenceable)3 Struct (org.apache.atlas.v1.model.instance.Struct)2