Search in sources :

Example 1 with Root_meta_pure_router_extension_RouterExtension

use of org.finos.legend.pure.generated.Root_meta_pure_router_extension_RouterExtension in project legend-sdlc by finos.

the class MappingTestCase method collectTestCases.

@LegendSDLCTestCaseCollector(collectorClass = Mapping.class)
public static void collectTestCases(PureModel pureModel, PureModelContextData pureModelContextData, MutableList<PlanTransformer> planTransformers, RichIterable<? extends Root_meta_pure_router_extension_RouterExtension> extensions, String pureVersion, Entity entity, Consumer<? super LegendSDLCTestCase> testCaseConsumer) {
    Mapping mapping = findPackageableElement(pureModelContextData.getElementsOfType(Mapping.class), entity.getPath());
    Optional.ofNullable(mapping.tests).orElse(Collections.emptyList()).stream().map(test -> new MappingTestCase(pureModel, pureModelContextData, mapping, test, planTransformers, extensions, pureVersion)).forEach(testCaseConsumer);
}
Also used : PrintWriter(java.io.PrintWriter) PureModel(org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel) MappingTestRunner(org.finos.legend.engine.test.runner.mapping.MappingTestRunner) Mapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping) StringWriter(java.io.StringWriter) MappingTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.mappingTest.MappingTest) TestResult(org.finos.legend.engine.test.runner.shared.TestResult) MutableList(org.eclipse.collections.api.list.MutableList) Root_meta_pure_router_extension_RouterExtension(org.finos.legend.pure.generated.Root_meta_pure_router_extension_RouterExtension) Consumer(java.util.function.Consumer) RichIterable(org.eclipse.collections.api.RichIterable) Connection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.Connection) PureModelContextData(org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData) Entity(org.finos.legend.sdlc.domain.model.entity.Entity) LegendSDLCTestCase(org.finos.legend.sdlc.test.junit.LegendSDLCTestCase) LegendSDLCTestCaseCollector(org.finos.legend.sdlc.test.junit.LegendSDLCTestCaseCollector) Optional(java.util.Optional) RichMappingTestResult(org.finos.legend.engine.test.runner.mapping.RichMappingTestResult) Collections(java.util.Collections) PlanTransformer(org.finos.legend.engine.plan.generation.transformers.PlanTransformer) Mapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping) LegendSDLCTestCaseCollector(org.finos.legend.sdlc.test.junit.LegendSDLCTestCaseCollector)

Example 2 with Root_meta_pure_router_extension_RouterExtension

use of org.finos.legend.pure.generated.Root_meta_pure_router_extension_RouterExtension 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)

Example 3 with Root_meta_pure_router_extension_RouterExtension

use of org.finos.legend.pure.generated.Root_meta_pure_router_extension_RouterExtension in project legend-sdlc by finos.

the class ServicesGenerationMojo method execute.

