@finos/legend-extension-dsl-data-space 10.1.17 → 10.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.d.ts.map +1 -1
  2. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.js +4 -3
  3. package/lib/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.js.map +1 -1
  4. package/lib/components/query/DataSpaceAdvancedSearchModal.d.ts.map +1 -1
  5. package/lib/components/query/DataSpaceAdvancedSearchModal.js +7 -2
  6. package/lib/components/query/DataSpaceAdvancedSearchModal.js.map +1 -1
  7. package/lib/components/query/DataSpaceQueryBuilder.d.ts +4 -1
  8. package/lib/components/query/DataSpaceQueryBuilder.d.ts.map +1 -1
  9. package/lib/components/query/DataSpaceQueryBuilder.js +31 -22
  10. package/lib/components/query/DataSpaceQueryBuilder.js.map +1 -1
  11. package/lib/components/studio/DSL_DataSpace_LegendStudioApplicationPlugin.d.ts.map +1 -1
  12. package/lib/components/studio/DSL_DataSpace_LegendStudioApplicationPlugin.js +10 -0
  13. package/lib/components/studio/DSL_DataSpace_LegendStudioApplicationPlugin.js.map +1 -1
  14. package/lib/components/studio/DataSpaceQueryAction.d.ts +22 -0
  15. package/lib/components/studio/DataSpaceQueryAction.d.ts.map +1 -0
  16. package/lib/components/studio/DataSpaceQueryAction.js +29 -0
  17. package/lib/components/studio/DataSpaceQueryAction.js.map +1 -0
  18. package/lib/index.css +1 -1
  19. package/lib/package.json +1 -1
  20. package/lib/stores/query/DataSpaceAdvancedSearchState.d.ts.map +1 -1
  21. package/lib/stores/query/DataSpaceAdvancedSearchState.js +12 -9
  22. package/lib/stores/query/DataSpaceAdvancedSearchState.js.map +1 -1
  23. package/lib/stores/query/DataSpaceInfo.d.ts +3 -3
  24. package/lib/stores/query/DataSpaceInfo.d.ts.map +1 -1
  25. package/lib/stores/query/DataSpaceQueryBuilderState.d.ts +11 -6
  26. package/lib/stores/query/DataSpaceQueryBuilderState.d.ts.map +1 -1
  27. package/lib/stores/query/DataSpaceQueryBuilderState.js +77 -41
  28. package/lib/stores/query/DataSpaceQueryBuilderState.js.map +1 -1
  29. package/lib/stores/query/DataSpaceQueryCreatorStore.d.ts.map +1 -1
  30. package/lib/stores/query/DataSpaceQueryCreatorStore.js +8 -7
  31. package/lib/stores/query/DataSpaceQueryCreatorStore.js.map +1 -1
  32. package/lib/stores/query/DataSpaceQuerySetupStore.d.ts.map +1 -1
  33. package/lib/stores/query/DataSpaceQuerySetupStore.js +2 -2
  34. package/lib/stores/query/DataSpaceQuerySetupStore.js.map +1 -1
  35. package/package.json +7 -7
  36. package/src/components/query/DSL_DataSpace_LegendQueryApplicationPlugin.tsx +17 -7
  37. package/src/components/query/DataSpaceAdvancedSearchModal.tsx +23 -26
  38. package/src/components/query/DataSpaceQueryBuilder.tsx +76 -48
  39. package/src/components/studio/DSL_DataSpace_LegendStudioApplicationPlugin.tsx +10 -0
  40. package/src/components/studio/DataSpaceQueryAction.tsx +34 -0
  41. package/src/stores/query/DataSpaceAdvancedSearchState.ts +19 -28
  42. package/src/stores/query/DataSpaceInfo.ts +3 -3
  43. package/src/stores/query/DataSpaceQueryBuilderState.ts +125 -71
  44. package/src/stores/query/DataSpaceQueryCreatorStore.ts +23 -16
  45. package/src/stores/query/DataSpaceQuerySetupStore.ts +4 -3
  46. package/tsconfig.json +1 -0
