Example #1
0
 public boolean equals(Object object) {
   if (object == null) {
     return false;
   } else if (object == this) {
     return true;
   } else if (this.getClass() != object.getClass()) {
     return false;
   }
   MatchScore matchScore = (MatchScore) object;
   return this.firstPlayerScore == matchScore.getFirstPlayerScore()
       && this.secondPlayerScore == matchScore.getSecondPlayerScore();
 }
Example #2
0
 public static MatchScore getMatchScore(String scoreName) {
   char i = 0; // runnerName.charAt(0);
   while (!Character.isDigit(scoreName.charAt(i))) {
     i++;
   }
   String lastName = scoreName.substring(0, i - 1);
   int firstScore = Integer.parseInt(((Character) scoreName.charAt(i)).toString());
   i++;
   while (!Character.isDigit(scoreName.charAt(i))) {
     i++;
   }
   int secondScore = Integer.parseInt(((Character) scoreName.charAt(i)).toString());
   MatchScore matchScore = new MatchScore(firstScore, secondScore);
   matchScore.setFirstPlayerLastName(lastName);
   return matchScore;
 }
  public static List<Bibtex> fetchResultList(List<MatchScore> orderedList, int num) {
    Set<Bibtex> bibtexList = new LinkedHashSet<Bibtex>();
    if (CollectionUtils.isEmpty(orderedList)) return null;

    setup();
    try {
      int count = 0;
      while (bibtexList.size() != num) {
        if (orderedList.size() < num && count == orderedList.size()) break;
        MatchScore ms = orderedList.get(count++);
        Result result = HBaseDAO.getRow(table, ms.getRowKey());

        byte[] articleTitleByte =
            result.getValue(
                Bytes.toBytes(PropertyConstant.ARTICLE), Bytes.toBytes(PropertyConstant.TITLE));
        if (articleTitleByte != null) {
          Article bibtex = new Article();
          bibtex.setTitle(Bytes.toString(articleTitleByte));
          bibtex.setAuthor(
              Bytes.toString(
                  result.getValue(
                      Bytes.toBytes(PropertyConstant.ARTICLE),
                      Bytes.toBytes(PropertyConstant.AUTHOR))));
          bibtex.setYear(
              Bytes.toString(
                  result.getValue(
                      Bytes.toBytes(PropertyConstant.ARTICLE),
                      Bytes.toBytes(PropertyConstant.YEAR))));
          bibtex.setJournal(
              Bytes.toString(
                  result.getValue(
                      Bytes.toBytes(PropertyConstant.ARTICLE),
                      Bytes.toBytes(PropertyConstant.JOURNAL))));
          bibtex.setPages(
              Bytes.toString(
                  result.getValue(
                      Bytes.toBytes(PropertyConstant.ARTICLE),
                      Bytes.toBytes(PropertyConstant.PAGES))));
          bibtex.setVolume(
              Bytes.toString(
                  result.getValue(
                      Bytes.toBytes(PropertyConstant.ARTICLE),
                      Bytes.toBytes(PropertyConstant.VOLUME))));
          bibtexList.add(bibtex);
        } else {
          Inproceedings bibtex = new Inproceedings();
          bibtex.setTitle(
              Bytes.toString(
                  result.getValue(
                      Bytes.toBytes(PropertyConstant.INPROCEEDINGS),
                      Bytes.toBytes(PropertyConstant.TITLE))));
          bibtex.setAuthor(
              Bytes.toString(
                  result.getValue(
                      Bytes.toBytes(PropertyConstant.INPROCEEDINGS),
                      Bytes.toBytes(PropertyConstant.AUTHOR))));
          bibtex.setBooktitle(
              Bytes.toString(
                  result.getValue(
                      Bytes.toBytes(PropertyConstant.INPROCEEDINGS),
                      Bytes.toBytes(PropertyConstant.BOOKTITLE))));
          bibtex.setYear(
              Bytes.toString(
                  result.getValue(
                      Bytes.toBytes(PropertyConstant.INPROCEEDINGS),
                      Bytes.toBytes(PropertyConstant.YEAR))));
          bibtexList.add(bibtex);
        }
      }
    } catch (Exception e) {
      System.out.println("Error: while fetch the bibtex data " + e);
      e.printStackTrace();
      System.exit(-1);
    }

    cleanup();

    List<Bibtex> result = new ArrayList<Bibtex>(bibtexList);
    return result;
  }