示例#1
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());
    }
  }
示例#2
0
  public double getBillOfMaterialPrice(
      String bomPartNumber, int bomRevision, String partNumber, int revision) {
    double price = 0.0;
    try {
      PartKey bomkey = new PartKey();
      bomkey.setPartNumber(bomPartNumber);
      bomkey.setRevision(bomRevision);

      Part bom = em.find(Part.class, bomkey);
      Collection<Part> parts = bom.getParts();
      for (Part part : parts) {
        VendorPart vendorPart = part.getVendorPart();
        price += vendorPart.getPrice();
      }

    } catch (Exception e) {
      throw new EJBException(e.getMessage());
    }
    return price;
  }