public JsonObject treeToJson()

in core/src/main/java/org/apache/sdap/mudrod/weblog/structure/session/SessionTree.java [156:186]


  public JsonObject treeToJson(SessionNode node) {
    Gson gson = new Gson();
    JsonObject json = new JsonObject();

    json.addProperty("seq", node.getSeq());
    if ("datasetlist".equals(node.getKey())) {
      json.addProperty("icon", "./resources/images/searching.png");
      json.addProperty("name", node.getRequest());
    } else if ("dataset".equals(node.getKey())) {
      json.addProperty("icon", "./resources/images/viewing.png");
      json.addProperty("name", node.getDatasetId());
    } else if ("ftp".equals(node.getKey())) {
      json.addProperty("icon", "./resources/images/downloading.png");
      json.addProperty("name", node.getRequest());
    } else if ("root".equals(node.getKey())) {
      json.addProperty("name", "");
      json.addProperty("icon", "./resources/images/users.png");
    }

    if (!node.children.isEmpty()) {
      List<JsonObject> jsonChildren = new ArrayList<>();
      for (int i = 0; i < node.children.size(); i++) {
        JsonObject jsonChild = treeToJson(node.children.get(i));
        jsonChildren.add(jsonChild);
      }
      JsonElement jsonElement = gson.toJsonTree(jsonChildren);
      json.add("children", jsonElement);
    }

    return json;
  }