Search in sources :

Example 1 with ParseError

use of org.graylog.plugins.pipelineprocessor.parser.errors.ParseError in project graylog2-server by Graylog2.

the class PipelineSource method fromDao.

public static PipelineSource fromDao(PipelineRuleParser parser, PipelineDao dao) {
    Set<ParseError> errors = null;
    Pipeline pipeline = null;
    try {
        pipeline = parser.parsePipeline(dao.id(), dao.source());
    } catch (ParseException e) {
        errors = e.getErrors();
    }
    final List<StageSource> stageSources = (pipeline == null) ? Collections.emptyList() : pipeline.stages().stream().map(stage -> StageSource.builder().match(stage.match()).rules(stage.ruleReferences()).stage(stage.stage()).build()).collect(Collectors.toList());
    return builder().id(dao.id()).title(dao.title()).description(dao.description()).source(dao.source()).createdAt(dao.createdAt()).modifiedAt(dao.modifiedAt()).stages(stageSources).errors(errors).build();
}
Also used : ParseError(org.graylog.plugins.pipelineprocessor.parser.errors.ParseError) ParseException(org.graylog.plugins.pipelineprocessor.parser.ParseException) Pipeline(org.graylog.plugins.pipelineprocessor.ast.Pipeline)

Aggregations

Pipeline (org.graylog.plugins.pipelineprocessor.ast.Pipeline)1 ParseException (org.graylog.plugins.pipelineprocessor.parser.ParseException)1 ParseError (org.graylog.plugins.pipelineprocessor.parser.errors.ParseError)1