コード例 #1
0
  @Override
  public void save() {
    List<WrappedVertex> vertices = new ArrayList<WrappedVertex>();
    for (Vertex vertex : getVertices()) {
      if (vertex.isGroup()) {
        vertices.add(new WrappedGroup(vertex));
      } else {
        vertices.add(new WrappedLeafVertex(vertex));
      }
    }
    List<WrappedEdge> edges = new ArrayList<WrappedEdge>();
    for (Edge edge : getEdges()) {
      WrappedEdge newEdge =
          new WrappedEdge(
              edge,
              new WrappedLeafVertex(m_vertexProvider.getVertex(edge.getSource().getVertex())),
              new WrappedLeafVertex(m_vertexProvider.getVertex(edge.getTarget().getVertex())));
      edges.add(newEdge);
    }

    WrappedGraph graph = new WrappedGraph(getEdgeNamespace(), vertices, edges);

    JAXB.marshal(graph, new File(getConfigurationFile()));
  }
コード例 #2
0
  protected String getEdgeTooltipText(DataLinkInterface link, Vertex source, Vertex target) {
    StringBuffer tooltipText = new StringBuffer();

    OnmsSnmpInterface sourceInterface =
        getSnmpInterfaceDao()
            .findByNodeIdAndIfIndex(Integer.parseInt(source.getId()), link.getIfIndex());
    OnmsSnmpInterface targetInterface =
        getSnmpInterfaceDao()
            .findByNodeIdAndIfIndex(Integer.parseInt(target.getId()), link.getParentIfIndex());

    tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
    if (sourceInterface != null
        && targetInterface != null
        && sourceInterface.getNetMask() != null
        && !sourceInterface.getNetMask().isLoopbackAddress()
        && targetInterface.getNetMask() != null
        && !targetInterface.getNetMask().isLoopbackAddress()) {
      tooltipText.append("Type of Link: Layer3/Layer2");
    } else {
      tooltipText.append("Type of Link: Layer2");
    }
    tooltipText.append(HTML_TOOLTIP_TAG_END);

    tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
    tooltipText.append("Name: &lt;endpoint1 " + source.getLabel());
    if (sourceInterface != null) tooltipText.append(":" + sourceInterface.getIfName());
    tooltipText.append(" ---- endpoint2 " + target.getLabel());
    if (targetInterface != null) tooltipText.append(":" + targetInterface.getIfName());
    tooltipText.append("&gt;");
    tooltipText.append(HTML_TOOLTIP_TAG_END);

    LinkStateMachine stateMachine = new LinkStateMachine();
    stateMachine.setParentInterfaces(sourceInterface, targetInterface);
    tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
    tooltipText.append("Link status: " + stateMachine.getLinkStatus());
    tooltipText.append(HTML_TOOLTIP_TAG_END);

    if (targetInterface != null) {
      if (targetInterface.getIfSpeed() != null) {
        tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
        tooltipText.append("Bandwidth: " + getHumanReadableIfSpeed(targetInterface.getIfSpeed()));
        tooltipText.append(HTML_TOOLTIP_TAG_END);
      }
    } else if (sourceInterface != null) {
      if (sourceInterface.getIfSpeed() != null) {
        tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
        tooltipText.append("Bandwidth: " + getHumanReadableIfSpeed(sourceInterface.getIfSpeed()));
        tooltipText.append(HTML_TOOLTIP_TAG_END);
      }
    }

    tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
    tooltipText.append("End Point 1: " + source.getLabel() + ", " + source.getIpAddress());
    tooltipText.append(HTML_TOOLTIP_TAG_END);

    tooltipText.append(HTML_TOOLTIP_TAG_OPEN);
    tooltipText.append("End Point 2: " + target.getLabel() + ", " + target.getIpAddress());
    tooltipText.append(HTML_TOOLTIP_TAG_END);

    return tooltipText.toString();
  }