@izara_project/izara-shared-search-and-sort 1.0.9 → 1.0.11
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.
- package/package.json +1 -1
- package/src/DataFieldsSharedLib.js +236 -142
- package/src/FiltersSharedLib.js +380 -616
- package/src/LogicalStructureSharedLib.js +159 -476
- package/src/SearchSortSharedLib.js +65 -37
package/src/FiltersSharedLib.js
CHANGED
|
@@ -19,114 +19,57 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
|
|
20
20
|
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
21
21
|
import lodash from 'lodash';
|
|
22
|
+
import objectHash from 'object-hash';
|
|
22
23
|
const { isEmpty } = lodash;
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
filterElements,
|
|
26
|
-
logicalElements
|
|
27
|
-
) {
|
|
28
|
-
let validate = false;
|
|
29
|
-
let countsBracket = 0;
|
|
30
|
-
let operationCounts = 0;
|
|
31
|
-
let logicalCounts = 0;
|
|
32
|
-
for (let logicalElement of Object.values(logicalElements)) {
|
|
33
|
-
if (logicalElement.logicalElementType === "openBracket" || logicalElement.logicalElementType === "closeBracket") {
|
|
34
|
-
countsBracket = countsBracket + 1;
|
|
35
|
-
} else if (logicalElement.logicalElementType === "operation") {
|
|
36
|
-
operationCounts = operationCounts + 1;
|
|
37
|
-
} else if (logicalElement.logicalElementType === "logical"
|
|
38
|
-
|| logicalElement.logicalElementType === "childComplexFilter"
|
|
39
|
-
|| logicalElement.logicalElementType === "identifiers"
|
|
40
|
-
|| logicalElement.logicalElementType === "translateIds"
|
|
41
|
-
|| logicalElement.logicalElementType === "traversal"
|
|
42
|
-
) {
|
|
43
|
-
logicalCounts = logicalCounts + 1;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
let logicalElementsLength = logicalCounts + operationCounts;
|
|
47
|
-
let filtersLength = Object.keys(filterElements).length;
|
|
48
|
-
console.log('check count: ', {
|
|
49
|
-
countsBracket,
|
|
50
|
-
operationCounts,
|
|
51
|
-
logicalCounts,
|
|
52
|
-
logicalElementsLength,
|
|
53
|
-
filtersLength
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (filtersLength === logicalElementsLength) {
|
|
57
|
-
validate = true;
|
|
58
|
-
}
|
|
59
|
-
return validate
|
|
60
|
-
}
|
|
25
|
+
const MAX_LOGICALS = 50;
|
|
61
26
|
|
|
62
27
|
function createFiltersRequest(
|
|
63
28
|
objType,
|
|
64
29
|
initialLogicalElementId,
|
|
65
30
|
logicalElements,
|
|
66
|
-
|
|
31
|
+
valueUserTags,
|
|
67
32
|
) {
|
|
68
33
|
console.log('createFiltersRequest: ', {
|
|
69
34
|
objType,
|
|
70
35
|
initialLogicalElementId,
|
|
71
36
|
logicalElements,
|
|
72
|
-
|
|
37
|
+
valueUserTags,
|
|
73
38
|
});
|
|
74
39
|
|
|
75
40
|
let filterMainId = null;
|
|
76
41
|
let filterMainObject = {};
|
|
77
|
-
let operation = null;
|
|
42
|
+
// let operation = null;
|
|
43
|
+
let nextFilterElementId = null;
|
|
78
44
|
|
|
79
45
|
let errorsObject = {};
|
|
80
46
|
let errorsFound = [];
|
|
81
47
|
let status = 'valid';
|
|
82
48
|
|
|
83
|
-
//* validate combine logicalStructure
|
|
84
|
-
let [validateObject, validateFilterMainId, validateFilterObject, validateErrorsObject, validateErrors] = validateCombinationStructure(
|
|
85
|
-
objType,
|
|
86
|
-
initialLogicalElementId,
|
|
87
|
-
logicalElements,
|
|
88
|
-
values
|
|
89
|
-
);
|
|
90
|
-
console.log('return validateCombinationStructure: ', {
|
|
91
|
-
validateObject,
|
|
92
|
-
validateFilterMainId,
|
|
93
|
-
validateFilterObject,
|
|
94
|
-
validateErrorsObject,
|
|
95
|
-
validateErrors
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
if (!validateObject || validateErrors.length > 0) {
|
|
99
|
-
Object.assign(errorsObject, validateErrorsObject);
|
|
100
|
-
errorsFound = errorsFound.concat(validateErrors);
|
|
101
|
-
return [
|
|
102
|
-
null,
|
|
103
|
-
'invalid',
|
|
104
|
-
errorsObject,
|
|
105
|
-
errorsFound
|
|
106
|
-
];
|
|
107
|
-
};
|
|
108
|
-
|
|
109
49
|
let operationErrorsObject = {};
|
|
110
50
|
let operationErrors = [];
|
|
51
|
+
let returnFilterElements = {};
|
|
111
52
|
|
|
112
53
|
[
|
|
113
54
|
filterMainId,
|
|
114
55
|
filterMainObject,
|
|
115
|
-
operation,
|
|
116
56
|
operationErrorsObject,
|
|
117
|
-
operationErrors
|
|
57
|
+
operationErrors,
|
|
58
|
+
returnFilterElements
|
|
118
59
|
] = filterLogicalElements(
|
|
119
60
|
objType,
|
|
120
61
|
initialLogicalElementId,
|
|
121
62
|
logicalElements,
|
|
122
|
-
|
|
63
|
+
valueUserTags,
|
|
123
64
|
);
|
|
65
|
+
|
|
124
66
|
console.log('final return filterLogicalElements: ', {
|
|
125
67
|
filterMainId,
|
|
126
68
|
filterMainObject,
|
|
127
|
-
operation,
|
|
128
69
|
operationErrorsObject,
|
|
129
|
-
operationErrors
|
|
70
|
+
operationErrors,
|
|
71
|
+
nextFilterElementId,
|
|
72
|
+
returnFilterElements
|
|
130
73
|
});
|
|
131
74
|
|
|
132
75
|
if (errorsFound.length > 0 || filterMainId === null) {
|
|
@@ -141,11 +84,8 @@ function createFiltersRequest(
|
|
|
141
84
|
};
|
|
142
85
|
|
|
143
86
|
let filterElements = {};
|
|
144
|
-
if (
|
|
145
|
-
filterElements =
|
|
146
|
-
|
|
147
|
-
delete filterMainObject.filterElement.filterElements;
|
|
148
|
-
Object.assign(filterElements, { [filterMainId]: filterMainObject });
|
|
87
|
+
if (!isEmpty(returnFilterElements)) {
|
|
88
|
+
filterElements = returnFilterElements;
|
|
149
89
|
};
|
|
150
90
|
|
|
151
91
|
if (isEmpty(filterElements)) {
|
|
@@ -174,13 +114,13 @@ function validateCombinationStructure(
|
|
|
174
114
|
objType,
|
|
175
115
|
initialLogicalElementId,
|
|
176
116
|
logicalElements,
|
|
177
|
-
|
|
117
|
+
valueUserTags
|
|
178
118
|
) {
|
|
179
119
|
console.log('validateCombinationStructure: ', {
|
|
180
120
|
objType,
|
|
181
121
|
initialLogicalElementId,
|
|
182
122
|
logicalElements,
|
|
183
|
-
|
|
123
|
+
valueUserTags
|
|
184
124
|
});
|
|
185
125
|
|
|
186
126
|
let validateObject = true;
|
|
@@ -218,7 +158,6 @@ function validateCombinationStructure(
|
|
|
218
158
|
|
|
219
159
|
if (logicalElementType === 'operation') {
|
|
220
160
|
console.log('----------------- operation --------------');
|
|
221
|
-
console.log('logicalElementObject: ', logicalElementObject);
|
|
222
161
|
|
|
223
162
|
lastOperation = logicalElementObject.operation;
|
|
224
163
|
console.log('lastOperation: ', lastOperation);
|
|
@@ -245,7 +184,7 @@ function validateCombinationStructure(
|
|
|
245
184
|
objType,
|
|
246
185
|
logicalElementObject.nextLogicalElementId,
|
|
247
186
|
logicalElements,
|
|
248
|
-
|
|
187
|
+
valueUserTags
|
|
249
188
|
);
|
|
250
189
|
console.log('return validateCombinationStruce for openBracket: ', {
|
|
251
190
|
validateObject,
|
|
@@ -260,7 +199,9 @@ function validateCombinationStructure(
|
|
|
260
199
|
initialLogicalElementId = nextElementId;
|
|
261
200
|
};
|
|
262
201
|
|
|
263
|
-
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (logicalElementType === 'closeBracket') {
|
|
264
205
|
console.log('----------------- closeBracket --------------');
|
|
265
206
|
|
|
266
207
|
return [
|
|
@@ -286,9 +227,9 @@ function validateCombinationStructure(
|
|
|
286
227
|
errorsObject[logicalElementId] = `this logical structure is not set comparison`;
|
|
287
228
|
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set comparison`);
|
|
288
229
|
};
|
|
289
|
-
if (!logicalElementObject.hasOwnProperty('
|
|
290
|
-
errorsObject[logicalElementId] = `this logical structure is not set
|
|
291
|
-
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set
|
|
230
|
+
if (!logicalElementObject.hasOwnProperty('valueUserTag')) {
|
|
231
|
+
errorsObject[logicalElementId] = `this logical structure is not set valueUserTag`;
|
|
232
|
+
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set valueUserTag`);
|
|
292
233
|
};
|
|
293
234
|
|
|
294
235
|
currentFilterMainId = logicalElementId;
|
|
@@ -333,7 +274,7 @@ function validateCombinationStructure(
|
|
|
333
274
|
logicalElementObject.pathLinkType.objType,
|
|
334
275
|
logicalElementObject.childLogicalElementId,
|
|
335
276
|
logicalElements,
|
|
336
|
-
|
|
277
|
+
valueUserTags
|
|
337
278
|
);
|
|
338
279
|
console.log('return validateCombinationStruce for childComplexFilter: ', {
|
|
339
280
|
childValidate,
|
|
@@ -400,9 +341,9 @@ function validateCombinationStructure(
|
|
|
400
341
|
errorsObject[logicalElementId] = `this logical structure is not set comparison`;
|
|
401
342
|
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set comparison`);
|
|
402
343
|
};
|
|
403
|
-
if (!logicalElementObject.hasOwnProperty('
|
|
404
|
-
errorsObject[logicalElementId] = `this logical structure is not set
|
|
405
|
-
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set
|
|
344
|
+
if (!logicalElementObject.hasOwnProperty('valueUserTag')) {
|
|
345
|
+
errorsObject[logicalElementId] = `this logical structure is not set valueUserTag`;
|
|
346
|
+
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set valueUserTag`);
|
|
406
347
|
};
|
|
407
348
|
|
|
408
349
|
currentFilterMainId = logicalElementId;
|
|
@@ -476,115 +417,6 @@ function validateCombinationStructure(
|
|
|
476
417
|
|
|
477
418
|
}
|
|
478
419
|
|
|
479
|
-
// function validateOperation(
|
|
480
|
-
// // _izContext,
|
|
481
|
-
// runningFilterMainId,
|
|
482
|
-
// runningFilterObject,
|
|
483
|
-
// lastOperation,
|
|
484
|
-
// currentFilterMainId,
|
|
485
|
-
// currentFilterObject,
|
|
486
|
-
// ) {
|
|
487
|
-
// console.log('validateOperation: ', {
|
|
488
|
-
// runningFilterMainId,
|
|
489
|
-
// runningFilterObject,
|
|
490
|
-
// lastOperation,
|
|
491
|
-
// currentFilterMainId,
|
|
492
|
-
// currentFilterObject,
|
|
493
|
-
// });
|
|
494
|
-
|
|
495
|
-
// let errorsObject = {};
|
|
496
|
-
// let errorsFound = [];
|
|
497
|
-
|
|
498
|
-
// if (!currentFilterObject) {
|
|
499
|
-
// errorsObject[currentFilterMainId] = 'cannot found current filterElement object';
|
|
500
|
-
// errorsFound.push(`${currentFilterMainId}: cannot found current filterElement object`);
|
|
501
|
-
// return [null, null, errorsObject, errorsFound];
|
|
502
|
-
// };
|
|
503
|
-
|
|
504
|
-
// if (!runningFilterObject) {
|
|
505
|
-
// return [currentFilterMainId, currentFilterObject, errorsObject, errorsFound];
|
|
506
|
-
// };
|
|
507
|
-
|
|
508
|
-
// if (!lastOperation) {
|
|
509
|
-
|
|
510
|
-
// let returnNextElementId = null;
|
|
511
|
-
// let returnNextElementObject = null;
|
|
512
|
-
|
|
513
|
-
// if (runningFilterObject.logicalElementType === 'openBracket') {
|
|
514
|
-
// if (currentFilterObject.logicalElementType === 'closeBracket') {
|
|
515
|
-
|
|
516
|
-
// errorsObject[currentFilterMainId] = `this path has logicalElementType: ${runningFilterObject.logicalElementType} and ${currentFilterObject.logicalElementType} are error`;
|
|
517
|
-
// errorsFound.push(`${currentFilterMainId}: this path has logicalElementType: ${runningFilterObject.logicalElementType} and ${currentFilterObject.logicalElementType} are error`);
|
|
518
|
-
|
|
519
|
-
// } else {
|
|
520
|
-
|
|
521
|
-
// runningFilterObject.nextLogicalElementId = currentFilterMainId;
|
|
522
|
-
// currentFilterObject.previousLogicalElementId = runningFilterMainId;
|
|
523
|
-
|
|
524
|
-
// operations = Object.assign(runningFilterObject, currentFilterObject);
|
|
525
|
-
|
|
526
|
-
// _izContext.logger.debug('operations: ', operations);
|
|
527
|
-
// returnNextElementId = currentFilterMainId;
|
|
528
|
-
// returnNextElementObject = currentFilterObject;
|
|
529
|
-
|
|
530
|
-
// };
|
|
531
|
-
|
|
532
|
-
// } else if (runningFilterObject.logicalElementType === 'closeBracket') {
|
|
533
|
-
// if (currentFilterObject.logicalElementType === "closeBracket") {
|
|
534
|
-
|
|
535
|
-
// runningFilterObject.nextLogicalElementId = currentFilterMainId;
|
|
536
|
-
// currentFilterObject.previousLogicalElementId = runningFilterMainId;
|
|
537
|
-
|
|
538
|
-
// operations = Object.assign(runningFilterObject, currentFilterObject);
|
|
539
|
-
// _izContext.logger.debug('operations: ', operations);
|
|
540
|
-
|
|
541
|
-
// returnNextElementId = currentFilterMainId;
|
|
542
|
-
// returnNextElementObject = currentFilterObject;
|
|
543
|
-
|
|
544
|
-
// } else {
|
|
545
|
-
// errorsObject[currentFilterMainId] = `this path has logicalElementType: ${runningFilterObject.logicalElementType} and ${currentFilterObject.logicalElementType} are error`;
|
|
546
|
-
// errorsFound.push(`${currentFilterMainId}: this path has logicalElementType: ${runningFilterObject.logicalElementType} and ${currentFilterObject.logicalElementType} are error`);
|
|
547
|
-
// };
|
|
548
|
-
|
|
549
|
-
// } else {
|
|
550
|
-
|
|
551
|
-
// if (currentFilterObject.logicalElementType === 'closeBracket') {
|
|
552
|
-
|
|
553
|
-
// runningFilterObject.nextLogicalElementId = currentFilterMainId;
|
|
554
|
-
// currentFilterObject.previousLogicalElementId = runningFilterMainId;
|
|
555
|
-
|
|
556
|
-
// operations = Object.assign(runningFilterObject, currentFilterObject);
|
|
557
|
-
// _izContext.logger.debug('operations: ', operations);
|
|
558
|
-
|
|
559
|
-
// returnNextElementId = currentFilterMainId;
|
|
560
|
-
// returnNextElementObject = nextLogicalElementObject;
|
|
561
|
-
// } else {
|
|
562
|
-
// errorsObject[currentFilterMainId] = `this path has logicalElementType: ${runningFilterObject.logicalElementType} and ${currentFilterObject.logicalElementType} are error`;
|
|
563
|
-
// errorsFound.push(`${currentFilterMainId}: this path has logicalElementType: ${runningFilterObject.logicalElementType} and ${currentFilterObject.logicalElementType} are error`);
|
|
564
|
-
// };
|
|
565
|
-
// };
|
|
566
|
-
|
|
567
|
-
// return [returnNextElementId, returnNextElementObject, errorsObject, errorsFound];
|
|
568
|
-
|
|
569
|
-
// };
|
|
570
|
-
|
|
571
|
-
// if (runningFilterMainId && lastOperation && currentFilterMainId) {
|
|
572
|
-
|
|
573
|
-
// // let operationFilterObject = {
|
|
574
|
-
// // runningFilterMainId: runningFilterObject,
|
|
575
|
-
// // operation: lastOperation,
|
|
576
|
-
// // currentFilterMainId: currentFilterObject
|
|
577
|
-
// // };
|
|
578
|
-
// // // let operationFilterMainId = hash(operationFilterObject);
|
|
579
|
-
|
|
580
|
-
// return [currentFilterMainId, currentFilterObject, errorsObject, errorsFound];
|
|
581
|
-
|
|
582
|
-
// } else {
|
|
583
|
-
// errorsFound.push("found some error that not expect");
|
|
584
|
-
// return [null, null, errorsObject, errorsFound];
|
|
585
|
-
// };
|
|
586
|
-
// };
|
|
587
|
-
|
|
588
420
|
function validateOperation(
|
|
589
421
|
objType,
|
|
590
422
|
runningFilterMainId,
|
|
@@ -592,6 +424,7 @@ function validateOperation(
|
|
|
592
424
|
lastLogicalOperator,
|
|
593
425
|
currentFilterMainId,
|
|
594
426
|
currentFilterObject,
|
|
427
|
+
filterElements
|
|
595
428
|
) {
|
|
596
429
|
try {
|
|
597
430
|
|
|
@@ -602,6 +435,7 @@ function validateOperation(
|
|
|
602
435
|
lastLogicalOperator: lastLogicalOperator,
|
|
603
436
|
currentFilterMainId: currentFilterMainId,
|
|
604
437
|
currentFilterObject: currentFilterObject,
|
|
438
|
+
filterElements: filterElements
|
|
605
439
|
});
|
|
606
440
|
|
|
607
441
|
let errorsFound = []
|
|
@@ -615,27 +449,50 @@ function validateOperation(
|
|
|
615
449
|
if (!currentFilterObject) {
|
|
616
450
|
console.log("validateOperation expected currentFilterObject not found");
|
|
617
451
|
errorsFound.push("validateOperation expected currentFilterObject not found");
|
|
618
|
-
return [currentFilterMainId, null,
|
|
452
|
+
return [currentFilterMainId, null, errorsFound];
|
|
619
453
|
}
|
|
620
454
|
// if runningFilterObject set we should always have lastLogicalOperator
|
|
621
455
|
if (runningFilterObject && !lastLogicalOperator) {
|
|
622
456
|
console.log("validateOperation expected lastLogicalOperator not found");
|
|
623
457
|
errorsFound.push("validateOperation expected lastLogicalOperator not found");
|
|
624
|
-
return [currentFilterMainId, currentFilterObject,
|
|
458
|
+
return [currentFilterMainId, currentFilterObject, errorsFound];
|
|
625
459
|
}
|
|
626
460
|
|
|
627
461
|
// check if is an operation, if not simply return currentFilterMainId
|
|
628
462
|
if (!runningFilterObject || !lastLogicalOperator) {
|
|
629
463
|
console.log("+++ validate no operation, R E T U R N currentFilterMainId ++");
|
|
630
|
-
|
|
464
|
+
|
|
465
|
+
let filterElements = {};
|
|
466
|
+
if (currentFilterObject.filterElement.filterType === "childComplexFilter") {
|
|
467
|
+
filterElements = currentFilterObject.filterElement.filterElements;
|
|
468
|
+
delete currentFilterObject.filterElement.filterElements;
|
|
469
|
+
} else if (currentFilterObject.filterElement.filterType === "logical") {
|
|
470
|
+
filterElements = {
|
|
471
|
+
[currentFilterMainId]: currentFilterObject
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return [currentFilterMainId, currentFilterObject, errorsFound, filterElements];
|
|
631
476
|
}
|
|
632
477
|
|
|
633
|
-
let filterElements = splitFilterElements(
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
);
|
|
478
|
+
// let filterElements = splitFilterElements(
|
|
479
|
+
// runningFilterMainId,
|
|
480
|
+
// runningFilterObject,
|
|
481
|
+
// currentFilterMainId,
|
|
482
|
+
// currentFilterObject
|
|
483
|
+
// );
|
|
484
|
+
|
|
485
|
+
if (currentFilterObject.filterElement.filterType === "childComplexFilter") {
|
|
486
|
+
Object.assign(filterElements, currentFilterObject.filterElement.filterElements)
|
|
487
|
+
delete currentFilterObject.filterElement.filterElements;
|
|
488
|
+
} else if (currentFilterObject.filterElement.filterType === "logical") {
|
|
489
|
+
Object.assign(filterElements, {
|
|
490
|
+
[currentFilterMainId]: currentFilterObject
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
console.log("----------------------------------------------------- filterElements", filterElements);
|
|
639
496
|
|
|
640
497
|
// create new operation FilterObject
|
|
641
498
|
let operationFilterObject = {
|
|
@@ -654,16 +511,17 @@ function validateOperation(
|
|
|
654
511
|
console.log("==== validate operationFilterMainId After Hash =====", operationFilterMainId);
|
|
655
512
|
|
|
656
513
|
console.log("RETURN validate operationFilterMainId ==>", operationFilterMainId);
|
|
514
|
+
delete operationFilterObject.filterElement.filterElements;
|
|
657
515
|
console.log("RETURN validate operationFilterObject ==>", operationFilterObject);
|
|
658
516
|
console.log("========= [validateOperation ::: End] =======");
|
|
659
517
|
|
|
660
|
-
let operation = {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
};
|
|
518
|
+
// let operation = {
|
|
519
|
+
// filterMainIdA: runningFilterMainId,
|
|
520
|
+
// operator: lastLogicalOperator,
|
|
521
|
+
// filterMainIdB: currentFilterMainId,
|
|
522
|
+
// };
|
|
665
523
|
|
|
666
|
-
return [operationFilterMainId, operationFilterObject,
|
|
524
|
+
return [operationFilterMainId, operationFilterObject, errorsFound, filterElements];
|
|
667
525
|
|
|
668
526
|
} catch (err) {
|
|
669
527
|
throw (err)
|
|
@@ -674,516 +532,422 @@ function filterLogicalElements(
|
|
|
674
532
|
objType,
|
|
675
533
|
initialLogicalElementId,
|
|
676
534
|
logicalElements,
|
|
677
|
-
|
|
678
|
-
nextLogicalElementId = null,
|
|
679
|
-
runningFilterMainId = null,
|
|
680
|
-
runningFilterObject = null,
|
|
681
|
-
lastLogicalOperator = null,
|
|
682
|
-
currentFilterMainId = null,
|
|
683
|
-
currentFilterObject = null
|
|
535
|
+
valueUserTags,
|
|
684
536
|
) {
|
|
685
537
|
console.log('filterLogicalElements: ', {
|
|
686
538
|
objType,
|
|
687
539
|
initialLogicalElementId,
|
|
688
540
|
logicalElements,
|
|
689
|
-
|
|
690
|
-
nextLogicalElementId,
|
|
691
|
-
runningFilterMainId,
|
|
692
|
-
runningFilterObject,
|
|
693
|
-
lastLogicalOperator,
|
|
694
|
-
currentFilterMainId,
|
|
695
|
-
currentFilterObject
|
|
541
|
+
valueUserTags,
|
|
696
542
|
});
|
|
697
543
|
|
|
698
544
|
let errorsObject = {};
|
|
699
545
|
let errorsFound = [];
|
|
700
546
|
|
|
701
|
-
let
|
|
702
|
-
let
|
|
703
|
-
let
|
|
704
|
-
let
|
|
547
|
+
let runningFilterObject = null;
|
|
548
|
+
let runningFilterMainId = null;
|
|
549
|
+
let currentFilterObject = null;
|
|
550
|
+
let currentFilterMainId = null;
|
|
705
551
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
}
|
|
552
|
+
let lastLogicalOperator = null;
|
|
553
|
+
let filterElements = {};
|
|
709
554
|
|
|
710
|
-
let
|
|
711
|
-
console.log('logicalElement: ', logicalElement)
|
|
555
|
+
let nextElementId = null;
|
|
712
556
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
errorsFound.push(`${currentLogicalElementId}: this logicalElement not found`);
|
|
716
|
-
};
|
|
717
|
-
if (!logicalElement.hasOwnProperty('logicalElementType')) {
|
|
718
|
-
errorsObject[currentLogicalElementId] = 'this logicalElement is not set logicalElementType';
|
|
719
|
-
errorsFound.push(`${currentLogicalElementId}: this logicalElement not set logicalElementType`);
|
|
720
|
-
};
|
|
557
|
+
let working_logicalElementId = initialLogicalElementId;
|
|
558
|
+
console.log("working_logicalElementId: ", working_logicalElementId)
|
|
721
559
|
|
|
722
|
-
let
|
|
723
|
-
console.log('logicalElementType: ', logicalElementType);
|
|
560
|
+
for (let i = 0; i <= MAX_LOGICALS; i++) {
|
|
724
561
|
|
|
725
|
-
|
|
562
|
+
if (i === MAX_LOGICALS) {
|
|
726
563
|
|
|
727
|
-
|
|
564
|
+
if (i < Object.keys(logicalElements).length) {
|
|
565
|
+
errorsObject = {
|
|
566
|
+
[initialLogicalElementId]: 'has remain logicalElements that want to process'
|
|
567
|
+
};
|
|
568
|
+
errorsFound.push(`${initialLogicalElementId}: has remain logicalElements that want to process`)
|
|
569
|
+
}
|
|
728
570
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
errorsObject,
|
|
734
|
-
errorsFound,
|
|
735
|
-
nextElementId
|
|
736
|
-
] = filterLogicalElements(
|
|
737
|
-
objType,
|
|
738
|
-
initialLogicalElementId,
|
|
739
|
-
logicalElements,
|
|
740
|
-
values,
|
|
741
|
-
logicalElement.nextLogicalElementId
|
|
742
|
-
);
|
|
743
|
-
console.log('return filterLogicalElement for openBracket: ', {
|
|
744
|
-
currentFilterMainId,
|
|
745
|
-
currentFilterObject,
|
|
746
|
-
operation,
|
|
747
|
-
errorsObject, errorsFound,
|
|
748
|
-
lastNextLogicalElementId
|
|
749
|
-
});
|
|
571
|
+
errorsObject = {
|
|
572
|
+
[initialLogicalElementId]: 'has max limit iterate in logicalElements'
|
|
573
|
+
};
|
|
574
|
+
errorsFound.push(`${initialLogicalElementId}: has max limit iterate in logicalElements`);
|
|
750
575
|
|
|
751
|
-
|
|
752
|
-
lastNextLogicalElementId = nextElementId;
|
|
576
|
+
return [null, null, errorsObject, errorsFound, null];
|
|
753
577
|
}
|
|
754
578
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
return [
|
|
579
|
+
console.log("iterate logicalElements: ", {
|
|
758
580
|
runningFilterMainId,
|
|
759
581
|
runningFilterObject,
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
582
|
+
currentFilterMainId,
|
|
583
|
+
currentFilterObject,
|
|
584
|
+
lastLogicalOperator,
|
|
585
|
+
filterElements
|
|
586
|
+
})
|
|
587
|
+
|
|
588
|
+
let logicalElement = logicalElements[working_logicalElementId];
|
|
589
|
+
console.log("logicalElement: ", logicalElement);
|
|
765
590
|
|
|
766
|
-
|
|
591
|
+
if (isEmpty(logicalElement)) {
|
|
592
|
+
errorsObject[currentLogicalElementId] = 'this logicalElement not found';
|
|
593
|
+
errorsFound.push(`${currentLogicalElementId}: this logicalElement not found`);
|
|
594
|
+
};
|
|
595
|
+
if (!logicalElement.hasOwnProperty('logicalElementType')) {
|
|
596
|
+
errorsObject[currentLogicalElementId] = 'this logicalElement is not set logicalElementType';
|
|
597
|
+
errorsFound.push(`${currentLogicalElementId}: this logicalElement not set logicalElementType`);
|
|
598
|
+
};
|
|
767
599
|
|
|
768
|
-
|
|
600
|
+
let logicalElementType = logicalElement.logicalElementType;
|
|
601
|
+
console.log('logicalElementType: ', logicalElementType);
|
|
769
602
|
|
|
770
|
-
if (
|
|
771
|
-
|
|
772
|
-
|
|
603
|
+
if (logicalElementType === "operation") {
|
|
604
|
+
|
|
605
|
+
if (!logicalElement.hasOwnProperty("operation")) {
|
|
606
|
+
errorsObject[working_logicalElementId] = `this logical structure is not set operation`;
|
|
607
|
+
errorsFound.push(`this logical structure logicalElementId: ${working_logicalElementId} is not set operation`);
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
if (errorsFound.length > 0) {
|
|
611
|
+
return [null, null, null, errorsObject, errorsFound];
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
lastLogicalOperator = logicalElement.operation;
|
|
615
|
+
working_logicalElementId = logicalElement.nextLogicalElementId;
|
|
616
|
+
continue;
|
|
773
617
|
}
|
|
774
618
|
|
|
775
|
-
|
|
776
|
-
logicalElementType = logicalElement.logicalElementType;
|
|
619
|
+
if (logicalElementType === "openBracket") {
|
|
777
620
|
|
|
778
|
-
|
|
621
|
+
let returnFilterElements = {};
|
|
622
|
+
let logicalErrorsObject = {};
|
|
623
|
+
let logicalErrorsFound = [];
|
|
779
624
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
625
|
+
[currentFilterMainId, currentFilterObject, logicalErrorsObject, logicalErrorsFound, returnFilterElements, nextElementId] = filterLogicalElements(
|
|
626
|
+
objType,
|
|
627
|
+
logicalElement.nextLogicalElementId,
|
|
628
|
+
logicalElements,
|
|
629
|
+
valueUserTags
|
|
630
|
+
);
|
|
631
|
+
console.log('return filter of openBracket: ', {
|
|
632
|
+
currentFilterMainId,
|
|
633
|
+
currentFilterObject,
|
|
634
|
+
logicalErrorsObject,
|
|
635
|
+
logicalErrorsFound,
|
|
636
|
+
returnFilterElements,
|
|
637
|
+
nextElementId
|
|
638
|
+
});
|
|
787
639
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
currentFilterMainId,
|
|
793
|
-
currentFilterObject
|
|
794
|
-
});
|
|
640
|
+
if (logicalErrorsFound.length > 0) {
|
|
641
|
+
Object.assign(errorsObject, logicalErrorsObject);
|
|
642
|
+
errorsFound = errorsFound.concat(logicalErrorsFound);
|
|
643
|
+
};
|
|
795
644
|
|
|
796
|
-
|
|
645
|
+
Object.assign(filterElements, returnFilterElements);
|
|
797
646
|
|
|
798
|
-
|
|
647
|
+
} else if (logicalElementType === "closeBracket") {
|
|
648
|
+
|
|
649
|
+
return [runningFilterMainId, runningFilterObject, errorsObject, errorsFound, filterElements, logicalElement.nextLogicalElementId];
|
|
799
650
|
|
|
800
|
-
if (!logicalElement.hasOwnProperty('objType')) {
|
|
801
|
-
errorsObject[initialLogicalElementId] = `this logical structure is not set objType`;
|
|
802
|
-
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set objType`);
|
|
803
|
-
};
|
|
804
|
-
if (hash(objType) !== hash(logicalElement.objType)) {
|
|
805
|
-
errorsObject[currentLogicalElementId] = `it' s not the same level objType to process this logicalElement`;
|
|
806
|
-
errorsFound.push(`it' s not the same level objType to process this logicalElement: ${currentLogicalElementId}`);
|
|
807
|
-
};
|
|
808
|
-
if (!logicalElement.hasOwnProperty('fieldName')) {
|
|
809
|
-
errorsObject[currentLogicalElementId] = `this logical structure is not set fieldName`;
|
|
810
|
-
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set fieldName`);
|
|
811
|
-
};
|
|
812
|
-
if (!logicalElement.hasOwnProperty('comparison')) {
|
|
813
|
-
errorsObject[currentLogicalElementId] = `this logical structure is not set comparison`;
|
|
814
|
-
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set comparison`);
|
|
815
|
-
};
|
|
816
|
-
if (!logicalElement.hasOwnProperty('value')) {
|
|
817
|
-
errorsObject[currentLogicalElementId] = `this logical structure is not set value`;
|
|
818
|
-
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set value`);
|
|
819
651
|
}
|
|
820
652
|
|
|
821
|
-
|
|
822
|
-
console.log('value: ', value);
|
|
653
|
+
if (logicalElementType === "logical") {
|
|
823
654
|
|
|
824
|
-
|
|
825
|
-
errorsObject[currentLogicalElementId] = `value is empty`;
|
|
826
|
-
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} value is empty`);
|
|
827
|
-
} else {
|
|
828
|
-
if (value.hasOwnProperty('valueSource')) {
|
|
655
|
+
console.log('------------------ logicalElementType: logical ----------------');
|
|
829
656
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
657
|
+
if (!logicalElement.hasOwnProperty('objType')) {
|
|
658
|
+
errorsObject[initialLogicalElementId] = `this logical structure is not set objType`;
|
|
659
|
+
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set objType`);
|
|
660
|
+
};
|
|
661
|
+
if (hash(objType) !== hash(logicalElement.objType)) {
|
|
662
|
+
errorsObject[currentLogicalElementId] = `it' s not the same level objType to process this logicalElement`;
|
|
663
|
+
errorsFound.push(`it' s not the same level objType to process this logicalElement: ${currentLogicalElementId}`);
|
|
664
|
+
};
|
|
665
|
+
if (!logicalElement.hasOwnProperty('fieldName')) {
|
|
666
|
+
errorsObject[currentLogicalElementId] = `this logical structure is not set fieldName`;
|
|
667
|
+
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set fieldName`);
|
|
668
|
+
};
|
|
669
|
+
if (!logicalElement.hasOwnProperty('comparison')) {
|
|
670
|
+
errorsObject[currentLogicalElementId] = `this logical structure is not set comparison`;
|
|
671
|
+
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set comparison`);
|
|
672
|
+
};
|
|
673
|
+
if (!logicalElement.hasOwnProperty('valueUserTag')) {
|
|
674
|
+
errorsObject[currentLogicalElementId] = `this logical structure is not set valueUserTags`;
|
|
675
|
+
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set valueUserTags`);
|
|
676
|
+
}
|
|
834
677
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
objType: logicalElement.objType,
|
|
838
|
-
filterElement: {
|
|
839
|
-
filterType: logicalElementType,
|
|
840
|
-
fieldName: logicalElement.fieldName,
|
|
841
|
-
comparison: logicalElement.comparison,
|
|
842
|
-
valueType: value.valueSource,
|
|
843
|
-
perParentIdentifierFieldname: value.perParentIdentifierFieldname
|
|
844
|
-
}
|
|
845
|
-
};
|
|
678
|
+
let value = valueUserTags[logicalElement.valueUserTag];
|
|
679
|
+
console.log('value: ', value);
|
|
846
680
|
|
|
681
|
+
if (isEmpty(value)) {
|
|
682
|
+
errorsObject[currentLogicalElementId] = `value is empty`;
|
|
683
|
+
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} value is empty`);
|
|
847
684
|
} else {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
685
|
+
if (value.hasOwnProperty('valueSource')) {
|
|
686
|
+
|
|
687
|
+
if (value.valueSource !== 'perParentIdentifier') {
|
|
688
|
+
errorsObject[currentLogicalElementId] = `valueType is not set type: perParentIdentifier`;
|
|
689
|
+
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} has valueType is not set type: perParentIdentifier`);
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
//* create complexFilter normalize here
|
|
693
|
+
currentFilterObject = {
|
|
694
|
+
objType: logicalElement.objType,
|
|
695
|
+
filterElement: {
|
|
696
|
+
filterType: logicalElementType,
|
|
697
|
+
fieldName: logicalElement.fieldName,
|
|
698
|
+
comparison: logicalElement.comparison,
|
|
699
|
+
valueType: value.valueSource,
|
|
700
|
+
perParentIdentifierFieldname: value.perParentIdentifierFieldname
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
} else {
|
|
705
|
+
|
|
706
|
+
//* create complexFilter normalize here
|
|
707
|
+
currentFilterObject = {
|
|
708
|
+
objType: logicalElement.objType,
|
|
709
|
+
filterElement: {
|
|
710
|
+
filterType: logicalElement.logicalElementType,
|
|
711
|
+
fieldName: logicalElement.fieldName,
|
|
712
|
+
comparison: logicalElement.comparison,
|
|
713
|
+
value: valueUserTags[logicalElement.valueUserTag].value
|
|
714
|
+
}
|
|
715
|
+
};
|
|
858
716
|
};
|
|
859
717
|
};
|
|
860
|
-
|
|
861
|
-
console.log('currentFilterObject: ', currentFilterObject);
|
|
862
|
-
|
|
863
|
-
currentFilterMainId = hash(currentFilterObject);
|
|
864
|
-
console.log('currentFilterMainId: ', currentFilterMainId);
|
|
718
|
+
console.log('currentFilterObject: ', currentFilterObject);
|
|
865
719
|
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
}
|
|
720
|
+
currentFilterMainId = hash(currentFilterObject);
|
|
721
|
+
console.log('currentFilterMainId: ', currentFilterMainId);
|
|
869
722
|
|
|
870
|
-
|
|
871
|
-
|
|
723
|
+
} else if (logicalElementType === "childComplexFilter") {
|
|
724
|
+
console.log('------------------ logicalElementType: childComplexFilter ----------------');
|
|
872
725
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
};
|
|
881
|
-
|
|
882
|
-
if (!logicalElement.hasOwnProperty('pathLinkType')) {
|
|
883
|
-
errorsObject[currentLogicalElementId] = `this logical structure is not set pathLinkType`;
|
|
884
|
-
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set pathLinkType`);
|
|
885
|
-
} else {
|
|
886
|
-
if (!logicalElement.pathLinkType.hasOwnProperty('objType')
|
|
887
|
-
|| !logicalElement.pathLinkType.hasOwnProperty('relType')
|
|
888
|
-
|| !logicalElement.pathLinkType.hasOwnProperty('direction')
|
|
889
|
-
) {
|
|
890
|
-
errorsObject[currentLogicalElementId] = `this logical structure is not set properties in pathLinkType`;
|
|
891
|
-
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set {objType | relType | direction} in pathLinkType`);
|
|
726
|
+
if (!logicalElement.hasOwnProperty('objType')) {
|
|
727
|
+
errorsObject[currentLogicalElementId] = `this logical structure is not set objType`;
|
|
728
|
+
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set objType`);
|
|
729
|
+
};
|
|
730
|
+
if (hash(objType) !== hash(logicalElement.objType)) {
|
|
731
|
+
errorsObject[currentLogicalElementId] = `it' s not the same level objType to process this logicalElement`
|
|
732
|
+
errorsFound.push(`it' s not the same level objType to process this logicalElement: ${currentLogicalElementId}`)
|
|
892
733
|
};
|
|
893
|
-
};
|
|
894
734
|
|
|
895
|
-
|
|
735
|
+
if (!logicalElement.hasOwnProperty('pathLinkType')) {
|
|
736
|
+
errorsObject[currentLogicalElementId] = `this logical structure is not set pathLinkType`;
|
|
737
|
+
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set pathLinkType`);
|
|
738
|
+
} else {
|
|
739
|
+
if (!logicalElement.pathLinkType.hasOwnProperty('objType')
|
|
740
|
+
|| !logicalElement.pathLinkType.hasOwnProperty('relType')
|
|
741
|
+
|| !logicalElement.pathLinkType.hasOwnProperty('direction')
|
|
742
|
+
) {
|
|
743
|
+
errorsObject[currentLogicalElementId] = `this logical structure is not set properties in pathLinkType`;
|
|
744
|
+
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set {objType | relType | direction} in pathLinkType`);
|
|
745
|
+
};
|
|
746
|
+
};
|
|
896
747
|
|
|
897
|
-
|
|
898
|
-
errorsObject[currentLogicalElementId] = `this logicalType: childComplexFilter is not set childLogicalElementId`;
|
|
899
|
-
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} logicalType: childComplexFilter is not set childLogicalElementId`);
|
|
900
|
-
}
|
|
748
|
+
let childLogicalElementId = logicalElement.childLogicalElementId;
|
|
901
749
|
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
750
|
+
if (childLogicalElementId === null) {
|
|
751
|
+
errorsObject[currentLogicalElementId] = `this logicalType: childComplexFilter is not set childLogicalElementId`;
|
|
752
|
+
errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} logicalType: childComplexFilter is not set childLogicalElementId`);
|
|
753
|
+
}
|
|
905
754
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
operation,
|
|
910
|
-
childErrorsObject,
|
|
911
|
-
childErrorsFound,
|
|
912
|
-
childNextLogicalElementId
|
|
913
|
-
] = filterLogicalElements(
|
|
914
|
-
logicalElement.pathLinkType.objType,
|
|
915
|
-
initialLogicalElementId,
|
|
916
|
-
logicalElements,
|
|
917
|
-
values,
|
|
918
|
-
logicalElement.childLogicalElementId
|
|
919
|
-
);
|
|
920
|
-
console.log('return child filterLogicalElement for child complexFilter: ', {
|
|
921
|
-
childFilterMainId,
|
|
922
|
-
childFilterObject,
|
|
923
|
-
operation,
|
|
924
|
-
childErrorsObject,
|
|
925
|
-
childErrorsFound,
|
|
926
|
-
childNextLogicalElementId
|
|
927
|
-
});
|
|
928
|
-
if (childErrorsFound.length > 0) {
|
|
929
|
-
Object.assign(errorsObject, childErrorsObject);
|
|
930
|
-
errorsFound = errorsFound.concat(childErrorsFound)
|
|
931
|
-
}
|
|
755
|
+
if (errorsFound.length > 0) {
|
|
756
|
+
return [null, null, null, errorsObject, errorsFound];
|
|
757
|
+
};
|
|
932
758
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
759
|
+
let [childFilterMainId, childFilterObject, childErrorsObject, childErrorsFound, childFilterElements] = filterLogicalElements(
|
|
760
|
+
logicalElement.pathLinkType.objType,
|
|
761
|
+
childLogicalElementId,
|
|
762
|
+
logicalElements,
|
|
763
|
+
valueUserTags
|
|
764
|
+
);
|
|
765
|
+
console.log('return filter main of child complexFilter: ', {
|
|
766
|
+
childFilterMainId,
|
|
767
|
+
childFilterObject,
|
|
768
|
+
childErrorsObject,
|
|
769
|
+
childErrorsFound,
|
|
770
|
+
childFilterElements
|
|
771
|
+
});
|
|
939
772
|
|
|
940
|
-
|
|
941
|
-
|
|
773
|
+
if (childErrorsFound.length > 0) {
|
|
774
|
+
Object.assign(errorsObject, childErrorsObject);
|
|
775
|
+
errorsFound = errorsFound.concat(childErrorsFound);
|
|
776
|
+
};
|
|
942
777
|
|
|
943
|
-
|
|
944
|
-
console.log('set requestProperties: ', { tag, requestPropertyId });
|
|
778
|
+
let setRequestProperties = {};
|
|
945
779
|
|
|
946
|
-
|
|
780
|
+
if (!isEmpty(logicalElement.requestProperties)) {
|
|
781
|
+
console.log('logicalElement: ', logicalElement);
|
|
947
782
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
errorsFound.push(`this filter logical structure logicalElementId: ${initialLogicalElementId} set valueSource`);
|
|
951
|
-
continue;
|
|
952
|
-
};
|
|
783
|
+
for (const [tag, requestPropertyId] of Object.entries(logicalElement.requestProperties)) {
|
|
784
|
+
console.log('set requestProperties: ', { tag, requestPropertyId });
|
|
953
785
|
|
|
954
|
-
|
|
786
|
+
let requestPropertyObject = valueUserTags[requestPropertyId];
|
|
955
787
|
|
|
788
|
+
if (requestPropertyObject.hasOwnProperty('valueSource')) {
|
|
789
|
+
errorsObject[initialLogicalElementId] = `requestProperties in filter logicalStructure set valueSource`;
|
|
790
|
+
errorsFound.push(`this filter logical structure logicalElementId: ${initialLogicalElementId} set valueSource`);
|
|
791
|
+
continue;
|
|
792
|
+
};
|
|
793
|
+
setRequestProperties[tag] = requestPropertyObject.value;
|
|
794
|
+
};
|
|
956
795
|
};
|
|
957
|
-
};
|
|
958
796
|
|
|
959
|
-
currentFilterObject = {
|
|
960
|
-
objType: logicalElement.objType,
|
|
961
|
-
filterElement: {
|
|
962
|
-
filterType: logicalElementType,
|
|
963
|
-
filterElements: filterElements,
|
|
964
|
-
childFilterElementId: childFilterMainId,
|
|
965
|
-
pathLinkType: logicalElement.pathLinkType,
|
|
966
|
-
requestProperties: setRequestProperties ?? {}
|
|
967
|
-
}
|
|
968
|
-
};
|
|
969
|
-
console.log('currentFilterObject: ', currentFilterObject);
|
|
970
797
|
|
|
971
|
-
|
|
972
|
-
|
|
798
|
+
currentFilterObject = {
|
|
799
|
+
objType: logicalElement.objType,
|
|
800
|
+
filterElement: {
|
|
801
|
+
filterType: logicalElementType,
|
|
802
|
+
filterElements: childFilterElements,
|
|
803
|
+
childFilterElementId: childFilterMainId,
|
|
804
|
+
pathLinkType: logicalElement.pathLinkType,
|
|
805
|
+
requestProperties: setRequestProperties ?? {}
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
console.log("currentFilterObject: ", currentFilterObject);
|
|
973
809
|
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
}
|
|
810
|
+
currentFilterMainId = hash(currentFilterObject);
|
|
811
|
+
console.log("currentFilterMainId: ", currentFilterMainId);
|
|
977
812
|
|
|
978
|
-
|
|
813
|
+
Object.assign(filterElements, childFilterElements);
|
|
814
|
+
console.log("filterElements: ", filterElements);
|
|
979
815
|
|
|
980
|
-
|
|
981
|
-
} else if (logicalElementType === "translateIds") {
|
|
816
|
+
} else if (logicalElementType === "traversal") {
|
|
982
817
|
|
|
983
|
-
|
|
984
|
-
|
|
818
|
+
console.log('logicalElementType: ', f);
|
|
819
|
+
} else if (logicalElementType === "translateIds") {
|
|
985
820
|
|
|
986
|
-
|
|
987
|
-
|
|
821
|
+
console.log('logicalElementType: ', g);
|
|
822
|
+
} else if (logicalElementType === "identifiers") {
|
|
988
823
|
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
}
|
|
824
|
+
console.log('logicalElementType: ', h);
|
|
825
|
+
}
|
|
992
826
|
|
|
993
|
-
|
|
827
|
+
let returnFilterElements = {};
|
|
828
|
+
let operationErrorsFound = [];
|
|
994
829
|
|
|
995
|
-
[runningFilterMainId, runningFilterObject,
|
|
830
|
+
[runningFilterMainId, runningFilterObject, operationErrorsFound, returnFilterElements] = validateOperation(
|
|
996
831
|
objType,
|
|
997
832
|
runningFilterMainId,
|
|
998
833
|
runningFilterObject,
|
|
999
834
|
lastLogicalOperator,
|
|
1000
835
|
currentFilterMainId,
|
|
1001
|
-
currentFilterObject
|
|
836
|
+
currentFilterObject,
|
|
837
|
+
filterElements
|
|
1002
838
|
);
|
|
1003
|
-
console.log('return
|
|
839
|
+
console.log('return validate operation : ', {
|
|
1004
840
|
runningFilterMainId,
|
|
1005
841
|
runningFilterObject,
|
|
1006
|
-
|
|
1007
|
-
|
|
842
|
+
operationErrorsFound,
|
|
843
|
+
returnFilterElements
|
|
1008
844
|
});
|
|
1009
845
|
|
|
1010
|
-
if (
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
let [
|
|
1015
|
-
nextFilterMainId,
|
|
1016
|
-
nextFilterObject,
|
|
1017
|
-
operations,
|
|
1018
|
-
nextErrorObject,
|
|
1019
|
-
nextErrorFound,
|
|
1020
|
-
nextElementId
|
|
1021
|
-
] = filterLogicalElements(
|
|
1022
|
-
objType,
|
|
1023
|
-
initialLogicalElementId,
|
|
1024
|
-
logicalElements,
|
|
1025
|
-
values,
|
|
1026
|
-
lastNextLogicalElementId,
|
|
1027
|
-
runningFilterMainId,
|
|
1028
|
-
runningFilterObject,
|
|
1029
|
-
lastLogicalOperator,
|
|
1030
|
-
);
|
|
1031
|
-
console.log('return validateOperation for lastNextLogicalElementId !== null: ', {
|
|
1032
|
-
nextFilterMainId,
|
|
1033
|
-
nextFilterObject,
|
|
1034
|
-
operations,
|
|
1035
|
-
nextErrorObject,
|
|
1036
|
-
nextErrorFound,
|
|
1037
|
-
nextElementId
|
|
1038
|
-
});
|
|
846
|
+
if (operationErrorsFound.length > 0) {
|
|
847
|
+
Object.assign(errorsObject, { [initialLogicalElementId]: 'has error in operation' });
|
|
848
|
+
errorsFound = errorsFound.concat(operationErrorsFound);
|
|
849
|
+
};
|
|
1039
850
|
|
|
1040
|
-
if (
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
}
|
|
851
|
+
if (errorsFound.length > 0) {
|
|
852
|
+
return [null, null, null, errorsObject, errorsFound];
|
|
853
|
+
};
|
|
1044
854
|
|
|
1045
|
-
|
|
1046
|
-
let filterErrorObject = {};
|
|
1047
|
-
let filterErrorFound = [];
|
|
855
|
+
Object.assign(filterElements, returnFilterElements, { [runningFilterMainId]: runningFilterObject });
|
|
1048
856
|
|
|
1049
|
-
|
|
1050
|
-
runningFilterMainId,
|
|
1051
|
-
runningFilterObject,
|
|
1052
|
-
operation,
|
|
1053
|
-
filterErrorObject,
|
|
1054
|
-
filterErrorFound,
|
|
1055
|
-
nextElementId
|
|
1056
|
-
] = filterLogicalElements(
|
|
1057
|
-
objType,
|
|
1058
|
-
initialLogicalElementId,
|
|
1059
|
-
logicalElements,
|
|
1060
|
-
values,
|
|
1061
|
-
nextElementId,
|
|
1062
|
-
nextFilterMainId,
|
|
1063
|
-
nextFilterObject,
|
|
1064
|
-
lastLogicalOperator
|
|
1065
|
-
);
|
|
1066
|
-
console.log('return validateOperation for lastNextLogicalElementId !== null: ', {
|
|
1067
|
-
runningFilterMainId,
|
|
1068
|
-
runningFilterObject,
|
|
1069
|
-
operation,
|
|
1070
|
-
filterErrorObject,
|
|
1071
|
-
filterErrorFound,
|
|
1072
|
-
nextElementId
|
|
1073
|
-
});
|
|
1074
|
-
return [
|
|
1075
|
-
runningFilterMainId,
|
|
1076
|
-
runningFilterObject,
|
|
1077
|
-
operation,
|
|
1078
|
-
filterErrorObject,
|
|
1079
|
-
filterErrorFound,
|
|
1080
|
-
nextElementId
|
|
1081
|
-
];
|
|
1082
|
-
} else {
|
|
1083
|
-
return [
|
|
1084
|
-
nextFilterMainId,
|
|
1085
|
-
nextFilterObject,
|
|
1086
|
-
operation,
|
|
1087
|
-
errorsObject,
|
|
1088
|
-
errorsFound,
|
|
1089
|
-
nextElementId
|
|
1090
|
-
];
|
|
1091
|
-
}
|
|
857
|
+
if (logicalElement.logicalElementType === "openBracket") {
|
|
1092
858
|
|
|
1093
|
-
|
|
859
|
+
if (nextElementId !== null) {
|
|
860
|
+
working_logicalElementId = nextElementId;
|
|
861
|
+
} else {
|
|
862
|
+
break;
|
|
863
|
+
}
|
|
1094
864
|
|
|
1095
|
-
|
|
1096
|
-
objType,
|
|
1097
|
-
runningFilterMainId,
|
|
1098
|
-
runningFilterObject,
|
|
1099
|
-
lastLogicalOperator,
|
|
1100
|
-
currentFilterMainId,
|
|
1101
|
-
currentFilterObject
|
|
1102
|
-
);
|
|
1103
|
-
console.log('return validateOperation for lastNextLogicalElementId == null: ', {
|
|
1104
|
-
runningFilterMainId,
|
|
1105
|
-
runningFilterObject,
|
|
1106
|
-
operation,
|
|
1107
|
-
operationErrorsFound
|
|
1108
|
-
});
|
|
865
|
+
} else {
|
|
1109
866
|
|
|
1110
|
-
|
|
1111
|
-
|
|
867
|
+
if (logicalElement.nextLogicalElementId === null) {
|
|
868
|
+
break;
|
|
869
|
+
};
|
|
870
|
+
working_logicalElementId = logicalElement.nextLogicalElementId;
|
|
1112
871
|
}
|
|
1113
872
|
|
|
1114
|
-
return [runningFilterMainId, runningFilterObject, operation, errorsObject, errorsFound, null];
|
|
1115
|
-
|
|
1116
873
|
}
|
|
1117
874
|
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
function splitFilterElements(
|
|
1121
|
-
runningFilterMainId,
|
|
1122
|
-
runningFilterObject,
|
|
1123
|
-
currentFilterMainId = null,
|
|
1124
|
-
currentFilterObject = null
|
|
1125
|
-
) {
|
|
1126
|
-
console.log('split FilterElements: ', {
|
|
875
|
+
console.log("before return filterLogicalStructure id process: ", {
|
|
1127
876
|
runningFilterMainId,
|
|
1128
877
|
runningFilterObject,
|
|
1129
|
-
|
|
1130
|
-
|
|
878
|
+
errorsObject,
|
|
879
|
+
errorsFound,
|
|
880
|
+
filterElements
|
|
1131
881
|
});
|
|
1132
882
|
|
|
1133
|
-
|
|
883
|
+
return [runningFilterMainId, runningFilterObject, errorsObject, errorsFound, filterElements, nextElementId];
|
|
884
|
+
|
|
885
|
+
};
|
|
1134
886
|
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
887
|
+
// function splitFilterElements(
|
|
888
|
+
// runningFilterMainId,
|
|
889
|
+
// runningFilterObject,
|
|
890
|
+
// currentFilterMainId = null,
|
|
891
|
+
// currentFilterObject = null
|
|
892
|
+
// ) {
|
|
893
|
+
// console.log('split FilterElements: ', {
|
|
894
|
+
// runningFilterMainId,
|
|
895
|
+
// runningFilterObject,
|
|
896
|
+
// currentFilterMainId,
|
|
897
|
+
// currentFilterObject
|
|
898
|
+
// });
|
|
1140
899
|
|
|
1141
|
-
|
|
1142
|
-
console.log('-------- operation ----------');
|
|
900
|
+
// let filterElements = {};
|
|
1143
901
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
902
|
+
// // if (runningFilterObject.filterElement.filterType === 'logical'
|
|
903
|
+
// // || runningFilterObject.filterElement.filterType === 'identifiers'
|
|
904
|
+
// // || runningFilterObject.filterElement.filterType === 'translateIds'
|
|
905
|
+
// // || runningFilterObject.filterElement.filterType === 'traversal'
|
|
906
|
+
// // ) {}
|
|
1147
907
|
|
|
1148
|
-
|
|
1149
|
-
|
|
908
|
+
// if (runningFilterObject.filterElement.filterType === 'operation') {
|
|
909
|
+
// console.log('-------- operation ----------');
|
|
1150
910
|
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
911
|
+
// Object.assign(filterElements, runningFilterObject.filterElement.filterElements);
|
|
912
|
+
// // delete runningFilterObject.filterElement.filterElements;
|
|
913
|
+
// filterElements[runningFilterMainId] = runningFilterObject;
|
|
1154
914
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
//'logical'| 'identifiers'|'translateIds'|'traversal'
|
|
1158
|
-
filterElements[runningFilterMainId] = runningFilterObject;
|
|
1159
|
-
};
|
|
915
|
+
// } else if (runningFilterObject.filterElement.filterType === 'childComplexFilter') {
|
|
916
|
+
// console.log('-------- childComplexFilter ----------');
|
|
1160
917
|
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
918
|
+
// Object.assign(filterElements, runningFilterObject.filterElement.filterElements);
|
|
919
|
+
// // delete runningFilterObject.filterElement.filterElements;
|
|
920
|
+
// filterElements[runningFilterMainId] = runningFilterObject;
|
|
1164
921
|
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
922
|
+
// } else {
|
|
923
|
+
// console.log(` -------- ${runningFilterObject.filterElement.filterType} ----------`);
|
|
924
|
+
// //'logical'| 'identifiers'|'translateIds'|'traversal'
|
|
925
|
+
// filterElements[runningFilterMainId] = runningFilterObject;
|
|
926
|
+
// };
|
|
1168
927
|
|
|
1169
|
-
|
|
1170
|
-
|
|
928
|
+
// if (currentFilterObject !== null) {
|
|
929
|
+
// if (currentFilterObject.filterType === 'operation') {
|
|
930
|
+
// console.log('-------- operation ----------');
|
|
1171
931
|
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
932
|
+
// Object.assign(filterElements, currentFilterObject.filterElement.filterElements);
|
|
933
|
+
// // delete currentFilterObject.filterElement.filterElements;
|
|
934
|
+
// filterElements[currentFilterMainId] = currentFilterObject;
|
|
1175
935
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
//'logical'| 'identifiers'|'translateIds'|'traversal'
|
|
1179
|
-
filterElements[currentFilterMainId] = currentFilterObject;
|
|
1180
|
-
};
|
|
1181
|
-
};
|
|
936
|
+
// } else if (currentFilterObject.filterElement.filterType === 'childComplexFilter') {
|
|
937
|
+
// console.log('-------- childComplexFilter ----------');
|
|
1182
938
|
|
|
1183
|
-
|
|
939
|
+
// Object.assign(filterElements, currentFilterObject.filterElement.filterElements);
|
|
940
|
+
// delete currentFilterObject.filterElement.filterElements;
|
|
941
|
+
// filterElements[currentFilterMainId] = currentFilterObject;
|
|
1184
942
|
|
|
1185
|
-
}
|
|
943
|
+
// } else {
|
|
944
|
+
// console.log(` -------- ${currentFilterObject.filterElement.filterType} ----------`);
|
|
945
|
+
// //'logical'| 'identifiers'|'translateIds'|'traversal'
|
|
946
|
+
// filterElements[currentFilterMainId] = currentFilterObject;
|
|
947
|
+
// };
|
|
948
|
+
// };
|
|
1186
949
|
|
|
950
|
+
// return filterElements;}
|
|
1187
951
|
|
|
1188
952
|
export default {
|
|
1189
953
|
//* create filter
|