package com.palmnest.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

/**
 * AbstractElement entity provides the base persistence definition of the
 * Element entity. @author MyEclipse Persistence Tools
 */
@MappedSuperclass
public abstract class AbstractElement {

	// Fields

	private static final long serialVersionUID = 1L;

	private Long         id;
	private ElementGroup elementGroup;
	private String       itemname;
	private String       itemcode;
	private String       isenabled;
	private Long         oprateversion;
	private String       opratetype;
	private Date         createTime;
	private String       createBy;
	private Date         lastUpdatedTime; // 最后更新时间
	private String       lastUpdatedBy; // 最后更新人
	private Long         orderno;

	@Transient
	public Date getCreatedTime() {
		return createTime;
	}

	public void setCreatedTime(Date createTime) {
		this.createTime = createTime;
	}

	@Transient
	public String getCreatedBy() {
		return createBy;
	}

	public void setCreatedBy(String createBy) {
		this.createBy = createBy;
	}

	@Column(name = "LASTUPDATEBY", length = 50)
	public String getLastUpdatedBy() {
		return lastUpdatedBy;
	}

	public void setLastUpdatedBy(String lastUpdatedBy) {
		this.lastUpdatedBy = lastUpdatedBy;
	}

	@Column(name = "LASTUPDATETIME")
	public Date getLastUpdatedTime() {
		return lastUpdatedTime;
	}

	public void setLastUpdatedTime(Date lastUpdatedTime) {
		this.lastUpdatedTime = lastUpdatedTime;
	}
	// Constructors
	/**
	 * default constructor
	 */
	public AbstractElement() {
	}

	/**
	 * minimal constructor
	 */
	public AbstractElement(Long id, ElementGroup elementGroup) {
		this.id = id;
		this.elementGroup = elementGroup;
	}


	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return this.id;
	}

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

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "GROUPID")
	public ElementGroup getElementGroup() {
		return this.elementGroup;
	}

	public void setElementGroup(ElementGroup elementGroup) {
		this.elementGroup = elementGroup;
	}

	@Column(name = "ITEMNAME", length = 30)
	public String getItemname() {
		return itemname;
	}

	public void setItemname(String itemname) {
		this.itemname = itemname;
	}

	@Column(name = "ITEMCODE", length = 30)
	public String getItemcode() {
		return itemcode;
	}

	public void setItemcode(String itemcode) {
		this.itemcode = itemcode;
	}

	@Column(name = "ISENABLED", length = 1)
	public String getIsenabled() {
		return isenabled;
	}

	public void setIsenabled(String isenabled) {
		this.isenabled = isenabled;
	}

	@Column(name = "OPRATEVERSION")
	public Long getOprateversion() {
		return oprateversion;
	}

	public void setOprateversion(Long oprateversion) {
		this.oprateversion = oprateversion;
	}

	@Column(name = "OPRATETYPE", length = 1)
	public String getOpratetype() {
		return opratetype;
	}

	public void setOpratetype(String opratetype) {
		this.opratetype = opratetype;
	}

	@Column(name = "CREATETIME")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "CREATEBY", length = 50)
	public String getCreateBy() {
		return createBy;
	}

	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}

	@Column(name = "ORDERNO")
	public Long getOrderno() {
		return orderno;
	}

	public void setOrderno(Long orderno) {
		this.orderno = orderno;
	}

	public AbstractElement(Long id, ElementGroup elementGroup, String itemname,
						   String itemcode, String isenabled, Long oprateversion,
						   String opratetype, Date createTime, String createBy,
						   Date lastUpdatedTime, String lastUpdatedBy,String remark) {
		super();
		this.id = id;
		this.elementGroup = elementGroup;
		this.itemname = itemname;
		this.itemcode = itemcode;
		this.isenabled = isenabled;
		this.oprateversion = oprateversion;
		this.opratetype = opratetype;
		this.createTime = createTime;
		this.createBy = createBy;
		this.lastUpdatedTime = lastUpdatedTime;
		this.lastUpdatedBy = lastUpdatedBy;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((createBy == null) ? 0 : createBy.hashCode());
		result = prime * result
				+ ((createTime == null) ? 0 : createTime.hashCode());
		result = prime * result
				+ ((elementGroup == null) ? 0 : elementGroup.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((isenabled == null) ? 0 : isenabled.hashCode());
		result = prime * result
				+ ((itemcode == null) ? 0 : itemcode.hashCode());
		result = prime * result
				+ ((itemname == null) ? 0 : itemname.hashCode());
		result = prime * result
				+ ((lastUpdatedBy == null) ? 0 : lastUpdatedBy.hashCode());
		result = prime * result
				+ ((lastUpdatedTime == null) ? 0 : lastUpdatedTime.hashCode());
		result = prime * result
				+ ((opratetype == null) ? 0 : opratetype.hashCode());
		result = prime * result
				+ ((oprateversion == null) ? 0 : oprateversion.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AbstractElement other = (AbstractElement) obj;
		if (createBy == null) {
			if (other.createBy != null)
				return false;
		} else if (!createBy.equals(other.createBy))
			return false;
		if (createTime == null) {
			if (other.createTime != null)
				return false;
		} else if (!createTime.equals(other.createTime))
			return false;
		if (elementGroup == null) {
			if (other.elementGroup != null)
				return false;
		} else if (!elementGroup.equals(other.elementGroup))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (isenabled == null) {
			if (other.isenabled != null)
				return false;
		} else if (!isenabled.equals(other.isenabled))
			return false;
		if (itemcode == null) {
			if (other.itemcode != null)
				return false;
		} else if (!itemcode.equals(other.itemcode))
			return false;
		if (itemname == null) {
			if (other.itemname != null)
				return false;
		} else if (!itemname.equals(other.itemname))
			return false;
		if (lastUpdatedBy == null) {
			if (other.lastUpdatedBy != null)
				return false;
		} else if (!lastUpdatedBy.equals(other.lastUpdatedBy))
			return false;
		if (lastUpdatedTime == null) {
			if (other.lastUpdatedTime != null)
				return false;
		} else if (!lastUpdatedTime.equals(other.lastUpdatedTime))
			return false;
		if (opratetype == null) {
			if (other.opratetype != null)
				return false;
		} else if (!opratetype.equals(other.opratetype))
			return false;
		if (oprateversion == null) {
			if (other.oprateversion != null)
				return false;
		} else if (!oprateversion.equals(other.oprateversion))
			return false;
		return true;
	}

}