Search in sources :

Example 1 with IRelationalParser

use of org.finos.legend.pure.m2.relational.serialization.grammar.v1.IRelationalParser in project legend-pure by finos.

the class RelationalGraphBuilder method visitMilestoningDefinition.

@Override
public String visitMilestoningDefinition(MilestoningDefinitionContext ctx) {
    RichIterable<Parser> relationalParsers = this.parserLibrary.getParsers().select(parser -> parser instanceof IRelationalParser);
    SourceInformation srcInfo = this.sourceInformation.getPureSourceInformation(ctx.identifier().getStart());
    String type = ctx.identifier().getText();
    org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.MilestoningContentContext contentCtx = ctx.milestoningContent();
    String content = contentCtx.start.getInputStream().getText(Interval.of(contentCtx.start.getStartIndex(), contentCtx.stop.getStopIndex()));
    List<String> results = relationalParsers.collect(relationalParser -> ((IRelationalParser) relationalParser).parseMilestoningDefinition(type, content, sourceInformation.getSourceName(), srcInfo.getLine() - 1, srcInfo.getEndColumn() + 1, this.importId)).reject(x -> x == null).toList();
    if (results.size() == 1) {
        return results.get(0);
    } else if (results.isEmpty()) {
        throw new PureParserException(srcInfo, "Milestoning type : " + type + " not supported!!");
    }
    throw new PureParserException(srcInfo, "Found multiple processors for milestoning type : " + type);
}
Also used : Op_boolean_operation_rightContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.Op_boolean_operation_rightContext) FilterMappingBlockContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.FilterMappingBlockContext) FunctionArgumentContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.FunctionArgumentContext) Interval(org.antlr.v4.runtime.misc.Interval) ColWithDbOrConstantContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ColWithDbOrConstantContext) MappingContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.MappingContext) Token(org.antlr.v4.runtime.Token) JoinColWithDbOrConstantContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.JoinColWithDbOrConstantContext) ColumnDataTypeException(org.finos.legend.pure.m2.relational.serialization.grammar.v1.processor.ColumnDataTypeFactory.ColumnDataTypeException) MutableList(org.eclipse.collections.api.list.MutableList) MappingElementsContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.MappingElementsContext) SingleMappingLinesContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.SingleMappingLinesContext) RichIterable(org.eclipse.collections.api.RichIterable) AssociationMappingContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.AssociationMappingContext) Op_atomicOperationContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.Op_atomicOperationContext) Op_functionContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.Op_functionContext) Tuples(org.eclipse.collections.impl.tuple.Tuples) MilestoningDefinitionContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.MilestoningDefinitionContext) ViewContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ViewContext) OneJoinContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.OneJoinContext) OtherwisePropertyMappingContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.OtherwisePropertyMappingContext) SimpleScopeInfoContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.SimpleScopeInfoContext) FilterMappingJoinSequenceContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.FilterMappingJoinSequenceContext) MainTableBlockContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.MainTableBlockContext) PropertyMappingsContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.PropertyMappingsContext) MappingBlockGroupByContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.MappingBlockGroupByContext) ViewColumnMappingLinesContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ViewColumnMappingLinesContext) RelationalMappingContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.RelationalMappingContext) DefinitionContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.DefinitionContext) OtherwisePropertyMappingsContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.OtherwisePropertyMappingsContext) TransformerContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.TransformerContext) List(java.util.List) ClassMappingContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ClassMappingContext) BussinessSnapshotDateContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.BussinessSnapshotDateContext) ColumnDefinitionsContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ColumnDefinitionsContext) DatabaseContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.DatabaseContext) OtherwiseJoinContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.OtherwiseJoinContext) MilestoneSpecContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.MilestoneSpecContext) ViewColumnMappingLineContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ViewColumnMappingLineContext) MilestoningDefinitionsContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.MilestoningDefinitionsContext) PlusSingleMappingLineContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.PlusSingleMappingLineContext) JoinContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.JoinContext) ParserLibrary(org.finos.legend.pure.m3.serialization.grammar.ParserLibrary) FilterContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.FilterContext) Op_groupOperationContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.Op_groupOperationContext) Op_operationContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.Op_operationContext) MappingBlockContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.MappingBlockContext) LocalMappingPropertyContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.LocalMappingPropertyContext) TableAliasColumnContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.TableAliasColumnContext) FastList(org.eclipse.collections.impl.list.mutable.FastList) IncludeContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.IncludeContext) NonePlusSingleMappingLineContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.NonePlusSingleMappingLineContext) JoinColWithDbOrConstantsContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.JoinColWithDbOrConstantsContext) IRelationalParser(org.finos.legend.pure.m2.relational.serialization.grammar.v1.IRelationalParser) Parser(org.finos.legend.pure.m3.serialization.grammar.Parser) BusinessMilestoningFromContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.BusinessMilestoningFromContext) TableContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.TableContext) PrimaryKeyContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.PrimaryKeyContext) Pair(org.eclipse.collections.api.tuple.Pair) ConstantContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ConstantContext) SchemaContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.SchemaContext) ColumnDefinitionContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ColumnDefinitionContext) ColumnDataTypeFactory(org.finos.legend.pure.m2.relational.serialization.grammar.v1.processor.ColumnDataTypeFactory) TableAliasColumnWithScopeInfoContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.TableAliasColumnWithScopeInfoContext) SourceInformation(org.finos.legend.pure.m4.coreinstance.SourceInformation) PureParserException(org.finos.legend.pure.m4.serialization.grammar.antlr.PureParserException) OneJoinRightContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.OneJoinRightContext) MappingElementContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.MappingElementContext) MultiGrainFilterContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.MultiGrainFilterContext) SingleMappingLineContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.SingleMappingLineContext) ParsingUtils(org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.ParsingUtils) AntlrSourceInformation(org.finos.legend.pure.m4.serialization.grammar.antlr.AntlrSourceInformation) Op_boolean_operatorContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.Op_boolean_operatorContext) FilterViewBlockContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.FilterViewBlockContext) ScopeContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ScopeContext) Op_operatorContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.Op_operatorContext) JoinSequenceContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.JoinSequenceContext) Op_columnContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.Op_columnContext) ScopeInfoContext(org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ScopeInfoContext) IRelationalParser(org.finos.legend.pure.m2.relational.serialization.grammar.v1.IRelationalParser) SourceInformation(org.finos.legend.pure.m4.coreinstance.SourceInformation) AntlrSourceInformation(org.finos.legend.pure.m4.serialization.grammar.antlr.AntlrSourceInformation) IRelationalParser(org.finos.legend.pure.m2.relational.serialization.grammar.v1.IRelationalParser) Parser(org.finos.legend.pure.m3.serialization.grammar.Parser) IRelationalParser(org.finos.legend.pure.m2.relational.serialization.grammar.v1.IRelationalParser) PureParserException(org.finos.legend.pure.m4.serialization.grammar.antlr.PureParserException)

Aggregations

List (java.util.List)1 Token (org.antlr.v4.runtime.Token)1 Interval (org.antlr.v4.runtime.misc.Interval)1 RichIterable (org.eclipse.collections.api.RichIterable)1 MutableList (org.eclipse.collections.api.list.MutableList)1 Pair (org.eclipse.collections.api.tuple.Pair)1 FastList (org.eclipse.collections.impl.list.mutable.FastList)1 Tuples (org.eclipse.collections.impl.tuple.Tuples)1 IRelationalParser (org.finos.legend.pure.m2.relational.serialization.grammar.v1.IRelationalParser)1 AssociationMappingContext (org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.AssociationMappingContext)1 BusinessMilestoningFromContext (org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.BusinessMilestoningFromContext)1 BussinessSnapshotDateContext (org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.BussinessSnapshotDateContext)1 ClassMappingContext (org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ClassMappingContext)1 ColWithDbOrConstantContext (org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ColWithDbOrConstantContext)1 ColumnDefinitionContext (org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ColumnDefinitionContext)1 ColumnDefinitionsContext (org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ColumnDefinitionsContext)1 ConstantContext (org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.ConstantContext)1 DatabaseContext (org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.DatabaseContext)1 DefinitionContext (org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.DefinitionContext)1 FilterContext (org.finos.legend.pure.m2.relational.serialization.grammar.v1.antlr.RelationalParser.FilterContext)1