Skip to content

Commit

Permalink
Add Function model to artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
Yasirmod17 committed Nov 5, 2024
1 parent b63158e commit b2c726c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public MutableList<? extends FunctionActivatorError> validate(Identity identity,
@Override
public HostedServiceArtifact renderArtifact(PureModel pureModel, Root_meta_external_function_activator_hostedService_HostedService activator, PureModelContext inputModel, String clientVersion, Function<PureModel, RichIterable<? extends Root_meta_pure_extension_Extension>> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -52,6 +55,7 @@

public class HostedServiceArtifactGenerator
{
private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(HostedServiceArtifactGenerator.class);
static final MutableList<PlanGeneratorExtension> 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<PureModel, RichIterable<? extends Root_meta_pure_extension_Extension>> routerExtensions)
Expand Down Expand Up @@ -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<org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement> 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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public List<Artifact> 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;
}

Expand Down

0 comments on commit b2c726c

Please sign in to comment.