Organization

/**
 * Copy right reserved.
 * Organization.java
 */
package com.etong.common.system.domain;


import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;


import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;


import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.Where;


import com.etong.common.system.domain.base.StringIdEntity;
import com.etong.cos.basedata.domain.Region;


/**
 * @version 1.0
 */
@Entity
@Table(name="SYS_ORGANIZATIONS"/*, schema="UAWP"*/)
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Organization extends StringIdEntity {


private static final long serialVersionUID = 8533554030914683070L;


/** 机构代码 */
private String code;

/** 内部代码,自动生成并能反映管辖关系 */
private String innerCode;


/** 名称 */
private String name;

/** 上级主管机构 */
private Organization parent;

/** 直接下属机构 */
private Set<Organization> children;

/** 主要负责人 */
private User manager;

/** 机构类别代码(字典) */
private int type;

/** 机构层级(遍历到根节点的层数,从零开始) */
private int layer;

/** 拼音(名称拼音首字母) */
private String spell;


/** 全名 */
private String fullName;

/** 地址 */
private String address;

/** 联系人 */
private String linkMan;


/** 联系电话  */
private String linkTel;

/** 传真 */
private String fax;


/** 描述 */
private String description;

/** 显示次序 */
private int order;

/** 用户 */
private Set<User> users;

/** 员工 */
private Set<Employee> employees;

/** 是否为独立机构(可配置独立的分支管理员,下属机构的用户仅可以访问该独立机构用的机构信息)*/
private boolean independent;

/** 是否禁用 */
private boolean disabled;

private Date updateDate;//最后修改时间

private Date disableDate;//注销时间

private Region region;//管理区域


public Organization() {
super();
}

public Organization(String name) {
this.name = name;
}

public Organization(String name, Organization parent) {
this.name = name;
this.parent = parent;
}

/**
* @return the code
*/
@Column(length=10, nullable=false)
public String getCode() {
return code;
}


/**
* @param code the code to set
*/
public void setCode(String code) {
this.code = code;
}


/**
* @return the innerCode
*/
@Column(length=16, unique=true, nullable=false)
@Index(name="IDX_ORG_INNER_CODE")
public String getInnerCode() {
return innerCode;
}


/**
* @param innerCode the innerCode to set
*/
public void setInnerCode(String innerCode) {
this.innerCode = innerCode;
}


/**
* @return the name
*/
@Column(length=20, nullable=false)
public String getName() {
return name;
}


/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}


/**
* @return the fullName
*/
@Column(length=40)
public String getFullName() {
return fullName;
}


/**
* @param fullName the fullName to set
*/
public void setFullName(String fullName) {
this.fullName = fullName;
}


/**
* @return the parent
*/
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="parent_id")
public Organization getParent() {
return parent;
}


/**
* @param parent the parent to set
*/
public void setParent(Organization parent) {
this.parent = parent;
}


/**
* @return the manager
*/
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="manager_id")
public User getManager() {
return manager;
}


/**
* @param manager the manager to set
*/
public void setManager(User manager) {
this.manager = manager;
}


/**
* @return the type
*/
public int getType() {
return type;
}


/**
* @param type the type to set
*/
public void setType(int type) {
this.type = type;
}


/**
* @return the layer
*/
public int getLayer() {
return layer;
}


/**
* @param layer the layer to set
*/
public void setLayer(int layer) {
this.layer = layer;
}


/**
* @return the spell
*/
@Column(length=10)
public String getSpell() {
return spell;
}


/**
* @param spell the spell to set
*/
public void setSpell(String spell) {
this.spell = spell;
}


/**
* @return the address
*/
@Column(length=64)
public String getAddress() {
return address;
}


/**
* @param address the address to set
*/
public void setAddress(String address) {
this.address = address;
}


/**
* @return the linkMan
*/
@Column(length=16)
public String getLinkMan() {
return linkMan;
}


/**
* @param linkMan the linkMan to set
*/
public void setLinkMan(String linkMan) {
this.linkMan = linkMan;
}


/**
* @return the linkTel
*/
@Column(length=20)
public String getLinkTel() {
return linkTel;
}


/**
* @param linkTel the linkTel to set
*/
public void setLinkTel(String linkTel) {
this.linkTel = linkTel;
}


/**
* @return the description
*/
@Column(length=255)
public String getDescription() {
return description;
}


/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}


/**
* @return the independent
*/
@Type(type="true_false")
public boolean isIndependent() {
return independent;
}


/**
* @param independent the independent to set
*/
public void setIndependent(boolean independent) {
this.independent = independent;
}


/**
* @return the disabled
*/
@Type(type="true_false")
public boolean isDisabled() {
return disabled;
}


/**
* @param disabled the disabled to set
*/
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}

/**
* @return the order
*/
@Index(name="IDX_ORG_ORDER")
public int getOrder() {
return order;
}


/**
* @param order the order to set
*/
public void setOrder(int order) {
this.order = order;
}


/**
* @return the fax
*/
@Column(length=13)
public String getFax() {
return fax;
}


/**
* @param fax the fax to set
*/
public void setFax(String fax) {
this.fax = fax;
}


/**
* @return 最后修改时间
*/
@Column(name="update_date")
public Date getUpdateDate() {
return updateDate;
}


/**
* @param updateDate 要设置的最后修改时间
*/
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}


/**
* @return 注销时间
*/
@Column(name="disable_date")
public Date getDisableDate() {
return disableDate;
}


/**
* @param disableDate 要设置的注销时间
*/
public void setDisableDate(Date disableDate) {
this.disableDate = disableDate;
}


/**
* @return the users
*/
@OneToMany(mappedBy="organization", fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
@Where(clause="f_disabled='F' and f_removed='F'")
@OrderBy("order")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public Set<User> getUsers() {
if(users == null) {
users = new LinkedHashSet<User>();
}
return users;
}


/**
* @param users the users to set
*/
public void setUsers(Set<User> users) {
this.users = users;
}


/**
* @return the employees
*/
@OneToMany(mappedBy="organization", fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
@Where(clause="f_deleted='F'")
@OrderBy("order")
public Set<Employee> getEmployees() {
if(employees == null) {
employees = new LinkedHashSet<Employee>();
}
return employees;
}


/**
* @param employees the employees to set
*/
public void setEmployees(Set<Employee> employees) {
this.employees = employees;
}


/**
* @return the children
*/
@OneToMany(mappedBy="parent", fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
@Where(clause="f_disabled='F'")
@OrderBy("order")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public Set<Organization> getChildren() {
if(children == null) {
children = new LinkedHashSet<Organization>();
}
return children;
}


/**
* @param children the children to set
*/
public void setChildren(Set<Organization> children) {
this.children = children;
}


/**
* @return the region
*/
@ForeignKey(name = "null")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "region_id")
public Region getRegion() {
return region;
}


/**
* @param region the region to set
*/
public void setRegion(Region region) {
this.region = region;
}


/**
  * 判断是否为叶节点,即是否包含有效的子部门 
* @return the leaf
*/
@Transient
public boolean isLeaf() {
return getChildren().size() == 0;
}


@Override
public String toString() {
return new StringBuilder(32).append("[code:").append(code)
.append(",innerCode:").append(innerCode)
.append(",name:").append(name).append(",id:").append(getId())
.append(']').toString();
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值