package com.k_int.aggr2.mimsy.data.hdo;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;


@Entity
@Table(name="MIMSY_INSTRUCTION")
public class InstructionHDO //implements java.io.Serializable 
{

	private static final long serialVersionUID = 1L;
	private Long id;
	private String type;
	private String status;
	private String instruction;
	private Date date;
	private String name;
	
	@Id
	@Column(name="ID")
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Long getId() 
	{
		return id;
	}
	
	protected void setId(Long id)
	{
		this.id = id;
	}
	
	@Column(name="INSTR_TYPE")
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	
	@Column(name="INSTR_NAME")
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name="STATUS")
	public String getStatus() {
		return status;
	}
	
	public void setStatus(String status) {
		this.status = status;
	}
	
	@Column(name="INSTRUCTION", length=1000)
	public String getInstruction() {
		return instruction;
	}
	
	public void setInstruction(String instruction) {
		this.instruction = instruction;
	}
	
	public void setDate(Date date)
	{
		this.date=date;
	}

	@Column(name="INSTR_DATE")
	public Date getDate()
	{
		return date;
	}
	
	
	public int hashCode()
	{
		return toString().hashCode();
	}
	
	 public boolean equals(Object o)
	  {
		  boolean retval=false;
		  if(o instanceof InstructionHDO)
		  {
			  retval = (o.toString()).equals(this.toString());
		  }
			  
		  return retval;  
	  }
	
	
	public String toString()
	{
		StringBuilder builder = new StringBuilder();
		
		if(instruction!=null)
			builder.append(instruction);
		
		//if(note!=null)
		//	builder.append(note);
		
		if(status!=null)
			builder.append(status);
		
		if(date!=null)
			builder.append(date);
		
		if(type!=null)
			builder.append(type);
		
		return builder.toString();
	}
	
	/*public void toRdfXMLElement(Writer writer) throws SerializationException
    {
		try
		{          
			writer.write("<mo:instructionLink>");
			if(this.getDate()!=null)
			{
				writer.write("<dc:date>");
				;
				writer.write(MimsyHelper.getDateString(this.getDate()));
				writer.write("</dc:date>");
			}
		
			if(this.getName()!=null)
			{
				writer.write("<mo:instructionBy>");
				writer.write(MimsyHelper.encodeForXml(this.getName()));
				writer.write("</mo:instructionBy>");
			}
		
			if(this.getStatus()!=null)
			{
				writer.write("<mo:instructionStatus>");
				writer.write(MimsyHelper.encodeForXml(this.getStatus()));
				writer.write("</mo:instructionStatus>");
			}
		
			if(this.getType()!=null)
			{
				writer.write("<mo:instructionType>");
				writer.write(MimsyHelper.encodeForXml(this.getType()));
				writer.write("</mo:instructionType>");
			}
			if(this.getInstruction()!=null)
			{
				writer.write("<mo:instruction>");
				writer.write(MimsyHelper.encodeForXml(this.getInstruction()));
				writer.write("</mo:instruction>");
			}           		
			writer.write("</mo:instructionLink>");
	        }
	        catch(Exception ex)
	        {
	            throw new SerializationException(ex);
	        }
    }*/
}
