Example #1
0
 public double getOrderPrice(Integer orderId) {
   double price = 0.0;
   try {
     CustomerOrder order = em.find(CustomerOrder.class, orderId);
     price = order.calculateAmmount();
   } catch (Exception e) {
     throw new EJBException(e.getMessage());
   }
   return price;
 }
Example #2
0
 public void adjustOrderDiscount(int adjustment) {
   try {
     List orders = em.createNamedQuery("findAllOrders").getResultList();
     for (Iterator it = orders.iterator(); it.hasNext(); ) {
       CustomerOrder order = (CustomerOrder) it.next();
       int newDiscount = order.getDiscount() + adjustment;
       order.setDiscount((newDiscount > 0) ? newDiscount : 0);
     }
   } catch (Exception e) {
     throw new EJBException(e.getMessage());
   }
 }
Example #3
0
  public void addLineItem(Integer orderId, String partNumber, int revision, int quantity) {
    try {
      CustomerOrder order = em.find(CustomerOrder.class, orderId);
      logger.log(Level.INFO, "Found order ID {0}", orderId);

      PartKey pkey = new PartKey();
      pkey.setPartNumber(partNumber);
      pkey.setRevision(revision);

      Part part = em.find(Part.class, pkey);

      LineItem lineItem = new LineItem(order, quantity, part.getVendorPart());
      order.addLineItem(lineItem);
    } catch (Exception e) {
      logger.log(
          Level.WARNING, "Couldn''t add {0} to order ID {1}.", new Object[] {partNumber, orderId});
      throw new EJBException(e.getMessage());
    }
  }