use of org.opennms.features.topology.api.topo.DefaultVertexRef in project opennms by OpenNMS.
the class VertexHopGraphProviderTest method testCollapseEdges.
@Test
public void testCollapseEdges() {
CollapsibleCriteria collapseMe = new CollapsibleCriteria() {
@Override
public void setCollapsed(boolean collapsed) {
}
@Override
public boolean isCollapsed() {
return true;
}
@Override
public Set<VertexRef> getVertices() {
Set<VertexRef> retval = new HashSet<VertexRef>();
retval.add(new DefaultVertexRef("nodes", "g2"));
return retval;
}
@Override
public String getNamespace() {
return "nodes";
}
@Override
public String getLabel() {
return "Test Criteria";
}
@Override
public String getId() {
return "Test Criteria";
}
@Override
public Vertex getCollapsedRepresentation() {
return new AbstractVertex("category", "c");
}
};
Set<Edge> edges = VertexHopGraphProvider.collapseEdges(new HashSet<Edge>(m_provider.getEdges()), new CollapsibleCriteria[] { collapseMe });
for (Edge edge : edges) {
assertEquals("nodes", edge.getNamespace());
/*
Here's the original list of edges
.edge("e1", "g0", "g1").eLabel("edge1").eStyleName("edge")
.edge("e2", "g0", "g2").eLabel("edge2").eStyleName("edge")
.edge("e3", "g1", "v1").eLabel("edge3").eStyleName("edge")
.edge("e4", "g1", "v2").eLabel("edge4").eStyleName("edge")
.edge("e5", "g2", "v3").eLabel("edge5").eStyleName("edge")
.edge("e6", "g2", "v4").eLabel("edge6").eStyleName("edge")
*/
if (edge.getId().equals("e1")) {
assertEquals("nodes", edge.getSource().getVertex().getNamespace());
assertEquals("g0", edge.getSource().getVertex().getId());
assertEquals("nodes", edge.getTarget().getVertex().getNamespace());
assertEquals("g1", edge.getTarget().getVertex().getId());
} else if (edge.getId().equals("collapsedTarget-e2")) {
assertEquals("nodes", edge.getSource().getVertex().getNamespace());
assertEquals("g0", edge.getSource().getVertex().getId());
assertEquals("category", edge.getTarget().getVertex().getNamespace());
assertEquals("c", edge.getTarget().getVertex().getId());
} else if (edge.getId().equals("e3")) {
assertEquals("nodes", edge.getSource().getVertex().getNamespace());
assertEquals("g1", edge.getSource().getVertex().getId());
assertEquals("nodes", edge.getTarget().getVertex().getNamespace());
assertEquals("v1", edge.getTarget().getVertex().getId());
} else if (edge.getId().equals("e4")) {
assertEquals("nodes", edge.getSource().getVertex().getNamespace());
assertEquals("g1", edge.getSource().getVertex().getId());
assertEquals("nodes", edge.getTarget().getVertex().getNamespace());
assertEquals("v2", edge.getTarget().getVertex().getId());
} else if (edge.getId().equals("collapsedSource-e5")) {
assertEquals("category", edge.getSource().getVertex().getNamespace());
assertEquals("c", edge.getSource().getVertex().getId());
assertEquals("nodes", edge.getTarget().getVertex().getNamespace());
assertEquals("v3", edge.getTarget().getVertex().getId());
} else if (edge.getId().equals("collapsedSource-e6")) {
assertEquals("category", edge.getSource().getVertex().getNamespace());
assertEquals("c", edge.getSource().getVertex().getId());
assertEquals("nodes", edge.getTarget().getVertex().getNamespace());
assertEquals("v4", edge.getTarget().getVertex().getId());
} else {
fail("Unexpected edge found: " + edge.toString());
}
}
}
use of org.opennms.features.topology.api.topo.DefaultVertexRef in project opennms by OpenNMS.
the class NodeSelectionLinkGenerator method generateCell.
@Override
public Object generateCell(final Table source, final Object itemId, Object columnId) {
final Property<Integer> nodeIdProperty = source.getContainerProperty(itemId, m_nodeIdProperty);
Object cellValue = m_generator.generateCell(source, itemId, columnId);
if (cellValue == null) {
return null;
} else {
if (nodeIdProperty.getValue() == null) {
return cellValue;
} else {
Button button = new Button(cellValue.toString());
button.setStyleName(BaseTheme.BUTTON_LINK);
button.setDescription(nodeIdProperty.getValue().toString());
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Integer nodeId = nodeIdProperty.getValue();
String nodeLabel = (String) source.getContainerProperty(itemId, m_nodeLabelProperty).getValue();
VertexRef vertexRef = new DefaultVertexRef("nodes", String.valueOf(nodeId), nodeLabel);
fireVertexUpdatedEvent(vertexRef);
}
});
return button;
}
}
}
Aggregations