use of org.graylog2.contentpacks.model.ModelId in project graylog2-server by Graylog2.
the class EventDefinitionFacade method exportEntity.
@Override
public Optional<Entity> exportEntity(EntityDescriptor entityDescriptor, EntityDescriptorIds entityDescriptorIds) {
final ModelId modelId = entityDescriptor.id();
final Optional<EventDefinitionDto> eventDefinition = eventDefinitionService.get(modelId.id());
if (!eventDefinition.isPresent()) {
LOG.debug("Couldn't find event definition {}", entityDescriptor);
return Optional.empty();
}
return Optional.of(exportNativeEntity(eventDefinition.get(), entityDescriptorIds));
}
use of org.graylog2.contentpacks.model.ModelId in project graylog2-server by Graylog2.
the class NotificationFacade method exportEntity.
@Override
public Optional<Entity> exportEntity(EntityDescriptor entityDescriptor, EntityDescriptorIds entityDescriptorIds) {
final ModelId modelId = entityDescriptor.id();
final Optional<NotificationDto> notificationDto = notificationService.get(modelId.id());
if (!notificationDto.isPresent()) {
LOG.debug("Couldn't find notification {}", entityDescriptor);
return Optional.empty();
}
final NotificationEntity entity = (NotificationEntity) notificationDto.get().toContentPackEntity(entityDescriptorIds);
final JsonNode data = objectMapper.convertValue(entity, JsonNode.class);
return Optional.of(EntityV1.builder().id(ModelId.of(entityDescriptorIds.getOrThrow(notificationDto.get().id(), ModelTypes.NOTIFICATION_V1))).type(ModelTypes.NOTIFICATION_V1).data(data).build());
}
use of org.graylog2.contentpacks.model.ModelId in project graylog2-server by Graylog2.
the class InputFacade method resolveNativeEntity.
@Override
public Graph<EntityDescriptor> resolveNativeEntity(EntityDescriptor entityDescriptor) {
final MutableGraph<EntityDescriptor> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode(entityDescriptor);
final ModelId modelId = entityDescriptor.id();
try {
final Input input = inputService.find(modelId.toString());
final InputWithExtractors inputWithExtractors = InputWithExtractors.create(input, inputService.getExtractors(input));
resolveNativeEntityLookupTable(entityDescriptor, inputWithExtractors, mutableGraph);
resolveNativeEntityGrokPattern(entityDescriptor, inputWithExtractors, mutableGraph);
return ImmutableGraph.copyOf(mutableGraph);
} catch (NotFoundException e) {
LOG.debug("Couldn't find input {}", entityDescriptor, e);
}
return ImmutableGraph.copyOf(mutableGraph);
}
use of org.graylog2.contentpacks.model.ModelId in project graylog2-server by Graylog2.
the class LookupTableFacade method resolveNativeEntity.
@Override
public Graph<EntityDescriptor> resolveNativeEntity(EntityDescriptor entityDescriptor) {
final MutableGraph<EntityDescriptor> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode(entityDescriptor);
final ModelId modelId = entityDescriptor.id();
final Optional<LookupTableDto> lookupTableDto = lookupTableService.get(modelId.id());
lookupTableDto.map(LookupTableDto::dataAdapterId).map(this::adapterDescriptor).ifPresent(dataAdapter -> mutableGraph.putEdge(entityDescriptor, dataAdapter));
lookupTableDto.map(LookupTableDto::cacheId).map(this::cacheDescriptor).ifPresent(cache -> mutableGraph.putEdge(entityDescriptor, cache));
return ImmutableGraph.copyOf(mutableGraph);
}
use of org.graylog2.contentpacks.model.ModelId in project graylog2-server by Graylog2.
the class SidecarCollectorFacade method exportEntity.
@Override
public Optional<Entity> exportEntity(EntityDescriptor entityDescriptor, EntityDescriptorIds entityDescriptorIds) {
final ModelId modelId = entityDescriptor.id();
final Collector collector = collectorService.find(modelId.id());
if (isNull(collector)) {
LOG.debug("Couldn't find collector {}", entityDescriptor);
return Optional.empty();
}
return Optional.of(exportNativeEntity(collector, entityDescriptorIds));
}
Aggregations