parent
6dcc93ee83
commit
9935a77bfb
@ -0,0 +1,38 @@
|
||||
package info.bukova.isspst.ui.workgroups;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import info.bukova.isspst.Constants;
|
||||
import info.bukova.isspst.data.JobMapping;
|
||||
import info.bukova.isspst.data.Member;
|
||||
import info.bukova.isspst.data.Workgroup;
|
||||
|
||||
import org.zkoss.zul.DefaultTreeModel;
|
||||
import org.zkoss.zul.TreeModel;
|
||||
import org.zkoss.zul.TreeNode;
|
||||
|
||||
public class WorkgroupTreeFactory {
|
||||
|
||||
public TreeModel<TreeNode<Member>> createTreeModel(Workgroup workgroup) {
|
||||
WorkgroupTreeNode root = new WorkgroupTreeNode(null, generateChildren(workgroup));
|
||||
|
||||
return new DefaultTreeModel<Member>(root);
|
||||
}
|
||||
|
||||
private Collection<WorkgroupTreeNode> generateChildren(Member member) {
|
||||
Collection<WorkgroupTreeNode> children = new LinkedList<WorkgroupTreeNode>();
|
||||
Workgroup workgroup = Workgroup.class.cast(member);
|
||||
|
||||
for (JobMapping jm : workgroup.getMembers()) {
|
||||
if (jm.getRole().getAuthority().equals(Constants.ROLE_USER) && jm.getMember().isHasJob()) {
|
||||
children.add(new WorkgroupTreeNode(jm.getMember()));
|
||||
} else if (jm.getRole().getAuthority().equals(Constants.ROLE_USER)) {
|
||||
children.add(new WorkgroupTreeNode(jm.getMember(), generateChildren(jm.getMember())));
|
||||
}
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package info.bukova.isspst.ui.workgroups;
|
||||
|
||||
import info.bukova.isspst.data.Member;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.zkoss.zul.DefaultTreeNode;
|
||||
|
||||
public class WorkgroupTreeNode extends DefaultTreeNode<Member> {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 465182942358883559L;
|
||||
|
||||
public WorkgroupTreeNode(Member data,
|
||||
Collection<WorkgroupTreeNode> children) {
|
||||
super(data, children);
|
||||
}
|
||||
|
||||
public WorkgroupTreeNode(Member data) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue