package com.palmnest.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.codehaus.jackson.annotate.JsonBackReference;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonManagedReference;

/**
 * 应用系统功能点实体
 *
 * @author yb
 */
@Entity
@Table(name = "tb_app_function")
public class AppFunction implements java.io.Serializable {

	/**
	 *
	 */
	private static final long serialVersionUID = -1021685936298210230L;

	// Fields
	private Integer           id;
	private Integer           systemcode;
	private String            functionName;
	private String            url;
	private Integer           rightType;
	private String            parentcode;
	private String            treecode;
	private Integer           lastupdateby;
	private Date              lastupdatetime;
	private Integer           status;
	private Integer           orderNumber;
	private Integer           isApp;
	private String            perms;
	private Set<AppMenu>      menuItems     = new HashSet<AppMenu>();
	private Set<RoleFunction> roleFunctions = new HashSet<RoleFunction>();
	// Constructors

	/**
	 * default constructor
	 */

	// Property accessors
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "SYSTEMCODE")
	public Integer getSystemcode() {
		return this.systemcode;
	}

	public void setSystemcode(Integer systemcode) {
		this.systemcode = systemcode;
	}

	@Column(name = "FUNCTION_NAME", length = 50)
	public String getFunctionName() {
		return this.functionName;
	}

	public void setFunctionName(String functionName) {
		this.functionName = functionName;
	}

	@Column(name = "URL", length = 200)
	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Column(name = "RIGHT_TYPE")
	public Integer getRightType() {
		return this.rightType;
	}

	public void setRightType(Integer rightType) {
		this.rightType = rightType;
	}

	@Column(name = "PARENTCODE", length = 50)
	public String getParentcode() {
		return this.parentcode;
	}

	public void setParentcode(String parentcode) {
		this.parentcode = parentcode;
	}

	@Column(name = "TREECODE", length = 50)
	public String getTreecode() {
		return this.treecode;
	}

	public void setTreecode(String treecode) {
		this.treecode = treecode;
	}

	@Column(name = "LASTUPDATEBY")
	public Integer getLastupdateby() {
		return this.lastupdateby;
	}

	public void setLastupdateby(Integer lastupdateby) {
		this.lastupdateby = lastupdateby;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "LASTUPDATETIME", length = 19)
	public Date getLastupdatetime() {
		return this.lastupdatetime;
	}

	public void setLastupdatetime(Date lastupdatetime) {
		this.lastupdatetime = lastupdatetime;
	}

	@Column(name = "STATUS")
	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(name = "ORDER_NUMBER")
	public Integer getOrderNumber() {
		return this.orderNumber;
	}

	public void setOrderNumber(Integer orderNumber) {
		this.orderNumber = orderNumber;
	}

	@Column(name = "IS_APP")
	public Integer getIsApp() {
		return isApp;
	}

	public void setIsApp(Integer isApp) {
		this.isApp = isApp;
	}

	@Column(name = "PERMS")
	public String getPerms() {
		return perms;
	}

	public void setPerms(String perms) {
		this.perms = perms;
	}

	@JsonIgnore
	@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REFRESH},
			fetch = FetchType.LAZY, mappedBy = "appfunction")
	public Set<AppMenu> getMenuItems() {
		return menuItems;
	}

	@JsonIgnore
	@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REFRESH},
			fetch = FetchType.LAZY, mappedBy = "function")
	public Set<RoleFunction> getRoleFunctions() {
		return roleFunctions;
	}

	public void setRoleFunctions(Set<RoleFunction> roleFunctions) {
		this.roleFunctions = roleFunctions;
	}

	public void setMenuItems(Set<AppMenu> menuItems) {
		this.menuItems = menuItems;
	}
}
