This is needed to save details with recursive.
Here I want to get data from a database and set a recursive method to my bean. So I can figure out the angularUi tree formate. How to write a recursive method to install in my beans.
My strict DB: -

I separate parents and children from rowId. You can access my sample.
For example: - Rowid - 1 for the parent child for this 1 is 1.1 and the child for 1.1 is 1.1.1, as this will extend.
I keep all the parents and the child in one table, which is above the image.
for each object (row) will be items[]. If there is any child element for the parent, then the child will be added to this array items[], if this child has any child, then the child will be added to the parent element of this row items[]... for example, it will be extended.
For example: - JSON object: -
{
"id": 1,
"rowId": "1",
"items": [
{
"id": 10,
"rowId": "1.1",
"items": [
{
"id": 100,
"rowId": "1.1.1",
"items": [
{
"id": 1000,
"rowId": "1.1.1.1",
"items": []
}
]
}
]
},
{
"id": 11,
"rowId": "1.2",
"items": []
}
]
}
I saved this data using this answer.
But when recovering, I ran into problems. The problem is that when retrieving, there will be no parent and child elements, since the data will be stored in one table. The relationship is just rowid. To do this, I need to write a recursive method, such as save, and add children to the parent array items[].
public class AdminComponentBean{
List<MultiAdminComponent> componentListbean;
}
MultiAdminComponent.java: -
public class MultiAdminComponent {
private String componentName;
private String componentIdentification;
private String componentType;
private String componentState;
private String componentUrl;
private String rowId;
private List<MultiAdminComponent> items;
}
parent.But
List<MultiAdminComponent> componentList=BaseDAO.getAdminComponentDAOObject().getComponentDetails();
if(null != componentList) {
for(MultiAdminComponent itemsList : componentList){
if(itemsList.getRowId().length().equals() "1"){
}
}
}