package com.acme.model.domain.sc.entity;


import com.acme.structure.BaseEntityListener;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;

@Entity(name = "TableOrder")
@javax.persistence.Table(name = "TABLEORDERS")
@DiscriminatorValue("TableOrder")
@PrimaryKeyJoinColumn(name = "ORDERID", referencedColumnName = "ID")
@EntityListeners( { BaseEntityListener.class })
public class TableOrder extends Order
{
    private Table table;
    private String waiterNote;
    private boolean requestedBill;

    public TableOrder()
    {
        entityName = "TableOrder";
        setOrderType(this.getEntityName());
    }

    public void setTable(Table table)
    {
        this.table = table;
    }

    @ManyToOne(targetEntity = Table.class, cascade = { })
    @JoinColumn(name = "TABLEID", nullable = false)
    public Table getTable()
    {
        return table;
    }

    public void setWaiterNote(String waiterNote)
    {
        this.waiterNote = waiterNote;
    }

    @Column(name = "WAITERNOTE")
    public String getWaiterNote()
    {
        return waiterNote;
    }

    public void setRequestedBill(boolean requestedBill)
    {
        this.requestedBill = requestedBill;
    }

    @Column(name = "REQUESTEDBILL")
    public boolean isRequestedBill()
    {
        return requestedBill;
    }

    @Override
    public String toString()
    {
        return getTable().getName() + " - " + getId();
    }
}
