@Override public Diagram<Graph, Metadata> doBuild(final String name, final Metadata metadata, final Graph<DefinitionSet, ?> graph) { final AbstractDiagram<Graph, Metadata> result = new DiagramImpl(name, metadata); result.setGraph(graph); return result; } }
@Override public boolean equals(Object o) { if (o instanceof DiagramImpl) { DiagramImpl other = (DiagramImpl) o; return ((null != getGraph()) ? getGraph().equals(other.getGraph()) : null == other.getGraph()) && ((null != getMetadata()) ? getMetadata().equals(other.getMetadata()) : null == other.getMetadata()) && ((null != getName()) ? getName().equals(other.getName()) : null == other.getName()); } else { return false; } } }
@Override public <M extends Metadata, D extends Diagram> D newDiagram(String uuid, String defSetId, M metadata) { final Graph graph = (Graph) this.newElement(uuid, defSetId); final DiagramImpl result = new DiagramImpl(uuid, new MetadataImpl.MetadataImplBuilder(defSetId).build()); result.setGraph(graph); return (D) result; }
@Test public void testDiagramHashCode() { DiagramImpl a = new DiagramImpl("Diagram", new MetadataImpl()); DiagramImpl b = new DiagramImpl("AnotherDiagram", new MetadataImpl()); assertNotEquals(a.hashCode(), b.hashCode()); b = new DiagramImpl("Diagram", new MetadataImpl()); assertEquals(a.hashCode(), b.hashCode()); a.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl())); b.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl())); assertEquals(a.hashCode(), b.hashCode()); a.getGraph().addNode(new NodeImpl("Node1")); b.getGraph().addNode(new NodeImpl("Node2")); assertNotEquals(a.hashCode(), b.hashCode()); b.getGraph().removeNode("Node2"); b.getGraph().addNode(new NodeImpl("Node1")); assertEquals(a.hashCode(), b.hashCode()); assertEquals(a.hashCode(), a.hashCode());
private Diagram<Graph, Metadata> unmarshall(InputStream is) throws Exception { Metadata metadata = new MetadataImpl.MetadataImplBuilder(BindableAdapterUtils.getDefinitionSetId(BPMNDefinitionSet.class)).build(); DiagramImpl result = new DiagramImpl(org.kie.workbench.common.stunner.core.util.UUID.uuid(), metadata); Graph graph = tested.unmarshall(metadata, is); result.setGraph(graph); // Update diagram's metadata attributes. tested.updateRootUUID(result.getMetadata(), graph); tested.updateTitle(result.getMetadata(), graph); return result; }
@Test public void testDiagramEquals() { DiagramImpl a = new DiagramImpl("Diagram", new MetadataImpl()); DiagramImpl b = new DiagramImpl("AnotherDiagram", new MetadataImpl()); assertNotEquals(a, b); b = new DiagramImpl("Diagram", new MetadataImpl()); assertEquals(a, b); a.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl())); assertNotEquals(a, b); b.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl())); assertEquals(a, b); a.getGraph().addNode(new NodeImpl("Node1")); b.getGraph().addNode(new NodeImpl("Node2")); assertNotEquals(a, b); b.getGraph().removeNode("Node2"); b.getGraph().addNode(new NodeImpl("Node1")); assertEquals(a, b);
@Override public <M extends Metadata, D extends Diagram> D newDiagram(String uuid, String defSetId, M metadata) { final Graph graph = (Graph) this.newElement(uuid, defSetId); final DiagramImpl result = new DiagramImpl(uuid, new MetadataImpl.MetadataImplBuilder(defSetId).build()); result.setGraph(graph); return (D) result; }
public static Diagram<Graph, Metadata> unmarshall(DiagramMarshaller tested, InputStream is) throws Exception { Metadata metadata = new MetadataImpl.MetadataImplBuilder( BindableAdapterUtils.getDefinitionSetId(BPMNDefinitionSet.class)).build(); DiagramImpl diagram = new DiagramImpl(UUID.uuid(), metadata); Graph<DefinitionSet, Node> graph = tested.unmarshall(metadata, is); diagram.setGraph(graph); return diagram; } }
@Override public Diagram<Graph, Metadata> doBuild(final String name, final Metadata metadata, final Graph<DefinitionSet, ?> graph) { final AbstractDiagram<Graph, Metadata> result = new DiagramImpl(name, metadata); result.setGraph(graph); return result; }
@Override public int hashCode() { int graphHash = (null != getGraph()) ? getGraph().hashCode() : 0; int metadataHash = (null != getMetadata()) ? getMetadata().hashCode() : 0; int nameHash = (null != getName()) ? getName().hashCode() : 0; return HashUtil.combineHashCodes(graphHash, metadataHash, nameHash); }
final Graph graph = (Graph) applicationFactoryManager.newElement(uuid, defSetId); final DiagramImpl result = new DiagramImpl(uuid, new MetadataImpl.MetadataImplBuilder(defSetId).build()); result.setGraph(graph); return result; }).when(applicationFactoryManager).newDiagram(anyString(),
@Override public Diagram<Graph, Metadata> build(final String name, final Metadata metadata, final Graph<DefinitionSet, ?> graph) { final AbstractDiagram<Graph, Metadata> result = new DiagramImpl(name, metadata); result.setGraph(graph); return result; }
final Graph graph = (Graph) applicationFactoryManager.newElement(uuid, defSetId); final DiagramImpl result = new DiagramImpl(uuid, new MetadataImpl.MetadataImplBuilder(defSetId).build()); result.setGraph(graph); return result; }).when(applicationFactoryManager).newDiagram(anyString(),
final Graph graph = (Graph) applicationFactoryManager.newElement(uuid, defSetId); final DiagramImpl result = new DiagramImpl(uuid, new MetadataImpl.MetadataImplBuilder(defSetId).build()); result.setGraph(graph); return result; }).when(applicationFactoryManager).newDiagram(anyString(),
metaData.setCanvasRootUUID("_0E761372-8B3C-4BE1-88BC-808D647D9EFF"); DiagramImpl diagram = new DiagramImpl("_D518B746-92D2-4BF1-8AD1-1EBA552C5F6F", metaData); diagram.setGraph(graph);
metaData.setCanvasRootUUID("_0E761372-8B3C-4BE1-88BC-808D647D9EFF"); DiagramImpl diagram = new DiagramImpl("_D518B746-92D2-4BF1-8AD1-1EBA552C5F6F", metaData); diagram.setGraph(graph);
metaData.setCanvasRootUUID("_0E761372-8B3C-4BE1-88BC-808D647D9EFF"); DiagramImpl diagram = new DiagramImpl("_D518B746-92D2-4BF1-8AD1-1EBA552C5F6F", metaData); diagram.setGraph(graph);
metaData.setCanvasRootUUID("_0E761372-8B3C-4BE1-88BC-808D647D9EFF"); DiagramImpl diagram = new DiagramImpl("_D518B746-92D2-4BF1-8AD1-1EBA552C5F6F", metaData); diagram.setGraph(graph);
metaData.setCanvasRootUUID("_0E761372-8B3C-4BE1-88BC-808D647D9EFF"); DiagramImpl diagram = new DiagramImpl("_D518B746-92D2-4BF1-8AD1-1EBA552C5F6F", metaData); diagram.setGraph(graph);
metaData.setCanvasRootUUID("_0E761372-8B3C-4BE1-88BC-808D647D9EFF"); DiagramImpl diagram = new DiagramImpl("_D518B746-92D2-4BF1-8AD1-1EBA552C5F6F", metaData); diagram.setGraph(graph);