Package net.sf.collabreview.core.users

Examples of net.sf.collabreview.core.users.Author


    String targetName = randomSelectWeak();
    if (targetName == null) {
      logger.error("No suitable candidate found");
      return false;
    }
    Author author = null;
    if (request.getSession().getAttribute(Constants.SESSION_ATTRIB_AUTHOR) != null) {
      author = collabReview.getAuthorManager().getAuthor((String) request.getSession().getAttribute(Constants.SESSION_ATTRIB_AUTHOR));
    }
    if (author == null) {
      writer.println("<p>Melde dich an, um eine Mail schreiben zu können.</p>");
      return true;
    }
    writer.println(String.format(sentence, targetName));
    writer.println(String.format("<p>" +
        "<form method=\"post\" action=\"%s\">" +
        "<input type=\"text\" name=\"mailsubject\" value=\"Betreff der Mail\" style=\"width:80%%\"/><input type=\"submit\"/><br>" +
        "<textarea name=\"mailbody\" style=\"width:100%%\">Ergänze ein paar persönliche Worte</textarea>" +
        "</form></p>",
        TipOfTheDayServlet.getURLToHintlet(this, request)
            + "&author=" + URLEncoder.encode(author.getName(), "utf-8")
            + "&recipient=" + URLEncoder.encode(targetName, "utf-8")));
    return true;
  }
View Full Code Here


  @Override
  public void renderResource(HttpServletRequest request, HttpServletResponse response) throws IOException, AddressException {
    try {
      String authorName = request.getParameter("author");
      Author author = collabReview.getAuthorManager().getAuthor(authorName);
      String recipientName = request.getParameter("recipient");
      Author recipient = collabReview.getAuthorManager().getAuthor(recipientName);
      if (author == null) {
        logger.error("Illegal author name: " + authorName);
        return;
      }
      if (recipient == null) {
        logger.error("Illegal recipient name: " + recipientName);
        return;
      }
      String subject = request.getParameter("mailsubject");
      if (subject == null) {
        subject = "--";
      }
      String text = request.getParameter("mailbody");
      if (text == null) {
        text = "-";
      }
      Mail mail = collabReview.getMailManager().newMail(subject, recipient.getEmail(), author.getEmail());
      mail.setBody(String.format(body, recipient.getName(), author.getName(), text));
      mail.send();
    } finally {
      response.sendRedirect(request.getRequestURI());
    }
  }
View Full Code Here

   *
   * @return name of one of the worst
   */
  private String randomSelectWeak() {
    ReputationMetric metric = collabReview.getReputationMetricManager().findReputationMetric(metricName);
    Author target = null;
    int candidateSetSize = 4;
    List<String> contributors = metric.listContributorsFillWithNoContributors();
    Collections.reverse(contributors);
    while (target == null && candidateSetSize < contributors.size()) {
      candidateSetSize = Math.min(contributors.size(), candidateSetSize + 1);
      int i = (int) (Math.random() * candidateSetSize);
      target = collabReview.getAuthorManager().getAuthor(contributors.get(i));
      if (target.isDisabled()) {
        target = null;
      }
    }
    if (target == null) {
      target = collabReview.getAuthorManager().getAuthor(contributors.get(0));
    }
    return target.getName();
  }
View Full Code Here

      return true;
    }
    String bestName = contributors.get(0);
    float bestScore = metric.getAuthorScore(bestName);
    writer.println(String.format(sentenceBest, bestName, bestScore * scoreScale));
    Author author = null;
    if (request.getSession().getAttribute(Constants.SESSION_ATTRIB_AUTHOR) != null) {
      author = collabReview.getAuthorManager().getAuthor((String) request.getSession().getAttribute(Constants.SESSION_ATTRIB_AUTHOR));
    }
    if (author == null) {
      writer.println("<p>Melde dich an, um deine eigene Position angezeigt zu bekommen.</p>");
      return true;
    }
    if (author.getName().equals(bestName)) {
      writer.println("<p>Herzlichen Glückwunsch, das bist du!</p>");
      return true;
    }
    if (contributors.size() < 2) {
      writer.println("<p>Andere Leute haben in diesem Bereich nichts beigetragen</p>");
      return true;
    }
    int ownRank = contributors.size();
    for (int i = 0; i < contributors.size(); i++) {
      if (contributors.get(i).equals(author.getName())) {
        ownRank = i;
      }
    }
    Float ownScore = metric.getAuthorScore(author.getName());
    if( ownScore == null ) {
      // I wonder if assuming 0 is always correct...
      ownScore = 0f;
    }
    String nextName = contributors.get(ownRank - 1);
View Full Code Here

  private static List<WikiAuthorResponsibilityComparator> calculateCurrentScores() {
    ReputationMetric reputationMetric = CollabReviewSingleton.get().getReputationMetricManager().findReputationMetric("silfwiki");
    List<WikiAuthorResponsibilityComparator> currentScoreList = new ArrayList<WikiAuthorResponsibilityComparator>();
    for (String authorName : CollabReviewSingleton.get().getAuthorManager().listAuthorNames()) {
      Author author = CollabReviewSingleton.get().getAuthorManager().getAuthor(authorName);
      String userName = author.getName();
      Float quality = reputationMetric.getAuthorScore(author.getName());
      if (quality == null) {
        quality = 0f;
      }
      currentScoreList.add(new WikiAuthorResponsibilityComparator(userName, quality, author.isDisabled()));
    }
    CollabReviewSingleton.get().getRepository().commit();
    Collections.sort(currentScoreList);
    return currentScoreList;
  }
