Пример #1
0
  public void removeProduct(ProductDTO productDTO) {

    productDAO.setEm(em);

    Product product = em.find(Product.class, productDTO.getId());

    productDAO.removeTop5(product.getId());

    em.remove(product);
  }
Пример #2
0
  public ProductDTO getProductDetailById(Long id) {
    productDAO.setEm(em);
    Product product = em.find(Product.class, id);
    Top5 productTop5 = productDAO.getProductTop5(product.getId());

    ProductDTO productDTO = OMSMapper.mapProduct(product);
    if (productTop5 != null) {
      productDTO.setTop5(OMSMapper.mapTop5(productDAO.getTopProducts(productTop5)));
    }

    return productDTO;
  }
Пример #3
0
  public ProductDTO getProductDetail(Long prodId) {
    productDAO.setEm(em);
    Product product = productDAO.getProduct(prodId);
    Top5 productTop5 = productDAO.getProductTop5(product.getId());

    ProductDTO productDTO = OMSMapper.mapProduct(product);
    if (productTop5 != null) {
      productDTO.setTop5(OMSMapper.mapTop5(productDAO.getTopProducts(productTop5)));
    }

    return productDTO;
  }
Пример #4
0
  public TableResultDTO<ProductDTO> getProductsList(final TableFilterDTO filter) {

    productDAO.setEm(em);
    final TableResultDTO<Product> products = productDAO.getProducts(filter);

    final TableResultDTO<ProductDTO> tableResultDTO = new TableResultDTO<ProductDTO>();
    tableResultDTO.setTotalOfRecords(products.getTotalOfRecords());

    final List<ProductDTO> productDTOs = new ArrayList<ProductDTO>(products.getResult().size());

    for (final Product product : products.getResult()) {
      productDTOs.add(OMSMapper.mapProduct(product));
    }

    tableResultDTO.setResult(productDTOs);

    return tableResultDTO;
  }
Пример #5
0
 public Product getProduct(Long prodId) {
   productDAO.setEm(em);
   Product product = productDAO.getProduct(prodId);
   return product;
 }