From: Gregor Riegler Date: Mon, 10 Jun 2013 15:23:56 +0000 (+0200) Subject: Merge branch 'master' of https://bitbucket.org/rgregor/sbc-ss-2013 X-Git-Url: https://git.somenet.org/pub/jan/sbc.git/commitdiff_plain/f123654e1d0eb313fe45af118a1af33a0507e42f?hp=e26430af9c2a1e0e891dfaa635656d124907c945 Merge branch 'master' of https://bitbucket.org/rgregor/sbc-ss-2013 Conflicts: src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/DeliveryOverviewModel.java --- diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java index fe89716..2f8b153 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java @@ -1,16 +1,5 @@ package at.ac.tuwien.sbc.valesriegler.group; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.swing.SwingUtilities; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.group.gui.DeliveryOverviewModel; import at.ac.tuwien.sbc.valesriegler.group.gui.GroupCreationDetailsRequest; @@ -22,6 +11,11 @@ import at.ac.tuwien.sbc.valesriegler.types.GroupData; import at.ac.tuwien.sbc.valesriegler.types.Order; import at.ac.tuwien.sbc.valesriegler.types.PizzaType; import at.ac.tuwien.sbc.valesriegler.xvsm.GroupAgentXVSM; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.util.*; /** * The Main class of the Group component. @@ -67,7 +61,7 @@ public class GroupAgent { } groupAgent = new GroupAgent(); - if (!Util.runSimulation) { + if (! Util.runSimulation) { groupGui = new GroupGUI(); SwingUtilities.invokeLater(groupGui); } diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/DeliveryOverviewModel.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/DeliveryOverviewModel.java index e91b45f..8bce9d4 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/DeliveryOverviewModel.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/DeliveryOverviewModel.java @@ -1,132 +1,104 @@ package at.ac.tuwien.sbc.valesriegler.group.gui; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import at.ac.tuwien.sbc.valesriegler.common.TableModel; import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.group.DeliveryGroup; import at.ac.tuwien.sbc.valesriegler.types.DeliveryGroupData; import at.ac.tuwien.sbc.valesriegler.types.DeliveryStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -public class DeliveryOverviewModel extends TableModel { - private static final Logger log = LoggerFactory.getLogger(GroupOverviewModel.class); - - private static final String STATE = "State"; - private static final String PIZZAS = "Pizzas"; - private static final String ADDRESS = "Address"; - private static final String ID = "ID"; - private static final String PIZZERIA = "Pizzeria"; - private static final String[] COLUMNS = new String[]{ID, ADDRESS, PIZZAS, STATE, PIZZERIA}; - - @Override - protected String[] getColumns() { - return COLUMNS; - } - - @Override - public void addItems(List newItems) { - log.info("addItems()"); - super.addItems(newItems); - for (DeliveryGroup g : newItems) { - if (Util.useJMS) - g.orderSomeFood(); - } - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - List values = new ArrayList<>(items.values()); - DeliveryGroup group = values.get(rowIndex); - String wantedColumn = COLUMNS[columnIndex]; - switch (wantedColumn) { - case ID : - int groupId = group.getId(); - return groupId; - case ADDRESS : - return group.getDeliveryGroupData().getAddress(); - case PIZZAS : - if (group.getDeliveryGroupData().getOrder() == null) - return "none"; - return Util.pizzaDisplay(group.getDeliveryGroupData().getOrder().getOrderedPizzas()); - case STATE : - return group.getDeliveryGroupData().getDeliveryStatus(); - case PIZZERIA : - return group.getDeliveryGroupData().getPizzeriaId(); - default : - throw new RuntimeException(UNHANDLEDCOLUMN); - } - } - - public void setOrdersTaken(List groups) { - for (DeliveryGroupData group : groups) { - changeStateOfGroup(group.getId(), DeliveryStatus.ORDERED); - } - - fireTableDataChanged(); - } - - private void changeStateOfGroup(int groupId, DeliveryStatus state) { - items.get(groupId).getDeliveryGroupData().setDeliveryStatus(state); - } - - public void setOrdersDelivered(List groups) { - for (DeliveryGroupData group : groups) { - changeStateOfGroup(group.getId(), group.getDeliveryStatus()); - } - - fireTableDataChanged(); - } - - public void addDeliveries(List groups) { - synchronized (items) { - for (DeliveryGroupData group : groups) { - final DeliveryGroup deliveryGroup = items.get(group.getId()); - if (deliveryGroup == null) { - log.error("Delivery group not found!!!"); - } - deliveryGroup.setDeliveryGroupData(group); - } - } - fireTableDataChanged(); - } - - public void createStatistics() { - int size; - int finished; - synchronized (items) { - final Collection values = items.values(); - size = values.size(); - finished = 0; - for (DeliveryGroup group : values) { - final DeliveryStatus status = group.getDeliveryGroupData().getDeliveryStatus(); - if (status == DeliveryStatus.DELIVERED || status == DeliveryStatus.DELIVERY_FAILED) { - finished++; - } - } - } - log.info("{} deliveries were ordered", size); - log.info("{} were finished", finished); - } +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; - public boolean hasFinished() { - int size; - int finished; - synchronized (items) { - final Collection values = items.values(); - size = values.size(); - finished = 0; - for (DeliveryGroup group : values) { - final DeliveryStatus status = group.getDeliveryGroupData().getDeliveryStatus(); - if (status == DeliveryStatus.DELIVERED || status == DeliveryStatus.DELIVERY_FAILED) { - finished++; - } - } - } - return size == finished; - } +public class DeliveryOverviewModel extends TableModel { + private static final Logger log = LoggerFactory.getLogger(GroupOverviewModel.class); + + private static final String STATE = "State"; + private static final String PIZZAS = "Pizzas"; + private static final String ADDRESS = "Address"; + private static final String ID = "ID"; + private static final String PIZZERIA = "Pizzeria"; + private static final String[] COLUMNS = new String[]{ID, ADDRESS, PIZZAS, STATE, PIZZERIA}; + + + @Override + protected String[] getColumns() { + return COLUMNS; + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + List values = new ArrayList<>(items.values()); + DeliveryGroup group = values.get(rowIndex); + String wantedColumn = COLUMNS[columnIndex]; + switch (wantedColumn) { + case ID: + int groupId = group.getId(); + return groupId; + case ADDRESS: + return group.getDeliveryGroupData().getAddress(); + case PIZZAS: + if (group.getDeliveryGroupData().getOrder() == null) + return "none"; + return Util.pizzaDisplay(group.getDeliveryGroupData().getOrder().getOrderedPizzas()); + case STATE: + return group.getDeliveryGroupData().getDeliveryStatus(); + case PIZZERIA: + return group.getDeliveryGroupData().getPizzeriaId(); + default: + throw new RuntimeException(UNHANDLEDCOLUMN); + } + } + + public void addDeliveries(List groups) { + synchronized (items) { + for (DeliveryGroupData group : groups) { + final DeliveryGroup deliveryGroup = items.get(group.getId()); + if(deliveryGroup==null) { + log.error("Delivery group not found: {}", group.getId()); + } + else deliveryGroup.setDeliveryGroupData(group); + } + } + fireTableDataChanged(); + } + + public void createStatistics() { + int size; + int finished; + synchronized (items) { + final Collection values = items.values(); + size = values.size(); + finished = 0; + for (DeliveryGroup group : values) { + final DeliveryStatus status = group.getDeliveryGroupData().getDeliveryStatus(); + if (status == DeliveryStatus.DELIVERED || status == DeliveryStatus.DELIVERY_FAILED) { + finished++; + } + } + } + log.info("{} deliveries were ordered", size); + log.info("{} were finished", finished); + } + + public boolean hasFinished() { + int size; + int finished; + synchronized (items) { + final Collection values = items.values(); + size = values.size(); + finished = 0; + for (DeliveryGroup group : values) { + final DeliveryStatus status = group.getDeliveryGroupData().getDeliveryStatus(); + if (status == DeliveryStatus.DELIVERED || status == DeliveryStatus.DELIVERY_FAILED) { + finished++; + } + } + } + final boolean result = size == finished; + return result; + } } 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 fcdfcc5..a321dff 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 @@ -47,7 +47,18 @@ public class GroupOverviewModel extends TableModel { @Override public Object getValueAt(int rowIndex, int columnIndex) { List values = new ArrayList<>(items.values()); - Group group = values.get(rowIndex); + // TODO make sure this is necessary... +// Collections.sort(values, new Comparator() { +// @Override +// public int compare(Group o1, Group o2) { +// final int o1Id = o1.getId(); +// final int o2Id = o2.getId(); +// if(o1Ido2Id) return 1; +// else return 0; +// } +// }); + Group group = values.get(rowIndex); String wantedColumn = COLUMNS[columnIndex]; switch (wantedColumn) { case ID: diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/PizzeriaAgent.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/PizzeriaAgent.java index 3e8c4d8..87a416c 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/PizzeriaAgent.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/PizzeriaAgent.java @@ -1,27 +1,19 @@ package at.ac.tuwien.sbc.valesriegler.pizzeria; -import java.util.List; - -import javax.swing.SwingUtilities; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.jms.nac.JMSNAC; import at.ac.tuwien.sbc.valesriegler.pizzeria.actions.TableNew; import at.ac.tuwien.sbc.valesriegler.pizzeria.gui.PizzeriaFrame; -import at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels.DeliveryDetailsModel; -import at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels.DeliveryOrdersModel; -import at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels.GroupsOverviewModel; -import at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels.OrdersOverviewModel; -import at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels.PizzasOfOrderModel; -import at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels.TablesOverviewModel; -import at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels.WaitersOfOrderModel; +import at.ac.tuwien.sbc.valesriegler.pizzeria.gui.tablemodels.*; import at.ac.tuwien.sbc.valesriegler.pizzeria.jms.JMSPizzeriaConnector; import at.ac.tuwien.sbc.valesriegler.pizzeria.jms.PizzeriaJMSNACMsgListener; import at.ac.tuwien.sbc.valesriegler.types.Table; import at.ac.tuwien.sbc.valesriegler.xvsm.PizzeriaAgentXVSM; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.swing.*; +import java.util.List; /** * The Main class of the Pizzeria compoment. @@ -61,7 +53,7 @@ public class PizzeriaAgent { case "XVSM" : pizzeriaAgent.createModels(); pizzeriaAgent.initXVSM(args[1]); - if (!Util.runSimulation) { + if (! Util.runSimulation) { pizzeriaAgent.initGUI(); } Util.useJMS = false; diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/tablemodels/DeliveryOrdersModel.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/tablemodels/DeliveryOrdersModel.java index c6bed84..336bfd3 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/tablemodels/DeliveryOrdersModel.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/tablemodels/DeliveryOrdersModel.java @@ -6,6 +6,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; public class DeliveryOrdersModel extends AbstractOrdersModel { @@ -28,6 +30,23 @@ public class DeliveryOrdersModel extends AbstractOrdersModel @Override public Object getValueAt(int rowIndex, int columnIndex) { List values = new ArrayList<>(items.values()); + // TODO: make sure that is necessary + Collections.sort(values, new Comparator() { + @Override + public int compare(DeliveryGroupData o1, DeliveryGroupData o2) { + final int o1Id = o1.getOrder().getId(); + final int o2Id = o2.getOrder().getId(); + if(o1Id==0) { + if(o2Id>0) return 1; + } + if(o2Id==0) { + if(o1Id>0) return 1; + } + if (o1Id < o2Id) return -1; + else if (o1Id > o2Id) return 1; + else return 0; + } + }); DeliveryGroupData group = values.get(rowIndex); Order order = group.getOrder(); String wantedColumn = COLUMNS[columnIndex]; diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/tablemodels/GroupsOverviewModel.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/tablemodels/GroupsOverviewModel.java index 26b2ef4..142e14f 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/tablemodels/GroupsOverviewModel.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/tablemodels/GroupsOverviewModel.java @@ -7,6 +7,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; public class GroupsOverviewModel extends TableModel { @@ -26,6 +28,23 @@ public class GroupsOverviewModel extends TableModel { public Object getValueAt(int rowIndex, int columnIndex) { List values = new ArrayList<>(items.values()); + // TODO: make sure that is necessary + Collections.sort(values, new Comparator() { + @Override + public int compare(GroupData o1, GroupData o2) { + final int o1Id = o1.getOrder().getId(); + final int o2Id = o2.getOrder().getId(); + if (o1Id == 0) { + if (o2Id > 0) return 1; + } + if (o2Id == 0) { + if (o1Id > 0) return 1; + } + if (o1Id < o2Id) return -1; + else if (o1Id > o2Id) return 1; + else return 0; + } + }); GroupData group = values.get(rowIndex); String wantedColumn = COLUMNS[columnIndex]; switch (wantedColumn) { diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/types/Order.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/types/Order.java index 687d84b..a463957 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/types/Order.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/types/Order.java @@ -1,14 +1,13 @@ package at.ac.tuwien.sbc.valesriegler.types; +import at.ac.tuwien.sbc.valesriegler.common.HasId; +import at.ac.tuwien.sbc.valesriegler.common.Util; +import org.mozartspaces.capi3.Queryable; + import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import org.mozartspaces.capi3.Queryable; - -import at.ac.tuwien.sbc.valesriegler.common.HasId; -import at.ac.tuwien.sbc.valesriegler.common.Util; - /** * Object denotes a Group's interest in pizzas and the state of the pizzas * themselves. @@ -79,7 +78,7 @@ public class Order implements Serializable, HasId { @Override public int getId() { - return id; + return Util.getIntSafe(id); } public List getOrderedPizzas() { diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java index 343b278..349b059 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java @@ -10,6 +10,7 @@ import at.ac.tuwien.sbc.valesriegler.types.Pizza; import at.ac.tuwien.sbc.valesriegler.xvsm.spacehelpers.SpaceAction; import org.mozartspaces.core.ContainerReference; import org.mozartspaces.core.MzsConstants; +import org.mozartspaces.core.MzsCoreException; import org.mozartspaces.core.TransactionReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,64 +43,68 @@ public class DriverXVSM extends AbstractXVSMConnector { @Override public void onEntriesWritten(List entries) throws Exception { - final List deliveries = castEntries(entries); + handleDeliveries(entries); - for (DeliveryGroupData delivery : deliveries) { - DeliveryGroupData template = new DeliveryGroupData(delivery.getId()); - template.setDeliveryStatus(DeliveryStatus.ORDERED); + } + }).createSpaceListenerImpl(); + } - final TransactionReference tx = capi.createTransaction( - 7000, - URI.create(String.format(Util.SERVER_ADDR, port))); - final String error = "Another driver wants to deliver this order!"; + private void handleDeliveries(List entries) throws MzsCoreException { + final List deliveries = castEntries(entries); - try { - // Get lock for delivering this delivery order - final DeliveryGroupData deliveryGroup = takeMatchingEntity(template, deliverDeliveryOrderContainer, tx, MzsConstants.RequestTimeout.DEFAULT, error); - final DeliveryGroupData group = takeMatchingEntity(template, pizzeriaDeliveryContainer, tx, MzsConstants.RequestTimeout.INFINITE, "Cannot get the delivery order!"); - group.setDriverId(driverId); - group.setDeliveryStatus(DeliveryStatus.IN_PROGRESS); + for (DeliveryGroupData delivery : deliveries) { + DeliveryGroupData template = new DeliveryGroupData(delivery.getId()); + template.setDeliveryStatus(DeliveryStatus.ORDERED); - final List groups = Arrays.asList(group); -// sendItemsToContainer(groups, -// pizzeriaDeliveryContainer, MzsConstants.RequestTimeout.ZERO, null); + final TransactionReference tx = capi.createTransaction( + 7000, + URI.create(String.format(Util.SERVER_ADDR, port))); + final String error = "Another driver wants to deliver this order!"; - if (!Util.runSimulation) { - Thread.sleep(3000); - } + try { + // Get lock for delivering this delivery order + final DeliveryGroupData deliveryGroup = takeMatchingEntity(template, deliverDeliveryOrderContainer, tx, MzsConstants.RequestTimeout.DEFAULT, error); + final DeliveryGroupData group = takeMatchingEntity(template, pizzeriaDeliveryContainer, tx, MzsConstants.RequestTimeout.INFINITE, "Cannot get the delivery order!"); + group.setDriverId(driverId); + group.setDeliveryStatus(DeliveryStatus.IN_PROGRESS); - final String address = String.format(Util.SERVER_ADDR, Util.DELIVERY_CUSTOMERS_PORT); - ContainerReference cref = null; - boolean success = false; - try { - cref = capi.lookupContainer(group.getAddress(), URI.create(address), MzsConstants.RequestTimeout.ZERO, null); - log.debug("Looked up container {} successfully!", address); - success = true; + final List groups = Arrays.asList(group); +// sendItemsToContainer(groups, +// pizzeriaDeliveryContainer, MzsConstants.RequestTimeout.ZERO, null); - } catch (Exception ex) { - log.info("Could not find container {}", address); - } - if (success) { - group.setDeliveryStatus(DeliveryStatus.DELIVERED); - if (!Util.runSimulation) { - sendItemsToContainer(Arrays.asList(new Bill(1000, group.getId())), cref, MzsConstants.RequestTimeout.DEFAULT, null); - } - } else { - group.setDeliveryStatus(DeliveryStatus.DELIVERY_FAILED); - } - sendItemsToContainer(groups, pizzeriaDeliveryContainer, MzsConstants.RequestTimeout.DEFAULT, tx); - capi.commitTransaction(tx); + if (!Util.runSimulation) { + Thread.sleep(3000); + } + final String address = String.format(Util.SERVER_ADDR, Util.DELIVERY_CUSTOMERS_PORT); + ContainerReference cref = null; + boolean success = false; + try { + cref = capi.lookupContainer(group.getAddress(), URI.create(address), MzsConstants.RequestTimeout.ZERO, null); + log.debug("Looked up container {} successfully!", address); + success = true; - } catch (Exception e) { - log.info("DRiverXVSM exception"); - log.info(e.getMessage()); - e.printStackTrace(); + } catch (Exception ex) { + log.info("Could not find container {}", address); + } + if (success) { + group.setDeliveryStatus(DeliveryStatus.DELIVERED); + if (!Util.runSimulation) { + sendItemsToContainer(Arrays.asList(new Bill(1000, group.getId())), cref, MzsConstants.RequestTimeout.DEFAULT, null); } + } else { + group.setDeliveryStatus(DeliveryStatus.DELIVERY_FAILED); } + sendItemsToContainer(groups, pizzeriaDeliveryContainer, MzsConstants.RequestTimeout.DEFAULT, tx); + capi.commitTransaction(tx); + + } catch (Exception e) { + log.info("DRiverXVSM exception"); + log.info(e.getMessage()); + e.printStackTrace(); } - }).createSpaceListenerImpl(); + } } public void listenForPreparedDeliveryPizzas() { @@ -143,6 +148,7 @@ public class DriverXVSM extends AbstractXVSMConnector { tx); capi.commitTransaction(tx); + handleDeliveries(groupsWithCompleteOrder); } else { log.info("Not yet all pizzas prepared! Order with id " + orderId + " has " + numberOfPizzas diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/GroupAgentXVSM.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/GroupAgentXVSM.java index c2a829f..c42b0a2 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/GroupAgentXVSM.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/GroupAgentXVSM.java @@ -83,7 +83,7 @@ public class GroupAgentXVSM extends AbstractXVSMConnector { boolean finished = GroupAgent.getInstance().getDeliveryModel().hasFinished(); if (finished) { final long now = new Date().getTime(); - final long difference = startTime.get() - now; + final long difference = now - startTime.get(); log.info("Finished after {} seconds", difference / 1000); } } @@ -126,20 +126,20 @@ public class GroupAgentXVSM extends AbstractXVSMConnector { List pizzaTypes2 = Arrays.asList(PizzaType.CARDINALE, PizzaType.SALAMI, PizzaType.MARGHERITA); List pizzaTypes3 = Arrays.asList(PizzaType.SALAMI, PizzaType.MARGHERITA); - final String pizzeria1 = "9875"; - final String pizzeria2 = "9874"; + final String pizzeria1 = "9874"; + final String pizzeria2 = "9875"; List groups1 = GroupAgent.getInstance().createGroups(pizzaTypes1, pizzeria1, 4); List groups2 = GroupAgent.getInstance().createGroups(pizzaTypes2, pizzeria2, 3); List groups3 = GroupAgent.getInstance().createGroups(pizzaTypes3, pizzeria2, 2); final DeliveryOverviewModel deliveryModel = GroupAgent.getInstance().getDeliveryModel(); - deliveryModel.addItems(groups1); +// deliveryModel.addItems(groups1); deliveryModel.addItems(groups2); deliveryModel.addItems(groups3); GroupAgent.getInstance().onDeliveryGroupsCreated(groups2); GroupAgent.getInstance().onDeliveryGroupsCreated(groups3); - GroupAgent.getInstance().onDeliveryGroupsCreated(groups1); +// GroupAgent.getInstance().onDeliveryGroupsCreated(groups1); log.info("ATTENTION: Now let's wait 60 seconds!");