コード例 #1
0
  @Override
  public BlipData toBlipData(
      ConversationBlip blip, Wavelet wavelet, EventMessageBundle eventMessageBundle) {
    ConversationBlip parentBlip = findBlipParent(blip);
    BlipData blipData = new BlipData();
    blipData.setCreator(blip.getAuthorId().getAddress());
    blipData.setContributors(idsToParticipantIdList(blip.getContributorIds()));
    blipData.setBlipId(blip.getId());
    blipData.setLastModifiedTime(blip.getLastModifiedTime());
    blipData.setVersion(blip.getLastModifiedVersion());
    blipData.setParentBlipId(parentBlip == null ? null : parentBlip.getId());
    blipData.setWaveId(ApiIdSerializer.instance().serialiseWaveId(wavelet.getWaveId()));
    blipData.setWaveletId(ApiIdSerializer.instance().serialiseWaveletId(wavelet.getId()));
    blipData.setChildBlipIds(toBlipIdList(findBlipChildren(blip)));

    ApiView apiView = new ApiView(blip.getContent(), wavelet);
    // Set content.
    blipData.setContent(apiView.apiContents());
    // Set Annotations.
    blipData.setAnnotations(extractAnnotations(blip.getContent(), apiView));
    // blip.getContent().rangedAnnotations(0, blip.getContent().size(), null),
    // Set Form Elements.
    blipData.setElements(ElementSerializer.serialize(blip.getContent(), wavelet));
    return blipData;
  }
コード例 #2
0
 /**
  * Extracts all annotations that span inside the body tag of the given document.
  *
  * @param doc the document to get the annotations from.
  * @param apiView provides a utility function to convert an xml offset point into text offset.
  * @return the annotations represented as a list of {@link Annotation}.
  */
 private static List<Annotation> extractAnnotations(Document doc, ApiView apiView) {
   List<Annotation> result = Lists.newArrayList();
   for (RangedAnnotation<String> annotation : doc.rangedAnnotations(0, doc.size(), null)) {
     if (annotation.key() != null && annotation.value() != null) {
       int start = apiView.transformToTextOffset(annotation.start());
       int end = apiView.transformToTextOffset(annotation.end());
       result.add(new Annotation(annotation.key(), annotation.value(), new Range(start, end)));
     }
   }
   return result;
 }