From d948af15bd6c72d262da7f15c8bb3e6db4af0b69 Mon Sep 17 00:00:00 2001 From: Jan Vales Date: Sun, 5 May 2013 21:57:16 +0200 Subject: [PATCH] GroupGui should display ordered pizzas correctly again. --- .../valesriegler/group/gui/GroupOverviewModel.java | 12 ++++++++---- .../ac/tuwien/sbc/valesriegler/types/GroupData.java | 2 ++ .../ac/tuwien/sbc/valesriegler/types/PizzaOrder.java | 5 +++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/GroupOverviewModel.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/GroupOverviewModel.java index 9c439c4..4d7e7a8 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/GroupOverviewModel.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/GroupOverviewModel.java @@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory; import at.ac.tuwien.sbc.valesriegler.common.TableModel; import at.ac.tuwien.sbc.valesriegler.group.Group; +import at.ac.tuwien.sbc.valesriegler.types.PizzaOrder; import at.ac.tuwien.sbc.valesriegler.types.PizzaType; public class GroupOverviewModel extends TableModel { @@ -56,7 +57,9 @@ public class GroupOverviewModel extends TableModel { log.info("This is the size : {}", groupSize); return groupSize; case PIZZAS: - return pizzaDisplay(group.getGroupData().getPizzas()); + if (group.getGroupData().getOrder() == null) + return "none"; + return pizzaDisplay(group.getGroupData().getOrder().getOrderedPizzas()); case STATE: return group.getGroupData().getState(); default: @@ -71,9 +74,10 @@ public class GroupOverviewModel extends TableModel { * e.g. Cardinale, Cardinale, Margherita is displayed as * "2xCARDINALE,1xMARGHERITA" */ - private String pizzaDisplay(List pizzas) { + private String pizzaDisplay(List list) { HashMap pizzaCount = new HashMap(); - for (PizzaType pizzaType : pizzas) { + for (PizzaOrder pizzaOrder : list) { + PizzaType pizzaType = pizzaOrder.getPizzaType(); if (pizzaCount.containsKey(pizzaType)) { pizzaCount.put(pizzaType, pizzaCount.get(pizzaType) + 1); } else @@ -85,7 +89,7 @@ public class GroupOverviewModel extends TableModel { boolean multiplePizzas = false; for (PizzaType pizzaType : pizzaTypes) { if (multiplePizzas) - sb.append(","); + sb.append(", "); else multiplePizzas = true; diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/types/GroupData.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/types/GroupData.java index 03d223c..3bb874b 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/types/GroupData.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/types/GroupData.java @@ -47,6 +47,7 @@ public class GroupData implements Serializable { return orderWaiter; } + @Deprecated public List getPizzas() { return pizzas; } @@ -85,6 +86,7 @@ public class GroupData implements Serializable { this.orderWaiter = orderWaiter; } + @Deprecated public void setPizzas(List pizzas) { this.pizzas = pizzas; } diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/types/PizzaOrder.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/types/PizzaOrder.java index 56d94cd..e5a102c 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/types/PizzaOrder.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/types/PizzaOrder.java @@ -30,4 +30,9 @@ public class PizzaOrder implements Serializable { public void setStatus(PizzaOrderStatus status) { this.status = status; } + + @Override + public String toString() { + return "PizzaOrder [id=" + id + ", pizzaType=" + pizzaType + ", status=" + status + "]"; + } } -- 2.43.0