Search in sources :

Example 1 with ExternalSource

use of org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalSource in project legend-engine by finos.

the class ExternalFormatConnectionCompilerExtension method getExtraConnectionSecondPassProcessors.

@Override
public List<Procedure3<Connection, org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Connection, CompileContext>> getExtraConnectionSecondPassProcessors() {
    return Collections.singletonList((connectionValue, pureConnection, context) -> {
        if (connectionValue instanceof ExternalFormatConnection) {
            ExternalFormatConnection externalFormatConnection = (ExternalFormatConnection) connectionValue;
            List<IExternalFormatCompilerExtension> extensions = IExternalFormatCompilerExtension.getExtensions(context);
            Root_meta_external_shared_format_executionPlan_ExternalFormatConnection connection = (Root_meta_external_shared_format_executionPlan_ExternalFormatConnection) pureConnection;
            Store store = context.pureModel.getStore(connectionValue.element, connectionValue.elementSourceInformation);
            if (!(store instanceof Root_meta_external_shared_format_binding_Binding)) {
                throw new EngineException("Store for ExternalFormatConnection must be a Binding", connectionValue.sourceInformation, EngineErrorType.COMPILATION);
            }
            connection._element(store);
            Root_meta_external_shared_format_executionPlan_ExternalSource externalSource = IExternalFormatCompilerExtension.process(externalFormatConnection.externalSource, ListIterate.flatCollect(extensions, IExternalFormatCompilerExtension::getExtraExternalSourceSpecificationProcessors), context);
            connection._externalSource(externalSource);
        }
    });
}
Also used : Root_meta_external_shared_format_binding_Binding(org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding) Root_meta_external_shared_format_executionPlan_ExternalFormatConnection(org.finos.legend.pure.generated.Root_meta_external_shared_format_executionPlan_ExternalFormatConnection) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) Root_meta_external_shared_format_executionPlan_ExternalSource(org.finos.legend.pure.generated.Root_meta_external_shared_format_executionPlan_ExternalSource) Store(org.finos.legend.pure.m3.coreinstance.meta.pure.store.Store) Root_meta_external_shared_format_executionPlan_ExternalFormatConnection(org.finos.legend.pure.generated.Root_meta_external_shared_format_executionPlan_ExternalFormatConnection) ExternalFormatConnection(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatConnection)

Example 2 with ExternalSource

use of org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalSource in project legend-engine by finos.

the class ExternalSourceSpecificationParseTreeWalker method visitUrlStreamExternalSourceSpecification.

public ExternalSource visitUrlStreamExternalSourceSpecification(ExternalSourceSpecificationSourceCode code, ExternalSourceSpecificationParserGrammar.UrlStreamExternalSourceSpecificationContext ctx) {
    UrlStreamExternalSource extSource = new UrlStreamExternalSource();
    extSource.sourceInformation = code.getSourceInformation();
    ExternalSourceSpecificationParserGrammar.UrlStreamUrlContext urlCtx = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.urlStreamUrl(), "url", code.getSourceInformation());
    extSource.url = PureGrammarParserUtility.fromGrammarString(urlCtx.STRING().getText(), true);
    return extSource;
}
Also used : UrlStreamExternalSource(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.UrlStreamExternalSource) ExternalSourceSpecificationParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.connection.externalSource.ExternalSourceSpecificationParserGrammar)

Example 3 with ExternalSource

use of org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalSource in project legend-engine by finos.

the class ExternalFormatGrammarComposerExtension method getExtraExternalSourceSpecificationComposers.

@Override
public List<Function2<ExternalSource, PureGrammarComposerContext, String>> getExtraExternalSourceSpecificationComposers() {
    return Lists.mutable.with((specification, context) -> {
        if (specification instanceof UrlStreamExternalSource) {
            UrlStreamExternalSource spec = (UrlStreamExternalSource) specification;
            int baseIndentation = 1;
            return "UrlStream\n" + context.getIndentationString() + getTabString(1) + "{\n" + context.getIndentationString() + getTabString(2) + "url: " + convertString(spec.url, true) + ";\n" + context.getIndentationString() + getTabString(1) + "}";
        }
        return null;
    });
}
Also used : UrlStreamExternalSource(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.UrlStreamExternalSource)

Example 4 with ExternalSource

use of org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalSource in project legend-engine by finos.

the class ExternalFormatConnectionParseTreeWalker method visitExternalFormatConnectionDatasourceSpecification.

private ExternalSource visitExternalFormatConnectionDatasourceSpecification(ExternalFormatConnectionParserGrammar.ExternalSourceContext ctx) {
    ExternalFormatConnectionParserGrammar.SpecificationContext specification = ctx.specification();
    SourceInformation sourceInformation = walkerSourceInformation.getSourceInformation(ctx);
    ExternalSourceSpecificationSourceCode code = new ExternalSourceSpecificationSourceCode(ctx.specification().getText(), specification.specificationType().getText(), sourceInformation, new ParseTreeWalkerSourceInformation.Builder(walkerSourceInformation).withLineOffset(sourceInformation.startLine - 1).withColumnOffset(sourceInformation.startColumn).build());
    List<IExternalFormatGrammarParserExtension> extensions = IExternalFormatGrammarParserExtension.getExtensions();
    ExternalSource result = IExternalFormatGrammarParserExtension.process(code, ListIterate.flatCollect(extensions, IExternalFormatGrammarParserExtension::getExtraExternalSourceSpecificationParsers));
    if (result == null) {
        throw new EngineException("Unsupported syntax", this.walkerSourceInformation.getSourceInformation(ctx), EngineErrorType.PARSER);
    }
    return result;
}
Also used : ExternalFormatConnectionParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.connection.ExternalFormatConnectionParserGrammar) ExternalSource(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalSource) ExternalSourceSpecificationSourceCode(org.finos.legend.engine.language.pure.grammar.from.externalSource.ExternalSourceSpecificationSourceCode) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) SourceInformation(org.finos.legend.engine.protocol.pure.v1.model.SourceInformation)

Aggregations

UrlStreamExternalSource (org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.UrlStreamExternalSource)2 EngineException (org.finos.legend.engine.shared.core.operational.errorManagement.EngineException)2 ExternalFormatConnectionParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.connection.ExternalFormatConnectionParserGrammar)1 ExternalSourceSpecificationParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.connection.externalSource.ExternalSourceSpecificationParserGrammar)1 ExternalSourceSpecificationSourceCode (org.finos.legend.engine.language.pure.grammar.from.externalSource.ExternalSourceSpecificationSourceCode)1 SourceInformation (org.finos.legend.engine.protocol.pure.v1.model.SourceInformation)1 ExternalFormatConnection (org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatConnection)1 ExternalSource (org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalSource)1 Root_meta_external_shared_format_binding_Binding (org.finos.legend.pure.generated.Root_meta_external_shared_format_binding_Binding)1 Root_meta_external_shared_format_executionPlan_ExternalFormatConnection (org.finos.legend.pure.generated.Root_meta_external_shared_format_executionPlan_ExternalFormatConnection)1 Root_meta_external_shared_format_executionPlan_ExternalSource (org.finos.legend.pure.generated.Root_meta_external_shared_format_executionPlan_ExternalSource)1 Store (org.finos.legend.pure.m3.coreinstance.meta.pure.store.Store)1