package org.cs.mgr.order.model;

import java.util.HashMap;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.cs.core.model.BaseEntity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

@Table(name = "progress_dic")
@Entity
@DynamicInsert
@DynamicUpdate
public class ProgressDic  extends  BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1496735081451963836L;
	private static final Class<ProgressDic> ENTITY_CLASS = ProgressDic.class;
	
	private String name;//进度名称
	private String type;//类别(0:汽车;1：非汽车)
	private String code;//代码
	private String action;//动作
	
	@Id
	@SequenceGenerator(name="sequenceGenerator",sequenceName="mgm_order_seq")
	@GeneratedValue(generator="sequenceGenerator",strategy=GenerationType.SEQUENCE)
	@Column(name = "id", unique = true, nullable = false, precision = 11, scale = 0)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	
	@Column(name = "name", columnDefinition="VARCHAR2(50) " )
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name = "type", columnDefinition="VARCHAR2(10) " )
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	
	@Column(name = "code", columnDefinition="VARCHAR2(10) " )
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	
	@Column(name = "action", columnDefinition="VARCHAR2(50) " )
	public String getAction() {
		return action;
	}
	public void setAction(String action) {
		this.action = action;
	}
	
	
	public Class entityClass()
	{
		return ENTITY_CLASS;
	}
	
	
	protected StringBuilder toStringBuilder(StringBuilder sb)
 	{
 		return sb 
		.append(",id=").append(this.id)
		.append(",attr1=").append(this.attr1)
		.append(",attr2=").append(this.attr2)
		.append(",attr3=").append(this.attr3)
		.append(",createDate=").append(this.createDate)
		.append(",modifyDate=").append(this.modifyDate)
		.append(",isDelete=").append(this.isDelete)
		.append(",name=").append(this.name)
		.append(",code=").append(this.code)
		.append(",type=").append(this.type)
		.append(",action=").append(this.action)
		;
 	}
	
	@Override
	public String toString()
	{
		return toStringBuilder(new StringBuilder().append("MgmOrder[")).append(']').toString();
	}
	 
	
	public Map<String,Object> mapValue()
	{
	    Map<String,Object> map=new HashMap<String,Object>();
	    if(this.id!=null){ map.put("id",this.id);}	    
		if(this.attr1 !=null){ map.put("attr1", this.attr1);}
		if(this.attr2 !=null){ map.put("attr2", this.attr2);}
		if(this.attr3 !=null){ map.put("attr3", this.attr3);}
		if(this.createDate != null){ map.put("createDate", this.createDate);}
		if(this.modifyDate != null){ map.put("modifyDate", this.modifyDate);}
		if(this.isDelete != null){ map.put("isDelete", this.isDelete);}
		if(this.name!=null) {map.put("name", this.name);}
		if(this.code!=null) {map.put("code",this.code);}
		if(this.type!=null) {map.put("type", this.type);}
		if(this.action!=null) {map.put("action", this.action);}
		return map;
	}
	
	public void mergeTo(ProgressDic en)
	{
		 if(this.id !=null){ en.setId(this.id);}		  
		 if(this.attr1!=null){ en.setAttr1(this.attr1);}
		 if(this.attr2!=null){ en.setAttr2(this.attr2);}
		 if(this.attr3!=null){ en.setAttr3(this.attr3);}
		 if(this.createDate != null){ en.setCreateDate(this.createDate);}
		 if(this.modifyDate != null){ en.setModifyDate(this.modifyDate);}
		 if(this.isDelete != null){ en.setIsDelete(this.isDelete);}
		 if(this.name!=null) {en.setName(this.name);}
		 if(this.code!=null) {en.setCode(this.code);}
		 if(this.type!=null) {en.setType(this.type);}
		 if(this.action!=null) {en.setAction(this.action);}
	}
	
  	@Override
  	public void copyFrom(Object obj)
  	{  
  		 if(!(obj instanceof ProgressDic)) {
  	 		super.copyFrom(obj);
  	 	}else {
  	 		ProgressDic bean=(ProgressDic)obj;
			this.setId(bean.getId());			
	     	this.setAttr1(bean.getAttr1());
	     	this.setAttr2(bean.getAttr2());
	     	this.setAttr3(bean.getAttr3());
	     	this.setCreateDate(bean.getCreateDate());
	     	this.setModifyDate(bean.getModifyDate());
	     	this.setIsDelete(bean.getIsDelete());
	     	this.setName(bean.getName());
	     	this.setCode(bean.getCode());
	     	this.setType(bean.getType());
	     	this.setAction(bean.getAction());
     	}
 	 }
  	
  	
  	public void copyFromMap(Object obj)
  	{  
  		ProgressDic bean=(ProgressDic)obj;
		this.setId(bean.getId());		
     	this.setAttr1(bean.getAttr1());
     	this.setAttr2(bean.getAttr2());
     	this.setAttr3(bean.getAttr3());
     	this.setCreateDate(bean.getCreateDate());
     	this.setModifyDate(bean.getModifyDate());
     	this.setIsDelete(bean.getIsDelete());     	
 	 }
	
}
