예제 #1
0
  protected void addNodes(
      Integer graphId, Connection con, ContainerLoader cl, Map<String, Object> graphParam)
      throws SQLException {
    String urlbaseTmp = (String) graphParam.get("url_base");

    final ElementDraft.Factory elementDraftFactory = cl.factory();
    final Pattern tagSplitter = Pattern.compile(",");
    final String urlbase = urlbaseTmp == null ? "/" : urlbaseTmp;

    graphDataSource.populateNodesForGraph(
        con,
        graphId,
        (num, name, tag) -> {
          String[] tags = tag != null ? tagSplitter.split(tag) : new String[] {};

          NodeDraft nd = elementDraftFactory.newNodeDraft(num.toString());
          nd.setLabel(name);
          nd.setValue(KEY_URL, urlbase + num);
          nd.setValue(KEY_TAG, tags);

          cl.addNode(nd);

          return true;
        });
  }
예제 #2
0
  protected void addEdges(
      Integer graphId, Connection con, ContainerLoader cl, Map<String, Object> graphParam)
      throws SQLException {
    final ElementDraft.Factory elementDraftFactory = cl.factory();

    graphDataSource.populateEdgesForGraph(
        con,
        graphId,
        (num, source, target, val) -> {
          EdgeDraft ed = elementDraftFactory.newEdgeDraft(num.toString());
          ed.setSource(cl.getNode(source.toString()));
          ed.setTarget(cl.getNode(target.toString()));
          ed.setWeight(val.floatValue());

          cl.addEdge(ed);

          return true;
        });
  }