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