1 43 package net.jforum.util; 44 45 import java.util.ArrayList ; 46 import java.util.Iterator ; 47 import java.util.List ; 48 49 import net.jforum.dao.DataAccessDriver; 50 import net.jforum.dao.TreeGroupDAO; 51 52 130 public class TreeGroup 131 { 132 135 public TreeGroup() { } 136 137 138 144 public List getNodes() throws Exception 145 { 146 List nodes = new ArrayList (); 147 148 TreeGroupDAO tgm = DataAccessDriver.getInstance().newTreeGroupDAO(); 149 150 List rootGroups = tgm.selectGroups(0); 151 152 for (Iterator iter = rootGroups.iterator(); iter.hasNext();) { 153 GroupNode n = (GroupNode)iter.next(); 154 155 this.checkExtraNodes(n); 156 157 nodes.add(n); 158 } 159 160 return nodes; 161 } 162 163 166 private void checkExtraNodes(GroupNode n) throws Exception 167 { 168 TreeGroupDAO tgm = DataAccessDriver.getInstance().newTreeGroupDAO(); 169 170 List childGroups = tgm.selectGroups(n.getId()); 171 172 for (Iterator iter = childGroups.iterator(); iter.hasNext();) { 173 GroupNode f = (GroupNode)iter.next(); 174 175 this.checkExtraNodes(f); 176 177 n.addNode(f); 178 } 179 } 180 } 181 | Popular Tags |