Пример #1
0
  public String getNYTLaius() {
    StringBuilder sb = new StringBuilder();

    sb.append("<div style=\"font-size:120%;\">");
    sb.append("<b>");
    sb.append("Media presence</b><br>");
    sb.append("</div>");

    if (!controllerBean.isNYTfound()) {
      sb.append("No media presence was detected for ");
      sb.append(controllerBean.getSearch().getFullname());
      sb.append(" (experimental feature).");

    } else {
      sb.append(controllerBean.getSearch().getFullname());
      sb.append(" is mentioned in the following article(s) fron the New York Times:<br>");
      for (Document element : controllerBean.getSetMediaDocs()) {
        if (!element.getPublication_outlet().equals("New York Times")) {
          continue;
        }
        sb.append(element.getYear());
        sb.append(". \"<a href=\"");
        sb.append(element.getNyt_url());
        sb.append("\">");
        sb.append(element.getTitle());
        sb.append("</a>.\"");
        sb.append("<br>");
      }
    }

    sb.append("<p></p>");
    return sb.toString();
  }
Пример #2
0
  public String getGeneralLaius() {
    StringBuilder toReturn = new StringBuilder();
    toReturn.append("This researcher has written ");
    toReturn.append(controllerBean.getSetDocs().size());
    if (controllerBean.getSetDocs().size() == 1) {
      toReturn.append(" document in ");
      toReturn.append(controllerBean.getSearch().getYearFirstCollab());

    } else if (controllerBean.getSearch().getYearFirstCollab()
        == controllerBean.getSearch().getYearLastCollab()) {
      toReturn.append(" documents in ");
      toReturn.append(controllerBean.getSearch().getYearFirstCollab());
    } else {
      toReturn.append(" documents between ");
      toReturn.append(controllerBean.getSearch().getYearFirstCollab());
      toReturn.append(" and ");
      toReturn.append(controllerBean.getSearch().getYearLastCollab());
    }
    if (controllerBean.getSearch().getNumberCoAuthors() > 0) {
      toReturn.append(", with a total of ");
      toReturn.append(controllerBean.getSearch().getNumberCoAuthors());
      toReturn.append(" co-authors");
    }
    toReturn.append(".");

    return toReturn.toString();
  }
Пример #3
0
  public String getAge() {
    StringBuilder sb = new StringBuilder();
    if (controllerBean.getSearch().getBirthYear() != null
        && controllerBean.getSearch().getBirthYear() != 0) {
      LocalDate today = new LocalDate();
      Integer currYear = today.getYear() - controllerBean.getSearch().getBirthYear();
      sb.append(controllerBean.getSearch().getFullname());
      sb.append(" is ").append(currYear).append(" years old.");
      sb.append("<p></p>");
    }

    return sb.toString();
  }
Пример #4
0
  public void passName() {
    FacesContext context = FacesContext.getCurrentInstance();
    Map map = context.getExternalContext().getRequestParameterMap();
    this.nameClicked = (String) map.get("nameClicked");
    this.countDocsCurrNameClicked = (String) map.get("countDocs");

    Iterator<Author> setAuthorsIterator = controllerBean.getSetAuthors().iterator();
    Author currAuthor = null;
    while (setAuthorsIterator.hasNext()) {
      currAuthor = setAuthorsIterator.next();
      if (currAuthor.getFullnameWithComma().equals(nameClicked)) {
        break;
      }
    }
    authorClicked = currAuthor;
    this.countDocsCurrNameClicked = String.valueOf(authorClicked.getTimesMentioned());

    FacesContext.getCurrentInstance()
        .getExternalContext()
        .getApplicationMap()
        .put("clickedAuthor", this.nameClicked);
    FacesContext.getCurrentInstance()
        .getExternalContext()
        .getApplicationMap()
        .put("uuid", controllerBean.uuid.toString());
  }
Пример #5
0
 @PostConstruct
 private void init() {
   this.json = controllerBean.getJson();
   authorClicked = new Author("fake name");
   authorClicked.setYearFirstCollab(0);
   authorClicked.setYearLastCollab(3000);
   authorClicked.setTimesMentioned(888);
 }
