Пример #1
0
  private TreeNodeDTO generateDTO(TreeNode treeNode) {
    TreeNodeDTO treeNodeDTO = new TreeNodeDTO();
    treeNodeDTO.setId(treeNode.getId());
    treeNodeDTO.setName(treeNode.getNodeName());
    Set<TreeNode> set = treeNode.getSubNodes();
    if (set.size() != 0) {
      ArrayList<TreeNodeDTO> arrayList = new ArrayList<TreeNodeDTO>();
      for (TreeNode child : set) {
        arrayList.add(generateDTO(child));
      }
      Collections.sort(arrayList);
      treeNodeDTO.setChildren(arrayList);
    }

    return treeNodeDTO;
  }
Пример #2
0
 private void listTreeNodesWithoutSub(List<TreeNode> list) throws Exception {
   JSONWriter writer = new JSONWriter();
   List<TreeNodeDTO> dtos = new ArrayList<TreeNodeDTO>();
   for (TreeNode treeNode : list) {
     TreeNodeDTO treeNodeDTO = new TreeNodeDTO();
     treeNodeDTO.setId(treeNode.getId());
     treeNodeDTO.setOrderId(treeNode.getOrderId());
     treeNodeDTO.setName(treeNode.getNodeName());
     treeNodeDTO.setExpanded(false);
     treeNodeDTO.set__viewicon(true);
     dtos.add(treeNodeDTO);
   }
   Collections.sort(dtos);
   String treeString = writer.write(dtos);
   response.getWriter().print(treeString);
   System.out.println(treeString);
 }