View Full Code Here

  public Pair<String, Double> getCurrentHeldDerWocheAndScore() throws FileNotFoundException {
    ReputationMetric reputationMetric = CollabReviewSingleton.get().getReputationMetricManager().findReputationMetric("silfwiki");
    HashMap<String, Double> lastWeekScoresHash = getLastWeekScoresHash();
    List<WikiAuthorResponsibilityComparator> oneWeekScoresList = new ArrayList<WikiAuthorResponsibilityComparator>();
    for (String authorName : CollabReviewSingleton.get().getAuthorManager().listAuthorNames()) {
      Author author = CollabReviewSingleton.get().getAuthorManager().getAuthor(authorName);
      Float qualityScore = reputationMetric.getAuthorScore(author.getName());
      if (qualityScore == null) {
        qualityScore = 0f;
      }
      double oneWeekScore = lastWeekScoresHash.get(authorName) != null ? qualityScore - lastWeekScoresHash.get(authorName) : qualityScore;
      oneWeekScoresList.add(new WikiAuthorResponsibilityComparator(authorName, oneWeekScore, author.isDisabled()));
    }
    Collections.sort(oneWeekScoresList);
    return new Pair<String, Double>(oneWeekScoresList.get(0).getUserName(), oneWeekScoresList.get(0).getUserScore());
  }
View Full Code Here

      writeUpdatedOneWeekScoresList();
    }

    private void informHeldDerWoche() throws FileNotFoundException {
      Pair<String, Double> heldDerWocheInfo = getCurrentHeldDerWocheAndScore();
      Author heldDerWoche = CollabReviewSingleton.get().getAuthorManager().getAuthor(heldDerWocheInfo.first);
      if (heldDerWocheInfo.second.floatValue() < 1) {
        CollabReviewSingleton.get().getMailManager().newMail("Kein Held der Woche")
            .setBody("Niemand hat auch nur einen einzigen Punkt gemacht. Deshalb gibt es leider diesmal keinen Held der Woche.")
            .send();
      } else {
        CollabReviewSingleton.get().getMailManager().newMail(heldDerWoche.getName() + " ist der Held der Woche", "Ubicomp@fit.fraunhofer.de")
            .setBody(String.format(
                "Hallo zusammen,\n\n" +
                    "%s hat sich diese Woche mit %.1f Punkten sehr verdient um die Moknowpedia\n" +
                    "und den Wissensaustausch in unserer Gruppe gemacht.\n" +
                    "Da können die anderen nur staunen und dürfen sich ruhig ein Beispiel nehmen! ;-)\n" +
                    "\n\n" +
                    "Seid fleißig,\n" +
                    "Euer Moknowpedianer",
                heldDerWoche.getName(), heldDerWocheInfo.second
            )).send();
      }
      CollabReviewSingleton.get().getMailManager().newMail("Du bist der Held der Woche :-)", heldDerWoche.getEmail())
          .setBody("Hallo " + heldDerWoche.getName() + ",\n\n Du hast diese Woche " + heldDerWocheInfo.second + " Punkte gemacht und bist damit Held der Woche geworden!\n\nDein Moknowpedianer")
          .send();
    }
View Full Code Here

        }
        int rating = newReview.getRating();
        String comment = newReview.getReviewText();
        boolean anonymous = newReview.getIsAnonymous();
        Author author = newReview.getAuthor();
        Artifact artifact = collabReview.getRepository().getArtifact(newReview.getArtifactIdentifier());
        String articleName = newReview.getArtifactIdentifier().getName();
        int mailCount = 3;
        String ratingName = "";
        switch (rating) {
          case 0:
            ratingName = "mangelhaft";
            break;
          case 2:
            ratingName = "ausreichend";
            break;
          case 4:
            ratingName = "befriedigend";
            break;
          case 7:
            ratingName = "gut";
            break;
          case 10:
            ratingName = "sehr gut";
            break;
        }
        if (comment.equals("Bitte geben Sie Ihren Kommentar hier ein!") || comment.equals("")) {
          comment = "- kein -";
        }
        Map<Author, Float> responsibilities = collabReview.getMeasurementsManager().getArtifactResponsibility().listResponsibilities(artifact);
        for (Author aa : responsibilities.keySet()) {
          if (mailCount == 0 || responsibilities.get(aa) < 0.1) {
            break;
          }
          mailCount--;
          logger.debug("Mail an " + aa + " email: " + aa.getEmail());
          String linkArticle = null;
          try {
            linkArticle = "http://moknowpedia.fit.fraunhofer.de/mediawiki/index.php5/" + java.net.URLEncoder.encode(articleName, "utf-8");
          } catch (UnsupportedEncodingException e) {
            logger.error("Encoding error when trying to send Moknowpedia Mail", e);
            linkArticle = "[ENCODING ERROR]";
          }
          String reviewerName = anonymous ? "anonym" : ("von " + author.getName());
          collabReview.getMailManager().newMail("Ein Artikel von dir wurde bewertet! :-)", aa.getEmail())
              .setBody("Hallo " + aa.getName() + ",\n\n dein Artikel \"" + articleName + "\" wurde gerade " + reviewerName + " mit _" + ratingName + "_ bewertet!" +
                  "\n Optionaler Kommentar der Bewertung: " + comment + "." +
                  "\n\nBester Gruß,\n Euer MoKnowPedianer" +
                  "\n\nPS: Diese URL führt dich eventuell direkt zum Artikel: " + linkArticle)
View Full Code Here

TOP

Related Classes of net.sf.collabreview.core.users.Author

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.