Search in sources :

Example 1 with Execute

use of org.finos.legend.engine.query.pure.api.Execute in project legend-engine by finos.

the class TestM2MGrammarCompileAndExecute method runTest.

private Response runTest(ExecuteInput input) {
    ModelManager modelManager = new ModelManager(DeploymentMode.TEST);
    PlanExecutor executor = PlanExecutor.newPlanExecutor(InMemory.build());
    HttpServletRequest request = (HttpServletRequest) Proxy.newProxyInstance(getClass().getClassLoader(), new java.lang.Class<?>[] { HttpServletRequest.class }, new ReflectiveInvocationHandler(new Request()));
    // Should use: core_pure_extensions_extension.Root_meta_pure_router_extension_defaultExtensions__RouterExtension_MANY_(modelManager.)
    Response result = new Execute(modelManager, executor, (PureModel pureModel) -> Lists.mutable.empty(), LegendPlanTransformers.transformers).execute(request, input, SerializationFormat.defaultFormat, null, null);
    Assert.assertEquals(200, result.getStatus());
    return result;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Response(javax.ws.rs.core.Response) Execute(org.finos.legend.engine.query.pure.api.Execute) PlanExecutor(org.finos.legend.engine.plan.execution.PlanExecutor) HttpServletRequest(javax.servlet.http.HttpServletRequest) BeforeClass(org.junit.BeforeClass) Class(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.Class) ModelManager(org.finos.legend.engine.language.pure.modelManager.ModelManager) PureModel(org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel)

Example 2 with Execute

use of org.finos.legend.engine.query.pure.api.Execute in project legend-engine by finos.

the class Server method run.

@Override
public void run(ServerConfiguration serverConfiguration, Environment environment) {
    loadVaults(serverConfiguration.vaults);
    this.environment = environment;
    DeploymentStateAndVersions.DEPLOYMENT_MODE = serverConfiguration.deployment.mode;
    SDLCLoader sdlcLoader = new SDLCLoader(serverConfiguration.metadataserver, null);
    ModelManager modelManager = new ModelManager(serverConfiguration.deployment.mode, sdlcLoader);
    ChainFixingFilterHandler.apply(environment.getApplicationContext(), serverConfiguration.filterPriorities);
    RelationalStoreExecutor relationalStoreExecutor = (RelationalStoreExecutor) Relational.build(serverConfiguration.relationalexecution);
    PlanExecutor planExecutor = PlanExecutor.newPlanExecutor(relationalStoreExecutor, ServiceStore.build(), InMemory.build());
    // Session Management
    SessionTracker sessionTracker = new SessionTracker();
    environment.servlets().setSessionHandler(new SessionHandler());
    environment.servlets().addServletListeners(sessionTracker);
    environment.jersey().register(new SessionInfo(sessionTracker));
    // API & Swagger
    environment.jersey().setUrlPattern("/api/*");
    ServerShared.registerSwagger(environment, serverConfiguration.swagger);
    // Server
    environment.jersey().register(new Info(serverConfiguration.deployment, serverConfiguration.opentracing));
    environment.jersey().register(new CurrentUser());
    environment.jersey().register(new Memory());
    environment.jersey().register(new RelationalExecutorInformation());
    // Grammar
    environment.jersey().register(new GrammarToJson());
    environment.jersey().register(new JsonToGrammar());
    environment.jersey().register(new RelationalOperationElementGrammarToJson());
    environment.jersey().register(new RelationalOperationElementJsonToGrammar());
    environment.jersey().register(new TransformGrammarToJson());
    environment.jersey().register(new TransformJsonToGrammar());
    environment.jersey().register(new TransformRelationalOperationElementGrammarToJson());
    environment.jersey().register(new TransformRelationalOperationElementJsonToGrammar());
    // Relational
    environment.jersey().register(new SchemaExplorationApi(modelManager, relationalStoreExecutor));
    // Compilation
    environment.jersey().register((DynamicFeature) (resourceInfo, context) -> context.register(new InflateInterceptor()));
    environment.jersey().register(new Compile(modelManager));
    // Generation and Import
    MutableList<GenerationExtension> genExtensions = Iterate.addAllTo(ServiceLoader.load(GenerationExtension.class), Lists.mutable.empty());
    environment.jersey().register(new CodeGenerators(modelManager, genExtensions.select(p -> p.getMode() == GenerationMode.Code).collect(GenerationExtension::getGenerationDescription).select(Objects::nonNull)));
    environment.jersey().register(new CodeImports(modelManager, genExtensions.select(p -> p.getMode() == GenerationMode.Code).collect(GenerationExtension::getImportDescription).select(Objects::nonNull)));
    environment.jersey().register(new SchemaGenerators(modelManager, genExtensions.select(p -> p.getMode() == GenerationMode.Schema).collect(GenerationExtension::getGenerationDescription).select(Objects::nonNull)));
    environment.jersey().register(new SchemaImports(modelManager, genExtensions.select(p -> p.getMode() == GenerationMode.Schema).collect(GenerationExtension::getImportDescription).select(Objects::nonNull)));
    genExtensions.forEach(p -> environment.jersey().register(p.getService(modelManager)));
    // Execution
    MutableList<PlanGeneratorExtension> generatorExtensions = Lists.mutable.withAll(ServiceLoader.load(PlanGeneratorExtension.class));
    Function<PureModel, RichIterable<? extends Root_meta_pure_router_extension_RouterExtension>> routerExtensions = (PureModel pureModel) -> generatorExtensions.flatCollect(e -> e.getExtraRouterExtensions(pureModel));
    environment.jersey().register(new Execute(modelManager, planExecutor, routerExtensions, generatorExtensions.flatCollect(PlanGeneratorExtension::getExtraPlanTransformers)));
    environment.jersey().register(new ExecutePlanStrategic(planExecutor));
    environment.jersey().register(new ExecutePlanLegacy(planExecutor));
    // GraphQL
    environment.jersey().register(new GraphQLGrammar());
    environment.jersey().register(new GraphQLExecute(modelManager, planExecutor, serverConfiguration.metadataserver, generatorExtensions.flatCollect(PlanGeneratorExtension::getExtraPlanTransformers)));
    environment.jersey().register(new GraphQLDebug(modelManager, serverConfiguration.metadataserver));
    // Service
    environment.jersey().register(new ServiceModelingApi(modelManager, serverConfiguration.deployment.mode));
    // Query
    environment.jersey().register(new ApplicationQuery(ApplicationQueryConfiguration.getMongoClient()));
    // Global
    environment.jersey().register(new JsonInformationExceptionMapper());
    environment.jersey().register(new CatchAllExceptionMapper());
    // External Format
    environment.jersey().register(new ExternalFormats(modelManager));
    enableCors(environment);
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) CurrentUser(org.finos.legend.engine.server.core.api.CurrentUser) ExecutePlanStrategic(org.finos.legend.engine.plan.execution.api.ExecutePlanStrategic) Memory(org.finos.legend.engine.server.core.api.Memory) SchemaExplorationApi(org.finos.legend.engine.plan.execution.stores.relational.connection.api.schema.SchemaExplorationApi) LegendPac4jBundle(org.finos.legend.server.pac4j.LegendPac4jBundle) MutableList(org.eclipse.collections.api.list.MutableList) SwaggerBundleConfiguration(io.federecio.dropwizard.swagger.SwaggerBundleConfiguration) RelationalOperationElementGrammarToJson(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.RelationalOperationElementGrammarToJson) ExecutePlanLegacy(org.finos.legend.engine.plan.execution.api.ExecutePlanLegacy) RichIterable(org.eclipse.collections.api.RichIterable) PlanExecutor(org.finos.legend.engine.plan.execution.PlanExecutor) GenerationMode(org.finos.legend.engine.external.shared.format.extension.GenerationMode) Info(org.finos.legend.engine.server.core.api.Info) GraphQLGrammar(org.finos.legend.engine.query.graphQL.api.grammar.GraphQLGrammar) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) SchemaGenerators(org.finos.legend.engine.external.shared.format.generations.loaders.SchemaGenerators) RelationalExecutorInformation(org.finos.legend.engine.plan.execution.stores.relational.api.RelationalExecutorInformation) EnumSet(java.util.EnumSet) Application(io.dropwizard.Application) PureModel(org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel) GraphQLDebug(org.finos.legend.engine.query.graphQL.api.debug.GraphQLDebug) CollectorRegistry(io.prometheus.client.CollectorRegistry) Execute(org.finos.legend.engine.query.pure.api.Execute) ServiceLoader(java.util.ServiceLoader) FilterRegistration(javax.servlet.FilterRegistration) SwaggerBundle(io.federecio.dropwizard.swagger.SwaggerBundle) Iterate(org.eclipse.collections.impl.utility.Iterate) Root_meta_pure_router_extension_RouterExtension(org.finos.legend.pure.generated.Root_meta_pure_router_extension_RouterExtension) ApplicationQuery(org.finos.legend.engine.application.query.api.ApplicationQuery) Objects(java.util.Objects) AssetsBundle(io.dropwizard.assets.AssetsBundle) DynamicFeature(javax.ws.rs.container.DynamicFeature) ExternalFormats(org.finos.legend.engine.external.shared.format.model.api.ExternalFormats) List(java.util.List) RelationalStoreExecutor(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutor) CodeGenerators(org.finos.legend.engine.external.shared.format.generations.loaders.CodeGenerators) TransformRelationalOperationElementGrammarToJson(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.TransformRelationalOperationElementGrammarToJson) SDLCLoader(org.finos.legend.engine.language.pure.modelManager.sdlc.SDLCLoader) TransformRelationalOperationElementJsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.TransformRelationalOperationElementJsonToGrammar) ObjectMapperFactory(org.finos.legend.engine.shared.core.ObjectMapperFactory) GraphQLExecute(org.finos.legend.engine.query.graphQL.api.execute.GraphQLExecute) InflateInterceptor(org.finos.legend.engine.shared.core.operational.http.InflateInterceptor) TransformGrammarToJson(org.finos.legend.engine.language.pure.grammar.api.grammarToJson.TransformGrammarToJson) PlanGeneratorExtension(org.finos.legend.engine.plan.generation.extension.PlanGeneratorExtension) SchemaImports(org.finos.legend.engine.external.shared.format.imports.loaders.SchemaImports) ServiceStore(org.finos.legend.engine.plan.execution.stores.service.plugin.ServiceStore) LegendDefaultDatabaseAuthenticationFlowProviderConfiguration(org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProviderConfiguration) CatchAllExceptionMapper(org.finos.legend.engine.server.core.exceptionMappers.CatchAllExceptionMapper) Bootstrap(io.dropwizard.setup.Bootstrap) Function(org.eclipse.collections.api.block.function.Function) GrammarToJson(org.finos.legend.engine.language.pure.grammar.api.grammarToJson.GrammarToJson) Lists(org.eclipse.collections.api.factory.Lists) Vault(org.finos.legend.engine.shared.core.vault.Vault) SessionAttributeBundle(org.finos.legend.engine.server.core.session.SessionAttributeBundle) ServiceModelingApi(org.finos.legend.engine.plan.execution.service.api.ServiceModelingApi) RelationalOperationElementJsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.RelationalOperationElementJsonToGrammar) JsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.jsonToGrammar.JsonToGrammar) CrossOriginFilter(org.eclipse.jetty.servlets.CrossOriginFilter) Environment(io.dropwizard.setup.Environment) CodeImports(org.finos.legend.engine.external.shared.format.imports.loaders.CodeImports) Logger(org.slf4j.Logger) Relational(org.finos.legend.engine.plan.execution.stores.relational.plugin.Relational) GenerationExtension(org.finos.legend.engine.external.shared.format.extension.GenerationExtension) ServerShared(org.finos.legend.engine.server.core.ServerShared) JsonInformationExceptionMapper(org.finos.legend.engine.server.core.exceptionMappers.JsonInformationExceptionMapper) VaultConfiguration(org.finos.legend.engine.shared.core.vault.VaultConfiguration) ListIterate(org.eclipse.collections.impl.utility.ListIterate) SessionInfo(org.finos.legend.engine.server.core.session.api.SessionInfo) SessionHandler(org.eclipse.jetty.server.session.SessionHandler) InMemory(org.finos.legend.engine.plan.execution.stores.inMemory.plugin.InMemory) MultiPartBundle(io.dropwizard.forms.MultiPartBundle) ApplicationQueryConfiguration(org.finos.legend.engine.application.query.configuration.ApplicationQueryConfiguration) TransformJsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.jsonToGrammar.TransformJsonToGrammar) ModelManager(org.finos.legend.engine.language.pure.modelManager.ModelManager) DeploymentStateAndVersions(org.finos.legend.engine.shared.core.deployment.DeploymentStateAndVersions) VaultFactory(org.finos.legend.engine.shared.core.vault.VaultFactory) LegendPlanTransformers(org.finos.legend.engine.plan.generation.transformers.LegendPlanTransformers) HostnameHeaderBundle(org.finos.legend.server.shared.bundles.HostnameHeaderBundle) PureProtocolObjectMapperFactory(org.finos.legend.engine.protocol.pure.v1.PureProtocolObjectMapperFactory) DispatcherType(javax.servlet.DispatcherType) ChainFixingFilterHandler(org.finos.legend.server.shared.bundles.ChainFixingFilterHandler) SessionTracker(org.finos.legend.engine.server.core.session.SessionTracker) EngineUrlStreamHandlerFactory(org.finos.legend.engine.shared.core.url.EngineUrlStreamHandlerFactory) Compile(org.finos.legend.engine.language.pure.compiler.api.Compile) CurrentUser(org.finos.legend.engine.server.core.api.CurrentUser) Execute(org.finos.legend.engine.query.pure.api.Execute) GraphQLExecute(org.finos.legend.engine.query.graphQL.api.execute.GraphQLExecute) Memory(org.finos.legend.engine.server.core.api.Memory) InMemory(org.finos.legend.engine.plan.execution.stores.inMemory.plugin.InMemory) RelationalStoreExecutor(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutor) SessionInfo(org.finos.legend.engine.server.core.session.api.SessionInfo) ExternalFormats(org.finos.legend.engine.external.shared.format.model.api.ExternalFormats) TransformRelationalOperationElementJsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.TransformRelationalOperationElementJsonToGrammar) RelationalOperationElementJsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.RelationalOperationElementJsonToGrammar) TransformGrammarToJson(org.finos.legend.engine.language.pure.grammar.api.grammarToJson.TransformGrammarToJson) Compile(org.finos.legend.engine.language.pure.compiler.api.Compile) JsonInformationExceptionMapper(org.finos.legend.engine.server.core.exceptionMappers.JsonInformationExceptionMapper) GraphQLExecute(org.finos.legend.engine.query.graphQL.api.execute.GraphQLExecute) ServiceModelingApi(org.finos.legend.engine.plan.execution.service.api.ServiceModelingApi) CatchAllExceptionMapper(org.finos.legend.engine.server.core.exceptionMappers.CatchAllExceptionMapper) RelationalExecutorInformation(org.finos.legend.engine.plan.execution.stores.relational.api.RelationalExecutorInformation) PlanGeneratorExtension(org.finos.legend.engine.plan.generation.extension.PlanGeneratorExtension) RelationalOperationElementGrammarToJson(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.RelationalOperationElementGrammarToJson) TransformRelationalOperationElementGrammarToJson(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.TransformRelationalOperationElementGrammarToJson) TransformGrammarToJson(org.finos.legend.engine.language.pure.grammar.api.grammarToJson.TransformGrammarToJson) GrammarToJson(org.finos.legend.engine.language.pure.grammar.api.grammarToJson.GrammarToJson) GraphQLDebug(org.finos.legend.engine.query.graphQL.api.debug.GraphQLDebug) GenerationExtension(org.finos.legend.engine.external.shared.format.extension.GenerationExtension) ExecutePlanLegacy(org.finos.legend.engine.plan.execution.api.ExecutePlanLegacy) ExecutePlanStrategic(org.finos.legend.engine.plan.execution.api.ExecutePlanStrategic) RelationalOperationElementGrammarToJson(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.RelationalOperationElementGrammarToJson) TransformRelationalOperationElementGrammarToJson(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.TransformRelationalOperationElementGrammarToJson) InflateInterceptor(org.finos.legend.engine.shared.core.operational.http.InflateInterceptor) GraphQLGrammar(org.finos.legend.engine.query.graphQL.api.grammar.GraphQLGrammar) SchemaExplorationApi(org.finos.legend.engine.plan.execution.stores.relational.connection.api.schema.SchemaExplorationApi) SchemaImports(org.finos.legend.engine.external.shared.format.imports.loaders.SchemaImports) PlanExecutor(org.finos.legend.engine.plan.execution.PlanExecutor) SchemaGenerators(org.finos.legend.engine.external.shared.format.generations.loaders.SchemaGenerators) CodeGenerators(org.finos.legend.engine.external.shared.format.generations.loaders.CodeGenerators) SDLCLoader(org.finos.legend.engine.language.pure.modelManager.sdlc.SDLCLoader) SessionTracker(org.finos.legend.engine.server.core.session.SessionTracker) TransformRelationalOperationElementGrammarToJson(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.TransformRelationalOperationElementGrammarToJson) CodeImports(org.finos.legend.engine.external.shared.format.imports.loaders.CodeImports) ModelManager(org.finos.legend.engine.language.pure.modelManager.ModelManager) Info(org.finos.legend.engine.server.core.api.Info) SessionInfo(org.finos.legend.engine.server.core.session.api.SessionInfo) PureModel(org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel) Root_meta_pure_router_extension_RouterExtension(org.finos.legend.pure.generated.Root_meta_pure_router_extension_RouterExtension) TransformRelationalOperationElementJsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.TransformRelationalOperationElementJsonToGrammar) RelationalOperationElementJsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.RelationalOperationElementJsonToGrammar) JsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.jsonToGrammar.JsonToGrammar) TransformJsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.jsonToGrammar.TransformJsonToGrammar) RichIterable(org.eclipse.collections.api.RichIterable) TransformJsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.jsonToGrammar.TransformJsonToGrammar) ApplicationQuery(org.finos.legend.engine.application.query.api.ApplicationQuery) Objects(java.util.Objects) TransformRelationalOperationElementJsonToGrammar(org.finos.legend.engine.language.pure.grammar.api.relationalOperationElement.TransformRelationalOperationElementJsonToGrammar)

Aggregations

PureModel (org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel)2 ModelManager (org.finos.legend.engine.language.pure.modelManager.ModelManager)2 PlanExecutor (org.finos.legend.engine.plan.execution.PlanExecutor)2 Execute (org.finos.legend.engine.query.pure.api.Execute)2 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)1 Application (io.dropwizard.Application)1 AssetsBundle (io.dropwizard.assets.AssetsBundle)1 MultiPartBundle (io.dropwizard.forms.MultiPartBundle)1 Bootstrap (io.dropwizard.setup.Bootstrap)1 Environment (io.dropwizard.setup.Environment)1 SwaggerBundle (io.federecio.dropwizard.swagger.SwaggerBundle)1 SwaggerBundleConfiguration (io.federecio.dropwizard.swagger.SwaggerBundleConfiguration)1 CollectorRegistry (io.prometheus.client.CollectorRegistry)1 EnumSet (java.util.EnumSet)1 List (java.util.List)1 Objects (java.util.Objects)1 ServiceLoader (java.util.ServiceLoader)1 DispatcherType (javax.servlet.DispatcherType)1 FilterRegistration (javax.servlet.FilterRegistration)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1