From b2c726c48348b2a718b4c6fb13513672389b8a26 Mon Sep 17 00:00:00 2001 From: Mohammed Ibrahim Date: Tue, 5 Nov 2024 18:29:09 -0500 Subject: [PATCH] Add Function model to artifact --- .../api/HostedServiceService.java | 2 +- .../HostedServiceArtifactGenerator.java | 20 ++++++++++++++++++- ...tedServiceArtifactGenerationExtension.java | 3 ++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java index 3b9cb4ac6c7..4de4ffd2de5 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-api/src/main/java/org/finos/legend/engine/language/hostedService/api/HostedServiceService.java @@ -101,7 +101,7 @@ public MutableList validate(Identity identity, @Override public HostedServiceArtifact renderArtifact(PureModel pureModel, Root_meta_external_function_activator_hostedService_HostedService activator, PureModelContext inputModel, String clientVersion, Function> routerExtensions) { - return new HostedServiceArtifact(activator._pattern(), this.hostedServiceArtifactgenerator.renderArtifact(pureModel,activator,inputModel,clientVersion,routerExtensions), ((Root_meta_external_function_activator_DeploymentOwnership)activator._ownership())._id(), null); + return this.hostedServiceArtifactgenerator.renderServiceArtifact(pureModel, activator, inputModel, clientVersion, routerExtensions); } @Override diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/HostedServiceArtifactGenerator.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/HostedServiceArtifactGenerator.java index 8fb9839e8a4..41f3df42a9f 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/HostedServiceArtifactGenerator.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/HostedServiceArtifactGenerator.java @@ -43,6 +43,9 @@ import org.finos.legend.pure.generated.Root_meta_pure_extension_Extension; import org.finos.legend.pure.generated.core_hostedservice_generation_generation; import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.ConcreteFunctionDefinition; +import org.finos.legend.pure.m3.navigation.function.FunctionDescriptor; +import org.finos.legend.pure.m3.navigation.function.InvalidFunctionDescriptorException; +import org.slf4j.Logger; import java.util.List; import java.util.Map; @@ -52,6 +55,7 @@ public class HostedServiceArtifactGenerator { + private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(HostedServiceArtifactGenerator.class); static final MutableList generatorExtensions = Lists.mutable.withAll(ServiceLoader.load(PlanGeneratorExtension.class)); public static GenerationInfoData renderArtifact(PureModel pureModel, Root_meta_external_function_activator_hostedService_HostedService activator, PureModelContext inputModel, String clientVersion, Function> routerExtensions) @@ -100,8 +104,22 @@ public static String generateLineage(PureModel pureModel, Root_meta_external_fun public static PureModelContextData fetchHostedService(Root_meta_external_function_activator_hostedService_HostedService activator, PureModelContextData data, PureModel pureModel) { + MutableList elements = org.eclipse.collections.api.factory.Lists.mutable.withAll(data.getElements()); + HostedService h = (HostedService)elements.select(e -> e instanceof HostedService && elementToPath(activator, pureModel).equals(e.getPath())).getFirst(); + org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function f = (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function)elements.select(e -> + { + try + { + return e instanceof org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function && e.getPath().equals(FunctionDescriptor.functionDescriptorToId(h.function.path)); + } + catch (InvalidFunctionDescriptorException invalidFunctionDescriptorException) + { + invalidFunctionDescriptorException.printStackTrace(); + } + return false; + }).getFirst(); return PureModelContextData.newBuilder() - .withElements(org.eclipse.collections.api.factory.Lists.mutable.withAll(data.getElements()).select(e -> e instanceof HostedService && elementToPath(activator, pureModel).equals(fullName(e)))) + .withElements(Lists.mutable.with(h,f)) .withOrigin(data.origin).build(); } diff --git a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceArtifactGenerationExtension.java b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceArtifactGenerationExtension.java index 111f9f95ac1..f191ebb96c9 100644 --- a/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceArtifactGenerationExtension.java +++ b/legend-engine-xts-hostedService/legend-engine-xt-hostedService-generation/src/main/java/org/finos/legend/engine/language/hostedService/generation/deployment/HostedServiceArtifactGenerationExtension.java @@ -94,7 +94,8 @@ public List generate(PackageableElement element, PureModel pureModel, public PureModelContextPointer generatePointerForActivator(PureModelContextData activator, PureModelContextData originalModel) { PureModelContextPointer origin = originalModel.getOrigin(); - origin.sdlcInfo.packageableElementPointers = Lists.mutable.with(new PackageableElementPointer(PackageableElementType.SERVICE, elementName(activator.getElementsOfType(HostedService.class).get(0)))); + origin.sdlcInfo.packageableElementPointers = Lists.mutable.with(new PackageableElementPointer(PackageableElementType.SERVICE, activator.getElementsOfType(HostedService.class).get(0).getPath()), + new PackageableElementPointer(PackageableElementType.FUNCTION, activator.getElementsOfType(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Function.class).get(0).getPath())); return origin; }