package cz.cvut.fel.restauracefel.hibernate;
// Generated 16.3.2009 21:36:54 by Hibernate Tools 3.2.1.GA
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
* MenuItem generated by hbm2java
*/
public class MenuItem implements Serializable {
private static final long serialVersionUID = 8674356004460574251L;
private Integer menuItemId;
private String name;
private double price;
private String quantity;
private int isAvailable;
private int isDeleted;
private MenuItemType menuItemType;
public MenuItem() {
}
public MenuItem(String name, double price, String quantity, int isAvailable, int isDeleted) {
this.name = name;
this.price = price;
this.quantity = quantity;
this.isAvailable = isAvailable;
this.isDeleted = isDeleted;
}
public MenuItem(String name, double price, String quantity, int isAvailable, int isDeleted, MenuItemType menuItemType) {
this.name = name;
this.price = price;
this.quantity = quantity;
this.isAvailable = isAvailable;
this.menuItemType = menuItemType;
}
//tato metoda zde musi byt, a to z duvodu, aby mohla probehnout spravne serializace
//zapis objektu do proudu bajtu
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.writeInt(menuItemId);
stream.writeObject(name);
stream.writeDouble(price);
stream.writeObject(quantity);
stream.writeInt(isAvailable);
stream.writeInt(isDeleted);
//stream.writeInt(menuItemTypeID);
MenuItemType mit = new MenuItemType(menuItemType.getName(), menuItemType.getItemCount(), menuItemType.getIsDeleted());
mit.setMenuItemTypeId(menuItemType.getMenuItemTypeId());
stream.writeObject(mit);
}
//tato metoda zde musi byt, a to z duvodu, aby mohla probehnout spravne serializace
//cteni a rekonstrukce objektu z proudu bajtu
private void readObject(ObjectInputStream stream) throws IOException {
try {
menuItemId = stream.readInt();
name = (String)stream.readObject();
price = stream.readDouble();
quantity = (String)stream.readObject();
isAvailable = stream.readInt();
isDeleted = stream.readInt();
menuItemType = (MenuItemType) stream.readObject();
} catch (Exception e) {
e.getMessage();
}
}
public Integer getMenuItemId() {
return this.menuItemId;
}
public void setMenuItemId(Integer menuItemId) {
this.menuItemId = menuItemId;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return this.price;
}
public void setPrice(double price) {
this.price = price;
}
public String getQuantity() {
return this.quantity;
}
public void setQuantity(String quantity) {
this.quantity = quantity;
}
public int getIsAvailable() {
return this.isAvailable;
}
public void setIsAvailable(int isAvailable) {
this.isAvailable = isAvailable;
}
public int getIsDeleted() {
return isDeleted;
}
public void setIsDeleted(int isDeleted) {
this.isDeleted = isDeleted;
}
public MenuItemType getMenuItemType() {
return this.menuItemType;
}
public void setMenuItemType(MenuItemType menuType) {
this.menuItemType = menuType;
}
}