@finos/legend-query-builder 4.11.17 → 4.13.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts.map +1 -1
- package/lib/components/explorer/QueryBuilderMilestoningEditor.js +19 -33
- package/lib/components/explorer/QueryBuilderMilestoningEditor.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +28 -2
- package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.d.ts +7 -3
- package/lib/graph/QueryBuilderMetaModelConst.d.ts.map +1 -1
- package/lib/graph/QueryBuilderMetaModelConst.js +8 -2
- package/lib/graph/QueryBuilderMetaModelConst.js.map +1 -1
- package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js +9 -3
- package/lib/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts +2 -0
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js +20 -0
- package/lib/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderState.d.ts +6 -1
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +15 -5
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.d.ts.map +1 -1
- package/lib/stores/QueryBuilderStateBuilder.js +50 -5
- package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilder.d.ts +1 -0
- package/lib/stores/QueryBuilderValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilder.js +49 -12
- package/lib/stores/QueryBuilderValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.js +4 -2
- package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.d.ts +2 -0
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.js +6 -0
- package/lib/stores/fetch-structure/tds/QueryResultSetModifierState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationStateBuilder.js +4 -2
- package/lib/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts +1 -0
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js +30 -4
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js +16 -0
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.d.ts +1 -0
- package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.d.ts.map +1 -1
- package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.js +4 -1
- package/lib/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.js.map +1 -1
- package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.d.ts +1 -0
- package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.d.ts.map +1 -1
- package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.js +10 -1
- package/lib/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.js.map +1 -1
- package/lib/stores/milestoning/QueryBuilderMilestoningHelper.d.ts.map +1 -1
- package/lib/stores/milestoning/QueryBuilderMilestoningHelper.js +5 -0
- package/lib/stores/milestoning/QueryBuilderMilestoningHelper.js.map +1 -1
- package/lib/stores/milestoning/QueryBuilderMilestoningImplementation.d.ts +4 -0
- package/lib/stores/milestoning/QueryBuilderMilestoningImplementation.d.ts.map +1 -1
- package/lib/stores/milestoning/QueryBuilderMilestoningImplementation.js.map +1 -1
- package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts +15 -0
- package/lib/stores/milestoning/QueryBuilderMilestoningState.d.ts.map +1 -1
- package/lib/stores/milestoning/QueryBuilderMilestoningState.js +191 -3
- package/lib/stores/milestoning/QueryBuilderMilestoningState.js.map +1 -1
- package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.d.ts +1 -0
- package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.d.ts.map +1 -1
- package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.js +10 -1
- package/lib/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.js.map +1 -1
- package/lib/stores/watermark/QueryBuilderWatermarkStateBuilder.d.ts.map +1 -1
- package/lib/stores/watermark/QueryBuilderWatermarkStateBuilder.js +4 -2
- package/lib/stores/watermark/QueryBuilderWatermarkStateBuilder.js.map +1 -1
- package/package.json +5 -5
- package/src/components/explorer/QueryBuilderMilestoningEditor.tsx +106 -35
- package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +84 -0
- package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +13 -0
- package/src/graph/QueryBuilderMetaModelConst.ts +9 -2
- package/src/graph-manager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.ts +30 -1
- package/src/graph-manager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.ts +65 -0
- package/src/stores/QueryBuilderState.ts +25 -6
- package/src/stores/QueryBuilderStateBuilder.ts +124 -5
- package/src/stores/QueryBuilderValueSpecificationBuilder.ts +76 -12
- package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeStateBuilder.ts +4 -1
- package/src/stores/fetch-structure/tds/QueryResultSetModifierState.ts +7 -0
- package/src/stores/fetch-structure/tds/aggregation/QueryBuilderAggregationStateBuilder.ts +7 -2
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionStateBuilder.ts +68 -1
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +27 -0
- package/src/stores/milestoning/QueryBuilderBitemporalMilestoningImplementation.ts +9 -0
- package/src/stores/milestoning/QueryBuilderBusinessTemporalMilestoningImplementation.ts +22 -1
- package/src/stores/milestoning/QueryBuilderMilestoningHelper.ts +7 -0
- package/src/stores/milestoning/QueryBuilderMilestoningImplementation.ts +7 -0
- package/src/stores/milestoning/QueryBuilderMilestoningState.ts +279 -1
- package/src/stores/milestoning/QueryBuilderProcessingTemporalMilestoningImplementation.ts +22 -1
- package/src/stores/watermark/QueryBuilderWatermarkStateBuilder.ts +4 -2
@@ -52,6 +52,7 @@ import {
|
|
52
52
|
PackageableRuntime,
|
53
53
|
RuntimePointer,
|
54
54
|
PackageableElementExplicitReference,
|
55
|
+
MILESTONING_STEREOTYPE,
|
55
56
|
} from '@finos/legend-graph';
|
56
57
|
import { processTDSPostFilterExpression } from './fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js';
|
57
58
|
import { processFilterExpression } from './filter/QueryBuilderFilterStateBuilder.js';
|
@@ -70,6 +71,7 @@ import {
|
|
70
71
|
processTDSProjectExpression,
|
71
72
|
processTDSProjectionColumnPropertyExpression,
|
72
73
|
processTDSProjectionDerivationExpression,
|
74
|
+
processTDSSliceExpression,
|
73
75
|
processTDSSortDirectionExpression,
|
74
76
|
processTDSSortExpression,
|
75
77
|
processTDSTakeExpression,
|
@@ -77,6 +79,7 @@ import {
|
|
77
79
|
import {
|
78
80
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
79
81
|
QUERY_BUILDER_SUPPORTED_CALENDAR_AGGREGATION_FUNCTIONS,
|
82
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS,
|
80
83
|
} from '../graph/QueryBuilderMetaModelConst.js';
|
81
84
|
import { LambdaParameterState } from './shared/LambdaParameterState.js';
|
82
85
|
import { processTDS_OLAPGroupByExpression } from './fetch-structure/tds/window/QueryBuilderWindowStateBuilder.js';
|
@@ -122,6 +125,87 @@ const processGetAllExpression = (
|
|
122
125
|
}
|
123
126
|
};
|
124
127
|
|
128
|
+
const processGetAllVersionsExpression = (
|
129
|
+
expression: SimpleFunctionExpression,
|
130
|
+
queryBuilderState: QueryBuilderState,
|
131
|
+
): void => {
|
132
|
+
const _class = expression.genericType?.value.rawType;
|
133
|
+
assertType(
|
134
|
+
_class,
|
135
|
+
Class,
|
136
|
+
`Can't process getAllVersions() expression: getAllVersions() return type is missing`,
|
137
|
+
);
|
138
|
+
queryBuilderState.setClass(_class);
|
139
|
+
queryBuilderState.milestoningState.clearMilestoningDates();
|
140
|
+
queryBuilderState.explorerState.refreshTreeData();
|
141
|
+
|
142
|
+
// check parameters (milestoning) and build state
|
143
|
+
const acceptedNoOfParameters = 1;
|
144
|
+
const stereotype = getMilestoneTemporalStereotype(
|
145
|
+
_class,
|
146
|
+
queryBuilderState.graphManagerState.graph,
|
147
|
+
);
|
148
|
+
assertNonNullable(
|
149
|
+
stereotype,
|
150
|
+
`Can't process getAllVersions() expression: getAllVersions() expects source class to be milestoned`,
|
151
|
+
);
|
152
|
+
|
153
|
+
assertTrue(
|
154
|
+
expression.parametersValues.length === acceptedNoOfParameters,
|
155
|
+
`Can't process getAllVersions() expression: getAllVersions() expects no arguments`,
|
156
|
+
);
|
157
|
+
queryBuilderState.setGetAllFunction(
|
158
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS,
|
159
|
+
);
|
160
|
+
};
|
161
|
+
|
162
|
+
const processGetAllVersionsInRangeExpression = (
|
163
|
+
expression: SimpleFunctionExpression,
|
164
|
+
queryBuilderState: QueryBuilderState,
|
165
|
+
): void => {
|
166
|
+
const _class = expression.genericType?.value.rawType;
|
167
|
+
assertType(
|
168
|
+
_class,
|
169
|
+
Class,
|
170
|
+
`Can't process getAllVersionsInRange() expression: getAllVersionsInRange() return type is missing`,
|
171
|
+
);
|
172
|
+
queryBuilderState.setClass(_class);
|
173
|
+
queryBuilderState.milestoningState.clearMilestoningDates();
|
174
|
+
queryBuilderState.explorerState.refreshTreeData();
|
175
|
+
|
176
|
+
// check parameters (milestoning) and build state
|
177
|
+
const acceptedNoOfParameters = 3;
|
178
|
+
const stereotype = getMilestoneTemporalStereotype(
|
179
|
+
_class,
|
180
|
+
queryBuilderState.graphManagerState.graph,
|
181
|
+
);
|
182
|
+
assertTrue(
|
183
|
+
stereotype !== undefined &&
|
184
|
+
stereotype !== MILESTONING_STEREOTYPE.BITEMPORAL,
|
185
|
+
`Can't process getAllVersionsInRange() expression: getAllVersionInRange() expects source class to be processing temporal or business temporal milestoned`,
|
186
|
+
);
|
187
|
+
|
188
|
+
assertTrue(
|
189
|
+
expression.parametersValues.length === acceptedNoOfParameters,
|
190
|
+
`Can't process getAllVersionsInRange() expression: getAllVersionsInRange() expects start and end date`,
|
191
|
+
);
|
192
|
+
queryBuilderState.setGetAllFunction(
|
193
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
194
|
+
);
|
195
|
+
queryBuilderState.milestoningState.setStartDate(
|
196
|
+
guaranteeNonNullable(
|
197
|
+
expression.parametersValues[1],
|
198
|
+
`Can't process getAllVersionsInRange() expression: getAllVersionsInRange() expects start date to be defined`,
|
199
|
+
),
|
200
|
+
);
|
201
|
+
queryBuilderState.milestoningState.setEndDate(
|
202
|
+
guaranteeNonNullable(
|
203
|
+
expression.parametersValues[2],
|
204
|
+
`Can't process getAllVersionsInRange() expression: getAllVersionsInRange() expects end date to be defined`,
|
205
|
+
),
|
206
|
+
);
|
207
|
+
};
|
208
|
+
|
125
209
|
const processLetExpression = (
|
126
210
|
expression: SimpleFunctionExpression,
|
127
211
|
queryBuilderState: QueryBuilderState,
|
@@ -381,10 +465,35 @@ export class QueryBuilderValueSpecificationProcessor
|
|
381
465
|
): void {
|
382
466
|
const functionName = valueSpecification.functionName;
|
383
467
|
if (
|
384
|
-
matchFunctionName(
|
468
|
+
matchFunctionName(
|
469
|
+
functionName,
|
470
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL,
|
471
|
+
)
|
385
472
|
) {
|
386
473
|
processGetAllExpression(valueSpecification, this.queryBuilderState);
|
387
474
|
return;
|
475
|
+
} else if (
|
476
|
+
matchFunctionName(
|
477
|
+
functionName,
|
478
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS,
|
479
|
+
)
|
480
|
+
) {
|
481
|
+
processGetAllVersionsExpression(
|
482
|
+
valueSpecification,
|
483
|
+
this.queryBuilderState,
|
484
|
+
);
|
485
|
+
return;
|
486
|
+
} else if (
|
487
|
+
matchFunctionName(
|
488
|
+
functionName,
|
489
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
490
|
+
)
|
491
|
+
) {
|
492
|
+
processGetAllVersionsInRangeExpression(
|
493
|
+
valueSpecification,
|
494
|
+
this.queryBuilderState,
|
495
|
+
);
|
496
|
+
return;
|
388
497
|
} else if (
|
389
498
|
matchFunctionName(
|
390
499
|
functionName,
|
@@ -427,10 +536,11 @@ export class QueryBuilderValueSpecificationProcessor
|
|
427
536
|
);
|
428
537
|
|
429
538
|
if (
|
430
|
-
matchFunctionName(
|
431
|
-
|
432
|
-
|
433
|
-
|
539
|
+
matchFunctionName(precedingExpression.functionName, [
|
540
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL,
|
541
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS,
|
542
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
543
|
+
])
|
434
544
|
) {
|
435
545
|
assertTrue(
|
436
546
|
matchFunctionName(
|
@@ -532,6 +642,15 @@ export class QueryBuilderValueSpecificationProcessor
|
|
532
642
|
this.parentLambda,
|
533
643
|
);
|
534
644
|
return;
|
645
|
+
} else if (
|
646
|
+
matchFunctionName(functionName, QUERY_BUILDER_SUPPORTED_FUNCTIONS.SLICE)
|
647
|
+
) {
|
648
|
+
processTDSSliceExpression(
|
649
|
+
valueSpecification,
|
650
|
+
this.queryBuilderState,
|
651
|
+
this.parentLambda,
|
652
|
+
);
|
653
|
+
return;
|
535
654
|
} else if (
|
536
655
|
matchFunctionName(functionName, [
|
537
656
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_ASC,
|
@@ -14,7 +14,11 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
import {
|
17
|
+
import {
|
18
|
+
UnsupportedOperationError,
|
19
|
+
guaranteeNonNullable,
|
20
|
+
guaranteeType,
|
21
|
+
} from '@finos/legend-shared';
|
18
22
|
import {
|
19
23
|
type Class,
|
20
24
|
Multiplicity,
|
@@ -35,7 +39,7 @@ import type { QueryBuilderState } from './QueryBuilderState.js';
|
|
35
39
|
import { buildFilterExpression } from './filter/QueryBuilderFilterValueSpecificationBuilder.js';
|
36
40
|
import type { LambdaFunctionBuilderOption } from './QueryBuilderValueSpecificationBuilderHelper.js';
|
37
41
|
import type { QueryBuilderFetchStructureState } from './fetch-structure/QueryBuilderFetchStructureState.js';
|
38
|
-
import {
|
42
|
+
import { QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS } from '../graph/QueryBuilderMetaModelConst.js';
|
39
43
|
import { buildWatermarkExpression } from './watermark/QueryBuilderWatermarkValueSpecificationBuilder.js';
|
40
44
|
import { buildExecutionQueryFromLambdaFunction } from './shared/LambdaParameterState.js';
|
41
45
|
import {
|
@@ -48,7 +52,27 @@ export const buildGetAllFunction = (
|
|
48
52
|
multiplicity: Multiplicity,
|
49
53
|
): SimpleFunctionExpression => {
|
50
54
|
const _func = new SimpleFunctionExpression(
|
51
|
-
extractElementNameFromPath(
|
55
|
+
extractElementNameFromPath(
|
56
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL,
|
57
|
+
),
|
58
|
+
);
|
59
|
+
const classInstance = new InstanceValue(
|
60
|
+
multiplicity,
|
61
|
+
GenericTypeExplicitReference.create(new GenericType(_class)),
|
62
|
+
);
|
63
|
+
classInstance.values[0] = PackageableElementExplicitReference.create(_class);
|
64
|
+
_func.parametersValues.push(classInstance);
|
65
|
+
return _func;
|
66
|
+
};
|
67
|
+
|
68
|
+
export const buildGetAllVersionsInRangeFunction = (
|
69
|
+
_class: Class,
|
70
|
+
multiplicity: Multiplicity,
|
71
|
+
): SimpleFunctionExpression => {
|
72
|
+
const _func = new SimpleFunctionExpression(
|
73
|
+
extractElementNameFromPath(
|
74
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
75
|
+
),
|
52
76
|
);
|
53
77
|
const classInstance = new InstanceValue(
|
54
78
|
multiplicity,
|
@@ -65,7 +89,7 @@ const buildGetAllVersionsFunction = (
|
|
65
89
|
): SimpleFunctionExpression => {
|
66
90
|
const _func = new SimpleFunctionExpression(
|
67
91
|
extractElementNameFromPath(
|
68
|
-
|
92
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS,
|
69
93
|
),
|
70
94
|
);
|
71
95
|
const classInstance = new InstanceValue(
|
@@ -159,15 +183,55 @@ export const buildLambdaFunction = (
|
|
159
183
|
);
|
160
184
|
lambdaFunction.expressionSequence[0] = getAllVersionsFunction;
|
161
185
|
} else {
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
186
|
+
switch (queryBuilderState.getAllFunction) {
|
187
|
+
case QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS: {
|
188
|
+
if (milestoningStereotype) {
|
189
|
+
const getAllVersionsFunction = buildGetAllVersionsFunction(
|
190
|
+
_class,
|
191
|
+
Multiplicity.ONE,
|
192
|
+
);
|
193
|
+
lambdaFunction.expressionSequence[0] = getAllVersionsFunction;
|
194
|
+
} else {
|
195
|
+
throw new UnsupportedOperationError(
|
196
|
+
`Unable to build query lamdba: getAllVersions() expects source class to be milestoned`,
|
197
|
+
);
|
198
|
+
}
|
199
|
+
break;
|
200
|
+
}
|
201
|
+
case QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE: {
|
202
|
+
if (milestoningStereotype) {
|
203
|
+
const getAllVersionsInRangeFunction =
|
204
|
+
buildGetAllVersionsInRangeFunction(_class, Multiplicity.ONE);
|
205
|
+
queryBuilderState.milestoningState
|
206
|
+
.getMilestoningImplementation(milestoningStereotype)
|
207
|
+
.buildGetAllVersionsInRangeParameters(
|
208
|
+
getAllVersionsInRangeFunction,
|
209
|
+
);
|
210
|
+
lambdaFunction.expressionSequence[0] = getAllVersionsInRangeFunction;
|
211
|
+
} else {
|
212
|
+
throw new UnsupportedOperationError(
|
213
|
+
`Unable to build query lamdba: getAllVersionsInRange() expects source class to be milestoned`,
|
214
|
+
);
|
215
|
+
}
|
216
|
+
break;
|
217
|
+
}
|
218
|
+
case QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL: {
|
219
|
+
// build getAll()
|
220
|
+
const getAllFunction = buildGetAllFunction(_class, Multiplicity.ONE);
|
221
|
+
if (milestoningStereotype) {
|
222
|
+
// build milestoning parameter(s) for getAll()
|
223
|
+
queryBuilderState.milestoningState
|
224
|
+
.getMilestoningImplementation(milestoningStereotype)
|
225
|
+
.buildGetAllParameters(getAllFunction);
|
226
|
+
}
|
227
|
+
lambdaFunction.expressionSequence[0] = getAllFunction;
|
228
|
+
break;
|
229
|
+
}
|
230
|
+
default:
|
231
|
+
throw new UnsupportedOperationError(
|
232
|
+
`Unable to build query lambda: unknown ${queryBuilderState.getAllFunction} function`,
|
233
|
+
);
|
169
234
|
}
|
170
|
-
lambdaFunction.expressionSequence[0] = getAllFunction;
|
171
235
|
}
|
172
236
|
|
173
237
|
// build watermark
|
@@ -46,6 +46,7 @@ import {
|
|
46
46
|
import {
|
47
47
|
QUERY_BUILDER_PURE_PATH,
|
48
48
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
49
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS,
|
49
50
|
} from '../../../graph/QueryBuilderMetaModelConst.js';
|
50
51
|
import { type QueryBuilderState } from '../../QueryBuilderState.js';
|
51
52
|
import { QueryBuilderValueSpecificationProcessor } from '../../QueryBuilderStateBuilder.js';
|
@@ -82,7 +83,9 @@ export const processGraphFetchExpression = (
|
|
82
83
|
assertTrue(
|
83
84
|
matchFunctionName(precedingExpression.functionName, [
|
84
85
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.FILTER,
|
85
|
-
|
86
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL,
|
87
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS,
|
88
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
86
89
|
]),
|
87
90
|
`Can't process ${functionName}(): only support ${functionName}() immediately following either getAll() or filter()`,
|
88
91
|
);
|
@@ -65,6 +65,7 @@ export class QueryResultSetModifierState implements Hashable {
|
|
65
65
|
limit?: number | undefined;
|
66
66
|
distinct = false;
|
67
67
|
sortColumns: SortColumnState[] = [];
|
68
|
+
slice: [number, number] | undefined;
|
68
69
|
|
69
70
|
constructor(tdsState: QueryBuilderTDSState) {
|
70
71
|
makeObservable(this, {
|
@@ -72,12 +73,14 @@ export class QueryResultSetModifierState implements Hashable {
|
|
72
73
|
limit: observable,
|
73
74
|
distinct: observable,
|
74
75
|
sortColumns: observable,
|
76
|
+
slice: observable.ref,
|
75
77
|
setShowModal: action,
|
76
78
|
setLimit: action,
|
77
79
|
toggleDistinct: action,
|
78
80
|
deleteSortColumn: action,
|
79
81
|
addSortColumn: action,
|
80
82
|
updateSortColumns: action,
|
83
|
+
setSlice: action,
|
81
84
|
reset: action,
|
82
85
|
hashCode: computed,
|
83
86
|
});
|
@@ -111,6 +114,10 @@ export class QueryResultSetModifierState implements Hashable {
|
|
111
114
|
);
|
112
115
|
}
|
113
116
|
|
117
|
+
setSlice(slice: [number, number] | undefined): void {
|
118
|
+
this.slice = slice;
|
119
|
+
}
|
120
|
+
|
114
121
|
reset(): void {
|
115
122
|
this.sortColumns = [];
|
116
123
|
this.distinct = false;
|
@@ -31,7 +31,10 @@ import {
|
|
31
31
|
returnUndefOnError,
|
32
32
|
UnsupportedOperationError,
|
33
33
|
} from '@finos/legend-shared';
|
34
|
-
import {
|
34
|
+
import {
|
35
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
36
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS,
|
37
|
+
} from '../../../../graph/QueryBuilderMetaModelConst.js';
|
35
38
|
import type { QueryBuilderState } from '../../../QueryBuilderState.js';
|
36
39
|
import { QueryBuilderValueSpecificationProcessor } from '../../../QueryBuilderStateBuilder.js';
|
37
40
|
import { extractNullableStringFromInstanceValue } from '../../../QueryBuilderValueSpecificationHelper.js';
|
@@ -202,7 +205,9 @@ export const processTDSGroupByExpression = (
|
|
202
205
|
);
|
203
206
|
assertTrue(
|
204
207
|
matchFunctionName(precedingExpression.functionName, [
|
205
|
-
|
208
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL,
|
209
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS,
|
210
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
206
211
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.FILTER,
|
207
212
|
]),
|
208
213
|
`Can't process groupBy() expression: only support groupBy() immediately following either getAll() or filter()`,
|
@@ -27,11 +27,13 @@ import {
|
|
27
27
|
V1_deserializeRawValueSpecification,
|
28
28
|
V1_RawLambda,
|
29
29
|
VariableExpression,
|
30
|
+
PrimitiveInstanceValue,
|
30
31
|
} from '@finos/legend-graph';
|
31
32
|
import {
|
32
33
|
assertNonNullable,
|
33
34
|
assertTrue,
|
34
35
|
assertType,
|
36
|
+
guaranteeIsNumber,
|
35
37
|
guaranteeNonNullable,
|
36
38
|
guaranteeType,
|
37
39
|
isNonNullable,
|
@@ -40,6 +42,7 @@ import {
|
|
40
42
|
import {
|
41
43
|
COLUMN_SORT_TYPE,
|
42
44
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS,
|
45
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS,
|
43
46
|
} from '../../../../graph/QueryBuilderMetaModelConst.js';
|
44
47
|
import type { QueryBuilderState } from '../../../QueryBuilderState.js';
|
45
48
|
import { QueryBuilderValueSpecificationProcessor } from '../../../QueryBuilderStateBuilder.js';
|
@@ -80,7 +83,9 @@ export const processTDSProjectExpression = (
|
|
80
83
|
);
|
81
84
|
assertTrue(
|
82
85
|
matchFunctionName(precedingExpression.functionName, [
|
83
|
-
|
86
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL,
|
87
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS,
|
88
|
+
QUERY_BUILDER_SUPPORTED_GET_ALL_FUNCTIONS.GET_ALL_VERSIONS_IN_RANGE,
|
84
89
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.FILTER,
|
85
90
|
QUERY_BUILDER_SUPPORTED_FUNCTIONS.WATERMARK,
|
86
91
|
]),
|
@@ -382,6 +387,68 @@ export const processTDSSortExpression = (
|
|
382
387
|
);
|
383
388
|
};
|
384
389
|
|
390
|
+
export const processTDSSliceExpression = (
|
391
|
+
exp: SimpleFunctionExpression,
|
392
|
+
queryBuilderState: QueryBuilderState,
|
393
|
+
parentLambda: LambdaFunction,
|
394
|
+
): void => {
|
395
|
+
// check parameters
|
396
|
+
assertTrue(
|
397
|
+
exp.parametersValues.length === 3,
|
398
|
+
`Can't process slice() expression: slice() expects 2 argument`,
|
399
|
+
);
|
400
|
+
|
401
|
+
// check preceding expression
|
402
|
+
const precedingExpression = guaranteeType(
|
403
|
+
exp.parametersValues[0],
|
404
|
+
SimpleFunctionExpression,
|
405
|
+
`Can't process slice() expression: only support slice() immediately following an expression`,
|
406
|
+
);
|
407
|
+
assertTrue(
|
408
|
+
matchFunctionName(precedingExpression.functionName, [
|
409
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_TAKE,
|
410
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_DISTINCT,
|
411
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_SORT,
|
412
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_PROJECT,
|
413
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_GROUP_BY,
|
414
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.TDS_FILTER,
|
415
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.OLAP_GROUPBY,
|
416
|
+
]),
|
417
|
+
`Can't process slice() expression: only support slice() in TDS expression`,
|
418
|
+
);
|
419
|
+
QueryBuilderValueSpecificationProcessor.process(
|
420
|
+
precedingExpression,
|
421
|
+
parentLambda,
|
422
|
+
queryBuilderState,
|
423
|
+
);
|
424
|
+
|
425
|
+
// build state
|
426
|
+
if (
|
427
|
+
queryBuilderState.fetchStructureState.implementation instanceof
|
428
|
+
QueryBuilderTDSState
|
429
|
+
) {
|
430
|
+
const tdsState = queryBuilderState.fetchStructureState.implementation;
|
431
|
+
const start = guaranteeIsNumber(
|
432
|
+
guaranteeType(
|
433
|
+
exp.parametersValues[1],
|
434
|
+
PrimitiveInstanceValue,
|
435
|
+
'Can`t process slice() function: first param should be a primitive instance value',
|
436
|
+
).values[0],
|
437
|
+
'Can`t process slice() function: first param should be a number primitive instance value',
|
438
|
+
);
|
439
|
+
|
440
|
+
const end = guaranteeIsNumber(
|
441
|
+
guaranteeType(
|
442
|
+
exp.parametersValues[2],
|
443
|
+
PrimitiveInstanceValue,
|
444
|
+
'Can`t process slice() function: first param should be a primitive instance value',
|
445
|
+
).values[0],
|
446
|
+
'Can`t process slice() function: first param should be a number primitive instance value',
|
447
|
+
);
|
448
|
+
tdsState.resultSetModifierState.setSlice([start, end]);
|
449
|
+
}
|
450
|
+
};
|
451
|
+
|
385
452
|
export const processTDSSortDirectionExpression = (
|
386
453
|
expression: SimpleFunctionExpression,
|
387
454
|
parentExpression: SimpleFunctionExpression | undefined,
|
package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionValueSpecificationBuilder.ts
CHANGED
@@ -136,6 +136,33 @@ const appendResultSetModifier = (
|
|
136
136
|
takeFunction.parametersValues[1] = limit;
|
137
137
|
currentExpression = takeFunction;
|
138
138
|
}
|
139
|
+
// build slice()
|
140
|
+
if (resultModifierState.slice) {
|
141
|
+
const sliceStart = resultModifierState.slice[0];
|
142
|
+
const sliceEnd = resultModifierState.slice[1];
|
143
|
+
const startVal = new PrimitiveInstanceValue(
|
144
|
+
GenericTypeExplicitReference.create(
|
145
|
+
new GenericType(PrimitiveType.INTEGER),
|
146
|
+
),
|
147
|
+
);
|
148
|
+
const endVal = new PrimitiveInstanceValue(
|
149
|
+
GenericTypeExplicitReference.create(
|
150
|
+
new GenericType(PrimitiveType.INTEGER),
|
151
|
+
),
|
152
|
+
);
|
153
|
+
startVal.values = [sliceStart];
|
154
|
+
endVal.values = [sliceEnd];
|
155
|
+
const sliceFunction = new SimpleFunctionExpression(
|
156
|
+
extractElementNameFromPath(QUERY_BUILDER_SUPPORTED_FUNCTIONS.SLICE),
|
157
|
+
);
|
158
|
+
sliceFunction.parametersValues = [
|
159
|
+
currentExpression,
|
160
|
+
startVal,
|
161
|
+
endVal,
|
162
|
+
];
|
163
|
+
currentExpression = sliceFunction;
|
164
|
+
}
|
165
|
+
|
139
166
|
lambdaFunction.expressionSequence[0] = currentExpression;
|
140
167
|
return lambdaFunction;
|
141
168
|
}
|
@@ -25,6 +25,7 @@ import {
|
|
25
25
|
PrimitiveType,
|
26
26
|
} from '@finos/legend-graph';
|
27
27
|
import {
|
28
|
+
UnsupportedOperationError,
|
28
29
|
assertTrue,
|
29
30
|
guaranteeNonNullable,
|
30
31
|
guaranteeType,
|
@@ -104,6 +105,14 @@ export class QueryBuilderBitemporalMilestoningImplementation extends QueryBuilde
|
|
104
105
|
getAllFunction.parametersValues.push(parameterValue);
|
105
106
|
}
|
106
107
|
|
108
|
+
buildGetAllVersionsInRangeParameters(
|
109
|
+
getAllVersionsInRangeFunction: SimpleFunctionExpression,
|
110
|
+
): void {
|
111
|
+
throw new UnsupportedOperationError(
|
112
|
+
`Can't build getAllVersionsInRange() function: expects root class to be business temporal or processing temporal milestoned`,
|
113
|
+
);
|
114
|
+
}
|
115
|
+
|
107
116
|
generateMilestoningDate(
|
108
117
|
isDatePropagationSupported: boolean,
|
109
118
|
hasDefaultMilestoningDate: boolean,
|
@@ -23,7 +23,11 @@ import {
|
|
23
23
|
INTERNAL__PropagatedValue,
|
24
24
|
PrimitiveType,
|
25
25
|
} from '@finos/legend-graph';
|
26
|
-
import {
|
26
|
+
import {
|
27
|
+
UnsupportedOperationError,
|
28
|
+
assertTrue,
|
29
|
+
guaranteeNonNullable,
|
30
|
+
} from '@finos/legend-shared';
|
27
31
|
import { getParameterValue } from '../../components/QueryBuilderSideBar.js';
|
28
32
|
import { QUERY_BUILDER_SUPPORTED_FUNCTIONS } from '../../graph/QueryBuilderMetaModelConst.js';
|
29
33
|
import { createSupportedFunctionExpression } from '../shared/ValueSpecificationEditorHelper.js';
|
@@ -67,6 +71,23 @@ export class QueryBuilderBusinessTemporalMilestoningImplementation extends Query
|
|
67
71
|
);
|
68
72
|
}
|
69
73
|
|
74
|
+
buildGetAllVersionsInRangeParameters(
|
75
|
+
getAllVersionsInRangeFunction: SimpleFunctionExpression,
|
76
|
+
): void {
|
77
|
+
if (this.milestoningState.startDate && this.milestoningState.endDate) {
|
78
|
+
getAllVersionsInRangeFunction.parametersValues.push(
|
79
|
+
this.milestoningState.startDate,
|
80
|
+
);
|
81
|
+
getAllVersionsInRangeFunction.parametersValues.push(
|
82
|
+
this.milestoningState.endDate,
|
83
|
+
);
|
84
|
+
} else {
|
85
|
+
throw new UnsupportedOperationError(
|
86
|
+
`Can't build getAllVersionsInRange() function: expected both startDate and endDate`,
|
87
|
+
);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
70
91
|
buildGetAllWithDefaultParameters(
|
71
92
|
getAllFunction: SimpleFunctionExpression,
|
72
93
|
): void {
|
@@ -110,6 +110,13 @@ export const isDefaultDatePropagationSupported = (
|
|
110
110
|
) {
|
111
111
|
return false;
|
112
112
|
}
|
113
|
+
if (
|
114
|
+
!prevPropertyExpression &&
|
115
|
+
property.genericType.value.rawType instanceof Class &&
|
116
|
+
queryBuilderState.milestoningState.isAllVersionsEnabled
|
117
|
+
) {
|
118
|
+
return false;
|
119
|
+
}
|
113
120
|
if (property.genericType.value.rawType instanceof Class) {
|
114
121
|
// the stereotype of source class of current property expression.
|
115
122
|
const sourceStereotype =
|
@@ -63,6 +63,13 @@ export abstract class QueryBuilderMilestoningImplementation {
|
|
63
63
|
getAllFunction: SimpleFunctionExpression,
|
64
64
|
): void;
|
65
65
|
|
66
|
+
/**
|
67
|
+
* Builds parameters for getAllVersionsInRange() function with milestoned class
|
68
|
+
*/
|
69
|
+
abstract buildGetAllVersionsInRangeParameters(
|
70
|
+
getAllVersionsInRangeFunction: SimpleFunctionExpression,
|
71
|
+
): void;
|
72
|
+
|
66
73
|
/**
|
67
74
|
* Builds parameters for getAll() function with milestoned class
|
68
75
|
*/
|