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);
}
});
}
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;
}
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;
});
}
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;
}
Aggregations