Search in sources :

Example 1 with Root_meta_legend_service_metamodel_PureSingleExecution_Impl

use of org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_PureSingleExecution_Impl in project legend-engine by finos.

the class HelperServiceBuilder method processServiceExecution.

public static Root_meta_legend_service_metamodel_Execution processServiceExecution(Execution execution, CompileContext context) {
    if (execution instanceof PureSingleExecution) {
        PureSingleExecution pureSingleExecution = (PureSingleExecution) execution;
        Mapping mapping = context.resolveMapping(pureSingleExecution.mapping, pureSingleExecution.mappingSourceInformation);
        inferEmbeddedRuntimeMapping(pureSingleExecution.runtime, pureSingleExecution.mapping);
        org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Runtime runtime = HelperRuntimeBuilder.buildPureRuntime(pureSingleExecution.runtime, context);
        HelperRuntimeBuilder.checkRuntimeMappingCoverage(runtime, Lists.fixedSize.of(mapping), context, pureSingleExecution.runtime.sourceInformation);
        return new Root_meta_legend_service_metamodel_PureSingleExecution_Impl("")._func(HelperValueSpecificationBuilder.buildLambda(pureSingleExecution.func, context))._mapping(mapping)._runtime(runtime);
    } else if (execution instanceof PureMultiExecution) {
        PureMultiExecution pureMultiExecution = (PureMultiExecution) execution;
        if (pureMultiExecution.executionParameters.isEmpty()) {
            throw new EngineException("Service multi execution must not be empty", pureMultiExecution.sourceInformation, EngineErrorType.COMPILATION);
        }
        Set<String> executionKeyValues = new HashSet<>();
        return new Root_meta_legend_service_metamodel_PureMultiExecution_Impl("")._executionKey(pureMultiExecution.executionKey)._func(HelperValueSpecificationBuilder.buildLambda(pureMultiExecution.func, context))._executionParameters(ListIterate.collect(pureMultiExecution.executionParameters, executionParameter -> processServiceKeyedExecutionParameter(executionParameter, context, executionKeyValues)));
    }
    return getServiceCompilerExtensions(context).stream().flatMap(extension -> extension.getExtraServiceExecutionProcessors().stream()).map(processor -> processor.value(execution, context)).filter(Objects::nonNull).findFirst().orElseThrow(() -> new UnsupportedOperationException("Unsupported service execution type '" + execution.getClass().getSimpleName() + "'"));
}
Also used : EngineErrorType(org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType) KeyedExecutionParameter(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.KeyedExecutionParameter) KeyedSingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.KeyedSingleExecutionTest) MultiExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.MultiExecutionTest) StringUtils(org.apache.commons.lang3.StringUtils) org.finos.legend.engine.language.pure.compiler.toPureGraph(org.finos.legend.engine.language.pure.compiler.toPureGraph) Root_meta_legend_service_metamodel_Execution(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_Execution) HashSet(java.util.HashSet) PackageableElementPointer(org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer) EngineRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime) Root_meta_legend_service_metamodel_KeyedSingleExecutionTest(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_KeyedSingleExecutionTest) Root_meta_legend_service_metamodel_KeyedExecutionParameter_Impl(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_KeyedExecutionParameter_Impl) Root_meta_legend_service_metamodel_MultiExecutionTest_Impl(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_MultiExecutionTest_Impl) Root_meta_legend_service_metamodel_KeyedExecutionParameter(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_KeyedExecutionParameter) Root_meta_legend_service_metamodel_SingleExecutionTest_Impl(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_SingleExecutionTest_Impl) Root_meta_legend_service_metamodel_TestContainer(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_TestContainer) Root_meta_legend_service_metamodel_KeyedSingleExecutionTest_Impl(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_KeyedSingleExecutionTest_Impl) Execution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Execution) Set(java.util.Set) ListIterate(org.eclipse.collections.impl.utility.ListIterate) Collectors(java.util.stream.Collectors) Root_meta_legend_service_metamodel_TestContainer_Impl(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_TestContainer_Impl) Root_meta_legend_service_metamodel_MultiExecutionTest(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_MultiExecutionTest) Root_meta_legend_service_metamodel_PureMultiExecution_Impl(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_PureMultiExecution_Impl) Objects(java.util.Objects) PackageableElementType(org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementType) ServiceTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.ServiceTest) List(java.util.List) PureMultiExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureMultiExecution) Mapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping) PureSingleExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureSingleExecution) Lists(org.eclipse.collections.impl.factory.Lists) SingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.SingleExecutionTest) TestContainer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.TestContainer) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) Root_meta_legend_service_metamodel_Test(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_Test) Root_meta_legend_service_metamodel_PureSingleExecution_Impl(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_PureSingleExecution_Impl) Root_meta_legend_service_metamodel_PureSingleExecution_Impl(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_PureSingleExecution_Impl) HashSet(java.util.HashSet) Set(java.util.Set) PureMultiExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureMultiExecution) PureSingleExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureSingleExecution) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) Mapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping) Objects(java.util.Objects) Root_meta_legend_service_metamodel_PureMultiExecution_Impl(org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_PureMultiExecution_Impl)

Aggregations

HashSet (java.util.HashSet)1 List (java.util.List)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Lists (org.eclipse.collections.impl.factory.Lists)1 ListIterate (org.eclipse.collections.impl.utility.ListIterate)1 org.finos.legend.engine.language.pure.compiler.toPureGraph (org.finos.legend.engine.language.pure.compiler.toPureGraph)1 EngineErrorType (org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType)1 PackageableElementPointer (org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer)1 PackageableElementType (org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementType)1 EngineRuntime (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime)1 Execution (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Execution)1 KeyedExecutionParameter (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.KeyedExecutionParameter)1 KeyedSingleExecutionTest (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.KeyedSingleExecutionTest)1 MultiExecutionTest (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.MultiExecutionTest)1 PureMultiExecution (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureMultiExecution)1 PureSingleExecution (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureSingleExecution)1 ServiceTest (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.ServiceTest)1