Skip to content

Commit

Permalink
cleanup after finos#1504
Browse files Browse the repository at this point in the history
  • Loading branch information
akphi committed Oct 11, 2022
1 parent 20e0127 commit 39b038b
Show file tree
Hide file tree
Showing 13 changed files with 327 additions and 454 deletions.
15 changes: 15 additions & 0 deletions .changeset/rude-vans-rhyme.md
Original file line number Diff line number Diff line change
@@ -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
---
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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 =
Expand All @@ -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);
}
Expand Down Expand Up @@ -201,31 +183,12 @@ export const ClassMappingEditor = observer(
</div>
</div>
</div>
{/* Driver */}
<div
className={clsx(
'mapping-element-editor__metadata__chunk',
'mapping-element-editor__metadata__driver-chunk',
`mapping-element-editor__metadata__driver--${setImplementationType.toLowerCase()}`,
{
'mapping-element-editor__metadata__source--none': !sourceName,
},
)}
>
<div className="mapping-element-editor__metadata__sub-chunk">
using
</div>
<div className="mapping-element-editor__metadata__sub-chunk mapping-element-editor__metadata__driver__type">
{setImplementationType.toUpperCase()}
</div>
</div>
{/* Instance Set Implementation Source */}
{setImplementationType !== SET_IMPLEMENTATION_TYPE.OPERATION && (
{!(setImplementation instanceof OperationSetImplementation) && (
<div
className={clsx(
'mapping-element-editor__metadata__chunk',
'mapping-element-editor__metadata__source-chunk',
`background--${setImplementationType.toLowerCase()}`,
{
'mapping-element-editor__metadata__source-chunk--none':
!sourceName,
Expand All @@ -251,12 +214,10 @@ export const ClassMappingEditor = observer(
</div>
)}
{/* Operation Set Implementation Operator */}
{setImplementationType === SET_IMPLEMENTATION_TYPE.OPERATION && (
{setImplementation instanceof OperationSetImplementation && (
<div className="mapping-element-editor__metadata__operator-selector">
<OperatorSelector
setImplementation={
setImplementation as OperationSetImplementation
}
setImplementation={setImplementation}
isReadOnly={isReadOnly}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import {
PackageableElementExplicitReference,
} from '@finos/legend-graph';
import {
enumMapping_updateSourceType,
enumerationMapping_updateSourceType,
enumValueMapping_addSourceValue,
enumValueMapping_deleteSourceValue,
enumValueMapping_updateSourceValue,
Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -540,7 +540,7 @@ export const InstanceSetImplementationEditor = observer(
{!isReadOnly &&
!isUnsupported &&
sortedProperties.map((property) => (
<PropertyMappingsEditor
<PropertyMappingEditor
key={property.name}
property={property}
instanceSetImplementationState={
Expand All @@ -562,7 +562,7 @@ export const InstanceSetImplementationEditor = observer(
).length,
)
.map((property) => (
<PropertyMappingsEditor
<PropertyMappingEditor
key={property.name}
property={property}
instanceSetImplementationState={
Expand Down
Loading

0 comments on commit 39b038b

Please sign in to comment.