📄 treemoduledb.java
字号:
package cn.com.iaspec.workflow.manage.managetree;
/**
* <p>Title:机构部门信息集合 </p>
*
* <p>Description: 深圳市劳动仲裁信息管理系统</p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: 永泰软件工程有限公司</p>
*
* @author syj
* @version 1.0
*/
import java.util.*;
import cn.com.iaspec.workflow.manage.*;
import cn.com.iaspec.workflow.manage.business.*;
import cn.com.iaspec.workflow.vo.workflow.*;
public class TreeModuleDB{
private ArrayList list=null;
private int gRecordCount=-1;
public TreeModuleDB(ArrayList list){
this.list=list;
}
public void deleteList(){
this.list=null;
}
public TreeModuleDB(){
}
/**
* 按照ID取得下一层的信息
* @param gID int
* @return TreeExample[]
*/
public TreeModule[] getByKeyField(String gID){
TreeModule[] arrTree=null;
ArrayList treeList=null;
if(list!=null&&list.size()>0){
if(gID!=null&&gID.equals("-1")){
treeList=getFirstLevelInfo();
if(treeList!=null){
arrTree=new TreeModule[treeList.size()];
arrTree=(TreeModule[])treeList.toArray(arrTree);
}
return arrTree;
}
treeList=getActorInfo(gID);
arrTree=new TreeModule[treeList.size()];
arrTree=(TreeModule[])treeList.toArray(arrTree);
}
return arrTree;
}
/**
* 取得树的第一层节点信息
*/
private ArrayList getFirstLevelInfo(){
ArrayList array=new ArrayList();
if(!(list.size()==0)){
Iterator it=list.iterator();
while(it.hasNext()){
TreeModule tree=(TreeModule)it.next();
if(!checkExistParentNode(tree)){
array.add(tree);
}
}
}
return array;
}
/**
* 检查由id指定的节点的父节点是否在list中存在
* @return boolean
*/
private boolean checkExistParentNode(TreeModule tree){
boolean bResult=false;
if(!(list.size()==0)&&tree!=null){
Iterator it=list.iterator();
while(it.hasNext()){
TreeModule tree1=(TreeModule)it.next();
if(tree1.getID().equals(tree.getFatherID())){
bResult=true;
break;
}
}
}
return bResult;
}
/**
* 按照ID取得下一层的信息
* @param gID int
* @return ArrayList
*/
public ArrayList getActorInfo(String gID){
ArrayList array=new ArrayList();
if(!(list.size()==0)){
Iterator it=list.iterator();
while(it.hasNext()){
TreeModule treeExceple=(TreeModule)it.next();
if(treeExceple.getFatherID().equals(gID)){
array.add(treeExceple);
}
}
}
Collections.sort(array);
System.out.println("------------");
printElements(array);
return array;
}
/**
* 按照ID取得下一层的信息(角色 和功能菜单维护专用函数)
* @param gID String
* @param m_role_id String
* @return TreeModule[]
*/
public TreeModule[] getByKeyField(String gID,String m_role_id){
TreeModule[] lTreeExampleArr=null;
if(!(list.size()==0)){
ArrayList alist=getActorInfo(gID,m_role_id);
lTreeExampleArr=new TreeModule[alist.size()];
lTreeExampleArr=(TreeModule[])alist.toArray(lTreeExampleArr);
}
return lTreeExampleArr;
}
/**
* 按照ID取得下一层的信息(角色 和功能菜单维护专用函数)
* @param gID String
* @param m_role_id String
* @return ArrayList
*/
public ArrayList getActorInfo(String gID,String m_role_id){
ArrayList array=new ArrayList();
if(!(list.size()==0)){
Iterator it=list.iterator();
while(it.hasNext()){
TreeModule treeExceple=(TreeModule)it.next();
if(treeExceple.getFatherID().equals(gID)&
treeExceple.getM_role_id().equals(m_role_id)){
array.add(treeExceple);
}
}
}
Collections.sort(array);
System.out.println("------------");
printElements(array);
return array;
}
/**
* 取得数据集list
* @param userID String
* @return ArrayList
*/
public ArrayList getArrsyList(String userID){
return list;
}
/**
* 设置参与者的集合list
* @param alist ArrayList
*/
public void setArrayList(ArrayList alist){
this.list=alist;
}
/**
* 判断是否还有子节点
* @param ID String
* @return boolean
*/
public boolean existChildren(String ID){
boolean lExist=false;
ArrayList al=getActorInfo(ID);
if(!(al.size()==0)){
lExist=true;
}
return lExist;
}
/**
* 判断是否还有子节点(角色 和功能菜单维护专用函数)
* @param ID String
* @param role_id String
* @return boolean
*/
public boolean existChildren(String ID,String role_id){
boolean lExist=false;
ArrayList al=getActorInfo(ID,role_id);
if(!(al.size()==0)){
lExist=true;
}
return lExist;
}
/**
* 打印集合
* @param c Collection
*/
public static void printElements(Collection c){
Iterator it=c.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
}
/**
* 查询ID=gID的TreeExample对象是否存在
* @param gID int
* @return TreeExample
*/
public TreeModule queryTreeExample(String gID,String gFatherID){
TreeModule treeExample=new TreeModule();
Iterator it=list.iterator();
while(it.hasNext()){
TreeModule tree=(TreeModule)it.next();
if(tree.getID().equals(gID)&tree.getFatherID().equals(gFatherID)){
treeExample=tree;
}
}
return treeExample;
}
public static void main(String[] args)
throws RoleManageException,MenuManageException,PurviewManageException{
RoleManageControl ManageControl=new RoleManageControl();
// ArrayList li=ManageControl.getCollectionInfo("02");
UserInfo in=new UserInfo();
ArrayList li=new PurviewManageControl().queryOrganization(in,"0202","0");
//ArrayList li=new MenuManageControl().getMenuInfo("0");
// ArrayList li=new MenuManageControl().getRole_func_info();
// ArrayList li= new RoleActivityManageControl().getRoleActivityInfo();
// ArrayList li=new RoleProcessManageControl().getProcdefInfo();
printElements(li);
TreeModuleDB ModuleDB=new TreeModuleDB(li);
// printElements(li);
//System.out.println(ModuleDB.existChildren("2","20003"));
// ModuleDB.getActorInfo("2","20003");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -