@finos/legend-query-builder 4.14.95 → 4.15.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/QueryBuilder.d.ts.map +1 -1
- package/lib/components/QueryBuilder.js +2 -1
- package/lib/components/QueryBuilder.js.map +1 -1
- package/lib/components/data-cube/QueryBuilderDataCube.d.ts +22 -0
- package/lib/components/data-cube/QueryBuilderDataCube.d.ts.map +1 -0
- package/lib/components/data-cube/QueryBuilderDataCube.js +48 -0
- package/lib/components/data-cube/QueryBuilderDataCube.js.map +1 -0
- package/lib/components/filter/QueryBuilderFilterPanel.js +2 -2
- package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
- package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/result/QueryBuilderResultPanel.js +6 -3
- package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js +2 -3
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts +2 -2
- package/lib/components/result/tds/QueryBuilderTDSResultShared.d.ts.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSResultShared.js +19 -155
- package/lib/components/result/tds/QueryBuilderTDSResultShared.js.map +1 -1
- package/lib/graph-manager/QueryBuilderConfig.d.ts +5 -1
- package/lib/graph-manager/QueryBuilderConfig.d.ts.map +1 -1
- package/lib/graph-manager/QueryBuilderConfig.js +6 -1
- package/lib/graph-manager/QueryBuilderConfig.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/package.json +2 -1
- package/lib/stores/QueryBuilderState.d.ts +2 -0
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +9 -19
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/data-cube/QueryBuilderDataCubeApplicationEngine.d.ts +38 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeApplicationEngine.d.ts.map +1 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeApplicationEngine.js +71 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeApplicationEngine.js.map +1 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.d.ts +52 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.d.ts.map +1 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.js +149 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeEngine.js.map +1 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeEngineHelper.d.ts +19 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeEngineHelper.d.ts.map +1 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeEngineHelper.js +31 -0
- package/lib/stores/data-cube/QueryBuilderDataCubeEngineHelper.js.map +1 -0
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts +1 -0
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.js.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts +1 -0
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +3 -0
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts +1 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js +3 -0
- package/lib/stores/fetch-structure/tds/QueryBuilderTDSState.js.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterOperator.d.ts +1 -1
- package/lib/stores/filter/QueryBuilderFilterOperator.d.ts.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.d.ts +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.js +3 -8
- package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterStateBuilder.js +1 -1
- package/lib/stores/filter/QueryBuilderFilterStateBuilder.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js +3 -3
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js +3 -3
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.d.ts +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.d.ts +2 -2
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.d.ts.map +1 -1
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js +3 -3
- package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js.map +1 -1
- package/package.json +7 -6
- package/src/components/QueryBuilder.tsx +4 -0
- package/src/components/data-cube/QueryBuilderDataCube.tsx +116 -0
- package/src/components/filter/QueryBuilderFilterPanel.tsx +2 -2
- package/src/components/result/QueryBuilderResultPanel.tsx +24 -0
- package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +2 -3
- package/src/components/result/tds/QueryBuilderTDSResultShared.tsx +26 -332
- package/src/graph-manager/QueryBuilderConfig.ts +7 -1
- package/src/index.ts +2 -0
- package/src/stores/QueryBuilderState.ts +13 -27
- package/src/stores/data-cube/QueryBuilderDataCubeApplicationEngine.ts +109 -0
- package/src/stores/data-cube/QueryBuilderDataCubeEngine.ts +255 -0
- package/src/stores/data-cube/QueryBuilderDataCubeEngineHelper.ts +41 -0
- package/src/stores/fetch-structure/QueryBuilderFetchStructureImplementationState.ts +1 -0
- package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +4 -0
- package/src/stores/fetch-structure/tds/QueryBuilderTDSState.ts +4 -0
- package/src/stores/filter/QueryBuilderFilterOperator.ts +1 -1
- package/src/stores/filter/QueryBuilderFilterState.ts +5 -10
- package/src/stores/filter/QueryBuilderFilterStateBuilder.ts +1 -1
- package/src/stores/filter/operators/QueryBuilderFilterOperator_Contain.ts +5 -3
- package/src/stores/filter/operators/QueryBuilderFilterOperator_EndWith.ts +5 -3
- package/src/stores/filter/operators/QueryBuilderFilterOperator_Equal.ts +2 -2
- package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.ts +4 -2
- package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.ts +4 -2
- package/src/stores/filter/operators/QueryBuilderFilterOperator_In.ts +2 -2
- package/src/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.ts +2 -2
- package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThan.ts +4 -2
- package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.ts +4 -2
- package/src/stores/filter/operators/QueryBuilderFilterOperator_StartWith.ts +5 -3
- package/tsconfig.json +4 -0
@@ -0,0 +1,116 @@
|
|
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 { DataCube, DataCubeProvider } from '@finos/legend-data-cube';
|
18
|
+
import type { QueryBuilderState } from '../../stores/QueryBuilderState.js';
|
19
|
+
import { observer } from 'mobx-react-lite';
|
20
|
+
import { QueryBuilderDataCubeApplicationEngine } from '../../stores/data-cube/QueryBuilderDataCubeApplicationEngine.js';
|
21
|
+
import {
|
22
|
+
clsx,
|
23
|
+
Dialog,
|
24
|
+
EmptyWindowRestoreIcon,
|
25
|
+
Modal,
|
26
|
+
TimesIcon,
|
27
|
+
WindowMaximizeIcon,
|
28
|
+
} from '@finos/legend-art';
|
29
|
+
import { useState } from 'react';
|
30
|
+
import { RuntimePointer } from '@finos/legend-graph';
|
31
|
+
import { QueryBuilderDataCubeEngine } from '../../stores/data-cube/QueryBuilderDataCubeEngine.js';
|
32
|
+
|
33
|
+
const QueryBuilderDataCube = observer(
|
34
|
+
(props: { queryBuilderState: QueryBuilderState }) => {
|
35
|
+
const { queryBuilderState } = props;
|
36
|
+
const applicationStore = new QueryBuilderDataCubeApplicationEngine(
|
37
|
+
queryBuilderState.applicationStore,
|
38
|
+
);
|
39
|
+
const runtime =
|
40
|
+
queryBuilderState.executionContextState.runtimeValue instanceof
|
41
|
+
RuntimePointer
|
42
|
+
? queryBuilderState.executionContextState.runtimeValue
|
43
|
+
.packageableRuntime.value.path
|
44
|
+
: undefined;
|
45
|
+
if (!runtime) {
|
46
|
+
// TODO: add better message
|
47
|
+
return null;
|
48
|
+
}
|
49
|
+
const queryBuilderEngine = new QueryBuilderDataCubeEngine(
|
50
|
+
queryBuilderState.buildQuery(),
|
51
|
+
queryBuilderState.executionContextState.mapping?.path,
|
52
|
+
runtime,
|
53
|
+
queryBuilderState.graphManagerState,
|
54
|
+
);
|
55
|
+
|
56
|
+
return (
|
57
|
+
<DataCubeProvider
|
58
|
+
application={applicationStore}
|
59
|
+
engine={queryBuilderEngine}
|
60
|
+
>
|
61
|
+
<DataCube />
|
62
|
+
</DataCubeProvider>
|
63
|
+
);
|
64
|
+
},
|
65
|
+
);
|
66
|
+
|
67
|
+
export const QueryBuilderDataCubeDialog = observer(
|
68
|
+
(props: { queryBuilderState: QueryBuilderState }) => {
|
69
|
+
const { queryBuilderState } = props;
|
70
|
+
const [isMaximized, setIsMaximized] = useState(false);
|
71
|
+
const toggleMaximize = (): void => setIsMaximized(!isMaximized);
|
72
|
+
const closeModal = () => queryBuilderState.setIsCubeEnabled(false);
|
73
|
+
return (
|
74
|
+
<Dialog
|
75
|
+
open={true}
|
76
|
+
onClose={closeModal}
|
77
|
+
classes={{ container: 'dataspace-info-modal__container' }}
|
78
|
+
>
|
79
|
+
<Modal
|
80
|
+
darkMode={false}
|
81
|
+
className={clsx('editor-modal query-builder__dialog', {
|
82
|
+
'query-builder__dialog--expanded': isMaximized,
|
83
|
+
})}
|
84
|
+
>
|
85
|
+
<div className="query-builder__dialog__header">
|
86
|
+
<div className="query-builder__dialog__header__actions">
|
87
|
+
<button
|
88
|
+
className="query-builder__dialog__header__action"
|
89
|
+
tabIndex={-1}
|
90
|
+
onClick={toggleMaximize}
|
91
|
+
title={isMaximized ? 'Minimize' : 'Maximize'}
|
92
|
+
>
|
93
|
+
{isMaximized ? (
|
94
|
+
<EmptyWindowRestoreIcon />
|
95
|
+
) : (
|
96
|
+
<WindowMaximizeIcon />
|
97
|
+
)}
|
98
|
+
</button>
|
99
|
+
<button
|
100
|
+
className="query-builder__dialog__header__action"
|
101
|
+
tabIndex={-1}
|
102
|
+
onClick={closeModal}
|
103
|
+
title="Close"
|
104
|
+
>
|
105
|
+
<TimesIcon />
|
106
|
+
</button>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
<div className="query-builder__dialog__content">
|
110
|
+
<QueryBuilderDataCube queryBuilderState={queryBuilderState} />
|
111
|
+
</div>
|
112
|
+
</Modal>
|
113
|
+
</Dialog>
|
114
|
+
);
|
115
|
+
},
|
116
|
+
);
|
@@ -1110,7 +1110,7 @@ const QueryBuilderFilterConditionEditor = observer(
|
|
1110
1110
|
className="query-builder-filter-tree__condition-node__operator__dropdown__option"
|
1111
1111
|
onClick={changeOperator(op)}
|
1112
1112
|
>
|
1113
|
-
{op.getLabel()}
|
1113
|
+
{op.getLabel(node.condition)}
|
1114
1114
|
</MenuContentItem>
|
1115
1115
|
))}
|
1116
1116
|
</MenuContent>
|
@@ -1122,7 +1122,7 @@ const QueryBuilderFilterConditionEditor = observer(
|
|
1122
1122
|
}}
|
1123
1123
|
>
|
1124
1124
|
<div className="query-builder-filter-tree__condition-node__operator__label">
|
1125
|
-
{node.condition.operator.getLabel()}
|
1125
|
+
{node.condition.operator.getLabel(node.condition)}
|
1126
1126
|
</div>
|
1127
1127
|
<div className="query-builder-filter-tree__condition-node__operator__dropdown__trigger">
|
1128
1128
|
<CaretDownIcon />
|
@@ -46,6 +46,7 @@ import {
|
|
46
46
|
CubesLoadingIndicator,
|
47
47
|
InfoCircleIcon,
|
48
48
|
ShareBoxIcon,
|
49
|
+
CubeIcon,
|
49
50
|
} from '@finos/legend-art';
|
50
51
|
import { observer } from 'mobx-react-lite';
|
51
52
|
import { flowResult } from 'mobx';
|
@@ -56,6 +57,7 @@ import {
|
|
56
57
|
TDSExecutionResult,
|
57
58
|
RawExecutionResult,
|
58
59
|
ExecutionError,
|
60
|
+
RuntimePointer,
|
59
61
|
} from '@finos/legend-graph';
|
60
62
|
import {
|
61
63
|
ActionAlertActionType,
|
@@ -837,6 +839,28 @@ export const QueryBuilderResultPanel = observer(
|
|
837
839
|
</MenuContentItemIcon>
|
838
840
|
<MenuContentItemLabel>Others...</MenuContentItemLabel>
|
839
841
|
</MenuContentItem>
|
842
|
+
{queryBuilderState.config?.TEMPORARY__enableExportToCube && (
|
843
|
+
<MenuContentItem
|
844
|
+
onClick={(): void =>
|
845
|
+
queryBuilderState.setIsCubeEnabled(true)
|
846
|
+
}
|
847
|
+
disabled={
|
848
|
+
!queryBuilderState.fetchStructureState.implementation
|
849
|
+
.canBeExportedToCube ||
|
850
|
+
!(
|
851
|
+
queryBuilderState.executionContextState
|
852
|
+
.runtimeValue instanceof RuntimePointer
|
853
|
+
)
|
854
|
+
}
|
855
|
+
>
|
856
|
+
<MenuContentItemIcon>
|
857
|
+
<CubeIcon />
|
858
|
+
</MenuContentItemIcon>
|
859
|
+
<MenuContentItemLabel>
|
860
|
+
Data Cube (BETA)
|
861
|
+
</MenuContentItemLabel>
|
862
|
+
</MenuContentItem>
|
863
|
+
)}
|
840
864
|
{extraExportMenuContentItems}
|
841
865
|
</MenuContent>
|
842
866
|
}
|
@@ -346,7 +346,7 @@ export const QueryBuilderTDSGridResult = observer(
|
|
346
346
|
resultState.mousedOverCell,
|
347
347
|
true,
|
348
348
|
fetchStructureImplementation,
|
349
|
-
)
|
349
|
+
);
|
350
350
|
},
|
351
351
|
},
|
352
352
|
{
|
@@ -357,7 +357,7 @@ export const QueryBuilderTDSGridResult = observer(
|
|
357
357
|
resultState.mousedOverCell,
|
358
358
|
false,
|
359
359
|
fetchStructureImplementation,
|
360
|
-
)
|
360
|
+
);
|
361
361
|
},
|
362
362
|
},
|
363
363
|
'copy',
|
@@ -376,7 +376,6 @@ export const QueryBuilderTDSGridResult = observer(
|
|
376
376
|
applicationStore,
|
377
377
|
resultState.mousedOverCell,
|
378
378
|
resultState.queryBuilderState.fetchStructureState.implementation,
|
379
|
-
queryBuilderState.applicationStore.alertUnhandledError,
|
380
379
|
],
|
381
380
|
);
|
382
381
|
|
@@ -22,13 +22,12 @@ import {
|
|
22
22
|
import { observer } from 'mobx-react-lite';
|
23
23
|
import { flowResult } from 'mobx';
|
24
24
|
import {
|
25
|
-
type AbstractPropertyExpression,
|
26
|
-
type Enumeration,
|
27
|
-
type ExecutionResult,
|
28
25
|
type TDSExecutionResult,
|
29
|
-
|
30
|
-
EnumValueInstanceValue,
|
26
|
+
type Enumeration,
|
31
27
|
InstanceValue,
|
28
|
+
EnumValueInstanceValue,
|
29
|
+
EnumValueExplicitReference,
|
30
|
+
type ExecutionResult,
|
32
31
|
RelationalExecutionActivities,
|
33
32
|
} from '@finos/legend-graph';
|
34
33
|
import { format as formatSQL } from 'sql-formatter';
|
@@ -48,7 +47,6 @@ import { forwardRef } from 'react';
|
|
48
47
|
import {
|
49
48
|
QueryBuilderDerivationProjectionColumnState,
|
50
49
|
QueryBuilderProjectionColumnState,
|
51
|
-
QueryBuilderSimpleProjectionColumnState,
|
52
50
|
} from '../../../stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js';
|
53
51
|
import {
|
54
52
|
type QueryBuilderPostFilterTreeNodeData,
|
@@ -83,30 +81,6 @@ import {
|
|
83
81
|
} from '../../../stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js';
|
84
82
|
import { getTDSColumnState } from '../../../stores/fetch-structure/tds/QueryBuilderTDSHelper.js';
|
85
83
|
import type { QueryBuilderTDSColumnState } from '../../../stores/fetch-structure/tds/QueryBuilderTDSColumnState.js';
|
86
|
-
import {
|
87
|
-
type QueryBuilderFilterState,
|
88
|
-
type QueryBuilderFilterTreeNodeData,
|
89
|
-
FilterConditionState,
|
90
|
-
FilterValueSpecConditionValueState,
|
91
|
-
isCollectionProperty,
|
92
|
-
QueryBuilderFilterTreeConditionNodeData,
|
93
|
-
} from '../../../stores/filter/QueryBuilderFilterState.js';
|
94
|
-
import { QueryBuilderAggregateColumnState } from '../../../stores/fetch-structure/tds/aggregation/QueryBuilderAggregationState.js';
|
95
|
-
import type { QueryBuilderFilterOperator } from '../../../stores/filter/QueryBuilderFilterOperator.js';
|
96
|
-
import {
|
97
|
-
QueryBuilderFilterOperator_Equal,
|
98
|
-
QueryBuilderFilterOperator_NotEqual,
|
99
|
-
} from '../../../stores/filter/operators/QueryBuilderFilterOperator_Equal.js';
|
100
|
-
import {
|
101
|
-
QueryBuilderFilterOperator_In,
|
102
|
-
QueryBuilderFilterOperator_NotIn,
|
103
|
-
} from '../../../stores/filter/operators/QueryBuilderFilterOperator_In.js';
|
104
|
-
import {
|
105
|
-
QueryBuilderFilterOperator_IsEmpty,
|
106
|
-
QueryBuilderFilterOperator_IsNotEmpty,
|
107
|
-
} from '../../../stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.js';
|
108
|
-
import type { QueryBuilderState } from '../../../stores/QueryBuilderState.js';
|
109
|
-
import type { QueryBuilderPropertyExpressionState } from '../../../stores/QueryBuilderPropertyEditorState.js';
|
110
84
|
|
111
85
|
export const tryToFormatSql = (sql: string): string => {
|
112
86
|
try {
|
@@ -165,13 +139,6 @@ export type IQueryRendererParamsWithGridType = DataGridCellRendererParams & {
|
|
165
139
|
tdsExecutionResult: TDSExecutionResult;
|
166
140
|
};
|
167
141
|
|
168
|
-
const filterEqualOperator = new QueryBuilderFilterOperator_Equal();
|
169
|
-
const filterNotEqualOperator = new QueryBuilderFilterOperator_NotEqual();
|
170
|
-
const filterInOperator = new QueryBuilderFilterOperator_In();
|
171
|
-
const filterNotInOperator = new QueryBuilderFilterOperator_NotIn();
|
172
|
-
const filterEmptyOperator = new QueryBuilderFilterOperator_IsEmpty();
|
173
|
-
const filterNotEmptyOperator = new QueryBuilderFilterOperator_IsNotEmpty();
|
174
|
-
|
175
142
|
const postFilterEqualOperator = new QueryBuilderPostFilterOperator_Equal();
|
176
143
|
const postFilterInOperator = new QueryBuilderPostFilterOperator_In();
|
177
144
|
const postFilterEmptyOperator = new QueryBuilderPostFilterOperator_IsEmpty();
|
@@ -181,22 +148,6 @@ const postFilterNotEqualOperator =
|
|
181
148
|
new QueryBuilderPostFilterOperator_NotEqual();
|
182
149
|
const postFilterNotInOperator = new QueryBuilderPostFilterOperator_NotIn();
|
183
150
|
|
184
|
-
const getExistingFilterNode = (
|
185
|
-
operators: QueryBuilderFilterOperator[],
|
186
|
-
propertyExpressionState: QueryBuilderPropertyExpressionState | undefined,
|
187
|
-
filterState: QueryBuilderFilterState,
|
188
|
-
): QueryBuilderFilterTreeNodeData | undefined =>
|
189
|
-
Array.from(filterState.nodes.values())
|
190
|
-
.filter(filterByType(QueryBuilderFilterTreeConditionNodeData))
|
191
|
-
.filter(
|
192
|
-
(node) =>
|
193
|
-
node.condition.propertyExpressionState.path ===
|
194
|
-
propertyExpressionState?.path &&
|
195
|
-
operators
|
196
|
-
.map((op) => op.getLabel())
|
197
|
-
.includes(node.condition.operator.getLabel()),
|
198
|
-
)[0];
|
199
|
-
|
200
151
|
const getExistingPostFilterNode = (
|
201
152
|
operators: QueryBuilderPostFilterOperator[],
|
202
153
|
projectionColumnName: string | undefined,
|
@@ -222,7 +173,7 @@ const getExistingPostFilterNode = (
|
|
222
173
|
const updateFilterConditionValue = (
|
223
174
|
conditionValue: InstanceValue,
|
224
175
|
_cellData: QueryBuilderTDSResultCellData,
|
225
|
-
|
176
|
+
tdsState: QueryBuilderTDSState,
|
226
177
|
): void => {
|
227
178
|
if (_cellData.value) {
|
228
179
|
instanceValue_setValue(
|
@@ -237,58 +188,11 @@ const updateFilterConditionValue = (
|
|
237
188
|
)
|
238
189
|
: _cellData.value,
|
239
190
|
0,
|
240
|
-
queryBuilderState.observerContext,
|
191
|
+
tdsState.queryBuilderState.observerContext,
|
241
192
|
);
|
242
193
|
}
|
243
194
|
};
|
244
195
|
|
245
|
-
const generateNewFilterConditionNodeData = (
|
246
|
-
applicationStore: ApplicationStore<
|
247
|
-
LegendApplicationConfig,
|
248
|
-
LegendApplicationPluginManager<LegendApplicationPlugin>
|
249
|
-
>,
|
250
|
-
operator: QueryBuilderFilterOperator,
|
251
|
-
_cellData: QueryBuilderTDSResultCellData,
|
252
|
-
filterState: QueryBuilderFilterState,
|
253
|
-
propertyExpression: AbstractPropertyExpression | undefined,
|
254
|
-
): void => {
|
255
|
-
let filterConditionState: FilterConditionState;
|
256
|
-
try {
|
257
|
-
if (propertyExpression) {
|
258
|
-
filterConditionState = new FilterConditionState(
|
259
|
-
filterState,
|
260
|
-
propertyExpression,
|
261
|
-
operator,
|
262
|
-
);
|
263
|
-
|
264
|
-
const defaultFilterConditionValue =
|
265
|
-
filterConditionState.operator.getDefaultFilterConditionValue(
|
266
|
-
filterConditionState,
|
267
|
-
);
|
268
|
-
|
269
|
-
filterConditionState.buildRightConditionValueFromValueSpec(
|
270
|
-
defaultFilterConditionValue,
|
271
|
-
);
|
272
|
-
updateFilterConditionValue(
|
273
|
-
defaultFilterConditionValue as InstanceValue,
|
274
|
-
_cellData,
|
275
|
-
filterState.queryBuilderState,
|
276
|
-
);
|
277
|
-
filterState.addNodeFromNode(
|
278
|
-
new QueryBuilderFilterTreeConditionNodeData(
|
279
|
-
undefined,
|
280
|
-
filterConditionState,
|
281
|
-
),
|
282
|
-
undefined,
|
283
|
-
);
|
284
|
-
}
|
285
|
-
} catch (error) {
|
286
|
-
assertErrorThrown(error);
|
287
|
-
applicationStore.notificationService.notifyWarning(error.message);
|
288
|
-
return;
|
289
|
-
}
|
290
|
-
};
|
291
|
-
|
292
196
|
const generateNewPostFilterConditionNodeData = async (
|
293
197
|
applicationStore: ApplicationStore<
|
294
198
|
LegendApplicationConfig,
|
@@ -331,7 +235,7 @@ const generateNewPostFilterConditionNodeData = async (
|
|
331
235
|
updateFilterConditionValue(
|
332
236
|
defaultFilterConditionValue as InstanceValue,
|
333
237
|
_cellData,
|
334
|
-
tdsState
|
238
|
+
tdsState,
|
335
239
|
);
|
336
240
|
tdsState.postFilterState.addNodeFromNode(
|
337
241
|
new QueryBuilderPostFilterTreeConditionNodeData(
|
@@ -348,91 +252,6 @@ const generateNewPostFilterConditionNodeData = async (
|
|
348
252
|
}
|
349
253
|
};
|
350
254
|
|
351
|
-
const updateExistingFilterConditionNodeData = (
|
352
|
-
existingPreFilterNode: QueryBuilderFilterTreeNodeData,
|
353
|
-
isFilterBy: boolean,
|
354
|
-
_cellData: QueryBuilderTDSResultCellData,
|
355
|
-
operator: QueryBuilderFilterOperator,
|
356
|
-
data: QueryBuilderTDSResultCellData | null,
|
357
|
-
queryBuilderState: QueryBuilderState,
|
358
|
-
): void => {
|
359
|
-
if (operator === filterEmptyOperator || operator === filterNotEmptyOperator) {
|
360
|
-
const conditionState = (
|
361
|
-
existingPreFilterNode as QueryBuilderFilterTreeConditionNodeData
|
362
|
-
).condition;
|
363
|
-
if (conditionState.operator.getLabel() !== operator.getLabel()) {
|
364
|
-
conditionState.changeOperator(
|
365
|
-
isFilterBy ? filterEmptyOperator : filterNotEmptyOperator,
|
366
|
-
);
|
367
|
-
}
|
368
|
-
return;
|
369
|
-
}
|
370
|
-
const conditionState = (
|
371
|
-
existingPreFilterNode as QueryBuilderFilterTreeConditionNodeData
|
372
|
-
).condition;
|
373
|
-
|
374
|
-
const rightSide = conditionState.rightConditionValue;
|
375
|
-
if (rightSide instanceof FilterValueSpecConditionValueState) {
|
376
|
-
if (conditionState.operator.getLabel() === operator.getLabel()) {
|
377
|
-
const doesValueAlreadyExist =
|
378
|
-
rightSide.value instanceof InstanceValue &&
|
379
|
-
(rightSide.value instanceof EnumValueInstanceValue
|
380
|
-
? rightSide.value.values.map((ef) => ef.value.name)
|
381
|
-
: rightSide.value.values
|
382
|
-
).includes(_cellData.value);
|
383
|
-
|
384
|
-
if (!doesValueAlreadyExist) {
|
385
|
-
const currentValueSpecificaton = rightSide.value;
|
386
|
-
const newValueSpecification =
|
387
|
-
conditionState.operator.getDefaultFilterConditionValue(
|
388
|
-
conditionState,
|
389
|
-
);
|
390
|
-
updateFilterConditionValue(
|
391
|
-
newValueSpecification as InstanceValue,
|
392
|
-
_cellData,
|
393
|
-
queryBuilderState,
|
394
|
-
);
|
395
|
-
conditionState.changeOperator(
|
396
|
-
isFilterBy ? filterInOperator : filterNotInOperator,
|
397
|
-
);
|
398
|
-
instanceValue_setValues(
|
399
|
-
rightSide.value as InstanceValue,
|
400
|
-
[currentValueSpecificaton, newValueSpecification],
|
401
|
-
queryBuilderState.observerContext,
|
402
|
-
);
|
403
|
-
}
|
404
|
-
} else {
|
405
|
-
const doesValueAlreadyExist =
|
406
|
-
rightSide.value instanceof InstanceValue &&
|
407
|
-
rightSide.value.values
|
408
|
-
.filter((v) => v instanceof InstanceValue)
|
409
|
-
.map((v) =>
|
410
|
-
v instanceof EnumValueInstanceValue
|
411
|
-
? v.values.map((ef) => ef.value.name)
|
412
|
-
: v.values,
|
413
|
-
)
|
414
|
-
.flat()
|
415
|
-
.includes(_cellData.value ?? data?.value);
|
416
|
-
|
417
|
-
if (!doesValueAlreadyExist) {
|
418
|
-
const newValueSpecification = (
|
419
|
-
isFilterBy ? filterEqualOperator : filterNotEqualOperator
|
420
|
-
).getDefaultFilterConditionValue(conditionState);
|
421
|
-
updateFilterConditionValue(
|
422
|
-
newValueSpecification as InstanceValue,
|
423
|
-
_cellData,
|
424
|
-
queryBuilderState,
|
425
|
-
);
|
426
|
-
instanceValue_setValues(
|
427
|
-
rightSide.value as InstanceValue,
|
428
|
-
[...(rightSide.value as InstanceValue).values, newValueSpecification],
|
429
|
-
queryBuilderState.observerContext,
|
430
|
-
);
|
431
|
-
}
|
432
|
-
}
|
433
|
-
}
|
434
|
-
};
|
435
|
-
|
436
255
|
const updateExistingPostFilterConditionNodeData = (
|
437
256
|
existingPostFilterNode: QueryBuilderPostFilterTreeNodeData,
|
438
257
|
isFilterBy: boolean,
|
@@ -478,7 +297,7 @@ const updateExistingPostFilterConditionNodeData = (
|
|
478
297
|
updateFilterConditionValue(
|
479
298
|
newValueSpecification as InstanceValue,
|
480
299
|
_cellData,
|
481
|
-
tdsState
|
300
|
+
tdsState,
|
482
301
|
);
|
483
302
|
conditionState.changeOperator(
|
484
303
|
isFilterBy ? postFilterInOperator : postFilterNotInOperator,
|
@@ -509,7 +328,7 @@ const updateExistingPostFilterConditionNodeData = (
|
|
509
328
|
updateFilterConditionValue(
|
510
329
|
newValueSpecification as InstanceValue,
|
511
330
|
_cellData,
|
512
|
-
tdsState
|
331
|
+
tdsState,
|
513
332
|
);
|
514
333
|
instanceValue_setValues(
|
515
334
|
rightSide.value as InstanceValue,
|
@@ -524,25 +343,6 @@ const updateExistingPostFilterConditionNodeData = (
|
|
524
343
|
const getFilterOperator = (
|
525
344
|
isFilterBy: boolean,
|
526
345
|
_cellData: QueryBuilderTDSResultCellData,
|
527
|
-
): QueryBuilderFilterOperator => {
|
528
|
-
if (isFilterBy) {
|
529
|
-
if (_cellData.value === null) {
|
530
|
-
return filterEmptyOperator;
|
531
|
-
} else {
|
532
|
-
return filterEqualOperator;
|
533
|
-
}
|
534
|
-
} else {
|
535
|
-
if (_cellData.value === null) {
|
536
|
-
return filterNotEmptyOperator;
|
537
|
-
} else {
|
538
|
-
return filterNotEqualOperator;
|
539
|
-
}
|
540
|
-
}
|
541
|
-
};
|
542
|
-
|
543
|
-
const getPostFilterOperator = (
|
544
|
-
isFilterBy: boolean,
|
545
|
-
_cellData: QueryBuilderTDSResultCellData,
|
546
346
|
): QueryBuilderPostFilterOperator => {
|
547
347
|
if (isFilterBy) {
|
548
348
|
if (_cellData.value === null) {
|
@@ -559,54 +359,7 @@ const getPostFilterOperator = (
|
|
559
359
|
}
|
560
360
|
};
|
561
361
|
|
562
|
-
const
|
563
|
-
applicationStore: ApplicationStore<
|
564
|
-
LegendApplicationConfig,
|
565
|
-
LegendApplicationPluginManager<LegendApplicationPlugin>
|
566
|
-
>,
|
567
|
-
isFilterBy: boolean,
|
568
|
-
_cellData: QueryBuilderTDSResultCellData,
|
569
|
-
data: QueryBuilderTDSResultCellData | null,
|
570
|
-
propertyExpressionState: QueryBuilderPropertyExpressionState,
|
571
|
-
queryBuilderState: QueryBuilderState,
|
572
|
-
): void => {
|
573
|
-
queryBuilderState.filterState.setShowPanel(true);
|
574
|
-
const operator = getFilterOperator(isFilterBy, _cellData);
|
575
|
-
const existingPreFilterNode = getExistingFilterNode(
|
576
|
-
_cellData.value === null
|
577
|
-
? [filterEmptyOperator, filterNotEmptyOperator]
|
578
|
-
: isFilterBy
|
579
|
-
? [filterEqualOperator, filterInOperator]
|
580
|
-
: [filterNotEqualOperator, filterNotInOperator],
|
581
|
-
propertyExpressionState,
|
582
|
-
queryBuilderState.filterState,
|
583
|
-
);
|
584
|
-
if (existingPreFilterNode) {
|
585
|
-
updateExistingFilterConditionNodeData(
|
586
|
-
existingPreFilterNode,
|
587
|
-
isFilterBy,
|
588
|
-
_cellData,
|
589
|
-
operator,
|
590
|
-
data,
|
591
|
-
queryBuilderState,
|
592
|
-
);
|
593
|
-
} else {
|
594
|
-
try {
|
595
|
-
generateNewFilterConditionNodeData(
|
596
|
-
applicationStore,
|
597
|
-
operator,
|
598
|
-
_cellData,
|
599
|
-
queryBuilderState.filterState,
|
600
|
-
propertyExpressionState.propertyExpression,
|
601
|
-
);
|
602
|
-
} catch (error) {
|
603
|
-
assertErrorThrown(error);
|
604
|
-
applicationStore.alertUnhandledError(error);
|
605
|
-
}
|
606
|
-
}
|
607
|
-
};
|
608
|
-
|
609
|
-
const postFilterByOrOutValue = async (
|
362
|
+
const filterByOrOutValue = (
|
610
363
|
applicationStore: ApplicationStore<
|
611
364
|
LegendApplicationConfig,
|
612
365
|
LegendApplicationPluginManager<LegendApplicationPlugin>
|
@@ -614,11 +367,13 @@ const postFilterByOrOutValue = async (
|
|
614
367
|
isFilterBy: boolean,
|
615
368
|
_cellData: QueryBuilderTDSResultCellData,
|
616
369
|
data: QueryBuilderTDSResultCellData | null,
|
617
|
-
tdsColState: QueryBuilderTDSColumnState,
|
618
370
|
tdsState: QueryBuilderTDSState,
|
619
|
-
):
|
371
|
+
): void => {
|
620
372
|
tdsState.setShowPostFilterPanel(true);
|
621
|
-
const operator =
|
373
|
+
const operator = getFilterOperator(isFilterBy, _cellData);
|
374
|
+
const tdsColState = data?.columnName
|
375
|
+
? getTDSColumnState(tdsState, data.columnName)
|
376
|
+
: undefined;
|
622
377
|
const existingPostFilterNode = getExistingPostFilterNode(
|
623
378
|
_cellData.value === null
|
624
379
|
? [postFilterEmptyOperator, postFilterNotEmptyOperator]
|
@@ -639,67 +394,17 @@ const postFilterByOrOutValue = async (
|
|
639
394
|
tdsState,
|
640
395
|
);
|
641
396
|
} else {
|
642
|
-
|
643
|
-
await generateNewPostFilterConditionNodeData(
|
644
|
-
applicationStore,
|
645
|
-
operator,
|
646
|
-
_cellData,
|
647
|
-
tdsState,
|
648
|
-
tdsColState,
|
649
|
-
);
|
650
|
-
} catch (error) {
|
651
|
-
assertErrorThrown(error);
|
652
|
-
applicationStore.alertUnhandledError(error);
|
653
|
-
}
|
654
|
-
}
|
655
|
-
};
|
656
|
-
|
657
|
-
const filterByOrOutValue = async (
|
658
|
-
applicationStore: ApplicationStore<
|
659
|
-
LegendApplicationConfig,
|
660
|
-
LegendApplicationPluginManager<LegendApplicationPlugin>
|
661
|
-
>,
|
662
|
-
isFilterBy: boolean,
|
663
|
-
_cellData: QueryBuilderTDSResultCellData,
|
664
|
-
data: QueryBuilderTDSResultCellData | null,
|
665
|
-
tdsState: QueryBuilderTDSState,
|
666
|
-
): Promise<void> => {
|
667
|
-
const tdsColState = data?.columnName
|
668
|
-
? getTDSColumnState(tdsState, data.columnName)
|
669
|
-
: undefined;
|
670
|
-
if (
|
671
|
-
tdsColState instanceof QueryBuilderDerivationProjectionColumnState ||
|
672
|
-
tdsColState instanceof QueryBuilderAggregateColumnState ||
|
673
|
-
(tdsColState instanceof QueryBuilderSimpleProjectionColumnState &&
|
674
|
-
isCollectionProperty(
|
675
|
-
tdsColState.propertyExpressionState.propertyExpression,
|
676
|
-
))
|
677
|
-
) {
|
678
|
-
await postFilterByOrOutValue(
|
397
|
+
generateNewPostFilterConditionNodeData(
|
679
398
|
applicationStore,
|
680
|
-
|
399
|
+
operator,
|
681
400
|
_cellData,
|
682
|
-
data,
|
683
|
-
tdsColState,
|
684
401
|
tdsState,
|
685
|
-
|
686
|
-
|
687
|
-
preFilterByOrOutValue(
|
688
|
-
applicationStore,
|
689
|
-
isFilterBy,
|
690
|
-
_cellData,
|
691
|
-
data,
|
692
|
-
tdsColState.propertyExpressionState,
|
693
|
-
tdsState.queryBuilderState,
|
694
|
-
);
|
695
|
-
} else {
|
696
|
-
applicationStore.notificationService.notifyError(
|
697
|
-
`Can't filter column '${data?.columnName}'`,
|
698
|
-
);
|
402
|
+
tdsColState,
|
403
|
+
).catch(applicationStore.alertUnhandledError);
|
699
404
|
}
|
700
405
|
};
|
701
406
|
|
702
|
-
export const filterByOrOutValues =
|
407
|
+
export const filterByOrOutValues = (
|
703
408
|
applicationStore: ApplicationStore<
|
704
409
|
LegendApplicationConfig,
|
705
410
|
LegendApplicationPluginManager<LegendApplicationPlugin>
|
@@ -707,17 +412,10 @@ export const filterByOrOutValues = async (
|
|
707
412
|
data: QueryBuilderTDSResultCellData | null,
|
708
413
|
isFilterBy: boolean,
|
709
414
|
tdsState: QueryBuilderTDSState,
|
710
|
-
):
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
applicationStore,
|
715
|
-
isFilterBy,
|
716
|
-
_cellData,
|
717
|
-
data,
|
718
|
-
tdsState,
|
719
|
-
);
|
720
|
-
}
|
415
|
+
): void => {
|
416
|
+
tdsState.queryBuilderState.resultState.selectedCells.forEach((_cellData) => {
|
417
|
+
filterByOrOutValue(applicationStore, isFilterBy, _cellData, data, tdsState);
|
418
|
+
});
|
721
419
|
};
|
722
420
|
|
723
421
|
export const QueryBuilderGridResultContextMenu = observer(
|
@@ -742,9 +440,7 @@ export const QueryBuilderGridResultContextMenu = observer(
|
|
742
440
|
<MenuContentItem
|
743
441
|
disabled={!tdsColState}
|
744
442
|
onClick={(): void => {
|
745
|
-
filterByOrOutValues(applicationStore, data, true, tdsState)
|
746
|
-
tdsState.queryBuilderState.applicationStore.alertUnhandledError,
|
747
|
-
);
|
443
|
+
filterByOrOutValues(applicationStore, data, true, tdsState);
|
748
444
|
}}
|
749
445
|
>
|
750
446
|
Filter By
|
@@ -752,9 +448,7 @@ export const QueryBuilderGridResultContextMenu = observer(
|
|
752
448
|
<MenuContentItem
|
753
449
|
disabled={!tdsColState}
|
754
450
|
onClick={(): void => {
|
755
|
-
filterByOrOutValues(applicationStore, data, false, tdsState)
|
756
|
-
tdsState.queryBuilderState.applicationStore.alertUnhandledError,
|
757
|
-
);
|
451
|
+
filterByOrOutValues(applicationStore, data, false, tdsState);
|
758
452
|
}}
|
759
453
|
>
|
760
454
|
Filter Out
|