Esempio n. 1
0
 @Transactional(readOnly = true)
 public List<Department> findRoots() {
   List<Department> roots = Lists.newArrayList();
   Iterable<Department> items = departmentDao.findAllCached();
   for (Department item : items) {
     if (item.getParent() == null) {
       roots.add(item);
     }
   }
   Collections.sort(roots);
   return roots;
 }
Esempio n. 2
0
 @Transactional(readOnly = true)
 public List<Department> findChildren(Department parent) {
   if (parent == null) {
     return findRoots();
   }
   List<Department> children = Lists.newArrayList();
   Iterable<Department> items = departmentDao.findAllCached();
   for (Department item : items) {
     if (parent.equals(item.getParent())) {
       children.add(item);
     }
   }
   Collections.sort(children);
   return children;
 }
Esempio n. 3
0
 @Transactional(readOnly = true)
 public List<Department> findChildrenCascade(Department parent) {
   Assert.notNull(parent);
   List<Department> children = Lists.newArrayList();
   Iterable<Department> items = departmentDao.findAllCached();
   for (Department item : items) {
     Department loop = item.getParent();
     while (loop != null) {
       if (parent.equals(loop)) {
         children.add(item);
         break;
       }
       loop = loop.getParent();
     }
   }
   Collections.sort(children);
   return children;
 }