package devopsdistilled.operp.server.data.entity.stock;

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.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import devopsdistilled.operp.server.data.entity.Entiti;

@Entity
public class StockKeeper extends Entiti<Long> {

	private static final long serialVersionUID = 6110042579005L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long stockKeeperId;

	@Column(insertable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date stockUpdateDate;

	@ManyToOne
	private Stock stock;

	private Long quantity;

	@OneToOne
	private StockKeeper transferStockKeeper;

	public Long getStockKeeperId() {
		return stockKeeperId;
	}

	public void setStockKeeperId(Long stockKeeperId) {
		this.stockKeeperId = stockKeeperId;
	}

	public Date getStockUpdateDate() {
		return stockUpdateDate;
	}

	public void setStockUpdateDate(Date stockUpdateDate) {
		this.stockUpdateDate = stockUpdateDate;
	}

	public Stock getStock() {
		return stock;
	}

	public void setStock(Stock stock) {
		this.stock = stock;
	}

	public Long getQuantity() {
		return quantity;
	}

	public void setQuantity(Long quantity) {
		this.quantity = quantity;
	}

	public StockKeeper getTransferStockKeeper() {
		return transferStockKeeper;
	}

	public void setTransferStockKeeper(StockKeeper transferStockKeeper) {
		this.transferStockKeeper = transferStockKeeper;
	}

	@Override
	public Long id() {
		return getStockKeeperId();
	}

	@Override
	public String toString() {
		return new String(getQuantity() + " " + getStock().toString());
	}

}

@@ -78,41 +78,8 @@
 e;%0A%0A
-import javax.persistence.Column;%0A
 impo
@@ -419,16 +419,76 @@
 .Entiti;
+%0Aimport devopsdistilled.operp.server.data.entity.items.Item;
 %0A%0A@Entit
@@ -689,56 +689,8 @@
 d;%0A%0A
-%09@Column(insertable = false, updatable = false)%0A
 %09@Te
@@ -1628,24 +1628,159 @@
 Keeper;%0A%09%7D%0A%0A
+%09public Item getItem() %7B%0A%09%09return getStock().getItem();%0A%09%7D%0A%0A%09public Warehouse getWarehouse() %7B%0A%09%09return getStock().getWarehouse();%0A%09%7D%0A%0A
 %09@Override%0A%09

Configure to manually set UpdateDate