Esempio n. 1
0
  /**
   * {@inheritDoc}
   *
   * @see
   *     edu.hm.lip.pizza.api.communication.request.IOrderService#create(edu.hm.lip.pizza.api.object.resource.Order)
   */
  @Override
  @Interceptors({OrderActiveMQInterceptor.class, OrderStageMailInterceptor.class})
  public Order create(Order order) {
    EntityOrder eOrder = OrderConverter.convertServiceToEntityOrder(order);
    EntityCustomer eCustomer = customerDAOBean.create(eOrder.getCustomer());
    eOrder.setCustomer(eCustomer);

    int i = 0;
    for (EntityOrderLine eOrderLine : eOrder.getOrderLines()) {
      EntityProductConfiguration eProductConfiguration =
          productConfigurationDAOBean.getProductConfiguration(
              order.getOrderLines().get(i++).getProductId(),
              eOrderLine.getProductConfiguration().getSize());

      eOrderLine.setOrder(eOrder);
      eOrderLine.setProductConfiguration(eProductConfiguration);
    }

    List<EntityOrderStage> stages = new ArrayList<EntityOrderStage>();
    EntityOrderStage eOrderStage = OrderStageManager.firstStage();
    eOrderStage.setOrder(eOrder);
    stages.add(eOrderStage);
    eOrder.setStages(stages);

    eOrder = orderDAOBean.create(eOrder);

    asyncGeoEncoder.doGeoEncoding(eCustomer);

    return OrderConverter.convertEntityToServiceOrder(eOrder);
  }
Esempio n. 2
0
  /**
   * {@inheritDoc}
   *
   * @see edu.hm.lip.pizza.api.communication.request.IOrderService#createPreviousOrderStage(int)
   */
  @Override
  public Order createPreviousOrderStage(int id) {
    EntityOrder eOrder = orderDAOBean.read(id);
    List<EntityOrderStage> eOrderStages = eOrder.getStages();

    EntityOrderStage currentStage = OrderStageManager.current(eOrderStages);
    if (currentStage != null) {
      eOrderStages.remove(currentStage);
      eOrder.setStages(eOrderStages);
      orderDAOBean.update(eOrder);
    }

    return OrderConverter.convertEntityToServiceOrder(eOrder);
  }
Esempio n. 3
0
  /**
   * {@inheritDoc}
   *
   * @see edu.hm.lip.pizza.api.communication.request.IOrderService#createNextOrderStage(int)
   */
  @Override
  @Interceptors({OrderStageMailInterceptor.class, BillingPrintMailInterceptor.class})
  public Order createNextOrderStage(int id) {
    EntityOrder eOrder = orderDAOBean.read(id);
    List<EntityOrderStage> eOrderStages = eOrder.getStages();

    EntityOrderStage nextStage = OrderStageManager.next(eOrderStages);
    if (nextStage != null) {
      nextStage.setOrder(eOrder);
      eOrderStages.add(nextStage);
      orderDAOBean.update(eOrder);
    }

    return OrderConverter.convertEntityToServiceOrder(eOrder);
  }
Esempio n. 4
0
  /**
   * {@inheritDoc}
   *
   * @see edu.hm.lip.pizza.api.communication.request.IOrderService#updateOrderToDelivered(int)
   */
  @Override
  @Interceptors(OrderDeliveredActiveMQInterceptor.class)
  public Order updateOrderToDelivered(int id) {
    EntityOrder eOrder = orderDAOBean.read(id);
    List<EntityOrderStage> eOrderStages = eOrder.getStages();

    EntityOrderStage nextStage = OrderStageManager.next(eOrderStages);
    if (nextStage != null && nextStage.getStage() == Stage.DELIVERED) {
      nextStage.setOrder(eOrder);

      eOrderStages.add(nextStage);

      orderDAOBean.update(eOrder);
    }

    return OrderConverter.convertEntityToServiceOrder(eOrder);
  }
Esempio n. 5
0
 /**
  * {@inheritDoc}
  *
  * @see edu.hm.lip.pizza.api.communication.request.IOrderService#find(int)
  */
 @Override
 public Order find(int id) {
   return OrderConverter.convertEntityToServiceOrder(orderDAOBean.read(id));
 }
Esempio n. 6
0
 /**
  * {@inheritDoc}
  *
  * @see edu.hm.lip.pizza.api.communication.request.IOrderService#findAll()
  */
 @Override
 public List<Order> findAll() {
   return OrderConverter.convertEntityToServiceOrderList(orderDAOBean.readAll());
 }
Esempio n. 7
0
 /**
  * {@inheritDoc}
  *
  * @see edu.hm.lip.pizza.api.communication.request.IOrderService#getUndeliveredOrders()
  */
 @Override
 public List<Order> getUndeliveredOrders() {
   return OrderConverter.convertEntityToServiceOrderList(orderDAOBean.getUndeliveredOrders());
 }