예제 #1
0
  private String assemblyCurSubDeptTree(List<Department> subDeptList) {
    StringBuffer strBuf = new StringBuffer();
    for (Department department : subDeptList) {
      strBuf.append("{\"text\" : \"" + department.getDeptName() + "\",");
      strBuf.append("\"id\" : \"" + department.getId() + "\",");
      strBuf.append("\"deptType\" : \"" + department.getDeptType() + "\",");
      HashMap<String, Integer> nameMap = new HashMap<String, Integer>();
      nameMap.put("parentId", department.getId());
      List<Department> list = entityDao.getDepartmentList(nameMap);
      if (list != null && list.size() > 0) {
        strBuf.append("\"leaf\" : false ,");
        strBuf.append("\"cls\" :\"fold\"");
      } else {
        strBuf.append("\"cls\" :'file',");
        strBuf.append("\"leaf\" : true");
      }
      strBuf.append("},");
    }

    if (strBuf.length() > 0) {
      strBuf.delete(strBuf.length() - 1, strBuf.length());
    }

    return strBuf.toString();
  }
예제 #2
0
 private String assemblyParentDeptTree(List<Department> subDeptList) {
   StringBuffer strBuf = new StringBuffer();
   for (int i = subDeptList.size() - 1; i >= 0; i--) {
     Department department = subDeptList.get(i);
     if (i > 0) {
       if (i == subDeptList.size() - 1) {
         strBuf.append("{\"text\" : \"" + department.getDeptName() + "\",");
         strBuf.append("\"id\" : \"" + department.getId() + "\",");
         strBuf.append("\"deptType\" : \"" + department.getDeptType() + "\",");
         strBuf.append("\"leaf\" : false ,");
         strBuf.append("\"cls\" :\"fold\",");
         strBuf.append("\"children\" :[");
       } else {
         strBuf.append("{\"text\" : \"" + department.getDeptName() + "\",");
         strBuf.append("\"id\" : \"" + department.getId() + "\",");
         strBuf.append("\"deptType\" : \"" + department.getDeptType() + "\",");
         strBuf.append("\"leaf\" : false ,");
         strBuf.append("\"cls\" :\"fold\",");
         strBuf.append("\"children\" :[");
       }
     } else {
       strBuf.append("{\"text\" : \"" + department.getDeptName() + "\",");
       strBuf.append("\"id\" : \"" + department.getId() + "\",");
       strBuf.append("\"deptType\" : \"" + department.getDeptType() + "\",");
       strBuf.append("\"cls\" :'file',");
       strBuf.append("\"leaf\" : true");
       for (int j = subDeptList.size() - 1; j >= 0; j--) {
         strBuf.append("}");
         strBuf.append("]");
       }
     }
   }
   if (strBuf.length() > 0) {
     strBuf.delete(strBuf.length() - 1, strBuf.length());
   }
   return strBuf.toString();
 }