use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.Section in project legend-engine by finos.
the class PersistenceParserExtension method parseSection.
private static Section parseSection(SectionSourceCode sectionSourceCode, Consumer<PackageableElement> elementConsumer, PureGrammarParserContext context) {
SourceCodeParserInfo parserInfo = getPersistenceParserInfo(sectionSourceCode);
ImportAwareCodeSection section = new ImportAwareCodeSection();
section.parserName = sectionSourceCode.sectionType;
section.sourceInformation = parserInfo.sourceInformation;
PersistenceParseTreeWalker walker = new PersistenceParseTreeWalker(parserInfo.walkerSourceInformation, elementConsumer, section);
walker.visit((PersistenceParserGrammar.DefinitionContext) parserInfo.rootContext);
return section;
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.Section in project legend-engine by finos.
the class DiagramParserExtension method parseSection.
private static Section parseSection(SectionSourceCode sectionSourceCode, Consumer<PackageableElement> elementConsumer, PureGrammarParserContext pureGrammarParserContext) {
SourceCodeParserInfo parserInfo = getDiagramParserInfo(sectionSourceCode);
ImportAwareCodeSection section = new ImportAwareCodeSection();
section.parserName = sectionSourceCode.sectionType;
section.sourceInformation = parserInfo.sourceInformation;
DiagramParseTreeWalker walker = new DiagramParseTreeWalker(parserInfo.walkerSourceInformation, elementConsumer, section);
walker.visit((DiagramParserGrammar.DefinitionContext) parserInfo.rootContext);
return section;
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.Section in project legend-engine by finos.
the class TestModelToFlatDataGeneration method testSimpleCsv.
@Test
public void testSimpleCsv() {
String modelCode = "Class test::gen::Data\n" + "{\n" + " name : String[1];\n" + " employed : Boolean[0..1];\n" + " iq : Integer[0..1];\n" + " weightKg : Float[0..1];\n" + " heightM : Decimal[1];\n" + " dateOfBirth : StrictDate[1];\n" + " timeOfDeath : DateTime[1];\n" + "}";
PureModelContextData generated = generateSchema(modelCode, config("test::gen"));
Binding binding = generated.getElementsOfType(Binding.class).stream().findFirst().get();
Assert.assertEquals("test::gen::TestBinding", binding.getPath());
Assert.assertEquals("test::gen::TestSchemaSet", binding.schemaSet);
Assert.assertEquals(Collections.singletonList("test::gen::Data"), binding.modelUnit.packageableElementIncludes);
ExternalFormatSchemaSet schemaSet = generated.getElementsOfType(ExternalFormatSchemaSet.class).stream().findFirst().get();
String expectedDefiniiton = "section Data: DelimitedWithHeadings\n" + "{\n" + " scope.untilEof;\n" + " delimiter: ',';\n" + "\n" + " Record\n" + " {\n" + " name: STRING;\n" + " employed: BOOLEAN(optional);\n" + " iq: INTEGER(optional);\n" + " weightKg: DECIMAL(optional);\n" + " heightM: DECIMAL;\n" + " dateOfBirth: DATE;\n" + " timeOfDeath: DATETIME;\n" + " }\n" + "}";
Assert.assertEquals(expectedDefiniiton, schemaSet.schemas.get(0).content);
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.Section in project legend-engine by finos.
the class TestFlatDataToModelGeneration method testSimpleCsvWithPurifiedNames.
@Test
public void testSimpleCsvWithPurifiedNames() {
String schemaCode = newExternalSchemaSetGrammarBuilder("test::Simple", "FlatData").withSchemaText("section data: DelimitedWithHeadings\n" + "{\n" + " scope.untilEof;\n" + " delimiter: ',';\n" + "\n" + " Record\n" + " {\n" + " Name : STRING;\n" + " Employed : INTEGER(optional);\n" + " IQ : INTEGER(optional);\n" + " 'Weight KG' : DECIMAL(optional);\n" + " 'DATE OF BIRTH' : DATE;\n" + " TIME_OF_DEATH : DATETIME;\n" + " }\n" + "}").build();
PureModelContextData model = generateModel(schemaCode, config("test::Simple", "test::gen", true));
String expected = ">>>test::gen::DataRecord\n" + "Class test::gen::DataRecord extends meta::pure::metamodel::type::Any\n" + "{\n" + " name: String[1];\n" + " employed: Integer[0..1];\n" + " iq: Integer[0..1];\n" + " weightKg: Float[0..1];\n" + " dateOfBirth: StrictDate[1];\n" + " timeOfDeath: DateTime[1];\n" + "}";
Assert.assertEquals(modelTextsFromString(expected), modelTextsFromContextData(model));
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.Section in project legend-engine by finos.
the class RuntimeParser method parse.
@Override
public Section parse(SourceCodeParserInfo sectionParserInfo, Consumer<PackageableElement> pureModelContextData, PureGrammarParserContext parserContext) {
ImportAwareCodeSection section = new ImportAwareCodeSection();
section.parserName = this.getName();
section.sourceInformation = sectionParserInfo.sourceInformation;
RuntimeParseTreeWalker walker = new RuntimeParseTreeWalker(sectionParserInfo.walkerSourceInformation, pureModelContextData, section, this.connectionParser);
walker.visit((RuntimeParserGrammar.DefinitionContext) sectionParserInfo.rootContext);
return section;
}
Aggregations