Ejemplo n.º 1
0
  public ProductDTO createProduct(ProductDTO productDTO) {

    Product product = new Product();
    product.setProdId(productDTO.getProdId());
    product.setName(productDTO.getName());
    product.setDescription(productDTO.getDescription());
    product.setCategory(productDTO.getCategory());
    product.setPrice(productDTO.getPrice());
    product.setProducer(productDTO.getProducer());

    String image_full_url = null;
    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);

      image_full_url = ImagesLoadManager.getInstance().loadRadomImage(false);
    }

    product.setImage_url_full(image_full_url);

    String image_full_thumbl = 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);
      image_full_thumbl = ImagesLoadManager.getInstance().loadRadomImage(true);
    }

    product.setImage_url_thumb(image_full_thumbl);

    em.persist(product);

    return productDTO;
  }
Ejemplo n.º 2
0
  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;
  }