Dynamic tree structure using multiple entities

Hi!


I would like to make a dynamic tree structure using different entities for different levels. For the first level I use entity A. For the next levels (not always the same amount of levels), I use enitity B, finishing with child level entity C. 

I do not have a attribute that tells me to whick level a record belongs. 

I have looked into Hierarchical tree, because that is what I ultimately want to accomplish, but I don't know how to go about it using multiple entities. 

I am trying to do this in reactive web. 


Thank you,


Liesbeth

Hi Daniel,


I have been looking at gtree and it has many functionalities that I am looking for. However, I need the ParentNodeId when mapping to the Node list. I have the ParentId, but how do I get the ParentNodeId?


Thank you!

Solution

Hi Liesbeth,

Did you also install the demo application and inspect the code?

The top node has an empty ParentNodeId, and for example NodeId 1. Then the node underneath that will have ParentNodeId 1 and NodeId for example 2. So you set the relationship of each node to its parent.

You append all these notes to a NodeList that is used to render the Tree.

So back to your request, given entity A at NodeLevel 1, related Entity B records underneath that level 1 nodes, and to Entity B related Entity C records you need

  •  An aggregate to get all Entity A records 
  • Foreach over the aggregate A list and for each record
    • Add a node to the list
    • An aggregate Entity B Records with filter to select only those matching the current entity A record
    • Foreach over the aggregate  B List
      • Add a node to the list, with ParentNodeId entityA.Id and nodeId, entityB.Id
      • An aggregate Entity C Records with filter to select only those matching the current entity B record
      • Foreach over the aggregate  C List
        • Add a node to the list, with ParentNodeId entityB.Id and nodeId, entityC.Id

Regards,

Daniel

Solution

Hi Daniel,


Thank you for your help so far! 


I feel like I am getting very close. The only thing I am struggling with right now it the NodeId's and ParentNodeId's


This is now how I am building my list, which looks about right when I see the result. When I append the Domains (entity A), I set the NodeId to the DomainId which works perfectly fine. However I cannot do that for entity B and C. I'm also not sure how to set the ParentNodeId there. Any ideas?


Thank you! 


Liesbeth

Hi Liesbeth,

Could you share the .oap or .oml? Although the shared action flow does look nice, it doesn't show the details that you are concerned about, specifically, the List append properties.

Regards,

Daniel

Hi Daniel,


I actually got it to work! 


For the node Id for Domain for instance, I put Dom + Domain identiefier.


For the node Id of doctypetype I used: DTT + Doctypetype identifier 

The parentnode id here is Dom + domain Identifier 


This actually works perfect for me. 


Thank you for your help! 



Liesbeth wrote:

Hi Daniel,

I actually got it to work! 

For the node Id for Domain for instance, I put Dom + Domain identiefier.

For the node Id of doctypetype I used: DTT + Doctypetype identifier 

The parentnode id here is Dom + domain Identifier 

This actually works perfect for me. 

Thank you for your help! 

 Good to read, glad I could help.