1 package at.ac.tuwien.sbc.valesriegler.group;
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
6 import at.ac.tuwien.sbc.valesriegler.common.HasId;
7 import at.ac.tuwien.sbc.valesriegler.group.actions.DeliveryOrderRequest;
8 import at.ac.tuwien.sbc.valesriegler.group.jms.JMSGroupConnector;
9 import at.ac.tuwien.sbc.valesriegler.types.DeliveryGroupData;
11 public class DeliveryGroup implements Runnable, HasId {
12 private static final Logger log = LoggerFactory.getLogger(DeliveryGroup.class);
13 private static int idNext = 0;
15 private DeliveryGroupData deliveryGroupData;
17 public DeliveryGroup() {
18 deliveryGroupData = new DeliveryGroupData(++idNext);
21 public DeliveryGroup(int id) {
22 deliveryGroupData = new DeliveryGroupData(id);
25 public DeliveryGroupData getDeliveryGroupData() {
26 return deliveryGroupData;
31 return deliveryGroupData.getId();
34 public void setDeliveryGroupData(DeliveryGroupData deliveryGroupData) {
35 this.deliveryGroupData = deliveryGroupData;
40 log.debug("Thread started for:" + this);
42 Thread.sleep((long) (Math.random() * 10000));
43 switch (deliveryGroupData.getDeliveryStatus()) {
45 JMSGroupConnector conn = JMSGroupConnector.getConnector(deliveryGroupData.getPizzeriaId());
46 conn.send(new DeliveryOrderRequest(deliveryGroupData));
50 case IN_PROGRESS :// TODO
58 case DELIVERY_FAILED :
64 } catch (InterruptedException e) {