Package it.hotel.model.photo

Examples of it.hotel.model.photo.Photo


    int widthUrl      = -1;
    Gallery gallery     = null;
    String namePhoto     = null;
    String baseUrlPhoto    = null;
   
    Photo photo = (Photo) command;
 
    if (photo.getImage().length != 0){
      image=Toolkit.getDefaultToolkit().createImage(photo.getImage());
     
      int h=image.getHeight(null);
      int w=image.getWidth(null);
     
      
      long startTime = System.currentTimeMillis();
       int numberPhoto=Toolkit.getDefaultToolkit().checkImage(image, w, h,null );
      while(h==-1 || w==-1 || (numberPhoto < 8) )
      {
         h=image.getHeight(null);
         w=image.getWidth(null);
         numberPhoto=Toolkit.getDefaultToolkit().checkImage(image, w, h,null );
         long endTime = System.currentTimeMillis();
         if((endTime-startTime)>3000){
           h=100;
           w=100;
           numberPhoto=100;
         }
      }
   
    HttpSession session = null;
    session = request.getSession();
    ServletContext context = session.getServletContext();
    String path = context.getRealPath("/");
    namePhoto = java.util.UUID.randomUUID().toString();
    photo.setName(namePhoto);
    User user = userContainer.getUser();
    int hotelId = user.getStructureId();
    Structure hotel = (Structure) structureManager.get(hotelId);
    ImageUtils.upload(namePhoto, path, image, hotelId, hotelId, 400, 400, "big");
    baseUrlPhoto =ImageUtils.upload(namePhoto, path, image, hotelId, hotelId, 50, 50, "small");
    photo.setUrl(baseUrlPhoto);
    photo.setGallery(hotel.getGallery());
   
    String locale = localeContainer.getLocale();
   
    String photoLocale = (String) request.getParameter("locale");
   
    if (!photoLocale.isEmpty())
    {
      photo.setLocale(photoLocale);
    }
    else
    {
      photo.setLocale(locale);
    }
   
    localeContainer.setLocale(photo.getLocale());
   
    photoManager.add(photo);
   
    localeContainer.setLocale(locale);
   
View Full Code Here


   * @param resp
   * @return
   */
  public ModelAndView delete(HttpServletRequest req, HttpServletResponse resp) {
    String id = req.getParameter("id");
    Photo photo = (Photo)photoManager.get(Integer.parseInt(id));
    photoManager.remove(Integer.parseInt(id));
    HttpSession session = null;
    session = req.getSession();
    ServletContext context = session.getServletContext();
    String path = context.getRealPath("/");
    DirectoryUtils.deleteFile(path + photo.getUrl() + "/small/" + photo.getName() + ".jpeg");
    DirectoryUtils.deleteFile(path + photo.getUrl() + "/big/" + photo.getName() + ".jpeg");
    return new ModelAndView("redirect:/photo/new.htm");
    }
View Full Code Here

    allFacilities.add(f1);
    allFacilities.add(f2);
    return allFacilities;
  }
  public  List<Photo> getAllPhotos(){
    Photo p1 = new Photo();
    p1.setId(1);
    p1.setDescription("Description1");
    Photo p2 = new Photo ();
    p2.setId(2);
    p2.setDescription("DEscription2");
    List<Photo> allPhotos = new ArrayList<Photo> ();
    allPhotos.add(p1);
    allPhotos.add(p2);
    return allPhotos;
  }
View Full Code Here

    if (id != null){
      if (locale != null){
        localeContainer.setLocale(locale);
      }
      Photo photo = (Photo) photoManager.get(Integer.parseInt(id));
      if (locale != null){
        photo.setLocale(locale);
      }
      else{
        photo.setLocale(oldLocale);
      }
      localeContainer.setLocale(oldLocale);
      ModelAndView mav = new ModelAndView("hotel.photo.new");;
      Gallery gallery = (Gallery)galleryManager.get(photo.getGallery().getId());
      mav.addObject("photo", photo);
      mav.addObject("photos", gallery.getPhotos());
      return mav;
    }
    return new ModelAndView("redirect:/photo/new.htm");   
View Full Code Here

    String locale = req.getParameter("locale");
    if (id != null){
      if (locale != null){
        localeContainer.setLocale(locale);
      }
      Photo photo = (Photo)photoManager.get(Integer.parseInt(id));
      photo.setDescription(description);
      photoManager.add(photo);
      localeContainer.setLocale(oldLocale);
      return new ModelAndView("redirect:/photo/new.htm");
    }
    return new ModelAndView("redirect:/photo/new.htm")
View Full Code Here

  private Photo photo;
 
 
    public void setUpPhoto() {
   
    photo = new Photo();
    Gallery gallery = new Gallery ();
    photo.setGallery(gallery);
   
   
  }
View Full Code Here

 
  /**
   * @param
   */
  public void validate(Object command, Errors errors) {
    Photo istance= (Photo) command;
      checkFormartImageFile(istance.getImage(), "image", errors);
  }
View Full Code Here

  protected IPhotoManager photoRawManager;
  protected Photo photo1, photo2;
 
    public Collection<Photo> setUpPhotos() {
   
      photo1 = new Photo();
    photo1.setDescription("description");

   
    photo2 = new Photo();
    photo2.setDescription("description");

   
    Set<Photo> photos = new HashSet<Photo>();
    photos.add(photo1);
View Full Code Here

 
 
  public Photo setUpPhotos() {


    Photo photo = new Photo();
    Gallery gallery = new Gallery ();
    galleryRawManager.add(gallery);
    photo.setDescription("description");
    photo.setGallery(gallery);
    return photo;
       
  }
View Full Code Here

       
  }
 
  public void testDeletePhoto() {
   
    Photo photo = setUpPhotos();
    Gallery gallery = new Gallery();
   
    galleryRawManager.add(gallery);
   
    photo.setGallery(gallery);
   
    gallery.addNewPhoto(photo);
   
    photoRawManager.add(photo);
   
    Collection<Photo> photos = photoRawManager.getAll();
   
    assertNotNull(photos);
   
    gallery.deletePhoto(photo);
   
    photoRawManager.remove(photo.getId());
 
    photos = photoRawManager.getAll();
   
    assertTrue(photos.isEmpty());
     
View Full Code Here

TOP

Related Classes of it.hotel.model.photo.Photo

Copyright © 2018 www.massapicom. 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.