@Override
public void execute() throws MojoExecutionException {
    if (this.inclusions != null) {
        getLog().info("include service paths: " + this.inclusions.servicePaths);
        getLog().info("include service packages: " + this.inclusions.packages);
        getLog().info("include service directories: " + Arrays.toString(this.inclusions.directories));
    }
    if (this.exclusions != null) {
        getLog().info("exclude service paths: " + this.exclusions.servicePaths);
        getLog().info("exclude service packages: " + this.exclusions.packages);
        getLog().info("exclude service directories: " + Arrays.toString(this.exclusions.directories));
    }
    getLog().info("package prefix: " + ((this.packagePrefix == null) ? null : ('"' + this.packagePrefix + '"')));
    getLog().info("Java source output directory: " + this.javaSourceOutputDirectory);
    getLog().info("resource output directory: " + this.resourceOutputDirectory);
    if ((this.packagePrefix != null) && !SourceVersion.isName(this.packagePrefix)) {
        throw new MojoExecutionException("Invalid package prefix: " + this.packagePrefix);
    }
    getLog().info("Loading model");
    long modelStart = System.nanoTime();
    PureModelBuilder pureModelBuilder = PureModelBuilder.newBuilder();
    try (EntityLoader allEntities = EntityLoader.newEntityLoader(Thread.currentThread().getContextClassLoader())) {
        pureModelBuilder.addEntitiesIfPossible(allEntities.getAllEntities());
    } catch (Exception e) {
        throw new MojoExecutionException("Error loading entities from model", e);
    }
    int elementCount = pureModelBuilder.getElementCount();
    getLog().info("Found " + elementCount + " elements in the model");
    if (elementCount == 0) {
        long modelEnd = System.nanoTime();
        getLog().info(String.format("Finished loading model (%.9fs)", (modelEnd - modelStart) / 1_000_000_000.0));
        getLog().info("No execution artifacts to generate");
        return;
    }
    PureModelBuilder.PureModelWithContextData pureModelWithContextData;
    try {
        pureModelWithContextData = pureModelBuilder.build();
    } catch (Exception e) {
        throw new MojoExecutionException("Error building Pure model", e);
    }
    PureModelContextData pureModelContextData = pureModelWithContextData.getPureModelContextData();
    PureModel pureModel = pureModelWithContextData.getPureModel();
    long modelEnd = System.nanoTime();
    getLog().info(String.format("Finished loading model (%.9fs)", (modelEnd - modelStart) / 1_000_000_000.0));
    JsonMapper jsonMapper = PureProtocolObjectMapperFactory.withPureProtocolExtensions(JsonMapper.builder().enable(SerializationFeature.INDENT_OUTPUT).enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS).enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY).disable(StreamWriteFeature.AUTO_CLOSE_TARGET).disable(StreamReadFeature.AUTO_CLOSE_SOURCE).serializationInclusion(JsonInclude.Include.NON_NULL).build());
    long start = System.nanoTime();
    Map<String, Service> servicesByPath = pureModelContextData.getElementsOfType(Service.class).stream().collect(Collectors.toMap(PackageableElement::getPath, el -> el));
    filterServicesByIncludes(servicesByPath);
    filterServicesByExcludes(servicesByPath);
    if (servicesByPath.isEmpty()) {
        getLog().info("Found 0 services for generation");
    } else if (getLog().isInfoEnabled()) {
        getLog().info(servicesByPath.keySet().stream().sorted().collect(Collectors.joining(", ", "Found " + servicesByPath.size() + " services for generation: ", "")));
    }
    for (Service service : servicesByPath.values()) {
        getLog().info("Generating execution artifacts for " + service.getPath());
        long serviceStart = System.nanoTime();
        try {
            MutableList<PlanGeneratorExtension> extensions = Lists.mutable.withAll(ServiceLoader.load(PlanGeneratorExtension.class));
            RichIterable<? extends Root_meta_pure_router_extension_RouterExtension> routerExtensions = extensions.flatCollect(e -> e.getExtraRouterExtensions(pureModel));
            MutableList<PlanTransformer> planTransformers = extensions.flatCollect(PlanGeneratorExtension::getExtraPlanTransformers);
            ServiceExecutionGenerator.newGenerator(service, pureModel, this.packagePrefix, this.javaSourceOutputDirectory.toPath(), this.resourceOutputDirectory.toPath(), jsonMapper, routerExtensions, planTransformers, null).generate();
        } catch (Exception e) {
            throw new MojoExecutionException("Error generating execution artifacts for " + service.getPath(), e);
        }
        long serviceEnd = System.nanoTime();
        getLog().info(String.format("Finished generating execution artifacts for %s (%.9fs)", service.getPath(), (serviceEnd - serviceStart) / 1_000_000_000.0));
    }
    long end = System.nanoTime();
    getLog().info(String.format("Finished generating execution artifacts for %d services (%.9fs)", servicesByPath.size(), (end - start) / 1_000_000_000.0));
}
Also used : Arrays(java.util.Arrays) PackageableElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement) Lists(org.eclipse.collections.api.factory.Lists) Parameter(org.apache.maven.plugins.annotations.Parameter) MutableList(org.eclipse.collections.api.list.MutableList) EntityToPureConverter(org.finos.legend.sdlc.protocol.pure.v1.EntityToPureConverter) ArrayList(java.util.ArrayList) MapperFeature(com.fasterxml.jackson.databind.MapperFeature) Mojo(org.apache.maven.plugins.annotations.Mojo) RichIterable(org.eclipse.collections.api.RichIterable) EntityLoader(org.finos.legend.sdlc.serialization.EntityLoader) PureModelContextData(org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData) Entity(org.finos.legend.sdlc.domain.model.entity.Entity) Map(java.util.Map) LifecyclePhase(org.apache.maven.plugins.annotations.LifecyclePhase) PlanTransformer(org.finos.legend.engine.plan.generation.transformers.PlanTransformer) PureModelBuilder(org.finos.legend.sdlc.language.pure.compiler.toPureGraph.PureModelBuilder) PureModel(org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel) Set(java.util.Set) ServiceLoader(java.util.ServiceLoader) StreamWriteFeature(com.fasterxml.jackson.core.StreamWriteFeature) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) StreamReadFeature(com.fasterxml.jackson.core.StreamReadFeature) JsonMapper(com.fasterxml.jackson.databind.json.JsonMapper) Collectors(java.util.stream.Collectors) Root_meta_pure_router_extension_RouterExtension(org.finos.legend.pure.generated.Root_meta_pure_router_extension_RouterExtension) File(java.io.File) SourceVersion(javax.lang.model.SourceVersion) List(java.util.List) Service(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Service) JsonInclude(com.fasterxml.jackson.annotation.JsonInclude) PureProtocolObjectMapperFactory(org.finos.legend.engine.protocol.pure.v1.PureProtocolObjectMapperFactory) SerializationFeature(com.fasterxml.jackson.databind.SerializationFeature) Comparator(java.util.Comparator) AbstractMojo(org.apache.maven.plugin.AbstractMojo) PlanGeneratorExtension(org.finos.legend.engine.plan.generation.extension.PlanGeneratorExtension) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) EntityLoader(org.finos.legend.sdlc.serialization.EntityLoader) PlanTransformer(org.finos.legend.engine.plan.generation.transformers.PlanTransformer) Service(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Service) PureModel(org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) JsonMapper(com.fasterxml.jackson.databind.json.JsonMapper) PlanGeneratorExtension(org.finos.legend.engine.plan.generation.extension.PlanGeneratorExtension) PureModelContextData(org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData) PureModelBuilder(org.finos.legend.sdlc.language.pure.compiler.toPureGraph.PureModelBuilder)

Aggregations

RichIterable (org.eclipse.collections.api.RichIterable)3 MutableList (org.eclipse.collections.api.list.MutableList)3 PureModel (org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel)3 Root_meta_pure_router_extension_RouterExtension (org.finos.legend.pure.generated.Root_meta_pure_router_extension_RouterExtension)3 List (java.util.List)2 ServiceLoader (java.util.ServiceLoader)2 Lists (org.eclipse.collections.api.factory.Lists)2 JsonInclude (com.fasterxml.jackson.annotation.JsonInclude)1 StreamReadFeature (com.fasterxml.jackson.core.StreamReadFeature)1 StreamWriteFeature (com.fasterxml.jackson.core.StreamWriteFeature)1 MapperFeature (com.fasterxml.jackson.databind.MapperFeature)1 SerializationFeature (com.fasterxml.jackson.databind.SerializationFeature)1 JsonMapper (com.fasterxml.jackson.databind.json.JsonMapper)1 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