Example #1
0
  public void createVendorPart(
      String partNumber, int revision, String description, double price, int vendorId) {
    try {
      PartKey pkey = new PartKey();
      pkey.setPartNumber(partNumber);
      pkey.setRevision(revision);

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

      VendorPart vendorPart = new VendorPart(description, price, part);
      em.persist(vendorPart);

      Vendor vendor = em.find(Vendor.class, vendorId);
      vendor.addVendorPart(vendorPart);
      vendorPart.setVendor(vendor);
    } catch (Exception e) {
      throw new EJBException(e.getMessage());
    }
  }
Example #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;
  }