public static void showGallery(Long id, String name) {
    notFoundIfNull(id);
    Gallery gallery = Gallery.findById(id);
    notFoundIfNull(gallery);

    List<Picture> pictures = gallery.getPictures();
    List<ImageView> images = new ArrayList<ImageView>();
    for (Picture picture : pictures) images.add(picture.toImageView());

    render("Application/gallery.html", images, gallery);
  }
Exemple #2
0
  public static void savePicture(File[] files, String milliTime) throws IOException {

    for (int i = 0; i < files.length; i++) {

      String filename = milliTime + "-" + files[i].getName();
      UploadImg fileToUpload = new UploadImg(files[i], filename);
      fileToUpload.upload("");
      CropImg fileToCrop = new CropImg(files[i], filename);
      UploadImg uploadCroppedImg = new UploadImg(fileToCrop.cropAsSquare(), filename);
      uploadCroppedImg.upload("square/");
      double ratio = fileToUpload.calculateAspectRatio();
      Picture pic = new Picture(filename, ratio);
      pic.save();
    }
  }
 public static void resized(Long galleryId, Long pictureId) {
   File picture = Picture.getFile(galleryId, pictureId, Application.RESIZED);
   if (!picture.exists()) notFound();
   renderBinary(picture);
 }
 public static void thumbnail(Long galleryId, Long pictureId) {
   File picture = Picture.getFile(galleryId, pictureId, Application.THUMBNAILS);
   if (!picture.exists()) notFound();
   renderBinary(picture);
 }
Exemple #5
0
  public static void savePictureData(
      String url,
      String styles,
      String colors,
      String length,
      String brands,
      String salonKey,
      String stylistUsername,
      String userUsername) {

    Picture pic = Picture.read(url);

    pic.styles = Tag.convertStringListToTagList(Arrays.asList(styles.split("\\s*,\\s*")));
    pic.colors = Tag.convertStringListToTagList(Arrays.asList(colors.split("\\s*,\\s*")));
    pic.length = Tag.convertStringListToTagList(Arrays.asList(length.split("\\s*,\\s*")));
    pic.brands = Tag.convertStringListToTagList(Arrays.asList(brands.split("\\s*,\\s*")));

    pic.salon = Salon.read(salonKey);
    pic.stylist = Stylist.readByUsername(stylistUsername);
    pic.user = User.read(userUsername);

    pic.salonKey = salonKey;
    pic.stylistUsername = stylistUsername;
    pic.userUsername = userUsername;

    pic.save();
  }