public ProductDTO updateProduct(ProductDTO productDTO) { Product product = em.find(Product.class, productDTO.getId()); product.setProdId(productDTO.getProdId()); product.setName(productDTO.getName()); product.setDescription(productDTO.getDescription()); product.setCategory(productDTO.getCategory()); product.setPrice(productDTO.getPrice()); product.setProducer(productDTO.getProducer()); if (productDTO.getImage_full_bytes() != null && productDTO.getImage_full_bytes().length > 0) { // image_full_url = ImagesLoadManager.getInstance().uploadJPG( // productDTO.getImage_full_bytes(), // productDTO.getName() + FULL_IMG_PREFIX); String image_full_url = ImagesLoadManager.getInstance().loadRadomImage(false); productDTO.setImage_url_full(image_full_url); productDTO.setImage_full_bytes(null); } if (productDTO.getImage_thumb_bytes() != null && productDTO.getImage_thumb_bytes().length > 0) { // image_full_thumbl = // ImagesLoadManager.getInstance().uploadJPG(productDTO.getImage_thumb_bytes(), // productDTO.getName()+THUMB_IMG_PREFIX); String image_full_thumbl = ImagesLoadManager.getInstance().loadRadomImage(true); product.setImage_url_thumb(image_full_thumbl); productDTO.setImage_thumb_bytes(null); } return productDTO; }
public void removeProduct(ProductDTO productDTO) { productDAO.setEm(em); Product product = em.find(Product.class, productDTO.getId()); productDAO.removeTop5(product.getId()); em.remove(product); }