package com.k_int.aggr2.mimsy.data.hdo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name="MIMSY_DESCRIPTION")
public class DescriptionHDO //implements java.io.Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Long id;
	private String description;
	private String type;
	private Boolean prior;
	private String date;
	private String source;

	protected DescriptionHDO()
	{
		super();
	}
	
	public DescriptionHDO(String description,String type, boolean prior)
	{
		this.description=description;
		this.type=type;
		this.prior=prior;
	}
	
	@Id
	@Column(name="ID")
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Long getId()
	{
		return this.id;
	}
	
	protected void setId(Long id)
	{
		this.id = id;
	}
	
	@Column(name="DESCRIPTION", length=4000)
	@Lob
	public String getDescription()
	{
		return description;
	}
	
	public void setDescription(String description)
	{
		this.description = description;
	}
	
	@Column(name="DESC_TYPE")
	public String getType()
	{
		return type;
	}
	
	public void setType(String type)
	{
		this.type = type;
	}
	
	@Column(name="DESC_SOURCE")
	public String getSource()
	{
		return source;
	}
	
	public void setSource(String source)
	{
		this.source=source;
	}
	
	@Column(name="DESC_DATE")
	public String getDate()
	{
		return date;
	}
	
	public void setDate(String date)
	{
		this.date=date;
	}

	@Column(name="PRIOR")
	public Boolean getPrior()
	{
		return prior;
	}
	
	public void setPrior(Boolean prior)
	{
		this.prior = prior;
	}
	
	@Transient
	public int hashCode()
	{
		return toString().hashCode();
	}
	
	@Transient
	public boolean equals(Object o)
	  {
		  boolean retval=false;
		  if(o instanceof DescriptionHDO)
		  {
			  retval = (o.toString()).equals(this.toString());
		  }
			  
		  return retval;  
	  }
	
	@Transient
	public String toString()
	{
		StringBuilder builder = new StringBuilder();
		if(description!=null)
			builder.append(description);
		
		if(type!=null)
			builder.append(type);
		
		if(source!=null)
			builder.append(source);
		
		if(date!=null)
			builder.append(date);
		
		builder.append(Boolean.toString(prior));
		
		return builder.toString();
		
		
	}
}
