String text = StorageService.ctx.getMessage(StringUtils.replaceChars(RStext, ' ', '_'), null,RStext, locale);
// if("1st Quarter".equals(rs.getString(2))){
// text = StorageService.ctx.getMessage("1stQuarter", null, "1stQuarter", locale);
// }
String parent_id = rs.getString(3);
return new DimensionTreeNode(id, text, parent_id);
}
});
Hashtable<String,DimensionTreeNode> dimHash = new Hashtable<String,DimensionTreeNode>();
List<DimensionTreeNode> roots = new ArrayList<DimensionTreeNode>();
for(DimensionTreeNode dim:dimRecords){//维护dimhash是为了便于高效的找到节点的父节点
dimHash.put(dim.getId(), dim);
}
for(DimensionTreeNode dim:dimRecords){//遍历所有节点,建立维度成员的树形结构
String parent = dim.getParent_id();
if(StringUtils.isBlank(parent)){
roots.add(dim);
}else{
DimensionTreeNode parentNode = dimHash.get(parent);
if(parentNode!=null){
parentNode.getChildren().add(dim);
}
}
}
for(DimensionTreeNode root:roots){
root.sortRecursive();