]> git.somenet.org - pub/jan/sbc.git/blob - src/main/java/at/ac/tuwien/sbc/valesriegler/types/Order.java
[XVSM] Waiters, Cooks and Pizzerias can be parameterized with a Space port. Group...
[pub/jan/sbc.git] / src / main / java / at / ac / tuwien / sbc / valesriegler / types / Order.java
1 package at.ac.tuwien.sbc.valesriegler.types;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.List;
6
7 import org.mozartspaces.capi3.Queryable;
8
9 import at.ac.tuwien.sbc.valesriegler.common.HasId;
10 import at.ac.tuwien.sbc.valesriegler.common.Util;
11 import at.ac.tuwien.sbc.valesriegler.group.Group;
12
13 /**
14  * Object denotes a Group's interest in pizzas and the state of the pizzas
15  * themselves.
16  * 
17  * @author jan
18  * 
19  */
20 @Queryable(autoindex = true)
21 public class Order implements Serializable, HasId {
22         private static int idNext = 0;
23         private Integer id;
24         private Integer groupId;
25         private OrderStatus status;
26
27         private List<PizzaOrder> orderedPizzas;
28         private List<Pizza> cookedPizzas;
29
30         // this is necessary so that i can make a xvsm linda selection on it
31         private Integer numberOfPizzas;
32
33         public Order() {
34         }
35
36         public Order(int groupId, List<PizzaOrder> orderedPizzas) {
37         // TODO don't set the id here but let the waiter set it
38                 id = ++idNext;
39                 this.groupId = groupId;
40                 status = OrderStatus.NEW;
41                 this.orderedPizzas = orderedPizzas;
42                 cookedPizzas = new ArrayList<Pizza>();
43         }
44
45         public Order(HasId group, List<PizzaOrder> orderedPizzas) {
46         // TODO don't set the id here but let the waiter set it
47                 id = ++idNext;
48                 groupId = group.getId();
49                 status = OrderStatus.NEW;
50                 this.orderedPizzas = orderedPizzas;
51                 cookedPizzas = new ArrayList<Pizza>();
52         }
53
54         public List<Pizza> getCookedPizzas() {
55                 return cookedPizzas;
56         }
57
58         public int getGroupId() {
59                 return groupId;
60         }
61
62         public int getNumberOfPizzas() {
63                 return Util.getIntSafe(numberOfPizzas);
64         }
65
66         public void setNumberOfPizzas(Integer numberOfPizzas) {
67                 this.numberOfPizzas = numberOfPizzas;
68         }
69
70         public void setId(Integer id) {
71                 this.id = id;
72         }
73
74         @Override
75         public int getId() {
76                 return id;
77         }
78
79         public List<PizzaOrder> getOrderedPizzas() {
80                 return orderedPizzas;
81         }
82
83         public OrderStatus getStatus() {
84                 return status;
85         }
86
87         public void setCookedPizzas(List<Pizza> cookedPizzas) {
88                 this.cookedPizzas = cookedPizzas;
89         }
90
91         public void setGroupId(int groupId) {
92                 this.groupId = groupId;
93         }
94
95         public void setOrderedPizzas(List<PizzaOrder> orderedPizzas) {
96                 this.orderedPizzas = orderedPizzas;
97         }
98
99         public void setStatus(OrderStatus status) {
100                 this.status = status;
101         }
102
103         @Override
104         public String toString() {
105                 return "Order [id=" + id + ", groupId=" + groupId + ", status=" + status + ", orderedPizzas=" + orderedPizzas
106                                 + ", cookedPizzas=" + cookedPizzas + "]";
107         }
108 }