From 39b038be8d18efd48c4f9bf11a2836bc370b9e23 Mon Sep 17 00:00:00 2001 From: An Phi Date: Sun, 9 Oct 2022 03:25:20 -0400 Subject: [PATCH] cleanup after #1504 --- .changeset/rude-vans-rhyme.md | 15 + .../mapping-editor/ClassMappingEditor.tsx | 123 ++---- .../EnumerationMappingEditor.tsx | 6 +- .../InstanceSetImplementationEditor.tsx | 6 +- .../mapping-editor/PropertyMappingsEditor.tsx | 401 +++++++++--------- ...LegendStudioApplicationPlugin_Extension.ts | 9 - .../src/stores/EditorGraphState.ts | 66 +-- .../mapping/MappingElementDecorator.ts | 24 +- .../DSL_Mapping_GraphModifierHelper.ts | 35 +- .../src/stores/shared/ModelClassifierUtils.ts | 11 - .../_mapping-element-editor.scss | 17 +- .../_property-mapping-editor.scss | 54 ++- ...iceStore_LegendStudioApplicationPlugin.tsx | 14 - 13 files changed, 327 insertions(+), 454 deletions(-) create mode 100644 .changeset/rude-vans-rhyme.md diff --git a/.changeset/rude-vans-rhyme.md b/.changeset/rude-vans-rhyme.md new file mode 100644 index 0000000000..46f16a67b8 --- /dev/null +++ b/.changeset/rude-vans-rhyme.md @@ -0,0 +1,15 @@ +--- +'@finos/legend-application': patch +'@finos/legend-application-query': patch +'@finos/legend-application-studio': patch +'@finos/legend-application-taxonomy': patch +'@finos/legend-art': patch +'@finos/legend-extension-dsl-data-space': patch +'@finos/legend-extension-dsl-diagram': patch +'@finos/legend-extension-dsl-service': patch +'@finos/legend-extension-dsl-text': patch +'@finos/legend-extension-format-morphir': patch +'@finos/legend-extension-store-service-store': patch +'@finos/legend-query-builder': patch +'@finos/legend-shared': patch +--- diff --git a/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/ClassMappingEditor.tsx b/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/ClassMappingEditor.tsx index db8ade5c32..5e39813d7f 100644 --- a/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/ClassMappingEditor.tsx +++ b/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/ClassMappingEditor.tsx @@ -29,10 +29,10 @@ import { MappingEditorState } from '../../../../stores/editor-state/element-edit import { useEditorStore } from '../../EditorStoreProvider.js'; import { type SetImplementation, - type PureInstanceSetImplementation, - type FlatDataInstanceSetImplementation, - type EmbeddedFlatDataPropertyMapping, - type RootRelationalInstanceSetImplementation, + PureInstanceSetImplementation, + FlatDataInstanceSetImplementation, + EmbeddedFlatDataPropertyMapping, + RootRelationalInstanceSetImplementation, fromElementPathToMappingElementId, OperationSetImplementation, OperationType, @@ -41,9 +41,8 @@ import { setImpl_nominateRoot, operationMapping_setOperation, operationMapping_setParameters, - setImpl_setRoot, + setImplementation_setRoot, } from '../../../../stores/graphModifier/DSL_Mapping_GraphModifierHelper.js'; -import { SET_IMPLEMENTATION_TYPE } from '../../../../stores/shared/ModelClassifierUtils.js'; import type { DSL_Mapping_LegendStudioApplicationPlugin_Extension } from '../../../../stores/DSL_Mapping_LegendStudioApplicationPlugin_Extension.js'; export const OperatorSelector = observer( @@ -94,8 +93,6 @@ export const ClassMappingEditor = observer( const editorStore = useEditorStore(); const mappingEditorState = editorStore.getCurrentEditorState(MappingEditorState); - const setImplementationType = - editorStore.graphState.getSetImplementationType(setImplementation); const _class = setImplementation.class; // ID const isDefaultId = @@ -113,62 +110,47 @@ export const ClassMappingEditor = observer( let sourceType = ''; let sourceName: string | undefined; - switch (setImplementationType) { - case SET_IMPLEMENTATION_TYPE.PUREINSTANCE: { - sourceType = CLASS_MAPPING_SOURCE_TYPE.CLASS; - sourceName = (setImplementation as PureInstanceSetImplementation) - .srcClass?.value.name; - break; - } - case SET_IMPLEMENTATION_TYPE.FLAT_DATA: { - sourceType = CLASS_MAPPING_SOURCE_TYPE.FLAT_DATA; - sourceName = (setImplementation as FlatDataInstanceSetImplementation) - .sourceRootRecordType.value._OWNER.name; - break; - } - case SET_IMPLEMENTATION_TYPE.EMBEDDED_FLAT_DATA: { - sourceType = CLASS_MAPPING_SOURCE_TYPE.FLAT_DATA; - const flatDataInstanceSetImpl = - setImplementation as EmbeddedFlatDataPropertyMapping; - sourceName = ( - flatDataInstanceSetImpl.rootInstanceSetImplementation as FlatDataInstanceSetImplementation - ).sourceRootRecordType.value._OWNER.name; - break; - } - case SET_IMPLEMENTATION_TYPE.RELATIONAL: { - sourceType = CLASS_MAPPING_SOURCE_TYPE.RELATIONAL; - sourceName = ( - setImplementation as RootRelationalInstanceSetImplementation - ).mainTableAlias?.relation.value.name; - break; - } - case SET_IMPLEMENTATION_TYPE.OPERATION: - sourceType = CLASS_MAPPING_SOURCE_TYPE.OPERATION; - break; - default: { - const extraMappingSourceTypeInfoGetters = editorStore.pluginManager - .getApplicationPlugins() - .flatMap( - (plugin) => - ( - plugin as DSL_Mapping_LegendStudioApplicationPlugin_Extension - ).getExtraMappingSourceTypeInfoGetters?.() ?? [], - ); - for (const sourceTypeInfoGetter of extraMappingSourceTypeInfoGetters) { - const mappingSourceTypeInfo = sourceTypeInfoGetter(setImplementation); - if (mappingSourceTypeInfo) { - sourceType = mappingSourceTypeInfo.sourceType; - sourceName = mappingSourceTypeInfo.sourceName; - } + if (setImplementation instanceof PureInstanceSetImplementation) { + sourceType = CLASS_MAPPING_SOURCE_TYPE.CLASS; + sourceName = setImplementation.srcClass?.value.name; + } else if (setImplementation instanceof FlatDataInstanceSetImplementation) { + sourceType = CLASS_MAPPING_SOURCE_TYPE.FLAT_DATA; + sourceName = setImplementation.sourceRootRecordType.value._OWNER.name; + } else if (setImplementation instanceof EmbeddedFlatDataPropertyMapping) { + sourceType = CLASS_MAPPING_SOURCE_TYPE.FLAT_DATA; + sourceName = ( + setImplementation.rootInstanceSetImplementation as FlatDataInstanceSetImplementation + ).sourceRootRecordType.value._OWNER.name; + } else if ( + setImplementation instanceof RootRelationalInstanceSetImplementation + ) { + sourceType = CLASS_MAPPING_SOURCE_TYPE.RELATIONAL; + sourceName = setImplementation.mainTableAlias?.relation.value.name; + } else if (setImplementation instanceof OperationSetImplementation) { + sourceType = CLASS_MAPPING_SOURCE_TYPE.OPERATION; + } else { + const extraMappingSourceTypeInfoGetters = editorStore.pluginManager + .getApplicationPlugins() + .flatMap( + (plugin) => + ( + plugin as DSL_Mapping_LegendStudioApplicationPlugin_Extension + ).getExtraMappingSourceTypeInfoGetters?.() ?? [], + ); + for (const sourceTypeInfoGetter of extraMappingSourceTypeInfoGetters) { + const mappingSourceTypeInfo = sourceTypeInfoGetter(setImplementation); + if (mappingSourceTypeInfo) { + sourceType = mappingSourceTypeInfo.sourceType; + sourceName = mappingSourceTypeInfo.sourceName; + break; } - break; } } const toggleRoot = (): void => { if (!isReadOnly) { const isRoot = setImplementation.root.value; - setImpl_setRoot(setImplementation, !isRoot); + setImplementation_setRoot(setImplementation, !isRoot); if (setImplementation.root.value) { setImpl_nominateRoot(setImplementation); } @@ -201,31 +183,12 @@ export const ClassMappingEditor = observer( - {/* Driver */} -
-
- using -
-
- {setImplementationType.toUpperCase()} -
-
{/* Instance Set Implementation Source */} - {setImplementationType !== SET_IMPLEMENTATION_TYPE.OPERATION && ( + {!(setImplementation instanceof OperationSetImplementation) && (
)} {/* Operation Set Implementation Operator */} - {setImplementationType === SET_IMPLEMENTATION_TYPE.OPERATION && ( + {setImplementation instanceof OperationSetImplementation && (
diff --git a/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.tsx b/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.tsx index b98540c377..6ae5a06e31 100644 --- a/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.tsx +++ b/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.tsx @@ -64,7 +64,7 @@ import { PackageableElementExplicitReference, } from '@finos/legend-graph'; import { - enumMapping_updateSourceType, + enumerationMapping_updateSourceType, enumValueMapping_addSourceValue, enumValueMapping_deleteSourceValue, enumValueMapping_updateSourceValue, @@ -115,7 +115,7 @@ const EnumerationMappingSourceSelectorModal = observer( ): void => { const value = val?.value; if (!value || value instanceof Type) { - enumMapping_updateSourceType( + enumerationMapping_updateSourceType( enumerationMapping, value ? PackageableElementExplicitReference.create(value) : undefined, ); @@ -368,7 +368,7 @@ export const EnumerationMappingEditor = observer( const handleDrop = useCallback( (item: MappingElementSourceDropTarget): void => { if (!isReadOnly && item.data.packageableElement instanceof Type) { - enumMapping_updateSourceType( + enumerationMapping_updateSourceType( enumerationMapping, PackageableElementExplicitReference.create( item.data.packageableElement, diff --git a/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/InstanceSetImplementationEditor.tsx b/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/InstanceSetImplementationEditor.tsx index 395674b9ff..f84c922c29 100644 --- a/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/InstanceSetImplementationEditor.tsx +++ b/packages/legend-application-studio/src/components/editor/edit-panel/mapping-editor/InstanceSetImplementationEditor.tsx @@ -51,7 +51,7 @@ import { } from '../../../../stores/editor-state/element-editor-state/mapping/MappingEditorState.js'; import { TypeTree } from '../../../shared/TypeTree.js'; import { FlatDataRecordTypeTree } from './FlatDataRecordTypeTree.js'; -import { PropertyMappingsEditor } from './PropertyMappingsEditor.js'; +import { PropertyMappingEditor } from './PropertyMappingsEditor.js'; import { useDrop } from 'react-dnd'; import { FlatDataInstanceSetImplementationState } from '../../../../stores/editor-state/element-editor-state/mapping/FlatDataInstanceSetImplementationState.js'; import { MappingElementDecorationCleaner } from '../../../../stores/editor-state/element-editor-state/mapping/MappingElementDecorator.js'; @@ -540,7 +540,7 @@ export const InstanceSetImplementationEditor = observer( {!isReadOnly && !isUnsupported && sortedProperties.map((property) => ( - ( - { + const { + children, + instanceSetImplementationState, + propertyMappingStates, + propertyMappingState, + propertyBasicType, + } = props; + + const removePropertyMapping = (pm: PropertyMapping): void => { + instanceSetImplementation_deletePropertyMapping( + instanceSetImplementationState.mappingElement, + pm, + ); + instanceSetImplementationState.decorate(); + }; + + return ( +
+ {children} + {propertyMappingStates.length > 1 && + propertyBasicType !== CLASS_PROPERTY_TYPE.CLASS && ( + + )} +
+ ); + }, +); + +export const PropertyMappingEditor = observer( (props: { property: Property; instanceSetImplementationState: InstanceSetImplementationState; isReadOnly: boolean; }) => { const { instanceSetImplementationState, property, isReadOnly } = props; + const instanceSetImplementation = + instanceSetImplementationState.mappingElement; const validationErrorMessage = - instanceSetImplementationState.mappingElement.propertyMappings.filter( + instanceSetImplementation.propertyMappings.filter( (pm) => pm.property.value === property, ).length > 1 && !(property.genericType.value.rawType instanceof Class) - ? 'Only one property mapping should exist per simple type (e.g. primitive, measure, unit) or enumeration type property' + ? 'Only one property mapping should exist per property of type other than class (e.g. primitive, measure, enumeration)' : undefined; const editorStore = useEditorStore(); const applicationStore = useApplicationStore(); @@ -104,12 +153,7 @@ export const PropertyMappingsEditor = observer( editorStore.getCurrentEditorState(MappingEditorState); const propertyRawType = property.genericType.value.rawType; const propertyBasicType = getClassPropertyType(propertyRawType); - const instanceSetImplementationType = - editorStore.graphState.getSetImplementationType( - instanceSetImplementationState.mappingElement, - ); - const isEmbedded = - instanceSetImplementationState.mappingElement._isEmbedded; + const isEmbedded = instanceSetImplementation._isEmbedded; // Parser Error const propertyMappingStates: PropertyMappingState[] = instanceSetImplementationState.propertyMappingStates.filter( @@ -123,22 +167,20 @@ export const PropertyMappingsEditor = observer( (pm) => pm.parserError, ), ); - const removePropertyMapping = (pm: PropertyMapping): void => { - instanceSetImpl_deletePropertyMapping( - instanceSetImplementationState.mappingElement, - pm, - ); - instanceSetImplementationState.decorate(); - }; - // Walker - // TODO: revisit this behavior now that we have more types of property mapping to support - // e.g. embedded, target set implementation, etc. - // See https://github.com/finos/legend-studio/issues/310 + + /** + * TODO: revisit this behavior now that we have more types of property mapping to support + * e.g. embedded, target set implementation, etc. + * See https://github.com/finos/legend-studio/issues/310 + * + * @modularize + * TODO: modularize this for other types + * See https://github.com/finos/legend-studio/issues/65 + */ const visitOrCreateMappingElement = (): void => { if (propertyRawType instanceof Class) { if ( - instanceSetImplementationState.mappingElement instanceof - PureInstanceSetImplementation + instanceSetImplementation instanceof PureInstanceSetImplementation ) { const rootMappingElement = getRootSetImplementation( mappingEditorState.mapping, @@ -146,7 +188,7 @@ export const PropertyMappingsEditor = observer( ); if (rootMappingElement) { if (!rootMappingElement.root.value) { - setImpl_setRoot(rootMappingElement, true); + setImplementation_setRoot(rootMappingElement, true); } const parent = rootMappingElement._PARENT; if (parent !== mappingEditorState.element) { @@ -204,6 +246,91 @@ export const PropertyMappingsEditor = observer( } }; + const renderPropertyMappingEntry = ( + propertyMappingState: PropertyMappingState, + ): React.ReactNode => { + if (instanceSetImplementation instanceof PureInstanceSetImplementation) { + return ( + + ); + } else if ( + instanceSetImplementation instanceof + FlatDataInstanceSetImplementation || + instanceSetImplementation instanceof EmbeddedFlatDataPropertyMapping + ) { + return ( + + ); + } else if ( + instanceSetImplementation instanceof + RootRelationalInstanceSetImplementation + ) { + return ( + + ); + } else { + const extraPropertyMappingEditorRenderers = editorStore.pluginManager + .getApplicationPlugins() + .flatMap( + (plugin) => + ( + plugin as DSL_Mapping_LegendStudioApplicationPlugin_Extension + ).getExtraPropertyMappingEditorRenderers?.() ?? [], + ); + for (const renderer of extraPropertyMappingEditorRenderers) { + const renderedPropertyMappingEditor = renderer( + instanceSetImplementationState, + propertyMappingState, + ); + if (renderedPropertyMappingEditor) { + return ( + + {renderedPropertyMappingEditor} + + ); + } + } + + return ( +
+ Unsupported property mapping +
+ ); + } + }; + return (
-
+
{property.name}
{validationErrorMessage && ( @@ -271,184 +398,50 @@ export const PropertyMappingsEditor = observer(
-
- {propertyMappingStates.map((propertyMappingState) => { - switch (instanceSetImplementationType) { - case SET_IMPLEMENTATION_TYPE.PUREINSTANCE: { - return ( -
- - {propertyMappingStates.length > 1 && - propertyBasicType !== CLASS_PROPERTY_TYPE.CLASS && ( - - )} -
- ); - } - case SET_IMPLEMENTATION_TYPE.FLAT_DATA: - case SET_IMPLEMENTATION_TYPE.EMBEDDED_FLAT_DATA: { - return ( -
( + + {renderPropertyMappingEntry(propertyMappingState)} + + ))} + {propertyBasicType === CLASS_PROPERTY_TYPE.CLASS && + !propertyMappingStates.length && ( + <> + {isEmbedded && ( +
+ Click + - )} -
- ); - } - case SET_IMPLEMENTATION_TYPE.RELATIONAL: { - return ( -
+ + {`to create an embedded class mapping for property '${property.name}'.`} +
+ )} + {!isEmbedded && ( +
+ No set implementation found. Click + - )} -
- ); - } - default: { - const extraPropertyMappingEditorRenderers = - editorStore.pluginManager - .getApplicationPlugins() - .flatMap( - (plugin) => - ( - plugin as DSL_Mapping_LegendStudioApplicationPlugin_Extension - ).getExtraPropertyMappingEditorRenderers?.() ?? [], - ); - for (const renderer of extraPropertyMappingEditorRenderers) { - const renderedPropertyMappingEditor = renderer( - instanceSetImplementationState, - propertyMappingState, - ); - if (renderedPropertyMappingEditor) { - return renderedPropertyMappingEditor; - } - } - throw new UnsupportedOperationError( - `Can't render property mapping editor: no compatible renderer available from plugins`, - ); - } - } - })} - {propertyBasicType === CLASS_PROPERTY_TYPE.CLASS && - !propertyMappingStates.length && ( - <> - {isEmbedded && ( -
- Click - - {`to create an embedded class mapping for property '${property.name}'.`} -
- )} - {!isEmbedded && ( -
- No set implementation found. Click - - {`to create a root class mapping for '${propertyRawType.name}'.`} -
- )} - - )} -
+ + + {`to create a root class mapping for '${propertyRawType.name}'.`} +
+ )} + + )}
); diff --git a/packages/legend-application-studio/src/stores/DSL_Mapping_LegendStudioApplicationPlugin_Extension.ts b/packages/legend-application-studio/src/stores/DSL_Mapping_LegendStudioApplicationPlugin_Extension.ts index 6a4233e7c0..8f6f888e74 100644 --- a/packages/legend-application-studio/src/stores/DSL_Mapping_LegendStudioApplicationPlugin_Extension.ts +++ b/packages/legend-application-studio/src/stores/DSL_Mapping_LegendStudioApplicationPlugin_Extension.ts @@ -61,10 +61,6 @@ export type MappingElementSourceExtractor = ( mappingElement: MappingElement, ) => MappingElementSource | undefined; -export type SetImplemtationClassifier = ( - setImplementation: SetImplementation, -) => string | undefined; - export type MappingElementStateCreator = ( mappingElement: MappingElement | undefined, editorStore: EditorStore, @@ -135,11 +131,6 @@ export interface DSL_Mapping_LegendStudioApplicationPlugin_Extension */ getExtraSetImplementationMappingElementLabelInfoBuilders?(): SetImplementationMappingElementLabelInfoBuilder[]; - /** - * Get the list of set implementation classifiers. - */ - getExtraSetImplementationClassifiers?(): SetImplemtationClassifier[]; - /** * Get the list of the mapping element state creators for the given class mapping. */ diff --git a/packages/legend-application-studio/src/stores/EditorGraphState.ts b/packages/legend-application-studio/src/stores/EditorGraphState.ts index e61274cc40..79688c6229 100644 --- a/packages/legend-application-studio/src/stores/EditorGraphState.ts +++ b/packages/legend-application-studio/src/stores/EditorGraphState.ts @@ -52,16 +52,13 @@ import { ProjectDependencyInfo, } from '@finos/legend-server-depot'; import { - type SetImplementation, type PackageableElement, GRAPH_MANAGER_EVENT, CompilationError, EngineError, extractSourceInformationCoordinates, Package, - PureInstanceSetImplementation, Profile, - OperationSetImplementation, PrimitiveType, Enumeration, Class, @@ -70,8 +67,6 @@ import { ConcreteFunctionDefinition, Service, FlatData, - FlatDataInstanceSetImplementation, - EmbeddedFlatDataPropertyMapping, PackageableConnection, PackageableRuntime, FileGenerationSpecification, @@ -80,9 +75,6 @@ import { Unit, Database, SectionIndex, - RootRelationalInstanceSetImplementation, - EmbeddedRelationalInstanceSetImplementation, - AggregationAwareSetImplementation, DependencyGraphBuilderError, GraphDataDeserializationError, GraphBuilderError, @@ -99,12 +91,8 @@ import { CONFIGURATION_EDITOR_TAB, getConflictsString, } from './editor-state/ProjectConfigurationEditorState.js'; -import type { DSL_Mapping_LegendStudioApplicationPlugin_Extension } from './DSL_Mapping_LegendStudioApplicationPlugin_Extension.js'; import { graph_dispose } from './graphModifier/GraphModifierHelper.js'; -import { - PACKAGEABLE_ELEMENT_TYPE, - SET_IMPLEMENTATION_TYPE, -} from './shared/ModelClassifierUtils.js'; +import { PACKAGEABLE_ELEMENT_TYPE } from './shared/ModelClassifierUtils.js'; import { GlobalTestRunnerState } from './sidebar-state/testable/GlobalTestRunnerState.js'; import { LEGEND_STUDIO_APP_EVENT } from './LegendStudioAppEvent.js'; @@ -142,7 +130,6 @@ export class EditorGraphState { editorStore: false, graphGenerationState: false, getPackageableElementType: false, - getSetImplementationType: false, hasCompilationError: computed, clearCompilationError: action, }); @@ -1194,17 +1181,6 @@ export class EditorGraphState { } // -------------------------------------------------- UTILITIES ----------------------------------------------------- - /** - * NOTE: Notice how this utility draws resources from all of metamodels and uses `instanceof` to classify behavior/response. - * As such, methods in this utility cannot be placed in place they should belong to. - * - * For example: `getSetImplemetnationType` cannot be placed in `SetImplementation` because of circular module dependency - * So this utility is born for such purpose, to avoid circular module dependency, and it should just be used for only that - * Other utilities that really should reside in the domain-specific meta model should be placed in the meta model module. - * - * NOTE: We expect the need for these methods will eventually go away as we complete modularization. But we need these - * methods here so that we can load plugins. - */ getPackageableElementType(element: PackageableElement): string { if (element instanceof PrimitiveType) { @@ -1264,44 +1240,4 @@ export class EditorGraphState { `Can't get type label for element '${element.path}': no compatible label getter available from plugins`, ); } - - getSetImplementationType(setImplementation: SetImplementation): string { - if (setImplementation instanceof PureInstanceSetImplementation) { - return SET_IMPLEMENTATION_TYPE.PUREINSTANCE; - } else if (setImplementation instanceof OperationSetImplementation) { - return SET_IMPLEMENTATION_TYPE.OPERATION; - } else if (setImplementation instanceof FlatDataInstanceSetImplementation) { - return SET_IMPLEMENTATION_TYPE.FLAT_DATA; - } else if (setImplementation instanceof EmbeddedFlatDataPropertyMapping) { - return SET_IMPLEMENTATION_TYPE.EMBEDDED_FLAT_DATA; - } else if ( - setImplementation instanceof RootRelationalInstanceSetImplementation - ) { - return SET_IMPLEMENTATION_TYPE.RELATIONAL; - } else if ( - setImplementation instanceof EmbeddedRelationalInstanceSetImplementation - ) { - return SET_IMPLEMENTATION_TYPE.EMBEDDED_RELATIONAL; - } else if (setImplementation instanceof AggregationAwareSetImplementation) { - return SET_IMPLEMENTATION_TYPE.AGGREGATION_AWARE; - } - const extraSetImplementationClassifiers = this.editorStore.pluginManager - .getApplicationPlugins() - .flatMap( - (plugin) => - ( - plugin as DSL_Mapping_LegendStudioApplicationPlugin_Extension - ).getExtraSetImplementationClassifiers?.() ?? [], - ); - for (const Classifier of extraSetImplementationClassifiers) { - const setImplementationClassifier = Classifier(setImplementation); - if (setImplementationClassifier) { - return setImplementationClassifier; - } - } - throw new UnsupportedOperationError( - `Can't classify set implementation: no compatible classifer available from plugins`, - setImplementation, - ); - } } diff --git a/packages/legend-application-studio/src/stores/editor-state/element-editor-state/mapping/MappingElementDecorator.ts b/packages/legend-application-studio/src/stores/editor-state/element-editor-state/mapping/MappingElementDecorator.ts index a93d6e144c..9e80fcb170 100644 --- a/packages/legend-application-studio/src/stores/editor-state/element-editor-state/mapping/MappingElementDecorator.ts +++ b/packages/legend-application-studio/src/stores/editor-state/element-editor-state/mapping/MappingElementDecorator.ts @@ -67,10 +67,10 @@ import { } from '@finos/legend-graph'; import type { EditorStore } from '../../../EditorStore.js'; import { - enumMapping_setEnumValueMappings, + enumerationMapping_setEnumValueMappings, enumValueMapping_addSourceValue, enumValueMapping_setSourceValues, - instanceSetImpl_setPropertyMappings, + instanceSetImplementation_setPropertyMappings, operationMapping_setParameters, pureInstanceSetImpl_setPropertyMappings, purePropertyMapping_setTransformer, @@ -157,7 +157,7 @@ export class MappingElementDecorator implements SetImplementationVisitor { } }); if (enumValueMappingsToAdd.length) { - enumMapping_setEnumValueMappings( + enumerationMapping_setEnumValueMappings( enumerationMapping, enumerationMapping.enumValueMappings.concat(enumValueMappingsToAdd), ); @@ -311,6 +311,8 @@ export class MappingElementDecorator implements SetImplementationVisitor { pureInstanceSetImpl_setPropertyMappings( setImplementation, decoratedPropertyMappings.concat( + // NOTE: here, we remove some low-quality property mappings + // i.e. stubbed property mappings from before adding new decorated property mappings propertyMappingsBeforeDecoration .filter( (propertyMapping) => @@ -426,9 +428,12 @@ export class MappingElementDecorator implements SetImplementationVisitor { setImplementation, decoratePropertyMapping, ); - instanceSetImpl_setPropertyMappings( + instanceSetImplementation_setPropertyMappings( setImplementation, decoratedPropertyMappings.concat( + // NOTE: here, we remove some low-quality property mappings + // i.e. stubbed property mappings, incompatible property mappings + // from before adding new decorated property mappings propertyMappingsBeforeDecoration .filter( (propertyMapping) => @@ -595,9 +600,12 @@ export class MappingElementDecorator implements SetImplementationVisitor { setImplementation, decoratePropertyMapping, ); - instanceSetImpl_setPropertyMappings( + instanceSetImplementation_setPropertyMappings( setImplementation, decoratedPropertyMappings.concat( + // NOTE: here, we remove some low-quality property mappings + // i.e. stubbed property mappings, incompatible property mappings + // from before adding new decorated property mappings propertyMappingsBeforeDecoration .filter( (propertyMapping) => @@ -669,7 +677,7 @@ export class MappingElementDecorationCleaner enumValueMapping.sourceValues.filter(isNonNullable), ); }); - enumMapping_setEnumValueMappings( + enumerationMapping_setEnumValueMappings( enumerationMapping, nonEmptyEnumValueMappings, ); @@ -700,7 +708,7 @@ export class MappingElementDecorationCleaner visit_PureInstanceSetImplementation( setImplementation: PureInstanceSetImplementation, ): void { - instanceSetImpl_setPropertyMappings( + instanceSetImplementation_setPropertyMappings( setImplementation, setImplementation.propertyMappings.filter( (propertyMapping) => !isStubbed_RawLambda(propertyMapping.transform), @@ -714,7 +722,7 @@ export class MappingElementDecorationCleaner | FlatDataInstanceSetImplementation | EmbeddedFlatDataPropertyMapping, ): void { - instanceSetImpl_setPropertyMappings( + instanceSetImplementation_setPropertyMappings( setImplementation, setImplementation.propertyMappings.filter( (propertyMapping) => diff --git a/packages/legend-application-studio/src/stores/graphModifier/DSL_Mapping_GraphModifierHelper.ts b/packages/legend-application-studio/src/stores/graphModifier/DSL_Mapping_GraphModifierHelper.ts index 62d1de6485..54e96e648f 100644 --- a/packages/legend-application-studio/src/stores/graphModifier/DSL_Mapping_GraphModifierHelper.ts +++ b/packages/legend-application-studio/src/stores/graphModifier/DSL_Mapping_GraphModifierHelper.ts @@ -86,7 +86,7 @@ import { } from '@finos/legend-shared'; import { action } from 'mobx'; -export const instanceSetImpl_setPropertyMappings = action( +export const instanceSetImplementation_setPropertyMappings = action( ( si: InstanceSetImplementation, pm: PropertyMapping[], @@ -98,23 +98,18 @@ export const instanceSetImpl_setPropertyMappings = action( }, ); -export const instanceSetImpl_deletePropertyMapping = action( +export const instanceSetImplementation_deletePropertyMapping = action( (si: InstanceSetImplementation, pm: PropertyMapping): void => { - deleteEntry( - si.propertyMappings, - pm, - (p1, p2) => p1.property._UUID === p2.property._UUID, - ); + deleteEntry(si.propertyMappings, pm); }, ); -export const setImpl_setRoot = action( +export const setImplementation_setRoot = action( (owner: SetImplementation, val: boolean): void => { owner.root.value = val; }, ); -// export const mapping_addClassMapping = action( ( mapping: Mapping, @@ -179,13 +174,13 @@ export const mapping_addTest = action( // --------------------------------------------- Enumeration Mapping ------------------------------------- -export const enumMapping_setId = action( +export const enumerationMapping_setId = action( (eM: EnumerationMapping, val: string): void => { eM.id.value = val; }, ); -export const enumMapping_setSourceType = action( +export const enumerationMapping_setSourceType = action( ( eM: EnumerationMapping, value: PackageableElementReference | undefined, @@ -196,18 +191,18 @@ export const enumMapping_setSourceType = action( }, ); -export const enumMapping_setEnumValueMappings = action( +export const enumerationMapping_setEnumValueMappings = action( (eM: EnumerationMapping, value: EnumValueMapping[]): void => { eM.enumValueMappings = value.map(observe_EnumValueMapping); }, ); -export const enumMapping_updateSourceType = action( +export const enumerationMapping_updateSourceType = action( ( eM: EnumerationMapping, value: PackageableElementReference | undefined, ): void => { if (eM.sourceType?.value !== value?.value) { - enumMapping_setSourceType(eM, value); + enumerationMapping_setSourceType(eM, value); eM.enumValueMappings = eM.enumValueMappings.map((enumValueMapping) => { enumValueMapping.sourceValues = []; enumValueMapping.sourceValues.push( @@ -362,15 +357,15 @@ export const setImpl_updateRootOnCreate = action( setImp.class.value, ).filter((si) => si !== setImp); if (classMappingsWithSimilarTarget.length) { - setImpl_setRoot(setImp, false); + setImplementation_setRoot(setImp, false); if (classMappingsWithSimilarTarget.length === 1) { - setImpl_setRoot( + setImplementation_setRoot( classMappingsWithSimilarTarget[0] as SetImplementation, false, ); } } else { - setImpl_setRoot(setImp, true); + setImplementation_setRoot(setImp, true); } }, ); @@ -387,7 +382,7 @@ export const setImpl_updateRootOnDelete = action( setImp.class.value, ).filter((si) => si !== setImp); if (classMappingsWithSimilarTarget.length === 1) { - setImpl_setRoot( + setImplementation_setRoot( classMappingsWithSimilarTarget[0] as SetImplementation, false, ); @@ -409,10 +404,10 @@ export const setImpl_nominateRoot = action( ); classMappingsWithSimilarTarget.forEach((si) => { if (si !== setImp) { - setImpl_setRoot(si, false); + setImplementation_setRoot(si, false); } }); - setImpl_setRoot(setImp, true); + setImplementation_setRoot(setImp, true); }, ); diff --git a/packages/legend-application-studio/src/stores/shared/ModelClassifierUtils.ts b/packages/legend-application-studio/src/stores/shared/ModelClassifierUtils.ts index a126ea42e7..98a89fee74 100644 --- a/packages/legend-application-studio/src/stores/shared/ModelClassifierUtils.ts +++ b/packages/legend-application-studio/src/stores/shared/ModelClassifierUtils.ts @@ -74,14 +74,3 @@ export enum BASIC_SET_IMPLEMENTATION_TYPE { OPERATION = 'operation', INSTANCE = 'instance', } - -export enum SET_IMPLEMENTATION_TYPE { - OPERATION = 'operation', - MERGE_OPERATION = 'mergeOperation', - PUREINSTANCE = 'pureInstance', - FLAT_DATA = 'flatData', - EMBEDDED_FLAT_DATA = 'embeddedFlatData', - RELATIONAL = 'relational', - EMBEDDED_RELATIONAL = 'embeddedRelational', - AGGREGATION_AWARE = 'aggregationAware', -} diff --git a/packages/legend-application-studio/style/components/editor/mapping-editor/_mapping-element-editor.scss b/packages/legend-application-studio/style/components/editor/mapping-editor/_mapping-element-editor.scss index 9cbb3ec94f..2dd17200fa 100644 --- a/packages/legend-application-studio/style/components/editor/mapping-editor/_mapping-element-editor.scss +++ b/packages/legend-application-studio/style/components/editor/mapping-editor/_mapping-element-editor.scss @@ -114,24 +114,9 @@ font-weight: 500; } - &__metadata__driver-chunk { - display: flex; - background: var(--color-magenta-50); - color: var(--color-light-grey-50); - } - - &__metadata__driver__type { - height: 2.4rem; - line-height: 2.4rem; - padding: 0 1rem; - border-radius: 0.2rem; - background: var(--color-dark-shade-100); - cursor: default; - font-size: 1.5rem; - } - &__metadata__source-chunk { color: var(--color-light-grey-50); + background: var(--color-blue-150); &--none { padding: 0 1rem; diff --git a/packages/legend-application-studio/style/components/editor/mapping-editor/_property-mapping-editor.scss b/packages/legend-application-studio/style/components/editor/mapping-editor/_property-mapping-editor.scss index ebaed99761..9ab4145919 100644 --- a/packages/legend-application-studio/style/components/editor/mapping-editor/_property-mapping-editor.scss +++ b/packages/legend-application-studio/style/components/editor/mapping-editor/_property-mapping-editor.scss @@ -112,22 +112,24 @@ color: var(--color-light-grey-100); } - &__entries { - &__entry { - display: flex; - align-items: center; - justify-content: flex-start; - - &__remove-btn { - flex: 2.8rem 0 0; - height: 2.8rem; - color: var(--color-light-grey-0); - background: var(--color-dark-grey-250); - border-left: 0.1rem solid var(--color-dark-shade-300); - margin-bottom: -0.5rem; - margin-left: 0.5rem; - cursor: pointer; - } + &__generic-entry { + @include flexVCenter; + + justify-content: flex-start; + height: 2.8rem; + margin-top: 0.5rem; + + &__remove-btn { + @include flexCenter; + + width: 2.8rem; + height: 2.8rem; + flex: 2.8rem 0 0; + color: var(--color-light-grey-0); + background: var(--color-dark-grey-300); + border-radius: 0.2rem; + margin-left: 0.5rem; + cursor: pointer; } } @@ -139,7 +141,6 @@ display: flex; flex-wrap: wrap; width: 100%; - margin-top: 0.5rem; } &__entry__id { @@ -199,16 +200,29 @@ font-size: 2rem; } + &__entry--unsupported { + @include flexVCenter; + + height: 2.8rem; + margin-top: 0.5rem; + padding: 0 0.5rem; + background: var(--color-light-grey-100); + color: var(--color-dark-grey-400); + cursor: not-allowed; + user-select: none; + } + &__entry--empty { + @include ellipsisTextOverflow; + height: 2.8rem; line-height: 2.8rem; - background: var(--color-light-grey-100); margin-top: 0.5rem; padding: 0 0.5rem; + background: var(--color-light-grey-100); color: var(--color-dark-grey-400); cursor: help; - - @include ellipsisTextOverflow; + user-select: none; } &__entry--empty__visit-btn { diff --git a/packages/legend-extension-store-service-store/src/components/STO_ServiceStore_LegendStudioApplicationPlugin.tsx b/packages/legend-extension-store-service-store/src/components/STO_ServiceStore_LegendStudioApplicationPlugin.tsx index 3000fc77de..b979d0ea59 100644 --- a/packages/legend-extension-store-service-store/src/components/STO_ServiceStore_LegendStudioApplicationPlugin.tsx +++ b/packages/legend-extension-store-service-store/src/components/STO_ServiceStore_LegendStudioApplicationPlugin.tsx @@ -28,7 +28,6 @@ import { type DragElementClassifier, type NewElementState, type DSL_Mapping_LegendStudioApplicationPlugin_Extension, - type SetImplemtationClassifier, type MappingElementStateCreator, type MappingElement, type MappingElementState, @@ -53,7 +52,6 @@ import type { Connection, EmbeddedData, PackageableElement, - SetImplementation, } from '@finos/legend-graph'; import { ServiceStore } from '../graph/metamodel/pure/model/packageableElements/store/serviceStore/model/STO_ServiceStore_ServiceStore.js'; import { RootServiceInstanceSetImplementation } from '../graph/metamodel/pure/model/packageableElements/store/serviceStore/mapping/STO_ServiceStore_RootServiceInstanceSetImplementation.js'; @@ -78,7 +76,6 @@ import type { DocumentationEntry } from '@finos/legend-application'; const SERVICE_STORE_ELEMENT_TYPE = 'SERVICE_STORE'; const SERVICE_STORE_ELEMENT_PROJECT_EXPLORER_DND_TYPE = 'PROJECT_EXPLORER_SERVICE_STORE'; -const SERVICE_STORE_MAPPING_TYPE = 'serviceStore'; const SERVICE_STORE_EMBEDDED_DATA_TYPE = 'ServiceStore'; export class STO_ServiceStore_LegendStudioApplicationPlugin @@ -177,17 +174,6 @@ export class STO_ServiceStore_LegendStudioApplicationPlugin return [SERVICE_STORE_ELEMENT_PROJECT_EXPLORER_DND_TYPE]; } - getExtraSetImplementationClassifiers(): SetImplemtationClassifier[] { - return [ - (setImplementation: SetImplementation): string | undefined => { - if (setImplementation instanceof RootServiceInstanceSetImplementation) { - return SERVICE_STORE_MAPPING_TYPE; - } - return undefined; - }, - ]; - } - getExtraMappingElementStateCreators(): MappingElementStateCreator[] { return [ (