Esempio n. 1
0
  /* (non-Javadoc)
   * @see ca.cmput301f13t03.adventure_datetime.model.IWebStorage#getStory(java.util.UUID)
   */
  @Override
  public Story getStory(UUID storyId) throws Exception {
    Get get = new Get.Builder(_index, storyId.toString()).type("story").build();
    JestResult result = execute(get);
    Story story = result.getSourceAsObject(Story.class);

    Image image = getImage(storyId);
    if (image != null) story.setThumbnail(image.getEncodedBitmap());

    return story;
  }
Esempio n. 2
0
  private void mapImagesToComments(List<Comment> comments) throws Exception {
    if (comments == null || comments.size() == 0) return;

    // Get the thumbnails
    List<UUID> ids = new ArrayList<UUID>();
    for (Comment c : comments) {
      ids.add(c.getId());
    }

    List<Image> images = getImages(ids);

    for (Image i : images) {
      for (Comment c : comments) {
        if (c.getId().equals(i.getId())) {
          c.setImage(i.getEncodedBitmap());
          break;
        }
      }
    }
  }
Esempio n. 3
0
  private void mapImagesToStories(List<Story> stories) throws Exception {
    if (stories == null || stories.size() == 0) return;

    // Get the thumbnails
    List<UUID> ids = new ArrayList<UUID>();
    for (Story s : stories) {
      ids.add(s.getId());
    }

    List<Image> images = getImages(ids);

    for (Image i : images) {
      for (Story s : stories) {
        if (s.getId().equals(i.getId())) {
          s.setThumbnail(i.getEncodedBitmap());
          break;
        }
      }
    }
  }