@izara_project/izara-shared-search-and-sort 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/DataFieldsSharedLib.js +236 -142
- package/src/FiltersSharedLib.js +380 -616
- package/src/LogicalStructureSharedLib.js +159 -476
- package/src/SearchSortSharedLib.js +65 -37
|
@@ -17,13 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
22
21
|
import lodash from 'lodash';
|
|
23
22
|
const { isEmpty } = lodash;
|
|
24
23
|
import { v4 as uuidV4 } from 'uuid';
|
|
25
24
|
const MAX_ITER = 4;
|
|
26
25
|
|
|
26
|
+
const MAX_LOGICALS = 50;
|
|
27
|
+
|
|
27
28
|
let getObjectSchema = {};
|
|
28
29
|
|
|
29
30
|
function initSchemaFn(getObjSchemaS3WithHierarchyShared, getObjectLinksShared) {
|
|
@@ -34,7 +35,6 @@ function initSchemaFn(getObjSchemaS3WithHierarchyShared, getObjectLinksShared) {
|
|
|
34
35
|
return getObjectSchema;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
38
|
function combineLogicalStructure(
|
|
39
39
|
objType,
|
|
40
40
|
initialLogicalElementId,
|
|
@@ -45,180 +45,136 @@ function combineLogicalStructure(
|
|
|
45
45
|
initialLogicalElementId,
|
|
46
46
|
logicalElements,
|
|
47
47
|
});
|
|
48
|
-
|
|
49
|
-
let returnInitialElementId = null;
|
|
50
|
-
let initialLogicalElementObject = logicalElements[initialLogicalElementId]
|
|
51
|
-
if (initialLogicalElementObject.logicalElementType !== 'logicalStructure') {
|
|
52
|
-
returnInitialElementId = initialLogicalElementId;
|
|
53
|
-
} else {
|
|
54
|
-
returnInitialElementId = logicalElements[initialLogicalElementId].initialLogicalElementId;
|
|
55
|
-
};
|
|
56
|
-
console.log('returnInitialElementId', returnInitialElementId);
|
|
57
|
-
|
|
58
|
-
let previousLogicalElementId = null;
|
|
59
|
-
let previousLogicalElementObject = null;
|
|
60
|
-
|
|
61
|
-
let operationLogicalElementId = null;
|
|
62
|
-
let operationLogicalElementObject = null;
|
|
63
|
-
|
|
64
|
-
let nextLogicalElementId = null;
|
|
65
|
-
let nextLogicalElementObject = null;
|
|
66
|
-
|
|
67
|
-
let returnLogicalElements = {};
|
|
68
|
-
|
|
69
48
|
let errorsObject = {};
|
|
70
49
|
let errorsFound = [];
|
|
71
50
|
|
|
72
|
-
|
|
73
|
-
console.log('extract logicalELements: ', { initialLogicalElementId, logicalElementId, logicalElementObject });
|
|
51
|
+
let combineFilterStructure = {};
|
|
74
52
|
|
|
75
|
-
|
|
76
|
-
continue;
|
|
77
|
-
};
|
|
53
|
+
let working_logicalElementId = initialLogicalElementId;
|
|
78
54
|
|
|
79
|
-
|
|
80
|
-
console.log('logicalElementType: ', logicalElementType);
|
|
55
|
+
for (let i = 0; i < MAX_LOGICALS; i++) {
|
|
81
56
|
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
errorsObject
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
57
|
+
if (i === MAX_LOGICALS) {
|
|
58
|
+
|
|
59
|
+
if (i < Object.keys(logicalElements).length) {
|
|
60
|
+
errorsObject = {
|
|
61
|
+
[initialLogicalElementId]: 'has remain logicalElements that want to process'
|
|
62
|
+
};
|
|
63
|
+
errorsFound.push(`${initialLogicalElementId}: has remain logicalElements that want to process`)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
errorsObject = {
|
|
67
|
+
[initialLogicalElementId]: 'has max limit iterate in logicalElements'
|
|
91
68
|
};
|
|
69
|
+
errorsFound.push(`${initialLogicalElementId}: has max limit iterate in logicalElements`)
|
|
70
|
+
return [null, errorsObject, errorsFound];
|
|
71
|
+
}
|
|
92
72
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
initialLogicalElementId = logicalElementObject.nextLogicalElementId;
|
|
73
|
+
let logicalElement = logicalElements[working_logicalElementId];
|
|
74
|
+
console.log("logicalElement: ", logicalElement);
|
|
96
75
|
|
|
97
|
-
|
|
98
|
-
console.log('----------type: logicalStructure ----------');
|
|
76
|
+
let lastLogicalElementId = null;
|
|
99
77
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
};
|
|
104
|
-
if (!logicalElementObject.hasOwnProperty('initialLogicalElementId')) {
|
|
105
|
-
errorsObject[logicalElementId] = `this logical structure is not set initialLogicalElementId`;
|
|
106
|
-
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set initialLogicalElementId`);
|
|
107
|
-
};
|
|
108
|
-
if (!logicalElementObject.hasOwnProperty('previousLogicalElementId')) {
|
|
109
|
-
errorsObject[logicalElementId] = `this logical structure is not set previousLogicalElementId`;
|
|
110
|
-
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set previousLogicalElementId`);
|
|
111
|
-
};
|
|
112
|
-
if (!logicalElementObject.hasOwnProperty('nextLogicalElementId')) {
|
|
113
|
-
errorsObject[logicalElementId] = `this logical structure is not set nextLogicalElementId`;
|
|
114
|
-
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set nextLogicalElementId`);
|
|
115
|
-
};
|
|
116
|
-
if (!logicalElementObject.hasOwnProperty('logicalElements')) {
|
|
117
|
-
errorsObject[logicalElementId] = `this logical structure is not set logicalElements`;
|
|
118
|
-
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set logicalElements`);
|
|
119
|
-
};
|
|
78
|
+
if (!isEmpty(combineFilterStructure)) {
|
|
79
|
+
lastLogicalElementId = combineFilterStructure.initialLogicalElementId;
|
|
80
|
+
}
|
|
120
81
|
|
|
121
|
-
|
|
122
|
-
nextLogicalElementObject = logicalElementObject.logicalElements;
|
|
82
|
+
for (let j = 0; j <= MAX_LOGICALS; j++) {
|
|
123
83
|
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
84
|
+
if (j === MAX_LOGICALS) {
|
|
85
|
+
errorsObject = {
|
|
86
|
+
[initialLogicalElementId]: 'has max limit iterate in logicalElements'
|
|
87
|
+
};
|
|
88
|
+
errorsFound.push(`${initialLogicalElementId}: has max limit iterate in logicalElements`)
|
|
89
|
+
return [null, errorsObject, errorsFound];
|
|
90
|
+
}
|
|
127
91
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
92
|
+
if (!isEmpty(combineFilterStructure)) {
|
|
93
|
+
let lastLogicalElement = combineFilterStructure.logicalElements[lastLogicalElementId];
|
|
94
|
+
if (lastLogicalElement.nextLogicalElementId === null) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
lastLogicalElementId = lastLogicalElement.nextLogicalElementId;
|
|
98
|
+
} else {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
console.log("lastLogicalElementId: ", lastLogicalElementId);
|
|
103
|
+
|
|
104
|
+
if (logicalElement.logicalElementType === "openBracket") {
|
|
105
|
+
|
|
106
|
+
if (isEmpty(combineFilterStructure)) {
|
|
107
|
+
combineFilterStructure.objType = objType;
|
|
108
|
+
combineFilterStructure.initialLogicalElementId = working_logicalElementId;
|
|
109
|
+
combineFilterStructure.logicalElements = {
|
|
110
|
+
[working_logicalElementId]: {
|
|
111
|
+
logicalElementType: "openBracket",
|
|
112
|
+
previousLogicalElementId: null,
|
|
113
|
+
nextLogicalElementId: null,
|
|
114
|
+
}
|
|
115
|
+
}
|
|
142
116
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
117
|
+
} else {
|
|
118
|
+
combineFilterStructure.logicalElements[lastLogicalElementId].nextLogicalElementId = working_logicalElementId;
|
|
119
|
+
Object.assign(combineFilterStructure.logicalElements, {
|
|
120
|
+
[working_logicalElementId]: {
|
|
121
|
+
logicalElementType: 'openBracket',
|
|
122
|
+
previousLogicalElementId: lastLogicalElementId,
|
|
123
|
+
nextLogicalElementId: null
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
147
127
|
|
|
148
|
-
|
|
149
|
-
console.log('----------type: closeBracket ----------');
|
|
150
|
-
if (!logicalElementObject.hasOwnProperty('previousLogicalElementId')) {
|
|
151
|
-
errorsObject[logicalElementId] = `this logical structure is not set previousLogicalElementId`;
|
|
152
|
-
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set previousLogicalElementId`);
|
|
153
|
-
};
|
|
154
|
-
if (!logicalElementObject.hasOwnProperty('nextLogicalElementId')) {
|
|
155
|
-
errorsObject[logicalElementId] = `this logical structure is not set nextLogicalElementId`;
|
|
156
|
-
errorsFound.push(`this logical structure logicalElementId: ${logicalElementId} is not set nextLogicalElementId`);
|
|
157
|
-
};
|
|
128
|
+
console.log("combineFilterStructure: ", combineFilterStructure);
|
|
158
129
|
|
|
159
|
-
|
|
160
|
-
nextLogicalElementObject = { [nextLogicalElementId]: logicalElementObject };
|
|
161
|
-
initialLogicalElementId = logicalElementObject.nextLogicalElementId;
|
|
130
|
+
} else if (logicalElement.logicalElementType === "closeBracket") {
|
|
162
131
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
132
|
+
combineFilterStructure.logicalElements[lastLogicalElementId].nextLogicalElementId = working_logicalElementId;
|
|
133
|
+
Object.assign(combineFilterStructure.logicalElements, {
|
|
134
|
+
[working_logicalElementId]: {
|
|
135
|
+
logicalElementType: 'closeBracket',
|
|
136
|
+
previousLogicalElementId: lastLogicalElementId,
|
|
137
|
+
nextLogicalElementId: null
|
|
138
|
+
}
|
|
139
|
+
});
|
|
168
140
|
|
|
169
|
-
if (
|
|
170
|
-
return [null, errorsObject, errorsFound];
|
|
171
|
-
};
|
|
141
|
+
} else if (logicalElement.logicalElementType === "operation") {
|
|
172
142
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
143
|
+
combineFilterStructure.logicalElements[lastLogicalElementId].nextLogicalElementId = working_logicalElementId;
|
|
144
|
+
Object.assign(combineFilterStructure.logicalElements, {
|
|
145
|
+
[working_logicalElementId]: {
|
|
146
|
+
logicalElementType: "operation",
|
|
147
|
+
previousLogicalElementId: lastLogicalElementId,
|
|
148
|
+
nextLogicalElementId: null,
|
|
149
|
+
operation: logicalElement.operation
|
|
150
|
+
}
|
|
151
|
+
});
|
|
176
152
|
|
|
177
|
-
|
|
178
|
-
previousLogicalElementId,
|
|
179
|
-
previousLogicalElementObject,
|
|
180
|
-
operations,
|
|
181
|
-
operationErrorObjects,
|
|
182
|
-
operationErrors
|
|
183
|
-
] = combineOperation(
|
|
184
|
-
previousLogicalElementId,
|
|
185
|
-
previousLogicalElementObject,
|
|
186
|
-
operationLogicalElementId,
|
|
187
|
-
operationLogicalElementObject,
|
|
188
|
-
nextLogicalElementId,
|
|
189
|
-
nextLogicalElementObject
|
|
190
|
-
);
|
|
191
|
-
console.log('return combineOperation: ', {
|
|
192
|
-
previousLogicalElementId,
|
|
193
|
-
previousLogicalElementObject,
|
|
194
|
-
operations,
|
|
195
|
-
operationErrors
|
|
196
|
-
});
|
|
153
|
+
} else if (logicalElement.logicalElementType === "logicalStructure") {
|
|
197
154
|
|
|
198
|
-
|
|
199
|
-
Object.assign(errorsObject, operationErrorObjects);
|
|
200
|
-
};
|
|
155
|
+
if (isEmpty(combineFilterStructure)) {
|
|
201
156
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
Object.assign(returnLogicalElements, previousLogicalElementObject);
|
|
208
|
-
};
|
|
157
|
+
combineFilterStructure.objType = logicalElement.objType;
|
|
158
|
+
combineFilterStructure.initialLogicalElementId = logicalElement.initialLogicalElementId;
|
|
159
|
+
combineFilterStructure.logicalElements = logicalElement.logicalElements;
|
|
160
|
+
|
|
161
|
+
} else {
|
|
209
162
|
|
|
210
|
-
|
|
163
|
+
combineFilterStructure.logicalElements[lastLogicalElementId].nextLogicalElementId = logicalElement.initialLogicalElementId;
|
|
164
|
+
logicalElement.logicalElements[logicalElement.initialLogicalElementId].previousLogicalElementId = lastLogicalElementId;
|
|
165
|
+
Object.assign(combineFilterStructure.logicalElements, logicalElement.logicalElements);
|
|
211
166
|
|
|
212
|
-
|
|
167
|
+
}
|
|
213
168
|
|
|
214
|
-
|
|
215
|
-
objType: objType,
|
|
216
|
-
initialLogicalElementId: returnInitialElementId,
|
|
217
|
-
logicalElements: returnLogicalElements
|
|
218
|
-
};
|
|
169
|
+
}
|
|
219
170
|
|
|
220
|
-
|
|
171
|
+
if (logicalElement.nextLogicalElementId === null) {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
working_logicalElementId = logicalElement.nextLogicalElementId;
|
|
175
|
+
}
|
|
221
176
|
|
|
177
|
+
return [combineFilterStructure, errorsObject, errorsFound];
|
|
222
178
|
};
|
|
223
179
|
|
|
224
180
|
function combineOperation(
|
|
@@ -602,303 +558,81 @@ async function changeObjTypePath(
|
|
|
602
558
|
requiredObjType,
|
|
603
559
|
filtersStructure,
|
|
604
560
|
path = null,
|
|
605
|
-
|
|
561
|
+
indexPath = 0
|
|
606
562
|
) {
|
|
607
563
|
try {
|
|
608
|
-
console.log('----- function
|
|
564
|
+
console.log('----- function changeObjTypePath -----', {
|
|
609
565
|
requiredObjType,
|
|
610
566
|
filtersStructure,
|
|
611
|
-
path
|
|
567
|
+
path,
|
|
568
|
+
indexPath,
|
|
612
569
|
});
|
|
613
570
|
|
|
614
|
-
let filterLogicalStructure = {};
|
|
615
|
-
|
|
616
571
|
let errorsObject = {};
|
|
617
572
|
let errorsFound = [];
|
|
618
573
|
|
|
619
|
-
if (
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
let previousLogicalElementId = null;
|
|
624
|
-
let previousLogicalElement = null;
|
|
625
|
-
let currentLogicalElementId = null;
|
|
626
|
-
let currentLogicalElement = null;
|
|
627
|
-
|
|
628
|
-
if (path.length > 1) {
|
|
629
|
-
|
|
630
|
-
for (let i = 0; i < path.length; i++) {
|
|
631
|
-
|
|
632
|
-
let pathObject = path[i];
|
|
633
|
-
let logicalStructureElements = filtersStructure.logicalElements;
|
|
634
|
-
console.log('logicalStructureElements', logicalStructureElements);
|
|
635
|
-
|
|
636
|
-
let initialLogicalElementId = filtersStructure.initialLogicalElementId;
|
|
637
|
-
console.log('initialLogicalElementId', initialLogicalElementId);
|
|
638
|
-
|
|
639
|
-
if (i + 1 === path.length) {
|
|
640
|
-
console.log(`------------------- final path: ${i} ---------------------`);
|
|
641
|
-
|
|
642
|
-
if (previousLogicalElementId !== null) {
|
|
643
|
-
|
|
644
|
-
if (checkObjType(pathObject.objType, logicalElements[previousLogicalElementId].objType) !== true) {
|
|
645
|
-
errorsFound.push('objType is not equals in structure');
|
|
646
|
-
console.log('before return: ', {
|
|
647
|
-
filterLogicalStructure: {},
|
|
648
|
-
errorsObject,
|
|
649
|
-
errorsFound
|
|
650
|
-
});
|
|
651
|
-
return [{}, errorsObject, errorsFound];
|
|
652
|
-
};
|
|
574
|
+
if (indexPath > 10) {
|
|
575
|
+
errorsObject = Object.assign(errorsObject, { [filtersStructure.objType.objectType]: 'has Limit max to iterate path for change level' })
|
|
576
|
+
errorsFound.push(`this objectType: ${filtersStructure.objType.objectType} has Limit max to iterate path for change level`);
|
|
577
|
+
}
|
|
653
578
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
579
|
+
if (path === null) {
|
|
580
|
+
errorsObject = Object.assign(
|
|
581
|
+
errorsObject, {
|
|
582
|
+
[filtersStructure.objType.objectType]: `this objectType filtersTructure cannot change level of objectType: ${requiredObjType.objectType}`
|
|
583
|
+
});
|
|
584
|
+
errorsFound.push(`this objectType: ${filtersStructure.objType.objectType} cannot change level of objectType: ${requiredObjType.objectType}`);
|
|
585
|
+
}
|
|
660
586
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
} else {
|
|
665
|
-
errorsFound.push('objType is not equals in structure');
|
|
666
|
-
console.log('before return: ', {
|
|
667
|
-
filterLogicalStructure: {},
|
|
668
|
-
errorsObject,
|
|
669
|
-
errorsFound
|
|
670
|
-
});
|
|
671
|
-
return [{}, errorsObject, errorsFound];
|
|
672
|
-
};
|
|
673
|
-
};
|
|
587
|
+
if (errorsFound.length > 0) {
|
|
588
|
+
return [null, errorsObject, errorsFound];
|
|
589
|
+
}
|
|
674
590
|
|
|
675
|
-
|
|
676
|
-
console.log(`------------------- between path: ${i} ---------------------`);
|
|
591
|
+
if (checkObjType(requiredObjType, filtersStructure.objType) !== true) {
|
|
677
592
|
|
|
678
|
-
|
|
679
|
-
|
|
593
|
+
let pathLevel = path[indexPath];
|
|
594
|
+
console.log('pathLevel: ', pathLevel);
|
|
680
595
|
|
|
681
|
-
|
|
596
|
+
let initialLogicalElementId = filtersStructure.initialLogicalElementId;
|
|
597
|
+
let initialLogicalElement = filtersStructure.logicalElements[initialLogicalElementId];
|
|
598
|
+
console.log('initialLogicalElement: ', initialLogicalElement);
|
|
682
599
|
|
|
683
|
-
|
|
684
|
-
|
|
600
|
+
let uuid_childLogicalElementId = uuidV4();
|
|
601
|
+
let childLogicalElement = {
|
|
602
|
+
logicalElementType: 'childComplexFilter',
|
|
603
|
+
previousLogicalElementId: null,
|
|
604
|
+
nextLogicalElementId: null,
|
|
685
605
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
606
|
+
childLogicalElementId: initialLogicalElementId,
|
|
607
|
+
objType: pathLevel.pathLinkType.objType,
|
|
608
|
+
pathLinkType: {
|
|
609
|
+
objType: pathLevel.objType,
|
|
610
|
+
relType: pathLevel.pathLinkType.relType,
|
|
611
|
+
direction: pathLevel.pathLinkType.direction
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
console.log('childLogicalElement: ', childLogicalElement);
|
|
691
615
|
|
|
692
|
-
|
|
693
|
-
pathLinkType: {
|
|
694
|
-
objType: pathObject.objType,
|
|
695
|
-
relType: pathObject.pathLinkType.relType,
|
|
696
|
-
direction: pathObject.pathLinkType.direction
|
|
697
|
-
}
|
|
698
|
-
};
|
|
699
|
-
console.log('currentLogicalElement', currentLogicalElement);
|
|
616
|
+
filtersStructure.logicalElements[initialLogicalElementId].previousLogicalElementId = uuid_childLogicalElementId;
|
|
700
617
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
previousLogicalElement,
|
|
706
|
-
currentLogicalElementId,
|
|
707
|
-
currentLogicalElement,
|
|
708
|
-
filtersStructure
|
|
709
|
-
);
|
|
710
|
-
console.log('return create child ', {
|
|
711
|
-
previousLogicalElementId,
|
|
712
|
-
previousLogicalElement,
|
|
713
|
-
logicalStructure,
|
|
714
|
-
errorsFound
|
|
715
|
-
});
|
|
716
|
-
|
|
717
|
-
logicalElements = logicalStructure;
|
|
718
|
-
|
|
719
|
-
} else {
|
|
720
|
-
|
|
721
|
-
if (logicalElementsStructure.logicalElementType === 'childComplexFilter') {
|
|
722
|
-
|
|
723
|
-
let childLogicalElementId = logicalElementsStructure.childLogicalElementId;
|
|
724
|
-
console.log('childLogicalElementId', childLogicalElementId);
|
|
725
|
-
|
|
726
|
-
if (childLogicalElementId !== null) {
|
|
727
|
-
console.log('-------- has child filter structure --------');
|
|
728
|
-
|
|
729
|
-
let childLogicalElement = logicalStructureElements[childLogicalElementId];
|
|
730
|
-
console.log('childLogicalElement', childLogicalElement);
|
|
731
|
-
|
|
732
|
-
let pathCheck = false;
|
|
733
|
-
|
|
734
|
-
for (const pathObj of path) {
|
|
735
|
-
if (checkObjType(childLogicalElement.objType, pathObj.objType) === true) {
|
|
736
|
-
pathCheck = true;
|
|
737
|
-
};
|
|
738
|
-
};
|
|
739
|
-
|
|
740
|
-
if (pathCheck) {
|
|
741
|
-
|
|
742
|
-
if (logicalElementsStructure.nextLogicalElementId === null) {
|
|
743
|
-
|
|
744
|
-
//* delete level of objType
|
|
745
|
-
let checkChild = false;
|
|
746
|
-
|
|
747
|
-
if (PATHCONSTANCES != null) {
|
|
748
|
-
|
|
749
|
-
for (const objType of PATHCONSTANCES.objTypes) {
|
|
750
|
-
if (checkObjType(objType, childLogicalElement.objType) === true) {
|
|
751
|
-
if (!childLogicalElement.hasOwnProperty('childLogicalElementId')) {
|
|
752
|
-
|
|
753
|
-
// let childSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
754
|
-
let childSchema = await getObjectSchema.getObjSchemaS3WithHierarchyShared(
|
|
755
|
-
childLogicalElement.objType
|
|
756
|
-
);
|
|
757
|
-
console.log('childSchema: ', childSchema);
|
|
758
|
-
|
|
759
|
-
if (childSchema.hasOwnProperty('extendObjType')) {
|
|
760
|
-
if (checkObjType(requiredObjType, childSchema.extendObjType) === true) {
|
|
761
|
-
checkChild = false;
|
|
762
|
-
break;
|
|
763
|
-
};
|
|
764
|
-
};
|
|
765
|
-
};
|
|
766
|
-
checkChild = true;
|
|
767
|
-
break;
|
|
768
|
-
};
|
|
769
|
-
};
|
|
770
|
-
} else {
|
|
771
|
-
checkChild = true;
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
if (checkChild) {
|
|
775
|
-
|
|
776
|
-
delete filtersStructure.logicalElements[initialLogicalElementId];
|
|
777
|
-
console.log('filtersStructure: ', filtersStructure);
|
|
778
|
-
|
|
779
|
-
filtersStructure.objType = childLogicalElement.objType;
|
|
780
|
-
filtersStructure.initialLogicalElementId = childLogicalElementId;
|
|
781
|
-
filtersStructure.logicalElements[childLogicalElementId].previousLogicalElementId = null;
|
|
782
|
-
console.log('after filtersStructure: ', filtersStructure);
|
|
783
|
-
|
|
784
|
-
logicalElements = filtersStructure.logicalElements;
|
|
785
|
-
|
|
786
|
-
continue;
|
|
787
|
-
|
|
788
|
-
};
|
|
789
|
-
};
|
|
790
|
-
};
|
|
791
|
-
|
|
792
|
-
currentLogicalElementId = uuidV4();
|
|
793
|
-
console.log('currentLogicalElementId: ', currentLogicalElementId)
|
|
794
|
-
|
|
795
|
-
currentLogicalElement = {
|
|
796
|
-
logicalElementType: 'childComplexFilter',
|
|
797
|
-
previousLogicalElementId: null,
|
|
798
|
-
nextLogicalElementId: null,
|
|
799
|
-
childLogicalElementId: filtersStructure.initialLogicalElementId,
|
|
800
|
-
|
|
801
|
-
objType: pathObject.pathLinkType.objType,
|
|
802
|
-
pathLinkType: {
|
|
803
|
-
objType: pathObject.objType,
|
|
804
|
-
relType: pathObject.pathLinkType.relType,
|
|
805
|
-
direction: pathObject.pathLinkType.direction
|
|
806
|
-
}
|
|
807
|
-
};
|
|
808
|
-
console.log('currentLogicalElement', currentLogicalElement);
|
|
809
|
-
|
|
810
|
-
let logicalStructure = {};
|
|
811
|
-
[previousLogicalElementId, previousLogicalElement, logicalStructure, errorsFound] = createChildComplexFilterStructure(
|
|
812
|
-
logicalElements,
|
|
813
|
-
previousLogicalElementId,
|
|
814
|
-
previousLogicalElement,
|
|
815
|
-
currentLogicalElementId,
|
|
816
|
-
currentLogicalElement,
|
|
817
|
-
filtersStructure
|
|
818
|
-
)
|
|
819
|
-
console.log('return create child', {
|
|
820
|
-
previousLogicalElementId,
|
|
821
|
-
previousLogicalElement,
|
|
822
|
-
logicalStructure,
|
|
823
|
-
errorsFound
|
|
824
|
-
});
|
|
825
|
-
|
|
826
|
-
logicalElements = logicalStructure;
|
|
827
|
-
console.log('logicalElements: ', logicalElements);
|
|
828
|
-
|
|
829
|
-
// if (logicalElementsStructure.nextLogicalElementId !== null) {
|
|
830
|
-
// console.log("-------- no child filter structure --------", vvv);
|
|
831
|
-
// }
|
|
832
|
-
|
|
833
|
-
} else {
|
|
834
|
-
console.log('-------- no child filter structure --------', vvv);
|
|
835
|
-
|
|
836
|
-
}
|
|
618
|
+
filtersStructure.objType = pathLevel.pathLinkType.objType;
|
|
619
|
+
filtersStructure.initialLogicalElementId = uuid_childLogicalElementId;
|
|
620
|
+
filtersStructure.logicalElements = Object.assign({ [uuid_childLogicalElementId]: childLogicalElement }, filtersStructure.logicalElements);
|
|
621
|
+
}
|
|
837
622
|
|
|
838
|
-
|
|
623
|
+
if (checkObjType(requiredObjType, filtersStructure.objType) === false) {
|
|
839
624
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
childLogicalElementId: filtersStructure.initialLogicalElementId,
|
|
848
|
-
|
|
849
|
-
objType: pathObject.pathLinkType.objType,
|
|
850
|
-
pathLinkType: {
|
|
851
|
-
objType: pathObject.objType,
|
|
852
|
-
relType: pathObject.pathLinkType.relType,
|
|
853
|
-
direction: pathObject.pathLinkType.direction
|
|
854
|
-
}
|
|
855
|
-
};
|
|
856
|
-
console.log('currentLogicalElement', currentLogicalElement);
|
|
857
|
-
|
|
858
|
-
let logicalStructure = {};
|
|
859
|
-
// change function name ==> set logicalElementId
|
|
860
|
-
[previousLogicalElementId, previousLogicalElement, logicalStructure, errorsFound] = createChildComplexFilterStructure(
|
|
861
|
-
logicalElements,
|
|
862
|
-
previousLogicalElementId,
|
|
863
|
-
previousLogicalElement,
|
|
864
|
-
currentLogicalElementId,
|
|
865
|
-
currentLogicalElement,
|
|
866
|
-
filtersStructure
|
|
867
|
-
)
|
|
868
|
-
console.log('return create child', {
|
|
869
|
-
previousLogicalElementId,
|
|
870
|
-
previousLogicalElement,
|
|
871
|
-
logicalStructure,
|
|
872
|
-
errorsFound
|
|
873
|
-
});
|
|
874
|
-
logicalElements = logicalStructure;
|
|
875
|
-
};
|
|
876
|
-
};
|
|
877
|
-
};
|
|
878
|
-
};
|
|
879
|
-
} else {
|
|
880
|
-
console.log('------------ path euals 1 -----------');
|
|
881
|
-
console.log('pathObject', path[0]);
|
|
625
|
+
filtersStructure = await changeObjTypePath(
|
|
626
|
+
requiredObjType,
|
|
627
|
+
filtersStructure,
|
|
628
|
+
path,
|
|
629
|
+
indexPath + 1
|
|
630
|
+
);
|
|
631
|
+
console.log('filtersStructure: ', filtersStructure);
|
|
882
632
|
|
|
883
|
-
|
|
884
|
-
filterLogicalStructure = filtersStructure;
|
|
885
|
-
} else {
|
|
886
|
-
errorsObject = {
|
|
887
|
-
[requiredObjType.objectType]: `is not equals objType in filter structure: objType: ${filtersStructure.objType.objectType}`
|
|
888
|
-
};
|
|
889
|
-
errorsFound.push(`${requiredObjType.objectType} is not equals objType in filter structure: objType: ${filtersStructure.objType.objectType}`);
|
|
890
|
-
return [filterLogicalStructure, errorsObject, errorsFound];
|
|
891
|
-
};
|
|
892
|
-
};
|
|
893
|
-
};
|
|
633
|
+
}
|
|
894
634
|
|
|
895
|
-
|
|
896
|
-
path,
|
|
897
|
-
filterLogicalStructure,
|
|
898
|
-
errorsObject,
|
|
899
|
-
errorsFound
|
|
900
|
-
});
|
|
901
|
-
return [filterLogicalStructure, errorsObject, errorsFound];
|
|
635
|
+
return [filtersStructure, errorsObject, errorsFound];
|
|
902
636
|
|
|
903
637
|
} catch (err) {
|
|
904
638
|
console.log('error ValidateSearchTypeFilterType: ', err)
|
|
@@ -906,56 +640,6 @@ async function changeObjTypePath(
|
|
|
906
640
|
};
|
|
907
641
|
|
|
908
642
|
};
|
|
909
|
-
//###################################################################################################################################################################################
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
function createChildComplexFilterStructure(
|
|
915
|
-
logicalElements,
|
|
916
|
-
previousLogicalElementId,
|
|
917
|
-
previousLogicalElement,
|
|
918
|
-
currentLogicalElementId,
|
|
919
|
-
currentLogicalElement,
|
|
920
|
-
filtersStructure
|
|
921
|
-
) {
|
|
922
|
-
console.log('createChildComplexFilterStructure: ', {
|
|
923
|
-
logicalElements,
|
|
924
|
-
previousLogicalElementId,
|
|
925
|
-
previousLogicalElement,
|
|
926
|
-
currentLogicalElementId,
|
|
927
|
-
currentLogicalElement,
|
|
928
|
-
filtersStructure
|
|
929
|
-
});
|
|
930
|
-
|
|
931
|
-
let errorsFound = [];
|
|
932
|
-
|
|
933
|
-
if (!currentLogicalElement) {
|
|
934
|
-
errorsFound.push('no current logical element to process');
|
|
935
|
-
return [previousLogicalElementId, previousLogicalElement, logicalElements, errorsFound];
|
|
936
|
-
};
|
|
937
|
-
|
|
938
|
-
if (!previousLogicalElement) {
|
|
939
|
-
filtersStructure.logicalElements[filtersStructure.initialLogicalElementId].previousLogicalElementId = currentLogicalElementId;
|
|
940
|
-
logicalElements = Object.assign({ [currentLogicalElementId]: currentLogicalElement }, logicalElements, filtersStructure.logicalElements);
|
|
941
|
-
} else {
|
|
942
|
-
|
|
943
|
-
currentLogicalElement.childLogicalElementId = previousLogicalElementId;
|
|
944
|
-
console.log('currentLogicalElement', currentLogicalElement);
|
|
945
|
-
|
|
946
|
-
logicalElements[previousLogicalElementId].previousLogicalElementId = currentLogicalElementId;
|
|
947
|
-
console.log('logicalElements', logicalElements);
|
|
948
|
-
|
|
949
|
-
logicalElements = Object.assign({ [currentLogicalElementId]: currentLogicalElement }, logicalElements);
|
|
950
|
-
console.log('after logicalElements', logicalElements);
|
|
951
|
-
|
|
952
|
-
};
|
|
953
|
-
|
|
954
|
-
previousLogicalElementId = currentLogicalElementId;
|
|
955
|
-
previousLogicalElement = currentLogicalElement;
|
|
956
|
-
|
|
957
|
-
return [previousLogicalElementId, previousLogicalElement, logicalElements, errorsFound];
|
|
958
|
-
};
|
|
959
643
|
|
|
960
644
|
async function findObjTypePathToAnotherObjType(
|
|
961
645
|
fromObjType,
|
|
@@ -1157,10 +841,9 @@ export default {
|
|
|
1157
841
|
initSchemaFn,
|
|
1158
842
|
|
|
1159
843
|
combineLogicalStructure,
|
|
1160
|
-
// combineOperation,
|
|
1161
|
-
// combineLogicalElements,
|
|
1162
844
|
|
|
1163
845
|
checkAndCreateBracket,
|
|
846
|
+
createLogicalElementBracket,
|
|
1164
847
|
|
|
1165
848
|
changeObjTypePath,
|
|
1166
849
|
findObjTypePathToAnotherObjType
|