From a8519901c85cdd5f6f2200ee6eea0fe5a7ed2a88 Mon Sep 17 00:00:00 2001 From: gs-rpant1729 Date: Sat, 25 Jan 2025 01:20:46 +0530 Subject: [PATCH] support Relation Function class mapping (#3837) --- .changeset/tame-islands-enjoy.md | 6 + .../function-activator/FunctionEditor.tsx | 30 ++--- .../uml-editor/ClassQueryBuilder.tsx | 4 +- .../src/stores/editor/NewElementState.ts | 6 +- .../testable/FunctionTestableState.ts | 2 +- .../mapping/MappingEditorState.ts | 13 +++ .../mapping/MappingElementDecorator.ts | 13 +++ .../DomainGraphModifierHelper.ts | 8 +- .../TEST_DATA__DomainRoundtrip.ts | 6 +- .../DSL_Mapping_ObserverHelper.ts | 14 +++ .../changeDetection/DomainObserverHelper.ts | 2 +- .../mapping/V1_ClassMapping.ts | 4 + .../mapping/V1_PropertyMapping.ts | 4 + .../V1_RelationFunctionClassMapping.ts | 60 ++++++++++ .../V1_RelationFunctionPropertyMapping.ts | 57 ++++++++++ .../pureGraph/from/V1_DomainTransformer.ts | 19 +++- .../pureGraph/from/V1_MappingTransformer.ts | 71 ++++++++++++ .../to/V1_ClassMappingFirstPassBuilder.ts | 18 +++ .../to/V1_ClassMappingSecondPassBuilder.ts | 46 ++++++++ .../to/V1_ElementFirstPassBuilder.ts | 7 +- .../to/V1_ElementSecondPassBuilder.ts | 9 +- .../pureGraph/to/V1_GraphBuilderContext.ts | 21 +++- .../pureGraph/to/V1_PropertyMappingBuilder.ts | 91 ++++++++++++++++ .../V1_ValueSpecificationBuilderHelper.ts | 4 +- .../V1_MappingSerializationHelper.ts | 59 ++++++++++ .../legend-graph/src/graph/Core_HashUtils.ts | 2 + .../src/graph/helpers/DomainHelper.ts | 16 ++- .../src/graph/helpers/PureLanguageHelper.ts | 16 ++- .../__tests__/PureLanguageHelper.test.ts | 15 +++ ...EST_DATA__FunctionSignatureGeneration.json | 40 +++++++ .../function/ConcreteFunctionDefinition.ts | 9 +- .../mapping/PropertyMapping.ts | 4 + .../mapping/SetImplementation.ts | 6 +- ...lationFunctionInstanceSetImplementation.ts | 58 ++++++++++ .../RelationFunctionPropertyMapping.ts | 72 ++++++++++++ packages/legend-graph/src/index.ts | 1 + ..._Relational-relation-function-mapping.pure | 99 +++++++++++++++++ ...ational-and-relation-function-mapping.pure | 103 ++++++++++++++++++ 38 files changed, 964 insertions(+), 51 deletions(-) create mode 100644 .changeset/tame-islands-enjoy.md create mode 100644 packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_RelationFunctionClassMapping.ts create mode 100644 packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_RelationFunctionPropertyMapping.ts create mode 100644 packages/legend-graph/src/graph/metamodel/pure/packageableElements/mapping/relationFunction/RelationFunctionInstanceSetImplementation.ts create mode 100644 packages/legend-graph/src/graph/metamodel/pure/packageableElements/mapping/relationFunction/RelationFunctionPropertyMapping.ts create mode 100644 packages/legend-manual-tests/src/__tests__/roundtrip-grammar/cases/STO_Relational-relation-function-mapping.pure create mode 100644 packages/legend-manual-tests/src/__tests__/roundtrip-grammar/cases/STO_Relational-relational-and-relation-function-mapping.pure diff --git a/.changeset/tame-islands-enjoy.md b/.changeset/tame-islands-enjoy.md new file mode 100644 index 0000000000..8e73cc6cfc --- /dev/null +++ b/.changeset/tame-islands-enjoy.md @@ -0,0 +1,6 @@ +--- +'@finos/legend-application-studio': patch +'@finos/legend-graph': patch +--- + +Support Relation Function class mapping in Studio. diff --git a/packages/legend-application-studio/src/components/editor/editor-group/function-activator/FunctionEditor.tsx b/packages/legend-application-studio/src/components/editor/editor-group/function-activator/FunctionEditor.tsx index 21201e09f1..469f98fa35 100644 --- a/packages/legend-application-studio/src/components/editor/editor-group/function-activator/FunctionEditor.tsx +++ b/packages/legend-application-studio/src/components/editor/editor-group/function-activator/FunctionEditor.tsx @@ -104,6 +104,7 @@ import { DatabaseType, RelationalDatabaseConnection, type FunctionActivator, + GenericType, } from '@finos/legend-graph'; import { type ApplicationStore, @@ -120,7 +121,7 @@ import { } from '@finos/legend-lego/graph-editor'; import { getElementIcon } from '../../../ElementIconUtils.js'; import { - function_setReturnType, + function_setReturnGenericType, function_setReturnMultiplicity, function_addParameter, function_deleteParameter, @@ -502,7 +503,7 @@ const ReturnTypeEditor = observer( editorStore.graphManagerState.usableClassPropertyTypes.map( buildElementOption, ); - const typeName = getFunctionParameterType(returnType.value); + const typeName = getFunctionParameterType(returnType.value.rawType); const filterOption = createFilter({ ignoreCase: true, ignoreAccents: false, @@ -510,21 +511,24 @@ const ReturnTypeEditor = observer( option.data.value.path, }); const selectedType = { - value: returnType.value, - label: returnType.value.name, + value: returnType.value.rawType, + label: returnType.value.rawType.name, }; const changeType = (val: PackageableElementOption): void => { - function_setReturnType(functionElement, val.value); + function_setReturnGenericType( + functionElement, + new GenericType(val.value), + ); setIsEditingType(false); updateFunctionName(editorStore, applicationStore, functionElement); }; const openElement = (): void => { - if (!(returnType.value instanceof PrimitiveType)) { + if (!(returnType.value.rawType instanceof PrimitiveType)) { editorStore.graphEditorMode.openElement( - returnType.value instanceof Unit - ? returnType.value.measure - : returnType.value, + returnType.value.rawType instanceof Unit + ? returnType.value.rawType.measure + : returnType.value.rawType, ); } }; @@ -597,11 +601,11 @@ const ReturnTypeEditor = observer( > {typeName !== FUNCTION_PARAMETER_TYPE.PRIMITIVE && (
- {getElementIcon(returnType.value, editorStore)} + {getElementIcon(returnType.value.rawType, editorStore)}
)}
- {returnType.value.name} + {returnType.value.rawType.name}
{typeName !== FUNCTION_PARAMETER_TYPE.PRIMITIVE && (
- {getElementIcon(returnType.value, editorStore)} + {getElementIcon(returnType.value.rawType, editorStore)}
)}
- {returnType.value.name} + {returnType.value.rawType.name}
{typeName !== FUNCTION_PARAMETER_TYPE.PRIMITIVE && (