My task involves manipulating a complex, deeply nested array of nodes to create a specific query string structure. The desired format for the query string is as follows:
(FULL_NAME="x" AND NOT(AGE="30" OR AGE="40" AND (ADDRESS="y" AND STREET="z" AND NOT(USER="admin" OR USER="super admin"))) AND TITLE="Developer")
Here's an overview of the JSON data I'm working with:
- A list of nodes that will receive user input.
- An operator that handles multiple node connections.
- If a user selects "NOT," the main container containing it will exclude certain nodes, resulting in a modified structure like
.NOT (X="y" AND Y="x")
- The primary vertical operators are used to join children nodes, and if a "NOT" operator is chosen, a parent container transforms into a group with another container inside containing "AND" or "OR" operators.
- Users can select between "NOT," "AND," or "OR" operators but cannot use the same operator when grouping unless it's a "NOT" operator.
Represented in the form of an array:
[
{
"uuid":"b7f0ddf4-0290-4c7e-bb59-771aa46bc850",
"operator":"AND",
"isMain":true,
"nodes":[
{
"values":{
"fieldValue":{
"FieldName":"ORIGINAL_FILE_NAME",
},
"operator":"=",
"primaryOperandValue":"new"
},
"uuid":"779fb920-eb7f-4441-9b5a-886c7a41e271"
}
],
"children":[
{
"uuid":"7467b8c9-212e-41b8-ac02-04296b95c88c",
"operator":"NOT",
"nodes":[],
"children":[
{
"operator":"AND",
"uuid":"eaad7c96-0e8f-466b-a255-1075a8e68647",
"nodes":[
{
"uuid":"f6057d1b-56d7-4ee6-ac5b-332fbd180fd4",
"values":{
"fieldValue":{
"FieldName":"CONTROL_NUMBER",
},
"operator":"BETWEEN",
"primaryOperandValue":"x",
"secondaryOperandValue":"y"
}
}
],
"children":[
{
"uuid":"95fd2b08-cc49-498a-bd9f-c50dc55bc39f",
"operator":"NOT",
"nodes":[],
"children":[
{
"uuid":"7637ecc1-28b4-47d7-a602-cd172fb5e269",
"operator":"OR",
"nodes":[
{
"uuid":"0598a915-5818-4c6e-a3d5-6724f893871a",
"values":{
"fieldValue":{
"FieldName":"CONTROL_NUMBER",
},
"operator":" > ",
"primaryOperandValue":"30",
"secondaryOperandValue":null
}
}
],
"children":[]
}
]
}
]
}
]
},
{
"uuid":"78218b5b-b18b-4418-beed-b3418361785f",
"operator":"OR",
"nodes":[
{
"uuid":"ec956407-4fc6-46df-baa7-d2233711dc20",
"values":{
"fieldValue":{
"FieldName":"EMAIL_ANY_ADDRESS",
},
"operator":"ENDS_WITH",
"primaryOperandValue":"log",
"secondaryOperandValue":null
}
},
{
"values":{
"fieldValue":{
"FieldName":"EMAIL_ANY_ADDRESS",
},
"operator":"BEGINS_WITH",
"primaryOperandValue":"log",
"secondaryOperandValue":null
},
"uuid":"6724e913-6e98-47b6-b6af-972a20f0173d"
}
],
"children":[
]
}
]
}
]
This information is visually represented in the following UI screenshot: https://i.stack.imgur.com/LC3Bw.png
I've explored various methods to extract a string from this array structure, but I'm facing challenges when dealing with deeply nested node groups.
Thank you.