Package info.galleria.domain

Examples of info.galleria.domain.Photo


  {
    //Setup
    Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    user.addToAlbums(album);
    Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT);
    photo.setUploadTime(new Date());
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.addToPhotos(photo);
      }
    }
    em.persist(user);
    long albumId = album.getAlbumId();
    long photoId = photo.getPhotoId();
   
    em.flush();
    em.clear();
   
    //Execute
    user.removeFromAlbums(album);
    user = repository.modify(user);
    em.flush();
    em.clear();
   
    //Verify
    User actualUser = em.find(User.class, TEST_USER_ID);
    Album actualAlbum =  em.find(Album.class, albumId);
    Photo actualPhoto =  em.find(Photo.class, photoId);
    assertEquals(user, actualUser);
    assertFalse(actualUser.getAlbums().contains(album));
    assertNull(actualAlbum);
    assertNull(actualPhoto);
  }
View Full Code Here


   
    em.flush();
    em.clear();
   
    //Execute
    Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT);
    photo.setUploadTime(new Date());
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.addToPhotos(photo);
View Full Code Here

  {
    //Setup
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
    user.addToAlbums(album);
    Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT);
    photo.setUploadTime(new Date());
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.addToPhotos(photo);
View Full Code Here

  {
    //Setup
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
    user.addToAlbums(album);
    Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT);
    photo.setUploadTime(new Date());
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.addToPhotos(photo);
View Full Code Here

  {
    //Setup
    Album album = new Album(TEST_ALBUM_NAME, TEST_ALBUM_DESCRIPTION);
    User user = new User(TEST_USER_ID , TEST_PASSWORD);
    user.addToAlbums(album);
    Photo photo = new Photo(TEST_PHOTO_NAME, TEST_PHOTO_CONTENT);
    photo.setUploadTime(new Date());
    for(Album anAlbum: user.getAlbums())
    {
      if(anAlbum.equals(album))
      {
        anAlbum.addToPhotos(photo);
      }
    }
    em.persist(user);
    long albumId = album.getAlbumId();
    long photoId = photo.getPhotoId();
   
    em.flush();
    em.clear();
   
    //Execute
    repository.delete(user);
    em.flush();
    em.clear();
   
    //Verify
    User actualUser = em.find(User.class, TEST_USER_ID);
    Album actualAlbum =  em.find(Album.class, albumId);
    Photo actualPhoto =  em.find(Photo.class, photoId);
    assertNull(actualUser);
    assertNull(actualAlbum);
    assertNull(actualPhoto);
  }
View Full Code Here

    else
    {
      try
      {
        long parsedId = Long.parseLong(photoId);
        Photo photo = photoService.findPhotoById(parsedId, true);
        byte[] photoContents = photo.getFile();
        InputStream inputStream = new ByteArrayInputStream(photoContents);
        fileContent = new DefaultStreamedContent(inputStream, "image/png");
        logger.info("Retrieved file content for image {}.", parsedId);
      }
      catch (PhotoException photoEx)
View Full Code Here

  @Override
  public Photo modify(Photo photo)
  {
    em.find(Photo.class, photo.getPhotoId());
    Photo mergedPhoto = em.merge(photo);
    return mergedPhoto;
  }
View Full Code Here

  }

  @Override
  public void delete(Photo photo)
  {
    Photo foundPhoto = em.find(Photo.class, photo.getPhotoId());
    foundPhoto.clearAlbum();
    em.remove(foundPhoto);
  }
View Full Code Here

  }

  @Override
  public Photo findById(Long photoId)
  {
    Photo foundPhoto = em.find(Photo.class, photoId);
    return foundPhoto;
  }
View Full Code Here

TOP

Related Classes of info.galleria.domain.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.