diff --git a/legend-engine-external-shared/src/main/java/org/finos/legend/engine/external/shared/format/imports/PureModelContextDataGenerator.java b/legend-engine-external-shared/src/main/java/org/finos/legend/engine/external/shared/format/imports/PureModelContextDataGenerator.java index 06a8b44e703..06f2a6e058d 100644 --- a/legend-engine-external-shared/src/main/java/org/finos/legend/engine/external/shared/format/imports/PureModelContextDataGenerator.java +++ b/legend-engine-external-shared/src/main/java/org/finos/legend/engine/external/shared/format/imports/PureModelContextDataGenerator.java @@ -277,10 +277,13 @@ public static PureModelContextData generatePureModelContextDataFromAssociations( { try { - builder.addElement(objectMapper.readValue(org.finos.legend.pure.generated.core_pure_protocol_protocol.Root_meta_alloy_metadataServer_alloyToJSON_Any_1__String_1_("vX_X_X".equals(pureVersion) ? transformMethod.invoke(null, association, core_pure_extensions_functions.Root_meta_pure_extension_defaultExtensions__Extension_MANY_(compiledExecutionSupport), compiledExecutionSupport) : transformMethod.invoke(null, association, compiledExecutionSupport), compiledExecutionSupport), Association.class)); + builder.addElement(objectMapper.readValue(org.finos.legend.pure.generated.core_pure_protocol_protocol.Root_meta_alloy_metadataServer_alloyToJSON_Any_1__String_1_( + transformMethod.invoke(null, association, core_pure_extensions_functions.Root_meta_pure_extension_defaultExtensions__Extension_MANY_(compiledExecutionSupport), + compiledExecutionSupport), compiledExecutionSupport), Association.class)); } - catch (Exception ignored) + catch (Exception e) { + throw new RuntimeException(e); } }); return builder.build(); diff --git a/legend-engine-xt-data-space-api/src/test/java/org/finos/legend/engine/api/analytics/test/TestDataSpaceAnalyticsApi.java b/legend-engine-xt-data-space-api/src/test/java/org/finos/legend/engine/api/analytics/test/TestDataSpaceAnalyticsApi.java index d5159c76290..30ac56cd3c2 100644 --- a/legend-engine-xt-data-space-api/src/test/java/org/finos/legend/engine/api/analytics/test/TestDataSpaceAnalyticsApi.java +++ b/legend-engine-xt-data-space-api/src/test/java/org/finos/legend/engine/api/analytics/test/TestDataSpaceAnalyticsApi.java @@ -68,6 +68,14 @@ public void testDataSpaceAnalysisWithMappingAnalytics() throws IOException testAnalyticsWithVersions(expected, modelContextData, "model::animal::AnimalDS"); } + @Test + public void testDataSpaceAnalysisWithAssociation() throws IOException + { + PureModelContextData modelContextData = objectMapper.readValue(Objects.requireNonNull(getClass().getClassLoader().getResource("dataSpaceAnalyticsWithAssociation.json")), PureModelContextData.class); + String expected = "{\"defaultExecutionContext\":\"dummyContext\",\"description\":\"Not over yet?\",\"executionContexts\":[{\"compatibleRuntimes\":[\"runtime::MyRuntime\"],\"defaultRuntime\":\"runtime::MyRuntime\",\"mapping\":\"mapping::CovidDataMapping\",\"mappingModelCoverageAnalysisResult\":{\"mappedEntities\":[]},\"name\":\"dummyContext\"},{\"compatibleRuntimes\":[\"runtime::MyRuntime\"],\"defaultRuntime\":\"runtime::MyRuntime\",\"mapping\":\"mapping::CovidDataMapping\",\"mappingModelCoverageAnalysisResult\":{\"mappedEntities\":[]},\"name\":\"dummyContext2\"}],\"featuredDiagrams\":[\"domain::COVIDDataDiagram\"],\"model\":{\"_type\":\"data\",\"elements\":[{\"_type\":\"class\",\"constraints\":[],\"name\":\"COVIDData\",\"originalMilestonedProperties\":[],\"package\":\"domain\",\"properties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"id\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"Integer\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"fips\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"String\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"date\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"StrictDate\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"caseType\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"String\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"cases\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"Float\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"lastReportedFlag\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"Boolean\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"demographics\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"domain::Demographics\"}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"diagram\",\"classViews\":[{\"class\":\"domain::COVIDData\",\"id\":\"6b69f44b-f729-46aa-b244-ec5ee8164142\",\"position\":{\"x\":280.0,\"y\":159.0},\"rectangle\":{\"height\":128.0,\"width\":205.8291015625}},{\"class\":\"domain::Demographics\",\"id\":\"159e797e-ae75-437d-ba9c-253f99a48826\",\"position\":{\"x\":698.0,\"y\":238.0},\"rectangle\":{\"height\":58.0,\"width\":111.68994140625}},{\"class\":\"domain::Class1\",\"id\":\"f6bd8a50-8d18-4bd9-9a8d-7fad88d02b07\",\"position\":{\"x\":360.844970703125,\"y\":49.0},\"rectangle\":{\"height\":58.0,\"width\":137.390625}},{\"class\":\"domain::Class2\",\"id\":\"690e89d4-23e9-46e8-8543-c89c22cc9e15\",\"position\":{\"x\":696.844970703125,\"y\":95.0},\"rectangle\":{\"height\":44.0,\"width\":133.68994140625}}],\"generalizationViews\":[],\"name\":\"COVIDDataDiagram\",\"package\":\"domain\",\"propertyViews\":[{\"line\":{\"points\":[{\"x\":382.91455078125,\"y\":223.0},{\"x\":753.844970703125,\"y\":267.0}]},\"property\":{\"class\":\"domain::COVIDData\",\"property\":\"demographics\"},\"sourceView\":\"6b69f44b-f729-46aa-b244-ec5ee8164142\",\"targetView\":\"159e797e-ae75-437d-ba9c-253f99a48826\"},{\"line\":{\"points\":[{\"x\":763.68994140625,\"y\":117.0},{\"x\":429.540283203125,\"y\":78.0}]},\"property\":{\"class\":\"domain::Class2\",\"property\":\"fromClass1\"},\"sourceView\":\"690e89d4-23e9-46e8-8543-c89c22cc9e15\",\"targetView\":\"f6bd8a50-8d18-4bd9-9a8d-7fad88d02b07\"},{\"line\":{\"points\":[{\"x\":429.540283203125,\"y\":78.0},{\"x\":763.68994140625,\"y\":117.0}]},\"property\":{\"class\":\"domain::Class1\",\"property\":\"fromClass2\"},\"sourceView\":\"f6bd8a50-8d18-4bd9-9a8d-7fad88d02b07\",\"targetView\":\"690e89d4-23e9-46e8-8543-c89c22cc9e15\"}]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"Class1\",\"originalMilestonedProperties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"fromClass2\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"domain::Class2\"}],\"package\":\"domain\",\"properties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"propClass1\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"String\"}],\"qualifiedProperties\":[],\"stereotypes\":[{\"profile\":\"meta::pure::profiles::temporal\",\"value\":\"businesstemporal\"}],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"association\",\"name\":\"Class12Assoc\",\"originalMilestonedProperties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"fromClass1\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"domain::Class1\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"fromClass2\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"domain::Class2\"}],\"package\":\"domain\",\"properties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"fromClass1\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"domain::Class1\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"fromClass2\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"domain::Class2\"}],\"qualifiedProperties\":[],\"stereotypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"Class2\",\"originalMilestonedProperties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"fromClass1\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"domain::Class1\"}],\"package\":\"domain\",\"properties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"propClass2\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"String\"}],\"qualifiedProperties\":[],\"stereotypes\":[{\"profile\":\"meta::pure::profiles::temporal\",\"value\":\"processingtemporal\"}],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"Demographics\",\"originalMilestonedProperties\":[],\"package\":\"domain\",\"properties\":[{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"fips\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"String\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"state\",\"stereotypes\":[],\"taggedValues\":[],\"type\":\"String\"}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"BusinessDateMilestoning\",\"originalMilestonedProperties\":[],\"package\":\"meta::pure::milestoning\",\"properties\":[],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ProcessingDateMilestoning\",\"originalMilestonedProperties\":[],\"package\":\"meta::pure::milestoning\",\"properties\":[],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"temporal\",\"package\":\"meta::pure::profiles\",\"stereotypes\":[\"bitemporal\",\"businesstemporal\",\"processingtemporal\"],\"tags\":[]}]},\"name\":\"COVIDDatapace\",\"package\":\"domain\",\"path\":\"domain::COVIDDatapace\",\"stereotypes\":[],\"taggedValues\":[],\"title\":\"COVID Sample Data\"}"; + testAnalyticsWithVersions(expected, modelContextData, "domain::COVIDDatapace"); + } + private void testAnalyticsWithVersions(String expected, PureModelContextData modelContextData, String dataSpace) { diff --git a/legend-engine-xt-data-space-api/src/test/resources/dataSpaceAnalyticsWithAssociation.json b/legend-engine-xt-data-space-api/src/test/resources/dataSpaceAnalyticsWithAssociation.json new file mode 100644 index 00000000000..a6414d75b16 --- /dev/null +++ b/legend-engine-xt-data-space-api/src/test/resources/dataSpaceAnalyticsWithAssociation.json @@ -0,0 +1,363 @@ +{ + "_type": "data", + "elements": [ + { + "_type": "class", + "name": "Demographics", + "package": "domain", + "properties": [ + { + "multiplicity": { + "lowerBound": 0, + "upperBound": 1 + }, + "name": "fips", + "type": "String" + }, + { + "multiplicity": { + "lowerBound": 0, + "upperBound": 1 + }, + "name": "state", + "type": "String" + } + ] + }, + { + "_type": "class", + "name": "Class2", + "package": "domain", + "properties": [ + { + "multiplicity": { + "lowerBound": 1, + "upperBound": 1 + }, + "name": "propClass2", + "type": "String" + } + ], + "stereotypes": [ + { + "profile": "meta::pure::profiles::temporal", + "value": "processingtemporal" + } + ] + }, + { + "_type": "class", + "name": "COVIDData", + "package": "domain", + "properties": [ + { + "multiplicity": { + "lowerBound": 1, + "upperBound": 1 + }, + "name": "id", + "type": "Integer" + }, + { + "multiplicity": { + "lowerBound": 0, + "upperBound": 1 + }, + "name": "fips", + "type": "String" + }, + { + "multiplicity": { + "lowerBound": 0, + "upperBound": 1 + }, + "name": "date", + "type": "StrictDate" + }, + { + "multiplicity": { + "lowerBound": 0, + "upperBound": 1 + }, + "name": "caseType", + "type": "String" + }, + { + "multiplicity": { + "lowerBound": 0, + "upperBound": 1 + }, + "name": "cases", + "type": "Float" + }, + { + "multiplicity": { + "lowerBound": 0, + "upperBound": 1 + }, + "name": "lastReportedFlag", + "type": "Boolean" + }, + { + "multiplicity": { + "lowerBound": 0, + "upperBound": 1 + }, + "name": "demographics", + "type": "domain::Demographics" + } + ] + }, + { + "_type": "class", + "name": "Class1", + "package": "domain", + "properties": [ + { + "multiplicity": { + "lowerBound": 1, + "upperBound": 1 + }, + "name": "propClass1", + "type": "String" + } + ], + "stereotypes": [ + { + "profile": "meta::pure::profiles::temporal", + "value": "businesstemporal" + } + ] + }, + { + "_type": "association", + "name": "Class12Assoc", + "package": "domain", + "properties": [ + { + "multiplicity": { + "lowerBound": 1, + "upperBound": 1 + }, + "name": "fromClass1", + "type": "domain::Class1" + }, + { + "multiplicity": { + "lowerBound": 1, + "upperBound": 1 + }, + "name": "fromClass2", + "type": "domain::Class2" + } + ] + }, + { + "_type": "mapping", + "classMappings": [], + "enumerationMappings": [], + "includedMappings": [], + "name": "CovidDataMapping", + "package": "mapping", + "tests": [] + }, + { + "_type": "runtime", + "name": "MyRuntime", + "package": "runtime", + "runtimeValue": { + "_type": "engineRuntime", + "connections": [ + { + "store": { + "path": "ModelStore", + "type": "STORE" + }, + "storeConnections": [ + { + "connection": { + "_type": "connectionPointer", + "connection": "runtime::connection::MyConnection" + }, + "id": "connection_1" + } + ] + } + ], + "mappings": [ + { + "path": "mapping::CovidDataMapping", + "type": "MAPPING" + } + ] + } + }, + { + "_type": "connection", + "connectionValue": { + "_type": "JsonModelConnection", + "class": "domain::COVIDData", + "element": "ModelStore", + "url": "data:application/json,%7B%7D" + }, + "name": "MyConnection", + "package": "runtime::connection" + }, + { + "_type": "diagram", + "classViews": [ + { + "class": "domain::COVIDData", + "id": "6b69f44b-f729-46aa-b244-ec5ee8164142", + "position": { + "x": 280, + "y": 159 + }, + "rectangle": { + "height": 128, + "width": 205.8291015625 + } + }, + { + "class": "domain::Demographics", + "id": "159e797e-ae75-437d-ba9c-253f99a48826", + "position": { + "x": 698, + "y": 238 + }, + "rectangle": { + "height": 58, + "width": 111.68994140625 + } + }, + { + "class": "domain::Class1", + "id": "f6bd8a50-8d18-4bd9-9a8d-7fad88d02b07", + "position": { + "x": 360.844970703125, + "y": 49 + }, + "rectangle": { + "height": 58, + "width": 137.390625 + } + }, + { + "class": "domain::Class2", + "id": "690e89d4-23e9-46e8-8543-c89c22cc9e15", + "position": { + "x": 696.844970703125, + "y": 95 + }, + "rectangle": { + "height": 44, + "width": 133.68994140625 + } + } + ], + "generalizationViews": [], + "name": "COVIDDataDiagram", + "package": "domain", + "propertyViews": [ + { + "line": { + "points": [ + { + "x": 382.91455078125, + "y": 223 + }, + { + "x": 753.844970703125, + "y": 267 + } + ] + }, + "property": { + "class": "domain::COVIDData", + "property": "demographics" + }, + "sourceView": "6b69f44b-f729-46aa-b244-ec5ee8164142", + "targetView": "159e797e-ae75-437d-ba9c-253f99a48826" + }, + { + "line": { + "points": [ + { + "x": 763.68994140625, + "y": 117 + }, + { + "x": 429.540283203125, + "y": 78 + } + ] + }, + "property": { + "class": "domain::Class2", + "property": "fromClass1" + }, + "sourceView": "690e89d4-23e9-46e8-8543-c89c22cc9e15", + "targetView": "f6bd8a50-8d18-4bd9-9a8d-7fad88d02b07" + }, + { + "line": { + "points": [ + { + "x": 429.540283203125, + "y": 78 + }, + { + "x": 763.68994140625, + "y": 117 + } + ] + }, + "property": { + "class": "domain::Class1", + "property": "fromClass2" + }, + "sourceView": "f6bd8a50-8d18-4bd9-9a8d-7fad88d02b07", + "targetView": "690e89d4-23e9-46e8-8543-c89c22cc9e15" + } + ] + }, + { + "_type": "dataSpace", + "defaultExecutionContext": "dummyContext", + "description": "Not over yet?", + "executionContexts": [ + { + "defaultRuntime": { + "path": "runtime::MyRuntime", + "type": "RUNTIME" + }, + "mapping": { + "path": "mapping::CovidDataMapping", + "type": "MAPPING" + }, + "name": "dummyContext" + }, + { + "defaultRuntime": { + "path": "runtime::MyRuntime", + "type": "RUNTIME" + }, + "mapping": { + "path": "mapping::CovidDataMapping", + "type": "MAPPING" + }, + "name": "dummyContext2" + } + ], + "featuredDiagrams": [ + { + "path": "domain::COVIDDataDiagram", + "type": "DIAGRAM" + } + ], + "name": "COVIDDatapace", + "package": "domain", + "title": "COVID Sample Data" + } + ] +} \ No newline at end of file