]> git.somenet.org - pub/jan/sbc.git/blob - src/main/java/at/ac/tuwien/sbc/valesriegler/types/Pizza.java
[XVSM] Some fixes for making sure that Cook only prepares normal pizzas when there...
[pub/jan/sbc.git] / src / main / java / at / ac / tuwien / sbc / valesriegler / types / Pizza.java
1 package at.ac.tuwien.sbc.valesriegler.types;
2
3 import at.ac.tuwien.sbc.valesriegler.common.Util;
4 import at.ac.tuwien.sbc.valesriegler.waiter.jms.JMSWaiter;
5
6 import java.io.Serializable;
7
8 /**
9  * this is a PIZZA! omnomnomnom
10  * 
11  * @author jan
12  * 
13  */
14 public class Pizza extends PizzaOrder implements Serializable {
15         public JMSWaiter deliveryAgent;
16     protected Boolean isDeliveryPizza;
17
18     /**
19          * Yes that's funny! the pizza has a field idOfOrder although PizzaOrder
20          * already has a field orderId! The reason: The space linda selection is a
21          * little bit limited. when I look for a template pizza with orderId set the
22          * space gives me ALL pizzas. The reason obviously is that it can't really
23          * include the field of the superclass in the search. So we must have an
24          * idOfOrder field in the pizza and not only in the PizzaOrder for the time
25          * being.. ^^
26          */
27         private Integer idOfOrder;
28
29         private Pizza(int id, PizzaType type, int cookId, int orderId, boolean isDeliveryPizza) {
30                 this.id = id;
31                 this.pizzaType = type;
32                 this.cookId = cookId;
33                 this.idOfOrder = orderId;
34         this.isDeliveryPizza = isDeliveryPizza;
35                 this.status = PizzaOrderStatus.DONE;
36         }
37
38         public Pizza() {
39                 super();
40         }
41
42         public static Pizza createPizzaFromPizzaOrder(PizzaOrder pizzaorder, int cookId, boolean isDeliveryPizza) {
43                 return new Pizza(pizzaorder.getId(), pizzaorder.getPizzaType(), cookId, pizzaorder.getOrderId(), isDeliveryPizza);
44         }
45
46         @Override
47         public String toString() {
48                 return "Pizza [deliveryAgent=" + deliveryAgent + ", id=" + id + ", orderId=" + orderId + ", pizzaType=" + pizzaType
49                                 + ", status=" + status + ", cookId=" + cookId + "]";
50         }
51
52         @Override
53         public int getOrderId() {
54                 return getIdOfOrder();
55         }
56
57         @Override
58         public void setOrderId(Integer orderId) {
59                 idOfOrder = orderId;
60         }
61
62         public int getIdOfOrder() {
63                 return Util.getIntSafe(idOfOrder);
64         }
65
66         public void setIdOfOrder(Integer idOfOrder) {
67                 this.idOfOrder = idOfOrder;
68         }
69
70     public void setDeliveryPizza(boolean deliveryPizza) {
71         this.isDeliveryPizza = deliveryPizza;
72     }
73
74     public boolean isDeliveryPizza() {
75         return isDeliveryPizza;
76     }
77 }