コード例 #1
0
ファイル: UnitForTree.java プロジェクト: ronesp86/miniSPM
  public static UnitForTree buildStructure(
      List<Accountability> accountabilities, AccountabilityType accountabilityType, Unit root) {
    if (root == null) return null;

    UnitForTree rootNode = new UnitForTree();
    rootNode.setId(root.getId());
    rootNode.setName(root.getName());
    buildChildren(accountabilities, rootNode);

    return rootNode;
  }
コード例 #2
0
ファイル: UnitForTree.java プロジェクト: ronesp86/miniSPM
  private static void buildChildren(List<Accountability> accountabilities, UnitForTree parent) {
    List<Unit> units = new ArrayList<Unit>();
    for (Accountability acc : accountabilities) {
      if (acc.getParent() == null) continue;
      if (StringUtils.equals(acc.getParent().getId(), parent.getId())
          && !StringUtils.equals(acc.getParent().getId(), acc.getChild().getId())) {
        units.add(acc.getChild());
      }
    }

    for (Unit child : units) {
      UnitForTree unitForTree = new UnitForTree();
      unitForTree.setId(child.getId());
      unitForTree.setName(child.getName());
      unitForTree.setPid(parent.getId());
      parent.getChildren().add(unitForTree);
      buildChildren(accountabilities, unitForTree);
    }
  }