Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 495628

Summary: Graph.Builder does not construct nodes in the order the builders are added.
Product: [Tools] GEF Reporter: Alexander Nyßen <nyssen>
Component: GEF GraphAssignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: matthias.wienand
Version: 0.2.0   
Target Milestone: 4.1.0 (Neon.1) RC2   
Hardware: All   
OS: All   
Whiteboard:

Description Alexander Nyßen CLA 2016-06-07 15:48:59 EDT
The Graph.Builder.Context collects Node.Builder in a map: 

protected Map<Object, Node.Builder> nodeBuilders = new HashMap<>();

Thereby, the order in which nodes are added to the builder via node() is not preserved.

We should ensure the nodes are created in the order, in which their respective builders were chained.
Comment 1 Matthias Wienand CLA 2016-08-22 18:20:23 EDT
Each node is associated with a key and stored in a node-map. Some nodes are not created immediately, but instead node-builders are constructed and used to create the nodes when building the graph. These builders are stored in a context, so that all builders (for graphs, edges, and nodes) can be used to add more builders.

I added a list of node-keys to the context, and let the individual builders add the keys of newly added nodes to that list. Therefore, the order in which nodes were added is reflected in the list of node-keys.

When building the graph, at first, the context's node-builders and edge-builders are iterated and used to create nodes and edges. Afterwards, a list of nodes is created by iterating the list of node-keys and fetching the respective node from the node-map per iteration. This list of nodes is then passed to Graph constructor.

The code is published on the master branch, as well as on the R4_0_maintenance branch. Therefore, I resolve this ticket as fixed for 4.1.0 RC2 / 5.0.0 M2.