@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.
@@ -22,92 +22,30 @@ import lodash from 'lodash';
22
22
  import objectHash from 'object-hash';
23
23
  const { isEmpty } = lodash;
24
24
 
25
- function validateFilterElement(
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
- values,
31
+ valueUserTags,
68
32
  ) {
69
33
  console.log('createFiltersRequest: ', {
70
34
  objType,
71
35
  initialLogicalElementId,
72
36
  logicalElements,
73
- values,
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
- values,
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
- values
117
+ valueUserTags
185
118
  ) {
186
119
  console.log('validateCombinationStructure: ', {
187
120
  objType,
188
121
  initialLogicalElementId,
189
122
  logicalElements,
190
- values
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
- values
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('value')) {
299
- errorsObject[logicalElementId] = `this logical structure is not set value`;
300
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set value`);
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
- values
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('value')) {
413
- errorsObject[logicalElementId] = `this logical structure is not set value`;
414
- errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set value`);
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, null, errorsFound];
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, null, errorsFound];
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
- let filterElements = currentFilterObject.filterElement.filterElements;
640
- delete currentFilterObject.filterElement.filterElements;
641
- return [currentFilterMainId, currentFilterObject, null, errorsFound, filterElements];
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
- runningFilterMainId,
646
- runningFilterObject,
647
- currentFilterMainId,
648
- currentFilterObject
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
- filterMainIdA: runningFilterMainId,
676
- operator: lastLogicalOperator,
677
- filterMainIdB: currentFilterMainId,
678
- };
518
+ // let operation = {
519
+ // filterMainIdA: runningFilterMainId,
520
+ // operator: lastLogicalOperator,
521
+ // filterMainIdB: currentFilterMainId,
522
+ // };
679
523
 
680
- return [operationFilterMainId, operationFilterObject, operation, errorsFound, filterElements];
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
- values,
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
- values,
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 operation = null;
717
- let operationErrorsFound = [];
718
- let lastNextLogicalElementId = null;
719
- let currentLogicalElementId = initialLogicalElementId;
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
- if (nextLogicalElementId !== null) {
724
- currentLogicalElementId = nextLogicalElementId;
725
- }
555
+ let nextElementId = null;
726
556
 
727
- let logicalElement = logicalElements[currentLogicalElementId];
728
- console.log('logicalElement: ', logicalElement)
557
+ let working_logicalElementId = initialLogicalElementId;
558
+ console.log("working_logicalElementId: ", working_logicalElementId)
729
559
 
730
- if (isEmpty(logicalElement)) {
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
- let logicalElementType = logicalElement.logicalElementType;
740
- console.log('logicalElementType: ', logicalElementType);
562
+ if (i === MAX_LOGICALS) {
741
563
 
742
- if (logicalElementType === "operation") {
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
- lastLogicalOperator = logicalElement.operation;
571
+ errorsObject = {
572
+ [initialLogicalElementId]: 'has max limit iterate in logicalElements'
573
+ };
574
+ errorsFound.push(`${initialLogicalElementId}: has max limit iterate in logicalElements`);
745
575
 
746
- if (logicalElement.nextLogicalElementId === null) {
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
- logicalElement = logicalElements[logicalElement.nextLogicalElementId];
752
- logicalElementType = logicalElement.logicalElementType;
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
- if (logicalElementType === "openBracket") {
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 nextElementId = null;
759
- let returnFilterElements = {};
600
+ let logicalElementType = logicalElement.logicalElementType;
601
+ console.log('logicalElementType: ', logicalElementType);
760
602
 
761
- [
762
- currentFilterMainId,
763
- currentFilterObject,
764
- operation,
765
- errorsObject,
766
- errorsFound,
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
- console.log("bb", bb)
610
+ if (errorsFound.length > 0) {
611
+ return [null, null, null, errorsObject, errorsFound];
612
+ }
787
613
 
788
- if (nextElementId !== null) {
789
- lastNextLogicalElementId = nextElementId;
614
+ lastLogicalOperator = logicalElement.operation;
615
+ working_logicalElementId = logicalElement.nextLogicalElementId;
616
+ continue;
790
617
  }
791
618
 
792
- } else if (logicalElementType === "closeBracket") {
619
+ if (logicalElementType === "openBracket") {
793
620
 
794
- return [
795
- runningFilterMainId,
796
- runningFilterObject,
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
- console.log("check logicalElement: ", logicalElement);
806
- console.log("check logicalElementType: ", logicalElementType);
807
- console.log("check filter main id: ", {
808
- runningFilterMainId,
809
- lastLogicalOperator,
810
- currentFilterMainId
811
- });
640
+ if (logicalErrorsFound.length > 0) {
641
+ Object.assign(errorsObject, logicalErrorsObject);
642
+ errorsFound = errorsFound.concat(logicalErrorsFound);
643
+ };
812
644
 
813
- console.log("check filter main id: ", {
814
- runningFilterMainId,
815
- runningFilterObject,
816
- lastLogicalOperator,
817
- currentFilterMainId,
818
- currentFilterObject
819
- });
645
+ Object.assign(filterElements, returnFilterElements);
820
646
 
821
- if (logicalElementType === "logical") {
647
+ } else if (logicalElementType === "closeBracket") {
822
648
 
823
- console.log('------------------ logicalElementType: logical ----------------');
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
- let value = values[logicalElement.value];
847
- console.log('value: ', value);
653
+ if (logicalElementType === "logical") {
848
654
 
849
- if (isEmpty(value)) {
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
- if (value.valueSource !== 'perParentIdentifier') {
856
- errorsObject[currentLogicalElementId] = `valueType is not set type: perParentIdentifier`;
857
- errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} has valueType is not set type: perParentIdentifier`);
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
- //* create complexFilter normalize here
861
- currentFilterObject = {
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
- //* create complexFilter normalize here
875
- currentFilterObject = {
876
- objType: logicalElement.objType,
877
- filterElement: {
878
- filterType: logicalElement.logicalElementType,
879
- fieldName: logicalElement.fieldName,
880
- comparison: logicalElement.comparison,
881
- value: values[logicalElement.value].value
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
- currentFilterMainId = hash(currentFilterObject);
889
- console.log('currentFilterMainId: ', currentFilterMainId);
890
-
891
- if (logicalElement.nextLogicalElementId !== null) {
892
- lastNextLogicalElementId = logicalElement.nextLogicalElementId;
893
- }
720
+ currentFilterMainId = hash(currentFilterObject);
721
+ console.log('currentFilterMainId: ', currentFilterMainId);
894
722
 
895
- } else if (logicalElementType === "childComplexFilter") {
896
- console.log('------------------ logicalElementType: childComplexFilter ----------------');
723
+ } else if (logicalElementType === "childComplexFilter") {
724
+ console.log('------------------ logicalElementType: childComplexFilter ----------------');
897
725
 
898
- if (!logicalElement.hasOwnProperty('objType')) {
899
- errorsObject[currentLogicalElementId] = `this logical structure is not set objType`;
900
- errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} is not set objType`);
901
- };
902
- if (hash(objType) !== hash(logicalElement.objType)) {
903
- errorsObject[currentLogicalElementId] = `it' s not the same level objType to process this logicalElement`
904
- errorsFound.push(`it' s not the same level objType to process this logicalElement: ${currentLogicalElementId}`)
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
- if (childLogicalElementId === null) {
923
- errorsObject[currentLogicalElementId] = `this logicalType: childComplexFilter is not set childLogicalElementId`;
924
- errorsFound.push(`this logical structure logicalElementId: ${currentLogicalElementId} logicalType: childComplexFilter is not set childLogicalElementId`);
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
- if (errorsFound.length > 0) {
928
- return [null, null, null, errorsObject, errorsFound];
929
- };
748
+ let childLogicalElementId = logicalElement.childLogicalElementId;
930
749
 
931
- let [
932
- childFilterMainId,
933
- childFilterObject,
934
- operation,
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
- delete childFilterObject.filterElement.filterElements;
755
+ if (errorsFound.length > 0) {
756
+ return [null, null, null, errorsObject, errorsFound];
757
+ };
962
758
 
963
- if (isEmpty(returnFilterElements)) {
964
- returnFilterElements = { [childFilterMainId]: childFilterObject };
965
- } else {
966
- returnFilterElements[childFilterMainId] = childFilterObject;
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
- // let childFilterElements = splitFilterElements(
971
- // childFilterMainId,
972
- // childFilterObject
973
- // );
974
- // console.log('childFilterElements: ', childFilterElements);
778
+ let setRequestProperties = {};
975
779
 
976
- Object.assign(filterElements, returnFilterElements);
977
- let setRequestProperties = {};
780
+ if (!isEmpty(logicalElement.requestProperties)) {
781
+ console.log('logicalElement: ', logicalElement);
978
782
 
979
- if (!isEmpty(logicalElement.requestProperties)) {
980
- console.log('logicalElement: ', logicalElement);
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
- let requestPropertyObject = values[requestPropertyId];
786
+ let requestPropertyObject = valueUserTags[requestPropertyId];
986
787
 
987
- if (requestPropertyObject.hasOwnProperty('valueSource')) {
988
- errorsObject[initialLogicalElementId] = `requestProperties in filter logicalStructure set valueSource`;
989
- errorsFound.push(`this filter logical structure logicalElementId: ${initialLogicalElementId} set valueSource`);
990
- continue;
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
- currentFilterMainId = hash(currentFilterObject);
1011
- console.log('currentFilterMainId: ', currentFilterMainId);
1012
-
1013
- if (logicalElement.nextLogicalElementId !== null) {
1014
- lastNextLogicalElementId = logicalElement.nextLogicalElementId;
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
- } else if (logicalElementType === "traversal") {
810
+ currentFilterMainId = hash(currentFilterObject);
811
+ console.log("currentFilterMainId: ", currentFilterMainId);
1018
812
 
1019
- console.log('logicalElementType: ', f);
1020
- } else if (logicalElementType === "translateIds") {
813
+ Object.assign(filterElements, childFilterElements);
814
+ console.log("filterElements: ", filterElements);
1021
815
 
1022
- console.log('logicalElementType: ', g);
1023
- } else if (logicalElementType === "identifiers") {
816
+ } else if (logicalElementType === "traversal") {
1024
817
 
1025
- console.log('logicalElementType: ', h);
1026
- }
818
+ console.log('logicalElementType: ', f);
819
+ } else if (logicalElementType === "translateIds") {
1027
820
 
1028
- if (errorsFound.length > 0) {
1029
- return [null, null, null, errorsObject, errorsFound, null];
1030
- }
821
+ console.log('logicalElementType: ', g);
822
+ } else if (logicalElementType === "identifiers") {
1031
823
 
1032
- if (lastNextLogicalElementId !== null) {
824
+ console.log('logicalElementType: ', h);
825
+ }
1033
826
 
1034
- let validateFilterElements = {};
827
+ let returnFilterElements = {};
828
+ let operationErrorsFound = [];
1035
829
 
1036
- [runningFilterMainId, runningFilterObject, operation, operationErrorsFound, validateFilterElements] = validateOperation(
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 validateOperation for lastNextLogicalElementId !== null: ', {
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 (nextErrorFound.length > 0) {
1091
- Object.assign(errorsObject, nextErrorObject);
1092
- errorsFound = errorsFound.concat(nextErrorFound);
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
- let filterErrorObject = {};
1100
- let filterErrorFound = [];
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
- return [
1139
- nextFilterMainId,
1140
- nextFilterObject,
1141
- operation,
1142
- errorsObject,
1143
- errorsFound,
1144
- nextElementId,
1145
- filterElements
1146
- ];
1147
- }
857
+ if (logicalElement.logicalElementType === "openBracket") {
1148
858
 
1149
- } else {
1150
- let returnFilterElements = {};
859
+ if (nextElementId !== null) {
860
+ working_logicalElementId = nextElementId;
861
+ } else {
862
+ break;
863
+ }
1151
864
 
1152
- [runningFilterMainId, runningFilterObject, operation, operationErrorsFound, returnFilterElements] = validateOperation(
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
- if (operationErrorsFound.length > 0) {
1169
- errorsFound = errorsFound.concat(operationErrorsFound)
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
- currentFilterMainId,
1188
- currentFilterObject
878
+ errorsObject,
879
+ errorsFound,
880
+ filterElements
1189
881
  });
1190
882
 
1191
- let filterElements = {};
883
+ return [runningFilterMainId, runningFilterObject, errorsObject, errorsFound, filterElements, nextElementId];
884
+
885
+ };
1192
886
 
1193
- // if (runningFilterObject.filterElement.filterType === 'logical'
1194
- // || runningFilterObject.filterElement.filterType === 'identifiers'
1195
- // || runningFilterObject.filterElement.filterType === 'translateIds'
1196
- // || runningFilterObject.filterElement.filterType === 'traversal'
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
- if (runningFilterObject.filterElement.filterType === 'operation') {
1200
- console.log('-------- operation ----------');
900
+ // let filterElements = {};
1201
901
 
1202
- Object.assign(filterElements, runningFilterObject.filterElement.filterElements);
1203
- // delete runningFilterObject.filterElement.filterElements;
1204
- filterElements[runningFilterMainId] = runningFilterObject;
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
- } else if (runningFilterObject.filterElement.filterType === 'childComplexFilter') {
1207
- console.log('-------- childComplexFilter ----------');
908
+ // if (runningFilterObject.filterElement.filterType === 'operation') {
909
+ // console.log('-------- operation ----------');
1208
910
 
1209
- Object.assign(filterElements, runningFilterObject.filterElement.filterElements);
1210
- // delete runningFilterObject.filterElement.filterElements;
1211
- filterElements[runningFilterMainId] = runningFilterObject;
911
+ // Object.assign(filterElements, runningFilterObject.filterElement.filterElements);
912
+ // // delete runningFilterObject.filterElement.filterElements;
913
+ // filterElements[runningFilterMainId] = runningFilterObject;
1212
914
 
1213
- } else {
1214
- console.log(` -------- ${runningFilterObject.filterElement.filterType} ----------`);
1215
- //'logical'| 'identifiers'|'translateIds'|'traversal'
1216
- filterElements[runningFilterMainId] = runningFilterObject;
1217
- };
915
+ // } else if (runningFilterObject.filterElement.filterType === 'childComplexFilter') {
916
+ // console.log('-------- childComplexFilter ----------');
1218
917
 
1219
- if (currentFilterObject !== null) {
1220
- if (currentFilterObject.filterType === 'operation') {
1221
- console.log('-------- operation ----------');
918
+ // Object.assign(filterElements, runningFilterObject.filterElement.filterElements);
919
+ // // delete runningFilterObject.filterElement.filterElements;
920
+ // filterElements[runningFilterMainId] = runningFilterObject;
1222
921
 
1223
- Object.assign(filterElements, currentFilterObject.filterElement.filterElements);
1224
- // delete currentFilterObject.filterElement.filterElements;
1225
- filterElements[currentFilterMainId] = currentFilterObject;
922
+ // } else {
923
+ // console.log(` -------- ${runningFilterObject.filterElement.filterType} ----------`);
924
+ // //'logical'| 'identifiers'|'translateIds'|'traversal'
925
+ // filterElements[runningFilterMainId] = runningFilterObject;
926
+ // };
1226
927
 
1227
- } else if (currentFilterObject.filterElement.filterType === 'childComplexFilter') {
1228
- console.log('-------- childComplexFilter ----------');
928
+ // if (currentFilterObject !== null) {
929
+ // if (currentFilterObject.filterType === 'operation') {
930
+ // console.log('-------- operation ----------');
1229
931
 
1230
- Object.assign(filterElements, currentFilterObject.filterElement.filterElements);
1231
- delete currentFilterObject.filterElement.filterElements;
1232
- filterElements[currentFilterMainId] = currentFilterObject;
932
+ // Object.assign(filterElements, currentFilterObject.filterElement.filterElements);
933
+ // // delete currentFilterObject.filterElement.filterElements;
934
+ // filterElements[currentFilterMainId] = currentFilterObject;
1233
935
 
1234
- } else {
1235
- console.log(` -------- ${currentFilterObject.filterElement.filterType} ----------`);
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
- return filterElements;
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