package pl.bnsit.peaa.temporalobject;

import java.io.Serializable;
import java.sql.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity 
@Table( name = "orders_versions" )
public class OrderVersion implements Serializable {

	@Id
	@GeneratedValue( strategy=GenerationType.AUTO )
	private Long id;
	
	@Column( name="custom_id" )
	private String customId;
	
	private String name;
	
	private Double price;

	private Date date;
	
	@OneToOne
	@JoinColumn(name="ref_order")
	private Order parentOrder;
	
	public Order getParentOrder() {
	
		return parentOrder;
	}

	
	public void setParentOrder( Order parentOrder ) {
	
		this.parentOrder = parentOrder;
	}

	public OrderVersion() {
		Date now = Utils.getNow();
		this.date = now;
	}
	
	public OrderVersion( OrderVersion version ) {
		super();
		this.customId = version.getCustomId();
		this.name = version.getName();
		this.price = version.getPrice();
	}
	
	public String getCustomId() {
		return customId;
	}

	public void setCustomId( String productId ) {
		this.customId = productId;
	}

	public String getName() {
		return name;
	}

	public void setName( String productName ) {
		this.name = productName;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice( Double price ) {
		this.price = price;
	}

	
	public Long getId() {
	
		return id;
	}

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

	
	public Date getDate() {
	
		return date;
	}

	
	public void setDate( Date date ) {
	
		this.date = date;
	}
	
}