@@ -30,7 +30,10 @@ import {
30
30
  } from '@finos/legend-art';
31
31
  import { observer } from 'mobx-react-lite';
32
32
  import { useApplicationStore } from '@finos/legend-application';
33
- import type { DataSpaceQueryBuilderState } from '../../stores/query/DataSpaceQueryBuilderState.js';
33
+ import {
34
+ DataSpaceQueryBuilderState,
35
+ resolveUsableDataSpaceClasses,
36
+ } from '../../stores/query/DataSpaceQueryBuilderState.js';
34
37
  import {
35
38
  buildRuntimeValueOption,
36
39
  getRuntimeOptionFormatter,
@@ -38,32 +41,22 @@ import {
38
41
  } from '@finos/legend-query-builder';
39
42
  import {
40
43
  type Runtime,
41
- type GraphManagerState,
42
- type Mapping,
43
- getMappingCompatibleClasses,
44
44
  getMappingCompatibleRuntimes,
45
45
  PackageableElementExplicitReference,
46
46
  RuntimePointer,
47
- Class,
48
- Package,
49
- getDescendantsOfPackage,
50
47
  } from '@finos/legend-graph';
51
48
  import type { DataSpaceInfo } from '../../stores/query/DataSpaceInfo.js';
52
49
  import { generateGAVCoordinates } from '@finos/legend-storage';
53
50
  import { useEffect, useMemo, useState } from 'react';
54
- import {
55
- debounce,
56
- filterByType,
57
- guaranteeType,
58
- uniq,
59
- } from '@finos/legend-shared';
51
+ import { debounce, guaranteeType } from '@finos/legend-shared';
60
52
  import { flowResult } from 'mobx';
61
- import type {
53
+ import {
62
54
  DataSpace,
63
- DataSpaceExecutionContext,
55
+ type DataSpaceExecutionContext,
64
56
  } from '../../graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js';
65
57
  import { DataSpaceIcon } from '../DSL_DataSpace_Icon.js';
66
58
  import { DataSpaceAdvancedSearchModal } from './DataSpaceAdvancedSearchModal.js';
59
+ import type { EditorStore } from '@finos/legend-application-studio';
67
60
 
68
61
  export type DataSpaceOption = {
69
62
  label: string;
@@ -80,11 +73,15 @@ export const formatDataSpaceOptionLabel = (
80
73
  ): React.ReactNode => (
81
74
  <div
82
75
  className="query-builder__setup__data-space__option"
83
- title={`${option.label} - ${option.value.path} - ${generateGAVCoordinates(
84
- option.value.groupId,
85
- option.value.artifactId,
86
- option.value.versionId,
87
- )}`}
76
+ title={`${option.label} - ${option.value.path} - ${
77
+ option.value.groupId && option.value.artifactId && option.value.versionId
78
+ ? generateGAVCoordinates(
79
+ option.value.groupId,
80
+ option.value.artifactId,
81
+ option.value.versionId,
82
+ )
83
+ : ''
84
+ }`}
88
85
  >
89
86
  <div className="query-builder__setup__data-space__option__label">
90
87
  {option.label}
@@ -93,34 +90,21 @@ export const formatDataSpaceOptionLabel = (
93
90
  {option.value.path}
94
91
  </div>
95
92
  <div className="query-builder__setup__data-space__option__gav">
96
- {generateGAVCoordinates(
97
- option.value.groupId,
98
- option.value.artifactId,
99
- option.value.versionId,
100
- )}
93
+ {option.value.groupId &&
94
+ option.value.artifactId &&
95
+ option.value.versionId && (
96
+ <>
97
+ {generateGAVCoordinates(
98
+ option.value.groupId,
99
+ option.value.artifactId,
100
+ option.value.versionId,
101
+ )}
102
+ </>
103
+ )}
101
104
  </div>
102
105
  </div>
103
106
  );
104
107
 
105
- const resolveDataSpaceClasses = (
106
- dataSpace: DataSpace,
107
- mapping: Mapping,
108
- graphManagerState: GraphManagerState,
109
- ): Class[] => {
110
- if (dataSpace.elements?.length) {
111
- const dataSpaceElements = dataSpace.elements.map((ep) => ep.element.value);
112
- return uniq([
113
- ...dataSpaceElements.filter(filterByType(Class)),
114
- ...dataSpaceElements
115
- .filter(filterByType(Package))
116
- .map((_package) => Array.from(getDescendantsOfPackage(_package)))
117
- .flat()
118
- .filter(filterByType(Class)),
119
- ]);
120
- }
121
- return getMappingCompatibleClasses(mapping, graphManagerState.usableClasses);
122
- };
123
-
124
108
  type ExecutionContextOption = {
125
109
  label: string;
126
110
  value: DataSpaceExecutionContext;
@@ -154,9 +138,9 @@ const DataSpaceQueryBuilderSetupPanelContent = observer(
154
138
  label:
155
139
  queryBuilderState.dataSpace.title ?? queryBuilderState.dataSpace.name,
156
140
  value: {
157
- groupId: queryBuilderState.groupId,
158
- artifactId: queryBuilderState.artifactId,
159
- versionId: queryBuilderState.versionId,
141
+ groupId: queryBuilderState.projectInfo?.groupId,
142
+ artifactId: queryBuilderState.projectInfo?.artifactId,
143
+ versionId: queryBuilderState.projectInfo?.versionId,
160
144
  title: queryBuilderState.dataSpace.title,
161
145
  name: queryBuilderState.dataSpace.name,
162
146
  path: queryBuilderState.dataSpace.path,
@@ -241,7 +225,7 @@ const DataSpaceQueryBuilderSetupPanelContent = observer(
241
225
  });
242
226
 
243
227
  // class
244
- const classes = resolveDataSpaceClasses(
228
+ const classes = resolveUsableDataSpaceClasses(
245
229
  queryBuilderState.dataSpace,
246
230
  queryBuilderState.executionContext.mapping.value,
247
231
  queryBuilderState.graphManagerState,
@@ -408,3 +392,47 @@ export const renderDataSpaceQueryBuilderSetupPanelContent = (
408
392
  queryBuilderState={queryBuilderState}
409
393
  />
410
394
  );
395
+
396
+ export const queryDataSpace = async (
397
+ dataSpace: DataSpace,
398
+ editorStore: EditorStore,
399
+ ): Promise<void> => {
400
+ const embeddedQueryBuilderState = editorStore.embeddedQueryBuilderState;
401
+ await flowResult(
402
+ embeddedQueryBuilderState.setEmbeddedQueryBuilderConfiguration({
403
+ setupQueryBuilderState: () => {
404
+ const queryBuilderState = new DataSpaceQueryBuilderState(
405
+ editorStore.applicationStore,
406
+ editorStore.graphManagerState,
407
+ editorStore.depotServerClient,
408
+ dataSpace,
409
+ dataSpace.defaultExecutionContext,
410
+ (dataSpaceInfo: DataSpaceInfo) => {
411
+ queryBuilderState.dataSpace = guaranteeType(
412
+ queryBuilderState.graphManagerState.graph.getElement(
413
+ dataSpaceInfo.path,
414
+ ),
415
+ DataSpace,
416
+ );
417
+ queryBuilderState.setExecutionContext(
418
+ queryBuilderState.dataSpace.defaultExecutionContext,
419
+ );
420
+ queryBuilderState.propagateExecutionContextChange(
421
+ queryBuilderState.dataSpace.defaultExecutionContext,
422
+ );
423
+ },
424
+ false,
425
+ );
426
+ queryBuilderState.setExecutionContext(
427
+ dataSpace.defaultExecutionContext,
428
+ );
429
+ queryBuilderState.propagateExecutionContextChange(
430
+ dataSpace.defaultExecutionContext,
431
+ );
432
+ return queryBuilderState;
433
+ },
434
+ actionConfigs: [],
435
+ disableCompile: true,
436
+ }),
437
+ );
438
+ };
@@ -56,6 +56,7 @@ import {
56
56
  DataSpacePreviewAction,
57
57
  } from './DataSpacePreviewAction.js';
58
58
  import type { PureGrammarTextSuggestion } from '@finos/legend-lego/code-editor';
59
+ import { DataSpaceQueryAction } from './DataSpaceQueryAction.js';
59
60
 
60
61
  const DATA_SPACE_ELEMENT_TYPE = 'DATA SPACE';
61
62
  const DATA_SPACE_ELEMENT_PROJECT_EXPLORER_DND_TYPE =
@@ -81,6 +82,15 @@ export class DSL_DataSpace_LegendStudioApplicationPlugin
81
82
 
82
83
  override getExtraExplorerContextMenuItemRendererConfigurations(): ExplorerContextMenuItemRendererConfiguration[] {
83
84
  return [
85
+ {
86
+ key: 'data-space-query',
87
+ renderer: (editorStore, element) => {
88
+ if (element instanceof DataSpace) {
89
+ return <DataSpaceQueryAction dataSpace={element} />;
90
+ }
91
+ return undefined;
92
+ },
93
+ },
84
94
  {
85
95
  key: 'data-space-preview',
86
96
  renderer: (editorStore, element) => {
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { MenuContentItem } from '@finos/legend-art';
18
+ import { observer } from 'mobx-react-lite';
19
+ import type { DataSpace } from '../../graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js';
20
+ import { useEditorStore } from '@finos/legend-application-studio';
21
+ import { queryDataSpace } from '../query/DataSpaceQueryBuilder.js';
22
+
23
+ export const DataSpaceQueryAction = observer(
24
+ (props: { dataSpace: DataSpace }) => {
25
+ const { dataSpace } = props;
26
+ const editorStore = useEditorStore();
27
+ const buildQuery = editorStore.applicationStore.guardUnhandledError(
28
+ async () => {
29
+ await queryDataSpace(dataSpace, editorStore);
30
+ },
31
+ );
32
+ return <MenuContentItem onClick={buildQuery}>Query...</MenuContentItem>;
33
+ },
34
+ );
@@ -32,6 +32,7 @@ import {
32
32
  type PlainObject,
33
33
  ActionState,
34
34
  assertErrorThrown,
35
+ guaranteeNonNullable,
35
36
  } from '@finos/legend-shared';
36
37
  import { action, flow, flowResult, makeObservable, observable } from 'mobx';
37
38
  import { DSL_DataSpace_getGraphManagerExtension } from '../../graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.js';
@@ -157,16 +158,15 @@ export class DataSpaceAdvancedSearchState {
157
158
  *loadDataSpace(dataSpace: DataSpaceInfo): GeneratorFn<void> {
158
159
  this.loadDataSpaceState.inProgress();
159
160
  this.loadDataSpaceState.setMessage(`Initializing...`);
160
-
161
161
  try {
162
+ const groupId = guaranteeNonNullable(dataSpace.groupId);
163
+ const artifactId = guaranteeNonNullable(dataSpace.artifactId);
164
+ const versionId = guaranteeNonNullable(dataSpace.versionId);
162
165
  // fetch project
163
166
  this.loadDataSpaceState.setMessage(`Fetching project...`);
164
167
  const project = StoreProjectData.serialization.fromJson(
165
168
  (yield flowResult(
166
- this.depotServerClient.getProject(
167
- dataSpace.groupId,
168
- dataSpace.artifactId,
169
- ),
169
+ this.depotServerClient.getProject(groupId, artifactId),
170
170
  )) as PlainObject<StoreProjectData>,
171
171
  );
172
172
  // analyze data space
@@ -177,13 +177,13 @@ export class DataSpaceAdvancedSearchState {
177
177
  () =>
178
178
  retrieveProjectEntitiesWithDependencies(
179
179
  project,
180
- dataSpace.versionId,
180
+ versionId,
181
181
  this.depotServerClient,
182
182
  ),
183
183
  () =>
184
184
  retrieveAnalyticsResultCache(
185
185
  project,
186
- dataSpace.versionId,
186
+ versionId,
187
187
  dataSpace.path,
188
188
  this.depotServerClient,
189
189
  ),
@@ -192,45 +192,36 @@ export class DataSpaceAdvancedSearchState {
192
192
  this.dataSpaceViewerState = new DataSpaceViewerState(
193
193
  this.applicationStore,
194
194
  this.graphManagerState,
195
- dataSpace.groupId,
196
- dataSpace.artifactId,
197
- dataSpace.versionId,
195
+ groupId,
196
+ artifactId,
197
+ versionId,
198
198
  analysisResult,
199
199
  {
200
200
  retrieveGraphData: () =>
201
201
  new GraphDataWithOrigin(
202
- new LegendSDLC(
203
- dataSpace.groupId,
204
- dataSpace.artifactId,
205
- dataSpace.versionId,
206
- ),
202
+ new LegendSDLC(groupId, artifactId, versionId),
207
203
  ),
208
204
  queryDataSpace: (executionContextKey: string) =>
209
205
  generateDataSpaceQueryCreatorRoute(
210
- dataSpace.groupId,
211
- dataSpace.artifactId,
212
- dataSpace.versionId,
206
+ groupId,
207
+ artifactId,
208
+ versionId,
213
209
  analysisResult.path,
214
210
  executionContextKey,
215
211
  ),
216
212
  viewProject: (path: string | undefined) =>
217
- this.viewProject(
218
- dataSpace.groupId,
219
- dataSpace.artifactId,
220
- dataSpace.versionId,
221
- path,
222
- ),
213
+ this.viewProject(groupId, artifactId, versionId, path),
223
214
  viewSDLCProject: (path: string | undefined) =>
224
- this.viewSDLCProject(dataSpace.groupId, dataSpace.artifactId, path),
215
+ this.viewSDLCProject(groupId, artifactId, path),
225
216
  queryClass: (_class: Class): void => {
226
217
  this.proceedToCreateQuery(_class);
227
218
  },
228
219
  openServiceQuery: (servicePath: string): void =>
229
220
  this.applicationStore.navigationService.navigator.visitAddress(
230
221
  generateServiceQueryCreatorRoute(
231
- dataSpace.groupId,
232
- dataSpace.artifactId,
233
- dataSpace.versionId,
222
+ groupId,
223
+ artifactId,
224
+ versionId,
234
225
  servicePath,
235
226
  ),
236
227
  ),
@@ -22,9 +22,9 @@ import { isString } from '@finos/legend-shared';
22
22
  import { extractEntityNameFromPath } from '@finos/legend-storage';
23
23
 
24
24
  export interface DataSpaceInfo {
25
- groupId: string;
26
- artifactId: string;
27
- versionId: string;
25
+ groupId: string | undefined;
26
+ artifactId: string | undefined;
27
+ versionId: string | undefined;
28
28
  title: string | undefined;
29
29
  name: string;
30
30
  path: string;
@@ -25,7 +25,10 @@ import {
25
25
  getMappingCompatibleClasses,
26
26
  RuntimePointer,
27
27
  type Runtime,
28
- type Class,
28
+ Class,
29
+ type Mapping,
30
+ getDescendantsOfPackage,
31
+ Package,
29
32
  } from '@finos/legend-graph';
30
33
  import {
31
34
  DepotScope,
@@ -38,21 +41,40 @@ import {
38
41
  ActionState,
39
42
  assertErrorThrown,
40
43
  getNullableFirstEntry,
44
+ filterByType,
45
+ uniq,
41
46
  } from '@finos/legend-shared';
42
47
  import { action, flow, makeObservable, observable } from 'mobx';
43
48
  import { renderDataSpaceQueryBuilderSetupPanelContent } from '../../components/query/DataSpaceQueryBuilder.js';
44
- import type {
49
+ import {
45
50
  DataSpace,
46
- DataSpaceExecutionContext,
51
+ type DataSpaceExecutionContext,
47
52
  } from '../../graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js';
48
53
  import { DATA_SPACE_ELEMENT_CLASSIFIER_PATH } from '../../graph-manager/protocol/pure/DSL_DataSpace_PureProtocolProcessorPlugin.js';
49
54
  import { type DataSpaceInfo, extractDataSpaceInfo } from './DataSpaceInfo.js';
50
55
  import { DataSpaceAdvancedSearchState } from './DataSpaceAdvancedSearchState.js';
51
56
  import type { DataSpaceAnalysisResult } from '../../graph-manager/action/analytics/DataSpaceAnalysis.js';
52
57
 
53
- export class DataSpaceQueryBuilderState extends QueryBuilderState {
54
- readonly depotServerClient: DepotServerClient;
55
- readonly dataSpace: DataSpace;
58
+ export const resolveUsableDataSpaceClasses = (
59
+ dataSpace: DataSpace,
60
+ mapping: Mapping,
61
+ graphManagerState: GraphManagerState,
62
+ ): Class[] => {
63
+ if (dataSpace.elements?.length) {
64
+ const dataSpaceElements = dataSpace.elements.map((ep) => ep.element.value);
65
+ return uniq([
66
+ ...dataSpaceElements.filter(filterByType(Class)),
67
+ ...dataSpaceElements
68
+ .filter(filterByType(Package))
69
+ .map((_package) => Array.from(getDescendantsOfPackage(_package)))
70
+ .flat()
71
+ .filter(filterByType(Class)),
72
+ ]);
73
+ }
74
+ return getMappingCompatibleClasses(mapping, graphManagerState.usableClasses);
75
+ };
76
+
77
+ export class DataSpaceProjectInfo {
56
78
  readonly groupId: string;
57
79
  readonly artifactId: string;
58
80
  readonly versionId: string;
@@ -67,6 +89,33 @@ export class DataSpaceQueryBuilderState extends QueryBuilderState {
67
89
  artifactId: string,
68
90
  entityPath: string | undefined,
69
91
  ) => Promise<void>;
92
+
93
+ constructor(
94
+ groupId: string,
95
+ artifactId: string,
96
+ versionId: string,
97
+ viewProject: (
98
+ groupId: string,
99
+ artifactId: string,
100
+ versionId: string,
101
+ entityPath: string | undefined,
102
+ ) => void,
103
+ viewSDLCProject: (
104
+ groupId: string,
105
+ artifactId: string,
106
+ entityPath: string | undefined,
107
+ ) => Promise<void>,
108
+ ) {
109
+ this.groupId = groupId;
110
+ this.artifactId = artifactId;
111
+ this.versionId = versionId;
112
+ this.viewProject = viewProject;
113
+ this.viewSDLCProject = viewSDLCProject;
114
+ }
115
+ }
116
+
117
+ export class DataSpaceQueryBuilderState extends QueryBuilderState {
118
+ readonly depotServerClient: DepotServerClient;
70
119
  readonly isAdvancedDataSpaceSearchEnabled: boolean;
71
120
  readonly loadDataSpacesState = ActionState.create();
72
121
  readonly onDataSpaceChange: (val: DataSpaceInfo) => void;
@@ -76,10 +125,12 @@ export class DataSpaceQueryBuilderState extends QueryBuilderState {
76
125
  readonly onRuntimeChange?: ((val: Runtime) => void) | undefined;
77
126
  readonly onClassChange?: ((val: Class) => void) | undefined;
78
127
  readonly dataSpaceAnalysisResult?: DataSpaceAnalysisResult | undefined;
128
+ readonly projectInfo?: DataSpaceProjectInfo | undefined;
79
129
 
80
130
  override TEMPORARY__setupPanelContentRenderer = (): React.ReactNode =>
81
131
  renderDataSpaceQueryBuilderSetupPanelContent(this);
82
132
 
133
+ dataSpace: DataSpace;
83
134
  executionContext!: DataSpaceExecutionContext;
84
135
  dataSpaces: DataSpaceInfo[] = [];
85
136
  showRuntimeSelector = false;
@@ -91,27 +142,15 @@ export class DataSpaceQueryBuilderState extends QueryBuilderState {
91
142
  depotServerClient: DepotServerClient,
92
143
  dataSpace: DataSpace,
93
144
  executionContext: DataSpaceExecutionContext,
94
- groupId: string,
95
- artifactId: string,
96
- versionId: string,
97
- viewProject: (
98
- groupId: string,
99
- artifactId: string,
100
- versionId: string,
101
- entityPath: string | undefined,
102
- ) => void,
103
- viewSDLCProject: (
104
- groupId: string,
105
- artifactId: string,
106
- entityPath: string | undefined,
107
- ) => Promise<void>,
108
145
  onDataSpaceChange: (val: DataSpaceInfo) => void,
146
+ isAdvancedDataSpaceSearchEnabled: boolean,
109
147
  dataSpaceAnalysisResult?: DataSpaceAnalysisResult | undefined,
110
148
  onExecutionContextChange?:
111
149
  | ((val: DataSpaceExecutionContext) => void)
112
150
  | undefined,
113
151
  onRuntimeChange?: ((val: Runtime) => void) | undefined,
114
152
  onClassChange?: ((val: Class) => void) | undefined,
153
+ projectInfo?: DataSpaceProjectInfo | undefined,
115
154
  ) {
116
155
  super(applicationStore, graphManagerState);
117
156
 
@@ -130,18 +169,12 @@ export class DataSpaceQueryBuilderState extends QueryBuilderState {
130
169
  this.depotServerClient = depotServerClient;
131
170
  this.dataSpace = dataSpace;
132
171
  this.executionContext = executionContext;
133
- this.groupId = groupId;
134
- this.artifactId = artifactId;
135
- this.versionId = versionId;
136
- this.viewProject = viewProject;
137
- this.viewSDLCProject = viewSDLCProject;
172
+ this.projectInfo = projectInfo;
138
173
  this.onDataSpaceChange = onDataSpaceChange;
139
174
  this.onExecutionContextChange = onExecutionContextChange;
140
175
  this.onRuntimeChange = onRuntimeChange;
141
176
  this.onClassChange = onClassChange;
142
- // NOTE: if we reuse this state in the future (e.g. in Studio), we might need
143
- // to turn this flag off
144
- this.isAdvancedDataSpaceSearchEnabled = true;
177
+ this.isAdvancedDataSpaceSearchEnabled = isAdvancedDataSpaceSearchEnabled;
145
178
  this.dataSpaceAnalysisResult = dataSpaceAnalysisResult;
146
179
  }
147
180
 
@@ -152,25 +185,27 @@ export class DataSpaceQueryBuilderState extends QueryBuilderState {
152
185
  }
153
186
 
154
187
  showAdvancedSearchPanel(): void {
155
- this.advancedSearchState = new DataSpaceAdvancedSearchState(
156
- this.applicationStore,
157
- this.graphManagerState,
158
- this.depotServerClient,
159
- {
160
- viewProject: this.viewProject,
161
- viewSDLCProject: this.viewSDLCProject,
162
- },
163
- {
164
- groupId: this.groupId,
165
- artifactId: this.artifactId,
166
- versionId: this.versionId,
167
- title: this.dataSpace.title,
168
- name: this.dataSpace.name,
169
- path: this.dataSpace.path,
170
- defaultExecutionContext: this.dataSpace.defaultExecutionContext.name,
171
- },
172
- this.versionId === SNAPSHOT_VERSION_ALIAS,
173
- );
188
+ if (this.projectInfo && this.isAdvancedDataSpaceSearchEnabled) {
189
+ this.advancedSearchState = new DataSpaceAdvancedSearchState(
190
+ this.applicationStore,
191
+ this.graphManagerState,
192
+ this.depotServerClient,
193
+ {
194
+ viewProject: this.projectInfo.viewProject,
195
+ viewSDLCProject: this.projectInfo.viewSDLCProject,
196
+ },
197
+ {
198
+ groupId: this.projectInfo.groupId,
199
+ artifactId: this.projectInfo.artifactId,
200
+ versionId: this.projectInfo.versionId,
201
+ title: this.dataSpace.title,
202
+ name: this.dataSpace.name,
203
+ path: this.dataSpace.path,
204
+ defaultExecutionContext: this.dataSpace.defaultExecutionContext.name,
205
+ },
206
+ this.projectInfo.versionId === SNAPSHOT_VERSION_ALIAS,
207
+ );
208
+ }
174
209
  }
175
210
 
176
211
  hideAdvancedSearchPanel(): void {
@@ -186,28 +221,46 @@ export class DataSpaceQueryBuilderState extends QueryBuilderState {
186
221
  }
187
222
 
188
223
  *loadDataSpaces(searchText: string): GeneratorFn<void> {
189
- const isValidSearchString =
190
- searchText.length >= DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH;
191
- this.loadDataSpacesState.inProgress();
192
- const toGetSnapShot = this.versionId === SNAPSHOT_VERSION_ALIAS;
193
- try {
194
- this.dataSpaces = (
195
- (yield this.depotServerClient.getEntitiesByClassifierPath(
196
- DATA_SPACE_ELEMENT_CLASSIFIER_PATH,
197
- {
198
- search: isValidSearchString ? searchText : undefined,
199
- scope: toGetSnapShot ? DepotScope.SNAPSHOT : DepotScope.RELEASES,
200
- limit: DEFAULT_TYPEAHEAD_SEARCH_LIMIT,
201
- },
202
- )) as StoredEntity[]
203
- ).map((storedEntity) =>
204
- extractDataSpaceInfo(storedEntity, toGetSnapShot),
205
- );
206
- this.loadDataSpacesState.pass();
207
- } catch (error) {
208
- assertErrorThrown(error);
209
- this.loadDataSpacesState.fail();
210
- this.applicationStore.notificationService.notifyError(error);
224
+ if (this.projectInfo) {
225
+ const isValidSearchString =
226
+ searchText.length >= DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH;
227
+ this.loadDataSpacesState.inProgress();
228
+ const toGetSnapShot =
229
+ this.projectInfo.versionId === SNAPSHOT_VERSION_ALIAS;
230
+ try {
231
+ this.dataSpaces = (
232
+ (yield this.depotServerClient.getEntitiesByClassifierPath(
233
+ DATA_SPACE_ELEMENT_CLASSIFIER_PATH,
234
+ {
235
+ search: isValidSearchString ? searchText : undefined,
236
+ scope: toGetSnapShot ? DepotScope.SNAPSHOT : DepotScope.RELEASES,
237
+ limit: DEFAULT_TYPEAHEAD_SEARCH_LIMIT,
238
+ },
239
+ )) as StoredEntity[]
240
+ ).map((storedEntity) =>
241
+ extractDataSpaceInfo(storedEntity, toGetSnapShot),
242
+ );
243
+ this.loadDataSpacesState.pass();
244
+ } catch (error) {
245
+ assertErrorThrown(error);
246
+ this.loadDataSpacesState.fail();
247
+ this.applicationStore.notificationService.notifyError(error);
248
+ }
249
+ } else {
250
+ this.dataSpaces = this.graphManagerState.graph.allOwnElements
251
+ .filter(filterByType(DataSpace))
252
+ .map(
253
+ (e) =>
254
+ ({
255
+ groupId: undefined,
256
+ artifactId: undefined,
257
+ versionId: undefined,
258
+ path: e.path,
259
+ name: e.name,
260
+ title: e.title,
261
+ defaultExecutionContext: e.defaultExecutionContext.title,
262
+ }) as DataSpaceInfo,
263
+ );
211
264
  }
212
265
  }
213
266
 
@@ -233,9 +286,10 @@ export class DataSpaceQueryBuilderState extends QueryBuilderState {
233
286
  }
234
287
  this.changeRuntime(new RuntimePointer(executionContext.defaultRuntime));
235
288
 
236
- const compatibleClasses = getMappingCompatibleClasses(
289
+ const compatibleClasses = resolveUsableDataSpaceClasses(
290
+ this.dataSpace,
237
291
  mapping,
238
- this.graphManagerState.usableClasses,
292
+ this.graphManagerState,
239
293
  );
240
294
  // if there is no chosen class or the chosen one is not compatible
241
295
  // with the mapping then pick a compatible class if possible