public void addPartToBillOfMaterial( String bomPartNumber, int bomRevision, String partNumber, int revision) { logger.log(Level.INFO, "BOM part number: {0}", bomPartNumber); logger.log(Level.INFO, "BOM revision: {0}", bomRevision); logger.log(Level.INFO, "Part number: {0}", partNumber); logger.log(Level.INFO, "Part revision: {0}", revision); try { PartKey bomKey = new PartKey(); bomKey.setPartNumber(bomPartNumber); bomKey.setRevision(bomRevision); Part bom = em.find(Part.class, bomKey); logger.log(Level.INFO, "BOM Part found: {0}", bom.getPartNumber()); PartKey partKey = new PartKey(); partKey.setPartNumber(partNumber); partKey.setRevision(revision); Part part = em.find(Part.class, partKey); logger.log(Level.INFO, "Part found: {0}", part.getPartNumber()); bom.getParts().add(part); part.setBomPart(bom); } catch (EJBException e) { } }
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; }