コード例 #1
0
 /* (non-Javadoc)
  * @see ca.cmput301f13t03.adventure_datetime.model.IWebStorage#putImage(ca.cmput301f13t03.adventure_datetime.model.Image)
  */
 @Override
 public boolean putImage(Image image) throws Exception {
   Index index =
       new Index.Builder(image).index(_index).type("image").id(image.getId().toString()).build();
   JestResult result = execute(index);
   return result.isSucceeded();
 }
コード例 #2
0
  private boolean putImages(List<Image> images) throws Exception {
    if (images == null) return true;

    Bulk.Builder bulkBuilder = new Bulk.Builder().defaultIndex(_index).defaultType("image");

    for (Image i : images) {
      bulkBuilder.addAction(new Index.Builder(i).id(i.getId().toString()).build());
    }

    JestResult result = execute(bulkBuilder.build());
    return result.isSucceeded();
  }
コード例 #3
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;
        }
      }
    }
  }
コード例 #4
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;
        }
      }
    }
  }