Beispiel #1
0
  @Override
  public DTOBestellung createNewOrder(
      int customerId, int source, List<DTOBestellposition> positions) throws AccessDeniedException {
    checkRole(UserRole.SYSUSER | UserRole.ADMIN);

    fTransaction.beginTransaction();
    try {
      // Save Order
      Bestellung order = new Bestellung();
      order.setQuelle(source);
      order.setPerson1(fPersonRepository.getById(customerId));
      order.setPerson2(fSessionAPI.getAuthenticatedUser());
      order.setBestelldatum(new Date());
      order.setLiefertermin_Ist(new Date());
      order.setLiefertermin_Soll(new Date());
      fOrderRepository.persistObject(order);

      // Save positions
      if (orderProducts(order, positions) == false) {
        fTransaction.rollbackTransaction();
        return null;
      }

      // The DeliveryDate could have been changed by orderProducts.
      fOrderRepository.persistObject(order);

      DTOBestellung dtoBestellung = new DTOBestellung(fOrderRepository.getById(order.getId()));
      fTransaction.commitTransaction();
      return dtoBestellung;
    } catch (Exception exception) {
      fTransaction.rollbackTransaction();
      return null;
    }
  }
Beispiel #2
0
  @Override
  public List<DTOBestellung> getOrders(int... ids) throws AccessDeniedException {
    checkRole(UserRole.SYSUSER | UserRole.ADMIN);

    List<Bestellung> searchList;
    try {
      searchList = fOrderRepository.getOrdersById(ids);
    } catch (IllegalArgumentException exception) {
      searchList = new ArrayList<Bestellung>(0);
    }

    return DTOConverter.convertBestellung(searchList);
  }