From 17d118c8206ca6b753c2831e39a9f5b05d8e325f Mon Sep 17 00:00:00 2001 From: Aziem Chawdhary Date: Fri, 22 Nov 2024 15:29:16 +0000 Subject: [PATCH 1/2] Add milestoning test model defined in Pure --- .../platform/pure/grammar/milestoning.pure | 220 ++++++++++++++++++ 1 file changed, 220 insertions(+) diff --git a/legend-pure-core/legend-pure-m3-core/src/main/resources/platform/pure/grammar/milestoning.pure b/legend-pure-core/legend-pure-m3-core/src/main/resources/platform/pure/grammar/milestoning.pure index 2b10c7ff5f..0fe8b2fbf0 100644 --- a/legend-pure-core/legend-pure-m3-core/src/main/resources/platform/pure/grammar/milestoning.pure +++ b/legend-pure-core/legend-pure-m3-core/src/main/resources/platform/pure/grammar/milestoning.pure @@ -57,6 +57,226 @@ native function <> meta::pure::functions::colle native function <> meta::pure::functions::collection::getAll(type:Class[1], milestoningDate:Date[1]):T[*]; native function <> meta::pure::functions::collection::getAll(type:Class[1], processingDate:Date[1], businessDate:Date[1]):T[*]; +Class meta::pure::test::model::ClassWithNoMilestoning +{ + toClass1 : meta::pure::test::model::ClassWithMilestoning1[0..1]; + toClass2 : meta::pure::test::model::ClassWithMilestoning2[0..1]; + toClass3 : meta::pure::test::model::ClassWithMilestoning3[0..1]; +} + +Class <> meta::pure::test::model::ClassWithMilestoning1 +{ + toClass2 : meta::pure::test::model::ClassWithMilestoning2[0..1]; + toClass3 : meta::pure::test::model::ClassWithMilestoning3[*]; +} + +Class <> meta::pure::test::model::ClassWithMilestoning2 +{ + toClass1 : meta::pure::test::model::ClassWithMilestoning1[0..1]; + toClass3 : meta::pure::test::model::ClassWithMilestoning3[*]; +} + +Class <> meta::pure::test::model::ClassWithMilestoning3 +{ + toClass1 : meta::pure::test::model::ClassWithMilestoning1[0..1]; + toClass2 : meta::pure::test::model::ClassWithMilestoning2[0..1]; +} + +Association meta::pure::test::model::AssociationWithMilestoning1 +{ + toClass1A : meta::pure::test::model::ClassWithMilestoning1[*]; + toClass2A : meta::pure::test::model::ClassWithMilestoning2[*]; +} + + +Association meta::pure::test::model::AssociationWithMilestoning2 +{ + toClass1B : meta::pure::test::model::ClassWithMilestoning1[*]; + toClass3B : meta::pure::test::model::ClassWithMilestoning3[*]; +} + +Association meta::pure::test::model::AssociationWithMilestoning3 +{ + toClass2C : meta::pure::test::model::ClassWithMilestoning2[*]; + toClass3C : meta::pure::test::model::ClassWithMilestoning3[*]; +} + +function <> meta::pure::test::model::TestNonTemporalClass():Any[*] +{ + let cls = meta::pure::test::model::ClassWithNoMilestoning; + + let props = $cls.properties; + assertEquals(3, $props->size()); + + let qualifiedProperties = $cls.qualifiedProperties; + + assertEquals('toClass1(Date[1])', $qualifiedProperties->at(0).id); + assertEquals(2, $qualifiedProperties->at(0)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass1AllVersionsInRange(Date[1],Date[1])', $qualifiedProperties->at(1).id); + assertEquals(3, $qualifiedProperties->at(1)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass2(Date[1])', $qualifiedProperties->at(2).id); + assertEquals('toClass2AllVersionsInRange(Date[1],Date[1])', $qualifiedProperties->at(3).id); + assertEquals('toClass3(Date[1],Date[1])', $qualifiedProperties->at(4).id); +} + +function <> meta::pure::test::model::TestBusinessTemporalClass():Any[*] +{ + let cls = meta::pure::test::model::ClassWithMilestoning1; + + let props = $cls.properties; + assertEquals(4, $props->size()); + + assertEquals('businessDate', $props->at(0).name); + assertEquals('milestoning', $props->at(1).name); + assertEquals('toClass2AllVersions', $props->at(2).name); + assertEquals('toClass3AllVersions', $props->at(3).name); + + let propertiesFromAssociations = $cls.propertiesFromAssociations; + + assertEquals('toClass2AAllVersions', $propertiesFromAssociations->at(0).name); + assertEquals('toClass3BAllVersions', $propertiesFromAssociations->at(1).name); + + let qualifiedProperties = $cls.qualifiedProperties; + + assertEquals('toClass2(Date[1])', $qualifiedProperties->at(0).id); + assertEquals(2, $qualifiedProperties->at(0)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass2AllVersionsInRange(Date[1],Date[1])', $qualifiedProperties->at(1).id); + assertEquals(3, $qualifiedProperties->at(1)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass3(Date[1],Date[1])', $qualifiedProperties->at(2).id); + assertEquals(3, $qualifiedProperties->at(2)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass3(Date[1])', $qualifiedProperties->at(3).id); + assertEquals(2, $qualifiedProperties->at(3)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + let qpFromAssociations = $cls.qualifiedPropertiesFromAssociations; + + assertEquals('toClass2A(Date[1])', $qpFromAssociations->at(0).id); + assertEquals(2, $qpFromAssociations->at(0)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass2AAllVersionsInRange(Date[1],Date[1])', $qpFromAssociations->at(1).id); + assertEquals(3, $qpFromAssociations->at(1)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass3B(Date[1],Date[1])', $qpFromAssociations->at(2).id); + assertEquals(3, $qpFromAssociations->at(2)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass3B(Date[1])', $qpFromAssociations->at(3).id); + assertEquals(2, $qpFromAssociations->at(3)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + +} + +function <> meta::pure::test::model::TestProcessingTemporalClass():Any[*] +{ + let cls = meta::pure::test::model::ClassWithMilestoning2; + + let props = $cls.properties; + assertEquals(4, $props->size()); + + assertEquals('processingDate', $props->at(0).name); + assertEquals('milestoning', $props->at(1).name); + assertEquals('toClass1AllVersions', $props->at(2).name); + assertEquals('toClass3AllVersions', $props->at(3).name); + + let propertiesFromAssociations = $cls.propertiesFromAssociations; + + assertEquals('toClass1AAllVersions', $propertiesFromAssociations->at(0).name); + assertEquals('toClass3CAllVersions', $propertiesFromAssociations->at(1).name); + + let qualifiedProperties = $cls.qualifiedProperties; + + assertEquals('toClass1(Date[1])', $qualifiedProperties->at(0).id); + assertEquals(2, $qualifiedProperties->at(0)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass1AllVersionsInRange(Date[1],Date[1])', $qualifiedProperties->at(1).id); + assertEquals(3, $qualifiedProperties->at(1)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass3(Date[1],Date[1])', $qualifiedProperties->at(2).id); + assertEquals(3, $qualifiedProperties->at(2)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass3(Date[1])', $qualifiedProperties->at(3).id); + assertEquals(2, $qualifiedProperties->at(3)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + let qpFromAssociations = $cls.qualifiedPropertiesFromAssociations; + assertEquals('toClass1A(Date[1])', $qpFromAssociations->at(0).id); + assertEquals(2, $qpFromAssociations->at(0)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass1AAllVersionsInRange(Date[1],Date[1])', $qpFromAssociations->at(1).id); + assertEquals(3, $qpFromAssociations->at(1)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass3C(Date[1],Date[1])', $qpFromAssociations->at(2).id); + assertEquals(3, $qpFromAssociations->at(2)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass3C(Date[1])', $qpFromAssociations->at(3).id); + assertEquals(2, $qpFromAssociations->at(3)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); +} + + +function <> meta::pure::test::model::TestBiTemporalClass():Any[*] +{ + let cls = meta::pure::test::model::ClassWithMilestoning3; + + let props = $cls.properties; + assertEquals(5, $props->size()); + assertEquals('processingDate', $props->at(0).name); + assertEquals('businessDate', $props->at(1).name); + assertEquals('milestoning', $props->at(2).name); + assertEquals('toClass1AllVersions', $props->at(3).name); + assertEquals('toClass2AllVersions', $props->at(4).name); + + let propertiesFromAssociations = $cls.propertiesFromAssociations; + + assertEquals('toClass2CAllVersions', $propertiesFromAssociations->at(0).name); + assertEquals('toClass1BAllVersions', $propertiesFromAssociations->at(1).name); + + let qualifiedProperties = $cls.qualifiedProperties; + assertEquals('toClass1()', $qualifiedProperties->at(0).id); + assertEquals(1, $qualifiedProperties->at(0)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass1(Date[1])', $qualifiedProperties->at(1).id); + assertEquals(2, $qualifiedProperties->at(1)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass1AllVersionsInRange(Date[1],Date[1])', $qualifiedProperties->at(2).id); + assertEquals(3, $qualifiedProperties->at(2)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass2()', $qualifiedProperties->at(3).id); + assertEquals(1, $qualifiedProperties->at(3)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass2(Date[1])', $qualifiedProperties->at(4).id); + assertEquals(2, $qualifiedProperties->at(4)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass2AllVersionsInRange(Date[1],Date[1])', $qualifiedProperties->at(5).id); + assertEquals(3, $qualifiedProperties->at(5)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + let qpFromAssociations = $cls.qualifiedPropertiesFromAssociations; + assertEquals('toClass2C()', $qpFromAssociations->at(0).id); + assertEquals(1, $qpFromAssociations->at(0)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass2C(Date[1])', $qpFromAssociations->at(1).id); + assertEquals(2, $qpFromAssociations->at(1)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass2CAllVersionsInRange(Date[1],Date[1])', $qpFromAssociations->at(2).id); + assertEquals(3, $qpFromAssociations->at(2)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass1B()', $qpFromAssociations->at(3).id); + assertEquals(1, $qpFromAssociations->at(3)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass1B(Date[1])', $qpFromAssociations->at(4).id); + assertEquals(2, $qpFromAssociations->at(4)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); + + assertEquals('toClass1BAllVersionsInRange(Date[1],Date[1])', $qpFromAssociations->at(5).id); + assertEquals(3, $qpFromAssociations->at(5)->genericType().typeArguments->at(0).rawType->toOne()->cast(@FunctionType).parameters->size()); +} + +function <> meta::pure::test::model::TestMilestoning():Boolean[1] +{ + let instances = ^meta::pure::test::model::ClassWithMilestoning1(businessDate = %2020-01-01); + let result1 = meta::pure::test::model::ClassWithMilestoning1.all(%2020-01-01); + assertEquals(1, $result1->size()); +} + From 8203e617339ec9f6cf111f79fe17225cc78dbb24 Mon Sep 17 00:00:00 2001 From: Aziem Chawdhary Date: Fri, 22 Nov 2024 15:29:29 +0000 Subject: [PATCH 2/2] Update project ID --- .gs-project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gs-project.yml b/.gs-project.yml index 2a5a55a0bc..904c6f1b48 100644 --- a/.gs-project.yml +++ b/.gs-project.yml @@ -1 +1 @@ -productGuid: "product::315843" +productGuid: "product::781483"