From 9a9014e4446edc60632701ee8949fdf16e9a623e Mon Sep 17 00:00:00 2001 From: PrateekGarg-gs Date: Thu, 14 Sep 2023 20:26:32 +0530 Subject: [PATCH] Create nonMilestonedSourceToMilestonedTargetProperty.pure --- ...tonedSourceToMilestonedTargetProperty.pure | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/modelToModelToRelational/milestoned/nonMilestonedSourceToMilestonedTargetProperty.pure diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/modelToModelToRelational/milestoned/nonMilestonedSourceToMilestonedTargetProperty.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/modelToModelToRelational/milestoned/nonMilestonedSourceToMilestonedTargetProperty.pure new file mode 100644 index 00000000000..fe1c8d90a80 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/modelToModelToRelational/milestoned/nonMilestonedSourceToMilestonedTargetProperty.pure @@ -0,0 +1,112 @@ +// Copyright 2023 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +###Pure +import meta::pure::mapping::*; +import meta::pure::milestoning::*; +import meta::pure::graphFetch::tests::m2m2r::milestoning::*; +import meta::pure::graphFetch::execution::*; +import meta::pure::alloy::connections::alloy::specification::*; +import meta::pure::alloy::connections::alloy::authentication::*; +import meta::pure::runtime::*; + +//empty target property in result because source is not milestoned +function <> meta::pure::graphFetch::tests::m2m2r::milestoning::nonMilestonedSourceToMilestonedTargetProperty::testWithHardcodedDate():Boolean[1] +{ + let mapping = meta::relational::tests::m2m2r::milestoning::nonMilestonedSourceToMilestonedTargetProperty::TargetToModelMappingWithMilestonedComplexProperty; + let runtime = getModelChainRuntime($mapping); + + let query={|meta::relational::tests::milestoning::TargetProductMilestoned.all(%2023-10-15T00:00:00)->graphFetch( + #{ + meta::relational::tests::milestoning::TargetProductMilestoned{ + id, + name, + synonymsMilestoned(%2020-10-15T00:00:00) + {synonym} + } + }# + )->serialize( + #{ + meta::relational::tests::milestoning::TargetProductMilestoned{ + id, + name, + synonymsMilestoned(%2020-10-15T00:00:00) + {synonym} + } + }# + ) + ->meta::pure::mapping::from($mapping,$runtime) + }; + let result = meta::legend::executeLegendQuery($query, [], ^meta::pure::runtime::ExecutionContext(), meta::relational::extension::relationalExtensions()); + assertJsonStringsEqual('{"builder":{"_type":"json"},"values":['+ + '{"id":2,"name":"ProductName2","synonymsMilestoned(2020-10-15T00:00:00+0000)":[]},'+ + '{"id":3,"name":"ProductName3","synonymsMilestoned(2020-10-15T00:00:00+0000)":[]}'+ + ']}', $result); +} + +//todo - fix source tree calc for allVersions on target +function <> meta::pure::graphFetch::tests::m2m2r::milestoning::nonMilestonedSourceToMilestonedTargetProperty::testAllVersionsQuery():Boolean[1] +{ + let mapping =meta::relational::tests::m2m2r::milestoning::nonMilestonedSourceToMilestonedTargetProperty::TargetToModelMappingWithMilestonedComplexProperty; + let runtime = getModelChainRuntime($mapping); + + let query={|meta::relational::tests::milestoning::TargetProductMilestoned.all(%2023-10-15T00:00:00)->graphFetch( + #{ + meta::relational::tests::milestoning::TargetProductMilestoned{ + id, + name, + synonymsMilestonedAllVersions + {synonym} + } + }# + )->serialize( + #{ + meta::relational::tests::milestoning::TargetProductMilestoned{ + id, + name, + synonymsMilestonedAllVersions + {synonym} + } + }# + ) + ->meta::pure::mapping::from($mapping,$runtime) + }; + let result = meta::legend::executeLegendQuery($query, [], ^meta::pure::runtime::ExecutionContext(), meta::relational::extension::relationalExtensions()); + assertJsonStringsEqual('{"builder":{"_type":"json"},"values":['+ + '{"id":2,"name":"ProductName2","synonymNames":["GS-Mod-S0","GS-Mod-S1","GS-Mod-S2","GS-Mod-S3"]},'+ + '{"id":3,"name":"ProductName3","synonymNames":["GS-Mod-S2","GS-Mod-S3"]}'+ + ']}', $result); +} + + +###Mapping +import meta::relational::tests::*; +Mapping meta::relational::tests::m2m2r::milestoning::nonMilestonedSourceToMilestonedTargetProperty::TargetToModelMappingWithMilestonedComplexProperty +( + include meta::relational::tests::milestoning::milestoningMapSmall + + *meta::relational::tests::milestoning::TargetProductMilestoned: Pure + { + ~src meta::relational::tests::milestoning::ProductMilestoned + id: $src.id, + name: $src.name, + synonymsMilestonedAllVersions: $src.synonymsNonMilestoned + } + + *meta::relational::tests::milestoning::TargetProductSynonymMilestoned: Pure + { + ~src meta::relational::tests::milestoning::ProductSynonymNonMilestoned + synonym: $src.synonym + } +)