Examples of ProductMedia


Examples of com.google.code.magja.model.product.ProductMedia

   *
   * @param map
   * @return ProductMedia
   */
  private ProductMedia buildProductMedia(Map<String, Object> map) {
    ProductMedia prd_media = new ProductMedia();

    for (Map.Entry<String, Object> att : map.entrySet())
      prd_media.set(att.getKey(), att.getValue());

    if (map.get("types") != null) {
      prd_media.setTypes(new HashSet<ProductMedia.Type>());
      List<String> types = (List<String>) map.get("types");
      for (String type : types)
        prd_media.getTypes().add(
            ProductMedia.Type.getValueOfString(type));
    }

    return prd_media;
  }
View Full Code Here

Examples of com.google.code.magja.model.product.ProductMedia

    if (medias == null)
      return null;

    for (Map<String, Object> media : medias) {
      ProductMedia productMedia = buildProductMedia(media);
      productMedia.setProduct(product);
      result.add(productMedia);
    }

    return result;
  }
View Full Code Here

Examples of com.google.code.magja.model.product.ProductMedia

      image1.setData(data1);

      Set<ProductMedia.Type> types1 = new HashSet<ProductMedia.Type>();
      types1.add(ProductMedia.Type.IMAGE);

      ProductMedia prd_media1 = new ProductMedia();
      prd_media1.setExclude(false);
      prd_media1.setImage(image1);
      prd_media1.setLabel("Image for Product");
      prd_media1.setPosition(1);
      prd_media1.setTypes(types1);

      product.addMedia(prd_media1);

      byte[] data2 = MagjaFileUtils
          .getBytesFromFileURL("http://www.rockstore.com.br/store/catalog/co356_foto.jpg");

      Media image2 = new Media();
      image2.setName("guevara");
      image2.setMime("image/jpeg");
      image2.setData(data2);

      Set<ProductMedia.Type> types2 = new HashSet<ProductMedia.Type>();
      types2.add(ProductMedia.Type.SMALL_IMAGE);

      ProductMedia prd_media2 = new ProductMedia();
      prd_media2.setExclude(true);
      prd_media2.setImage(image2);
      prd_media2.setLabel("Small Image for Product");
      prd_media2.setPosition(2);
      prd_media2.setTypes(types2);

      product.addMedia(prd_media2);

      productService.save(product);
View Full Code Here

Examples of com.google.code.magja.model.product.ProductMedia

      // options for the product media
      Set<ProductMedia.Type> types = new HashSet<ProductMedia.Type>();
      types.add(ProductMedia.Type.IMAGE);

      // finally, creates the product media and persists
      ProductMedia prd_media = new ProductMedia();
      prd_media.setExclude(false);
      prd_media.setImage(image);
      prd_media.setLabel("Testing that");
      prd_media.setPosition(1);
      prd_media.setTypes(types);
      prd_media.setProduct(product);

      service.save(prd_media);

      assertTrue(prd_media.getFile() != null);

      product.addMedia(prd_media);
      file = prd_media.getFile();

    } catch (IOException e1) {
      fail(e1.getMessage());
    } catch (ServiceException e2) {
      fail(e2.getMessage());
View Full Code Here

Examples of com.google.code.magja.model.product.ProductMedia

  public void testDelete() {

    try {

      testSave();
      ProductMedia media = product.getMedias().get(0);
      service.delete(media);

    } catch (ServiceException e) {
      e.printStackTrace();
    }
View Full Code Here

Examples of com.google.code.magja.model.product.ProductMedia

  @Test
  public void testGetByProductAndFile() {
    try {

      testSave();
      ProductMedia media = service.getByProductAndFile(product, file);
      assertTrue("media is null!", media != null);

    } catch (ServiceException e) {
      fail(e.getMessage());
    }
View Full Code Here

Examples of com.google.code.magja.model.product.ProductMedia

 
      Set<ProductMedia.Type> types = new HashSet<ProductMedia.Type>();
      types.add(ProductMedia.Type.IMAGE);
      types.add(ProductMedia.Type.SMALL_IMAGE);
 
      ProductMedia media = new ProductMedia();
      media.setExclude(false);
      media.setImage(image);
      media.setLabel("Image for Product");
      media.setPosition(1);
      media.setTypes(types);
 
      product.addMedia(media);
    } catch(Exception e) {
      System.err.println("fail to add media to product");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.