Exemplo n.º 1
0
  @Override
  public boolean requiresShipping(List<ShoppingCartItem> items, MerchantStore store)
      throws ServiceException {

    boolean requiresShipping = false;
    for (ShoppingCartItem item : items) {
      Product product = item.getProduct();
      if (!product.isProductVirtual() && product.isProductShipeable()) {
        requiresShipping = true;
      }
    }

    return requiresShipping;
  }
  @Override
  public void removeProductImages(Product product) throws ServiceException {

    if (cacheManager.getTreeCache() == null) {
      throw new ServiceException(
          "CmsImageFileManagerInfinispan has a null cacheManager.getTreeCache()");
    }

    try {

      StringBuilder nodePath = new StringBuilder();
      nodePath.append(product.getMerchantStore().getCode());

      Node<String, Object> merchantNode = this.getNode(nodePath.toString());

      merchantNode.remove(product.getSku());

    } catch (Exception e) {
      throw new ServiceException(e);
    } finally {

    }
  }
  @Override
  public List<OutputContentFile> getImages(Product product) throws ServiceException {

    if (cacheManager.getTreeCache() == null) {
      throw new ServiceException(
          "CmsImageFileManagerInfinispan has a null cacheManager.getTreeCache()");
    }

    List<OutputContentFile> images = new ArrayList<OutputContentFile>();

    try {

      FileNameMap fileNameMap = URLConnection.getFileNameMap();
      StringBuilder nodePath = new StringBuilder();
      nodePath.append(product.getMerchantStore().getCode());

      Node<String, Object> merchantNode = this.getNode(nodePath.toString());

      if (merchantNode == null) {
        return null;
      }

      for (String key : merchantNode.getKeys()) {

        byte[] imageBytes = (byte[]) merchantNode.get(key);

        OutputContentFile contentImage = new OutputContentFile();

        InputStream input = new ByteArrayInputStream(imageBytes);
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        IOUtils.copy(input, output);

        String contentType = fileNameMap.getContentTypeFor(key);

        contentImage.setFile(output);
        contentImage.setMimeType(contentType);
        contentImage.setFileName(key);

        images.add(contentImage);
      }

    } catch (Exception e) {
      throw new ServiceException(e);
    } finally {

    }

    return images;
  }
Exemplo n.º 4
0
  @Override
  public List<ProductReview> getByProduct(Product product) {

    QProductReview qEntity = QProductReview.productReview;
    QProductReviewDescription qDescription = QProductReviewDescription.productReviewDescription;
    QProduct qProduct = QProduct.product;

    JPQLQuery query = new JPAQuery(getEntityManager());

    query
        .from(qEntity)
        .join(qEntity.customer)
        .fetch()
        .join(qEntity.product, qProduct)
        .fetch()
        .leftJoin(qProduct.merchantStore)
        .fetch()
        .leftJoin(qEntity.descriptions, qDescription)
        .fetch()
        .where(qProduct.id.eq(product.getId()));

    return query.list(qEntity);
  }