Skip to content

Commit

Permalink
minor dataSpace query editor improvements (#2469)
Browse files Browse the repository at this point in the history
* order usable elements by own, system then dependencies

* use dataspace elements to filter on classes
  • Loading branch information
MauricioUyaguari authored Aug 1, 2023
1 parent addc5fc commit 2503ccb
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-pandas-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-graph': patch
---

Change ordering of usable elements to own, system, dependency except for types/profiles.
5 changes: 5 additions & 0 deletions .changeset/dull-pandas-united.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-extension-dsl-data-space': minor
---

Use dataSpace `elements` to filter on explorer classes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,30 @@ import {
} from '@finos/legend-query-builder';
import {
type Runtime,
type GraphManagerState,
type Mapping,
getMappingCompatibleClasses,
getMappingCompatibleRuntimes,
PackageableElementExplicitReference,
RuntimePointer,
Class,
Package,
getDescendantsOfPackage,
} from '@finos/legend-graph';
import type { DataSpaceInfo } from '../../stores/query/DataSpaceInfo.js';
import { generateGAVCoordinates } from '@finos/legend-storage';
import { useEffect, useMemo, useState } from 'react';
import { debounce, guaranteeType } from '@finos/legend-shared';
import {
debounce,
filterByType,
guaranteeType,
uniq,
} from '@finos/legend-shared';
import { flowResult } from 'mobx';
import type { DataSpaceExecutionContext } from '../../graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js';
import type {
DataSpace,
DataSpaceExecutionContext,
} from '../../graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js';
import { DataSpaceIcon } from '../DSL_DataSpace_Icon.js';
import { DataSpaceAdvancedSearchModal } from './DataSpaceAdvancedSearchModal.js';

Expand Down Expand Up @@ -89,6 +102,25 @@ export const formatDataSpaceOptionLabel = (
</div>
);

const resolveDataSpaceClasses = (
dataSpace: DataSpace,
mapping: Mapping,
graphManagerState: GraphManagerState,
): Class[] => {
if (dataSpace.elements?.length) {
const dataSpaceElements = dataSpace.elements.map((ep) => ep.element.value);
return uniq([
...dataSpaceElements.filter(filterByType(Class)),
...dataSpaceElements
.filter(filterByType(Package))
.map((_package) => Array.from(getDescendantsOfPackage(_package)))
.flat()
.filter(filterByType(Class)),
]);
}
return getMappingCompatibleClasses(mapping, graphManagerState.usableClasses);
};

type ExecutionContextOption = {
label: string;
value: DataSpaceExecutionContext;
Expand Down Expand Up @@ -204,9 +236,10 @@ const DataSpaceQueryBuilderSetupPanelContent = observer(
});

// class
const classes = getMappingCompatibleClasses(
const classes = resolveDataSpaceClasses(
queryBuilderState.dataSpace,
queryBuilderState.executionContext.mapping.value,
queryBuilderState.graphManagerState.usableClasses,
queryBuilderState.graphManagerState,
);

useEffect(() => {
Expand Down
40 changes: 22 additions & 18 deletions packages/legend-graph/src/graph-manager/GraphManagerState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ export class GraphManagerState extends BasicGraphManagerState {
this.pluginManager.getPureGraphPlugins(),
);
}

/**
* NOTE: for all elements the ordering of usable elements will be own elements, system elements, dependency elements.
* Exception is made for types and profiles where we will show primitive and system elements first as those will be
* leveraged most by users
*/
get usableClassPropertyTypes(): Type[] {
return [
...this.graph.primitiveTypes.filter(
Expand All @@ -179,147 +183,147 @@ export class GraphManagerState extends BasicGraphManagerState {
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownProfiles,
),
...this.graph.dependencyManager.profiles,
...this.graph.ownProfiles,
...this.graph.dependencyManager.profiles,
];
}
get usableEnumerations(): Enumeration[] {
return [
...this.graph.ownEnumerations,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownEnumerations,
),
...this.graph.dependencyManager.enumerations,
...this.graph.ownEnumerations,
];
}
get usableMeasures(): Measure[] {
return [
...this.graph.ownMeasures,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownMeasures,
),
...this.graph.dependencyManager.measures,
...this.graph.ownMeasures,
];
}
get usableClasses(): Class[] {
return [
...this.graph.ownClasses,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownClasses,
),
...this.graph.dependencyManager.classes,
...this.graph.ownClasses,
];
}
get usableAssociationPropertyClasses(): Class[] {
return [...this.graph.dependencyManager.classes, ...this.graph.ownClasses];
return [...this.graph.ownClasses, ...this.graph.dependencyManager.classes];
}

get usableAssociations(): Association[] {
return [
...this.graph.ownAssociations,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownAssociations,
),
...this.graph.dependencyManager.associations,
...this.graph.ownAssociations,
];
}
get usableFunctions(): ConcreteFunctionDefinition[] {
return [
...this.graph.ownFunctions,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownFunctions,
),
...this.graph.dependencyManager.functions,
...this.graph.ownFunctions,
];
}
get usableStores(): Store[] {
return [
...this.graph.ownStores,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownStores,
),
...this.graph.dependencyManager.stores,
...this.graph.ownStores,
];
}
get usableDatabases(): Database[] {
return [
...this.graph.ownDatabases,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownDatabases,
),
...this.graph.dependencyManager.databases,
...this.graph.ownDatabases,
];
}
get usableMappings(): Mapping[] {
return [
...this.graph.ownMappings,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownMappings,
),
...this.graph.dependencyManager.mappings,
...this.graph.ownMappings,
];
}
get usableServices(): Service[] {
return [
...this.graph.ownServices,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownServices,
),
...this.graph.dependencyManager.services,
...this.graph.ownServices,
];
}
get usableRuntimes(): PackageableRuntime[] {
return [
...this.graph.ownRuntimes,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownRuntimes,
),
...this.graph.dependencyManager.runtimes,
...this.graph.ownRuntimes,
];
}
get usableConnections(): PackageableConnection[] {
return [
...this.graph.ownConnections,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownConnections,
),
...this.graph.dependencyManager.connections,
...this.graph.ownConnections,
];
}
get usableDataElements(): DataElement[] {
return [
...this.graph.ownDataElements,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownDataElements,
),
...this.graph.dependencyManager.dataElements,
...this.graph.ownDataElements,
];
}
get usableGenerationSpecifications(): GenerationSpecification[] {
return [
...this.graph.ownGenerationSpecifications,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownGenerationSpecifications,
),
...this.graph.dependencyManager.generationSpecifications,
...this.graph.ownGenerationSpecifications,
];
}
get usableFileGenerations(): FileGenerationSpecification[] {
return [
...this.graph.ownFileGenerations,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.ownFileGenerations,
),
...this.graph.dependencyManager.fileGenerations,
...this.graph.ownFileGenerations,
];
}
get usableElements(): PackageableElement[] {
return [
...this.graph.ownMeasures,
...this.graphManager.collectExposedSystemElements(
this.graph.systemModel.allOwnElements,
),
...this.graph.dependencyManager.allOwnElements,
...this.graph.ownMeasures,
];
}
}

0 comments on commit 2503ccb

Please sign in to comment.