Search in sources :

Example 1 with PureGrammarComposerUtility.getTabString

use of org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.getTabString in project legend-engine by finos.

the class ExternalFormatGrammarComposerExtension method renderSchemaBinding.

private static String renderSchemaBinding(Binding schemaBinding) {
    StringBuilder builder = new StringBuilder().append("Binding ").append(PureGrammarComposerUtility.convertPath(schemaBinding.getPath())).append("\n{\n");
    if (schemaBinding.schemaSet != null) {
        PureGrammarComposerUtility.appendTabString(builder).append("schemaSet: ").append(PureGrammarComposerUtility.convertPath(schemaBinding.schemaSet)).append(";\n");
        if (schemaBinding.schemaId != null) {
            PureGrammarComposerUtility.appendTabString(builder).append("schemaId: ").append(PureGrammarComposerUtility.convertIdentifier(schemaBinding.schemaId)).append(";\n");
        }
    }
    PureGrammarComposerUtility.appendTabString(builder).append("contentType: ").append(PureGrammarComposerUtility.convertString(schemaBinding.contentType, true)).append(";\n");
    ModelUnit modelUnit = schemaBinding.modelUnit;
    PureGrammarComposerUtility.appendTabString(builder).append("modelIncludes: [\n");
    builder.append(modelUnit.packageableElementIncludes.stream().map(pe -> PureGrammarComposerUtility.getTabString(2) + PureGrammarComposerUtility.convertPath(pe)).collect(Collectors.joining(",\n"))).append("\n");
    PureGrammarComposerUtility.appendTabString(builder).append("];\n");
    if (!modelUnit.packageableElementExcludes.isEmpty()) {
        PureGrammarComposerUtility.appendTabString(builder).append("modelExcludes: [\n");
        builder.append(modelUnit.packageableElementExcludes.stream().map(pe -> PureGrammarComposerUtility.getTabString(2) + PureGrammarComposerUtility.convertPath(pe)).collect(Collectors.joining(",\n"))).append("\n");
        PureGrammarComposerUtility.appendTabString(builder).append("];\n");
    }
    return builder.append("}").toString();
}
Also used : ExternalFormatSchema(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatSchema) PackageableElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement) PureGrammarComposerUtility.convertString(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.convertString) Lists(org.eclipse.collections.api.factory.Lists) ExternalSource(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalSource) ExternalFormatConnection(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatConnection) UrlStreamExternalSource(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.UrlStreamExternalSource) ListIterate(org.eclipse.collections.impl.utility.ListIterate) Collectors(java.util.stream.Collectors) Binding(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.Binding) Function3(org.eclipse.collections.api.block.function.Function3) ModelUnit(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.ModelUnit) PureGrammarComposerExtension(org.finos.legend.engine.language.pure.grammar.to.extension.PureGrammarComposerExtension) List(java.util.List) ExternalFormatGrammarParserExtension(org.finos.legend.engine.language.pure.grammar.from.ExternalFormatGrammarParserExtension) Connection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.Connection) ExternalFormatSchemaSet(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatSchemaSet) LazyIterate(org.eclipse.collections.impl.utility.LazyIterate) Function2(org.eclipse.collections.api.block.function.Function2) PureGrammarComposerUtility.getTabString(org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.getTabString) Tuples(org.eclipse.collections.impl.tuple.Tuples) Pair(org.eclipse.collections.api.tuple.Pair) ModelUnit(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.ModelUnit)

Aggregations

List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Function2 (org.eclipse.collections.api.block.function.Function2)1 Function3 (org.eclipse.collections.api.block.function.Function3)1 Lists (org.eclipse.collections.api.factory.Lists)1 Pair (org.eclipse.collections.api.tuple.Pair)1 Tuples (org.eclipse.collections.impl.tuple.Tuples)1 LazyIterate (org.eclipse.collections.impl.utility.LazyIterate)1 ListIterate (org.eclipse.collections.impl.utility.ListIterate)1 ExternalFormatGrammarParserExtension (org.finos.legend.engine.language.pure.grammar.from.ExternalFormatGrammarParserExtension)1 PureGrammarComposerUtility.convertString (org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.convertString)1 PureGrammarComposerUtility.getTabString (org.finos.legend.engine.language.pure.grammar.to.PureGrammarComposerUtility.getTabString)1 PureGrammarComposerExtension (org.finos.legend.engine.language.pure.grammar.to.extension.PureGrammarComposerExtension)1 PackageableElement (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement)1 Connection (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.Connection)1 ModelUnit (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.ModelUnit)1 Binding (org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.Binding)1 ExternalFormatConnection (org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatConnection)1 ExternalFormatSchema (org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatSchema)1 ExternalFormatSchemaSet (org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatSchemaSet)1