⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webuser.java

📁 OBPM是一个开源
💻 JAVA
字号:
package cn.myapps.core.user.action;

import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;

import cn.myapps.base.dao.PersistenceUtils;
import cn.myapps.core.department.ejb.DepartmentProcess;
import cn.myapps.core.department.ejb.DepartmentVO;
import cn.myapps.core.role.ejb.RoleVO;
import cn.myapps.core.user.ejb.UserVO;
import cn.myapps.util.ProcessFactory;

public class WebUser extends UserVO {
	private static final long serialVersionUID = -1479514876856665353L;

	private Date loginTime;

	private String managerdeptid;

	public static final int DATA_AUTHORITY_POLICY_DEPARTMENT_UP = 1;

	public static final int DATA_AUTHORITY_POLICY_DEPARTMENT_DOWN = 2;

	public static final int DATA_AUTHORITY_POLICY_DEPARTMENT_SELF = 3;

	public static final int DATA_AUTHORITY_POLICY_GROUP_SELF = 4;

	public static final int DATA_AUTHORITY_POLICY_USER_SELF = 5;

	private HashMap policy = new HashMap();

	private String lowerDepartmentList;

	private String superiorDepartmentList;

	private String rolelist;

	private String deptlist;
	
	private String lowerdepcodelist;

	// public Collection submenus; //生成左侧树型菜单

	// public Collection topmenus;//生成顶端菜单
	// public Collection getSubmenus() {
	// return submenus;
	// }

	// public void setSubmenus(UserVO vo) throws Exception{
	// PermissionHelper helper = PermissionHelper.getInstance();
	// helper.setUser(vo);
	// this.submenus = helper.get_submenus();
	// }

	// public Collection getTopmenus() {
	// return topmenus;
	// }

	// public void setTopmenus(UserVO vo)throws Exception {
	// PermissionHelper helper = PermissionHelper.getInstance();
	// helper.setUser(vo);
	// this.topmenus = helper.get_topmenus();
	// }

	public String getSuperiorDepartmentList() {
		return superiorDepartmentList;
	}

	public void setSuperiorDepartmentList(String superiorDepartmentList)
			throws Exception {
		StringBuffer list = new StringBuffer();
		Collection deplist = new HashSet();
		Collection col = getDepartments();
		if (col != null) {
			Iterator it = col.iterator();

			DepartmentProcess dp = (DepartmentProcess) ProcessFactory
					.createProcess(DepartmentProcess.class);
			while (it.hasNext()) {
				DepartmentVO dep = (DepartmentVO) it.next();
				if (dep != null) {
					deplist.add(dep);
					deplist.addAll(dp.getSuperiorDeptList(dep.getId()));
				}
			}
			it = deplist.iterator();
			while (it.hasNext()) {
				DepartmentVO dep = (DepartmentVO) it.next();
				if (dep != null)
					list.append("'" + dep.getId() + "',");
			}
			if (list.length() > 0)
				list.deleteCharAt(list.length() - 1);
			this.superiorDepartmentList = list.toString();
		}
	}

	public WebUser(UserVO vo) throws Exception {
		this.setId(vo.getId());
		this.setName(vo.getName());
		this.setLoginno(vo.getLoginno());
		this.setLoginpwd(vo.getLoginpwd());
		this.setEmail(vo.getEmail());
		this.loginTime = new Date();
		this.setStatus(vo.getStatus());
		this.setDepartments(vo.getDepartments());
		this.setRoles(vo.getRoles());
		this.setStatus(vo.getStatus());
		this.setLanguageType(vo.getLanguageType());
		this.setPermission(vo.getPermission());
		this.setLowerDepartmentList();
		this.setDeptlist(vo.getDepartments());
		this.setRolelist(vo.getRoles());
		this.setApplicationid(vo.getApplicationid());
	}

	public String getLowerDepartmentList() {
		return lowerDepartmentList;
	}

	private void setLowerDepartmentList() throws Exception {
		StringBuffer list = new StringBuffer();
		StringBuffer codes= new StringBuffer();
		Collection deplist = new HashSet();
		Collection col = getDepartments();
		if (col != null) { 
			Iterator it = col.iterator();

			DepartmentProcess dp = (DepartmentProcess) ProcessFactory
					.createProcess(DepartmentProcess.class);
			while (it.hasNext()) {
				DepartmentVO dep = (DepartmentVO) it.next();
				if (dep != null) {
				//	deplist.add(dep);
					deplist.addAll(dp.getUnderDeptList(dep.getId()));
				}
			}
			it = deplist.iterator();
			while (it.hasNext()) {
				DepartmentVO dep = (DepartmentVO) it.next();
				if (dep != null)
				{	list.append("'" + dep.getId() + "',");
				   if(dep.getCode()!=null&&dep.getCode().trim().length()>0)
				    codes.append("'" + dep.getCode() + "',"); 
				}
			}
			if (list.length() > 0)
			list.deleteCharAt(list.length() - 1);
			if(codes.length()>0)
			codes.deleteCharAt(codes.length() - 1);
			
			this.lowerDepartmentList = list.toString();
			this.lowerdepcodelist=codes.toString();
		}
	}

	public Date getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(Date loginTime) {
		this.loginTime = loginTime;
	}


	public String getLowerdepcodelist() {
		return lowerdepcodelist;
	}

	/**
	 * @return Returns the managerdeptid.
	 */
	public String getManagerdeptid() {
		return managerdeptid;
	}

	/**
	 * @param managerdeptid
	 *            The managerdeptid to set.
	 */
	public void setManagerdeptid(String managerdeptid) {
		this.managerdeptid = managerdeptid;
	}

	public void setAuthorityString(int policy, String authroityStr) {
		String key = policy + "";
		this.policy.put(key, authroityStr);
	}

	public String getAuthorityString(int policy) throws Exception {
		if (policy == DATA_AUTHORITY_POLICY_DEPARTMENT_UP
				|| policy == DATA_AUTHORITY_POLICY_DEPARTMENT_DOWN
				|| policy == DATA_AUTHORITY_POLICY_DEPARTMENT_SELF
				|| policy == DATA_AUTHORITY_POLICY_GROUP_SELF
				|| policy == DATA_AUTHORITY_POLICY_USER_SELF) {
			String key = policy + "";
			String as = (String) this.policy.get(key);
			return as;
		} else {
			throw new Exception("Can't use this type policy!");
		}
	}

	public static String deptList2AuthorityString(Collection depts) {
		StringBuffer sb = new StringBuffer();
		Iterator iter = depts.iterator();
		int count = 0;
		while (iter.hasNext()) {
			Object o = iter.next();
			if (o != null && o instanceof DepartmentVO) {
				DepartmentVO d = (DepartmentVO) o;
				sb.append("'");
				sb.append(d.getId());
				sb.append("'");
				count++;
				if (count < depts.size()) {
					sb.append(",");
				}
			}
		}
		return sb.toString();
	}

	public String getRolelist() throws Exception {
		return this.rolelist;
	}

	public String getDeptlist() throws Exception {
		return this.deptlist;
	}

	public void setDeptlist(Collection departments) {
		StringBuffer list = new StringBuffer();
		Collection col = departments;
		Iterator it = col.iterator();
		while (it.hasNext()) {
			DepartmentVO dv = (DepartmentVO) it.next();
			if (dv != null)
				list.append("'" + dv.getId() + "',");
		}
		if (list.length() > 0)
			list.deleteCharAt(list.length() - 1);
		String deptlist = list.toString();
		this.deptlist = deptlist;
	}

	public void setRolelist(Collection roles) {
		StringBuffer list = new StringBuffer();
		Collection col = roles;
		Iterator it = col.iterator();
		while (it.hasNext()) {
			RoleVO rv = (RoleVO) it.next();
			if (rv != null)
				list.append("'" + rv.getId() + "',");
		}
		if (list.length() > 0)
			list.deleteCharAt(list.length() - 1);
		String rolelist = list.toString();
		this.rolelist = rolelist;
	}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -