package com.hotent.uc.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.hotent.base.util.BeanUtils;
/**
 * 组织树
 * @author Administrator
 *
 */
public class OrgTree extends Org {

	private static final long serialVersionUID = -3645769164167420062L;
	
	public static final String ICON_COMORG ="/styles/theme/default/images/icons/u_darkblue/u_zzgl_darkblue.png";
	protected Long  sn; /*序号*/
	protected String  icon; /*图标*/
	protected boolean  nocheck = false; /***/
	protected boolean chkDisabled =false ;
	protected boolean click = true;
	protected String title = ""; //*title  默认为name 、如果name添加了 css 、则默认为 “” */  
	protected String demId = "0";
	protected boolean authRoot = false; /*分级组织管理时用于判断是否为根节点*/
	protected boolean post = false; /*判断是否为岗位*/
	protected String joinExtSystemType="0";//集成的外部系统（0=无，1=钉钉2=企业微信）
	protected String joinExtSystemSyndir="0";//同步方向0=向第三方系统同步 ，1=第三方系统向中台同步
	protected String extSetting="0";//是否有外部系统参数配置
	public OrgTree() {
	}
	public OrgTree(String name,String id,String parentId,String icon){
		setName(name);
		this.parentId = parentId;
		this.id =id;
		this.icon = icon;
		
	}
	/**
	 * GroupList2TreeList
	 */
	public static List<OrgTree> GroupList2TreeList(List<Org> groupList,String icon){
		if(groupList == null || groupList.size() == 0) 
			return Collections.emptyList();
		
		List<OrgTree> groupTreeList = new ArrayList<OrgTree>();
		for(Org group : groupList){
			OrgTree grouptree = new OrgTree(group);
			grouptree.setIcon(icon);
			groupTreeList.add(grouptree);
		}
		return groupTreeList;
	}
	
	public OrgTree(Org group) {
		this.id =group.id;
		this.name = group.name;
		this.code = group.code;
		this.sn = group.orderNo;
		this.parentId = group.parentId;
		this.demId = group.demId;
		this.isIsParent = group.isIsParent;
		this.path = group.path;

		if(group.joinExtSystemType==null){
			this.joinExtSystemType=Org.ORG_SYN_TYPE_0;
		}else{
			this.joinExtSystemType=group.joinExtSystemType;
		}
		if(group.joinExtSystemSyndir==null){
			this.joinExtSystemSyndir=Org.ORG_SYN_DIR_0;
		}else{
			this.joinExtSystemSyndir=group.joinExtSystemSyndir;
		}

		this.extSetting= group.extSetting;

		if(BeanUtils.isNotEmpty(this.name) && !this.name.contains("style=")){
			this.title = name;
		}
		this.orgType = group.orgType;
	}
	public OrgTree(OrgPost orgPost) {
		this.id =orgPost.id;
		this.name = orgPost.name;
		this.code = orgPost.code;
		this.parentId = orgPost.orgId;
		if(BeanUtils.isNotEmpty(this.name)&& !this.name.contains("style=")){
			this.title = name;
		}
	}
	@Override
	public void setName(String name) {
		this.name = name; 
		// 将title 设置成name
		if("".equals(title) && !this.name.contains("style=")){
			this.title = name;
		} 
	};

	@Override
	public String getJoinExtSystemSyndir() {
		return joinExtSystemSyndir;
	}

	@Override
	public void setJoinExtSystemSyndir(String joinExtSystemSyndir) {
		this.joinExtSystemSyndir = joinExtSystemSyndir;
	}

	public String getDemId() {
		return demId;
	}
	public void setDemId(String demId) {
		this.demId = demId;
	}
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title; 
	}

	public Long getSn() {
		return sn;
	}
	public void setSn(Long sn) {
		this.sn = sn;
	}
	public String getIcon() {
		return icon;
	}
	public void setIcon(String icon) {
		this.icon = icon;
	}
	public boolean isNocheck() {
		return nocheck;
	}
	public void setNocheck(boolean nocheck) {
		this.nocheck = nocheck;
	}
	public boolean isChkDisabled() {
		return chkDisabled;
	}

	public boolean isClick() {
		return click;
	}

	public void setClick(boolean click) {
		this.click = click;
	}

	public void setChkDisabled(boolean chkDisabled) {
		this.chkDisabled = chkDisabled;
	}
	public boolean isAuthRoot() {
		return authRoot;
	}
	public void setAuthRoot(boolean authRoot) {
		this.authRoot = authRoot;
	}
	public boolean isPost() {
		return post;
	}
	public void setPost(boolean post) {
		this.post = post;
	}

	public String getExtSetting() {
		return extSetting;
	}

	public void setExtSetting(String extSetting) {
		this.extSetting = extSetting;
	}

	@Override
	public String getJoinExtSystemType() {
		return joinExtSystemType;
	}

	@Override
	public void setJoinExtSystemType(String joinExtSystemType) {
		this.joinExtSystemType = joinExtSystemType;
	}
}
