Search in sources :

Example 1 with EnumerationMappingParser

use of org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.EnumerationMappingParser in project legend-pure by finos.

the class TestSimpleGrammar method testReferredEnumMappingFromIncludes.

@Test
public void testReferredEnumMappingFromIncludes() {
    final String pureCode = "Enum TradeType\n" + "{\n" + "    BUY,\n" + "    SELL\n" + "}\n" + "Class Trade\n" + "{\n" + "    type: TradeType[1];\n" + "}\n" + "\n" + "Class EquityTrade extends Trade\n" + "{\n" + "    product: String[1];\n" + "    quantity: Integer[1];\n" + "}\n" + "###Relational\n" + "\n" + "Database tradeDB\n" + "(\n" + "    Table eqTradeTable\n" + "    (\n" + "        id INT PRIMARY KEY,\n" + "        product VARCHAR(200),\n" + "        type VARCHAR(10),\n" + "        qty INTEGER\n" + "    )\n" + ")\n" + "###Mapping\n" + "\n" + "Mapping tradeMapping1\n" + "(\n" + "    TradeType: EnumerationMapping TradeSource1\n" + "    {\n" + "       BUY:  ['BUY', 'B'],\n" + "       SELL: ['SELL', 'S']\n" + "    }\n" + ")\n" + "\n" + "Mapping tradeMapping2\n" + "(\n" + "    include tradeMapping1\n" + "\n" + "    TradeType: EnumerationMapping TradeSource2\n" + "    {\n" + "       BUY:  ['CREDIT'],\n" + "       SELL: ['DEBIT']\n" + "    }\n" + ")\n" + "\n" + "Mapping tradeMapping3\n" + "(\n" + "    include tradeMapping2\n" + "\n" + "    EquityTrade: Relational\n" + "    {\n" + "        scope( [tradeDB] default.eqTradeTable)\n" + "        (\n" + "            product: product,\n" + "            quantity: qty,\n" + "            type : EnumerationMapping TradeSource1 : type\n" + "        )\n" + "    }\n" + ")\n" + "\n";
    Loader.parseM3(pureCode, this.repository, new ParserLibrary(Lists.immutable.with(new M3AntlrParser(), new MappingParser(), new RelationalParser(), new EnumerationMappingParser())), ValidationType.DEEP, VoidM3M4StateListener.VOID_M3_M4_STATE_LISTENER, this.context);
    this.runtime.compile();
}
Also used : EnumerationMappingParser(org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.EnumerationMappingParser) MappingParser(org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.MappingParser) ParserLibrary(org.finos.legend.pure.m3.serialization.grammar.ParserLibrary) M3AntlrParser(org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3AntlrParser) EnumerationMappingParser(org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.EnumerationMappingParser) RelationalParser(org.finos.legend.pure.m2.relational.serialization.grammar.v1.RelationalParser) Test(org.junit.Test)

Example 2 with EnumerationMappingParser

use of org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.EnumerationMappingParser in project legend-pure by finos.

the class TestSimpleGrammar method testValidDuplicateEnumMapping.

@Test
public void testValidDuplicateEnumMapping() {
    final String pureCode = "Enum TradeType\n" + "{\n" + "    BUY,\n" + "    SELL\n" + "}\n" + "###Mapping\n" + "Mapping tradeMapping\n" + "(\n" + "   TradeType: EnumerationMapping TradeSource1\n" + "   {\n" + "       BUY:  ['BUY', 'B'],\n" + "       SELL: ['SELL', 'S']\n" + "   }\n" + "   TradeType: EnumerationMapping TradeSource2\n" + "   {\n" + "       BUY:  ['CREDIT'],\n" + "       SELL: ['DEBIT']\n" + "   }\n" + ")\n";
    Loader.parseM3(pureCode, this.repository, new ParserLibrary(Lists.immutable.with(new M3AntlrParser(), new MappingParser(), new RelationalParser(), new EnumerationMappingParser())), ValidationType.DEEP, VoidM3M4StateListener.VOID_M3_M4_STATE_LISTENER, this.context);
    this.runtime.compile();
}
Also used : EnumerationMappingParser(org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.EnumerationMappingParser) MappingParser(org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.MappingParser) ParserLibrary(org.finos.legend.pure.m3.serialization.grammar.ParserLibrary) M3AntlrParser(org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3AntlrParser) EnumerationMappingParser(org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.EnumerationMappingParser) RelationalParser(org.finos.legend.pure.m2.relational.serialization.grammar.v1.RelationalParser) Test(org.junit.Test)

Aggregations

EnumerationMappingParser (org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.EnumerationMappingParser)2 MappingParser (org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.MappingParser)2 RelationalParser (org.finos.legend.pure.m2.relational.serialization.grammar.v1.RelationalParser)2 ParserLibrary (org.finos.legend.pure.m3.serialization.grammar.ParserLibrary)2 M3AntlrParser (org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3AntlrParser)2 Test (org.junit.Test)2