Пример #6
0
  public String getListDocs() {
    StringBuilder sb = new StringBuilder();
    sb.append("<b>List of ");
    sb.append(controllerBean.getSearch().getFullname());
    sb.append("'s publications</b>:<br>");
    ArrayList<Document> listDocs = new ArrayList();
    listDocs.addAll(controllerBean.getSetDocs());
    Collections.sort(listDocs, new DocSortByYear());
    for (Document doc : listDocs) {
      sb.append(doc.getAuthorsToString());
      sb.append(" ");
      sb.append("(<b>").append(doc.getYear()).append("</b>).");
      sb.append(" \"").append(doc.getTitle()).append("\". ");
      sb.append("<i>").append(doc.getPublication_outlet()).append("</i>.");
      sb.append("<p></p>");
    }

    return sb.toString();
  }
Пример #7
0
  public String getMostFrequentSource() {
    StringBuilder toReturn = new StringBuilder();
    int countTitle = controllerBean.getSearch().getMostFrequentOutlet().getRight();
    if (countTitle == 0) {
      return toReturn.toString();
    }
    toReturn.append("<div style=\"font-size:120%;\">");

    toReturn.append("<b>Journal with most publications by this researcher</b><br>");
    toReturn.append("</div>");

    toReturn.append(controllerBean.getSearch().getMostFrequentOutlet().getLeft());
    toReturn.append(" (");
    toReturn.append(countTitle);
    if (countTitle == 1) {
      toReturn.append(" document published in this outlet).");
    } else {
      toReturn.append(" documents published in this outlet).");
    }

    toReturn.append("<p></p>");
    return toReturn.toString();
  }
Пример #8
0
  public String getMostFrequentCoAuthors() {
    Set<Author> mostFrequentCoAuthors = controllerBean.getSearch().getSetMostFrequentCoAuthors();
    StringBuilder toReturn = new StringBuilder();

    if (mostFrequentCoAuthors == null || mostFrequentCoAuthors.isEmpty()) {
      return toReturn.toString();
    }

    toReturn.append("<div style=\"font-size:120%;\">");
    toReturn.append("<b>Most frequent co-author(s)</b><br>");
    toReturn.append("</div>");

    if (mostFrequentCoAuthors.size() == 1) {
      Author mostFrequentCoAuthor = mostFrequentCoAuthors.iterator().next();
      int nbCollab = mostFrequentCoAuthor.getTimesMentioned();
      toReturn.append("<b>");
      toReturn.append(mostFrequentCoAuthor.getFullname());
      toReturn.append("</b>");
      toReturn.append(".<br>");
      toReturn.append("Together, they have written ");
      toReturn.append(mostFrequentCoAuthor.getTimesMentioned());
      if (nbCollab == 1) {
        toReturn.append(" document");
      } else {
        toReturn.append(" documents");
      }
      if (controllerBean.getSearch().getYearFirstCollab()
          == controllerBean.getSearch().getYearLastCollab()) {
        toReturn.append(" in  ");
        toReturn.append(mostFrequentCoAuthor.getYearFirstCollab());
      } else {
        toReturn.append(" from ");
        toReturn.append(mostFrequentCoAuthor.getYearFirstCollab());
        toReturn.append(" to ");
        toReturn.append(mostFrequentCoAuthor.getYearLastCollab());
        toReturn.append(".");
      }

    } else {
      Iterator<Author> mostFrequentCoAuthorsIterator = mostFrequentCoAuthors.iterator();
      Author currAuthor;
      int maxNbCollab = 0;
      while (mostFrequentCoAuthorsIterator.hasNext()) {
        currAuthor = mostFrequentCoAuthorsIterator.next();
        maxNbCollab = Math.max(currAuthor.getTimesMentioned(), maxNbCollab);
      }
      if (maxNbCollab == 1) {
        toReturn.append(
            "- multiple coauthors, did not write more than one paper with the same coauthor.");

      } else {
        mostFrequentCoAuthorsIterator = mostFrequentCoAuthors.iterator();
        while (mostFrequentCoAuthorsIterator.hasNext()) {
          currAuthor = mostFrequentCoAuthorsIterator.next();
          toReturn.append("- <b>");
          toReturn.append(currAuthor.getFullname());
          toReturn.append("</b>, with ");
          toReturn.append(currAuthor.getTimesMentioned());
          if (currAuthor.getYearFirstCollab() == currAuthor.getYearLastCollab()) {
            toReturn.append(" shared publications in ");
            toReturn.append(currAuthor.getYearFirstCollab());
          } else {
            toReturn.append(" shared publications from ");
            toReturn.append(currAuthor.getYearFirstCollab());
            toReturn.append(" to ");
            toReturn.append(currAuthor.getYearLastCollab());
            toReturn.append(".<br>");
          }
        }
      }
    }
    toReturn.append("<p></p>");
    return toReturn.toString();
  }