Exemplo n.º 1
0
  @SuppressWarnings("unchecked")
  private AnnotationView buildAnnotationView(Annotation annotation, boolean loadAllReplies) {
    Object values[];
    try {
      values =
          (Object[])
              hibernateTemplate
                  .findByCriteria(
                      DetachedCriteria.forClass(Article.class)
                          .add(Restrictions.eq("ID", annotation.getArticleID()))
                          .setProjection(
                              Projections.projectionList()
                                  .add(Projections.property("doi"))
                                  .add(Projections.property("title"))),
                      0,
                      1)
                  .get(0);

    } catch (IndexOutOfBoundsException e) {
      // this should never happen
      throw new IllegalStateException(
          "Annotation "
              + annotation.getID()
              + " pointed to an article that didn't exist;"
              + " articleID: "
              + annotation.getArticleID());
    }

    String articleDoi = (String) values[0];
    String articleTitle = (String) values[1];

    return buildAnnotationView(annotation, articleDoi, articleTitle, loadAllReplies);
  }
Exemplo n.º 2
0
  @SuppressWarnings("unchecked")
  private AnnotationView buildAnnotationView(
      Annotation annotation, String articleDoi, String articleTitle, boolean loadAllReplies) {
    Map<Long, List<Annotation>> fulReplyMap = null;
    if (loadAllReplies) {
      fulReplyMap = buildReplyMap(annotation.getArticleID());
    }

    return new AnnotationView(annotation, articleDoi, articleTitle, fulReplyMap);
  }