use of org.finos.legend.pure.generated.Root_meta_legend_service_metamodel_Execution 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() + "'"));
}
Aggregations