]> git.somenet.org - pub/jan/sbc.git/blob - src/main/java/at/ac/tuwien/sbc/valesriegler/types/Pizza.java
added commandline argument parsing to allow custom IDs.
[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 java.io.Serializable;
4
5 import at.ac.tuwien.sbc.valesriegler.common.Util;
6 import at.ac.tuwien.sbc.valesriegler.waiter.jms.JMSWaiter;
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
17         /**
18          * Yes that's funny! the pizza has a field idOfOrder although PizzaOrder
19          * already has a field orderId! The reason: The space linda selection is a
20          * little bit limited. when I look for a template pizza with orderId set the
21          * space gives me ALL pizzas. The reason obviously is that it can't really
22          * include the field of the superclass in the search. So we must have an
23          * idOfOrder field in the pizza and not only in the PizzaOrder for the time
24          * being.. ^^
25          */
26         private Integer idOfOrder;
27
28         // private Person consumer;
29
30         private Pizza(int id, PizzaType type, int cookId, int orderId) {
31                 super(id);
32                 super.setCookId(cookId);
33                 this.id = id;
34                 pizzaType = type;
35                 this.cookId = cookId;
36                 idOfOrder = orderId;
37                 status = PizzaOrderStatus.DONE;
38         }
39
40         public Pizza() {
41                 super();
42         }
43
44         public static Pizza createPizzaFromPizzaOrder(PizzaOrder pizzaorder, int cookId) {
45                 return new Pizza(pizzaorder.getId(), pizzaorder.getPizzaType(), cookId, pizzaorder.getOrderId());
46         }
47
48         @Override
49         public String toString() {
50                 return "Pizza [deliveryAgent=" + deliveryAgent + ", id=" + id + ", orderId=" + orderId + ", pizzaType=" + pizzaType
51                                 + ", status=" + status + ", cookId=" + cookId + "]";
52         }
53
54         @Override
55         public int getOrderId() {
56                 return getIdOfOrder();
57         };
58
59         @Override
60         public void setOrderId(Integer orderId) {
61                 idOfOrder = orderId;
62         };
63
64         public int getIdOfOrder() {
65                 return Util.getIntSafe(idOfOrder);
66         }
67
68         public void setIdOfOrder(Integer idOfOrder) {
69                 this.idOfOrder = idOfOrder;
70         }
71
72 }