Search in sources :

Example 6 with EventDefinitionEntity

use of org.graylog.events.contentpack.entities.EventDefinitionEntity in project graylog2-server by Graylog2.

the class EventDefinitionFacade method decode.

private NativeEntity<EventDefinitionDto> decode(EntityV1 entity, Map<String, ValueReference> parameters, Map<EntityDescriptor, Object> nativeEntities, User user) {
    final EventDefinitionEntity eventDefinitionEntity = objectMapper.convertValue(entity.data(), EventDefinitionEntity.class);
    final EventDefinitionDto eventDefinition = eventDefinitionEntity.toNativeEntity(parameters, nativeEntities);
    final EventDefinitionDto savedDto;
    if (eventDefinitionEntity.isScheduled().asBoolean(parameters)) {
        savedDto = eventDefinitionHandler.create(eventDefinition, Optional.ofNullable(user));
    } else {
        savedDto = eventDefinitionHandler.createWithoutSchedule(eventDefinition, Optional.ofNullable(user));
    }
    return NativeEntity.create(entity.id(), savedDto.id(), ModelTypes.EVENT_DEFINITION_V1, savedDto.title(), savedDto);
}
Also used : EventDefinitionDto(org.graylog.events.processor.EventDefinitionDto) EventDefinitionEntity(org.graylog.events.contentpack.entities.EventDefinitionEntity)

Aggregations

EventDefinitionEntity (org.graylog.events.contentpack.entities.EventDefinitionEntity)6 AggregationEventProcessorConfigEntity (org.graylog.events.contentpack.entities.AggregationEventProcessorConfigEntity)3 Entity (org.graylog2.contentpacks.model.entities.Entity)3 NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 EventNotificationHandlerConfigEntity (org.graylog.events.contentpack.entities.EventNotificationHandlerConfigEntity)2 HttpEventNotificationConfigEntity (org.graylog.events.contentpack.entities.HttpEventNotificationConfigEntity)2 NotificationEntity (org.graylog.events.contentpack.entities.NotificationEntity)2 MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)2 EntityDescriptorIds (org.graylog2.contentpacks.EntityDescriptorIds)2 ModelId (org.graylog2.contentpacks.model.ModelId)2 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)2 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)2 NativeEntityDescriptor (org.graylog2.contentpacks.model.entities.NativeEntityDescriptor)2 Test (org.junit.Test)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Expr (org.graylog.events.conditions.Expr)1 EventFieldSpec (org.graylog.events.fields.EventFieldSpec)1 EventDefinitionDto (org.graylog.events.processor.EventDefinitionDto)1 AggregationConditions (org.graylog.events.processor.aggregation.AggregationConditions)1