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

Bug 509077

Summary: Cannot reuse identfier elements when building a graph using Graph.Builder with identifiable nodes.
Product: [Tools] GEF Reporter: Matthias Wienand <matthias.wienand>
Component: GEF GraphAssignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.0.1   
Target Milestone: 5.0.0 (Oxygen) M4   
Hardware: All   
OS: All   
Whiteboard:

Description Matthias Wienand CLA 2016-12-12 08:30:44 EST
The Graph.Builder API allows the construction of nodes for semantic elements so that the nodes can be referenced via the corresponding semantic elements. This allows the construction of edges between semantic elements, as well as the manipulation of nodes for semantic elements, such as the addition of attributes.

However, it is currently not possible to reuse identifier elements as follows:

Builder b = new Graph.Builder();
Semantic s1 = new Semantic("a");
b.node(s1).attr("test", "value");
b.node(s1).attr("test2", "value2");
Graph graph = b.build();
assertEquals(1, graph.getNodes().size());
assertEquals(0, graph.getEdges().size());
assertEquals("value", graph.getNodes().get(0).getAttributes().get("test"));
assertEquals("value2", graph.getNodes().get(0).getAttributes().get("test2"));

Every call to Graph.Builder#node(Object) inserts a new node into the resulting graph when building. This should be changed so that the same node builder that was previously setup is reused if the same semantic/identifier element is used.
Comment 1 Matthias Wienand CLA 2016-12-12 10:01:29 EST
I fixed the Graph.Builder#node(key:Object):Node.Builder method so that an already existing Node.Builder for the given key can be reused. The code is published on the master branch, therefore, I resolve this ticket as fixed for 5.0.0 M4.