Exemplo n.º 1
0
 /**
  * JSP EL Function to get an Image for a Store in a specific format
  *
  * @param store the store
  * @param format the desired image format
  * @return the image
  */
 public static ImageData getImageForStoreAndFormat(
     final PointOfServiceData store, final String format) {
   if (store != null && format != null) {
     final Collection<ImageData> images = store.getStoreImages();
     if (images != null && !images.isEmpty()) {
       for (final ImageData image : images) {
         if (format.equals(image.getFormat())) {
           return image;
         }
       }
     }
   }
   return null;
 }
Exemplo n.º 2
0
 /**
  * JSP EL Function to get a primary Image for a Product in a specific format
  *
  * @param product the product
  * @param format the desired format
  * @return the image
  */
 public static ImageData getPrimaryImageForProductAndFormat(
     final ProductData product, final String format) {
   if (product != null && format != null) {
     final Collection<ImageData> images = product.getImages();
     if (images != null && !images.isEmpty()) {
       for (final ImageData image : images) {
         if (ImageDataType.PRIMARY.equals(image.getImageType())
             && format.equals(image.getFormat())) {
           return image;
         }
       }
     }
   }
   return null;
 }
 /**
  * Populating images for container
  *
  * @param source
  * @param target
  */
 protected void populateImages(
     final MediaContainerModel source,
     final List<ImageData> target,
     final ImageDataType imageType) {
   if (source != null) {
     final Collection<MediaModel> mediaModels = source.getMedias();
     if (CollectionUtils.isNotEmpty(mediaModels)) {
       for (final MediaModel media : mediaModels) {
         if (media != null) {
           final ImageData imageData = getImageConverter().convert(media);
           imageData.setImageType(imageType);
           target.add(imageData);
         }
       }
       sortMediasBasedOnWidth(target);
     } else {
       LOG.info("No medias found for this media container.");
     }
   }
 }