package com.vci.ubcs.starter.web.pagemodel; import org.springblade.core.tool.utils.StringUtil; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; public class Tree implements Serializable { private static final long serialVersionUID = 6886695271635257882L; private String oid; private String text; private boolean leaf = false; private boolean showCheckbox = false; private boolean checked = false; private List children = new ArrayList(); private String icon; private String iconCls; private String parentId; private String parentName; private String parentBtmName; private boolean expanded = false; private String href; private String index; private Map attributes = new HashMap(); public Tree() { } public Tree(String oid, String text) { this.setOid(oid); this.setText(text); } public String getOid() { return this.oid; } public void setOid(String oid) { this.oid = oid; } public String getText() { return this.text; } public void setText(String text) { this.text = text; } public boolean isLeaf() { return this.leaf; } public void setLeaf(boolean leaf) { this.leaf = leaf; } public boolean isShowCheckbox() { return this.showCheckbox; } public void setShowCheckbox(boolean showCheckbox) { this.showCheckbox = showCheckbox; } public boolean isChecked() { return this.checked; } public void setChecked(boolean checked) { this.checked = checked; } public List getChildren() { return this.children; } public void setChildren(List children) { this.children = children; } public String getIcon() { return this.icon; } public void setIcon(String icon) { this.icon = icon; } public String getIconCls() { return this.iconCls; } public void setIconCls(String iconCls) { this.iconCls = iconCls; } public String getParentId() { return this.parentId; } public void setParentId(String parentId) { this.parentId = parentId; } public boolean isExpanded() { return this.expanded; } public void setExpanded(boolean expanded) { this.expanded = expanded; } public String getHref() { return this.href; } public void setHref(String href) { this.href = href; } public String getIndex() { return this.index; } public void setIndex(String index) { this.index = index; } public Map getAttributes() { return this.attributes; } public void setAttributes(Map attributes) { this.attributes = attributes; } public String getParentName() { return this.parentName; } public void setParentName(String parentName) { this.parentName = parentName; } public String getParentBtmName() { return this.parentBtmName; } public void setParentBtmName(String parentBtmName) { this.parentBtmName = parentBtmName; } public static List getChildList(List rootTree, List children) { if (rootTree == null || rootTree.size() == 0) { if (children == null || children.size() <= 0) { return null; } rootTree = children.subList(0, children.size()); } Tree bt = new Tree(); bt.findChild(rootTree, children); return rootTree; } public void findChild(List treenode, List children) { Tree node; for(Iterator var3 = treenode.iterator(); var3.hasNext(); this.getChildren().add(node)) { node = (Tree)var3.next(); Iterator var5 = children.iterator(); while(var5.hasNext()) { Tree childnode = (Tree)var5.next(); if (node.getOid().equalsIgnoreCase(childnode.getParentId())) { childnode.setParentName(node.getText()); if (StringUtil.isBlank(childnode.getParentBtmName())) { childnode.setParentBtmName((String)node.getAttributes().getOrDefault("btmname", "")); } node.getChildren().add(childnode); } } if (node.getChildren().size() > 0) { this.findChild(node.getChildren(), children); node.setLeaf(false); } else { node.setLeaf(true); } } } public String toString() { return "Tree{oid='" + this.oid + '\'' + ", text='" + this.text + '\'' + ", leaf=" + this.leaf + ", showCheckbox=" + this.showCheckbox + ", checked=" + this.checked + ", children=" + this.children + ", icon='" + this.icon + '\'' + ", iconCls='" + this.iconCls + '\'' + ", parentId='" + this.parentId + '\'' + ", parentName='" + this.parentName + '\'' + ", parentBtmName='" + this.parentBtmName + '\'' + ", expanded=" + this.expanded + ", href='" + this.href + '\'' + ", index='" + this.index + '\'' + ", attributes=" + this.attributes + '}'; } }