示例#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);
  }
示例#2
0
  /**
   * {@inheritDoc}
   *
   * @see edu.hm.lip.pizza.api.communication.request.IOrderService#getPreviousOrderStage(int)
   */
  @Override
  public String getPreviousOrderStage(int id) {
    EntityOrder eOrder = orderDAOBean.read(id);
    List<EntityOrderStage> eOrderStages = eOrder.getStages();
    EntityOrderStage previousStage = OrderStageManager.previous(eOrderStages);

    if (previousStage == null) {
      return null;
    }
    return "{\"previousStage\": " + previousStage.getStage().name() + "}";
  }
示例#3
0
  /**
   * {@inheritDoc}
   *
   * @see edu.hm.lip.pizza.api.communication.request.IOrderService#getNextOrderStage(int)
   */
  @Override
  public String getNextOrderStage(int id) {
    EntityOrder eOrder = orderDAOBean.read(id);
    List<EntityOrderStage> eOrderStages = eOrder.getStages();
    EntityOrderStage nextStage = OrderStageManager.next(eOrderStages);

    if (nextStage == null) {
      return null;
    }
    return "{\"nextStage\": " + nextStage.getStage().name() + "}";
  }
示例#4
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);
  }
示例#5
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);
  }
示例#6
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);
  }