コード例 #1
0
  private TeamResult readTeamResultXml(
      final List<MatchInfo> matchCache,
      final List<TeamInfo> teamCache,
      final List<Category> categories,
      final Element resultElm)
      throws Exception {
    /*  example team result XML file content
    <result matchNumber="1" teamNumber="1" cat1="-1" cat2="-1" cat3="-1" ... >
        Specific notes about this team and this match
    </result>
    */

    // Process <result> XML element
    int theMatchNumber = resultElm.getAttribute("matchNumber").getIntValue();
    MatchInfo match =
        matchCache.stream().filter(m -> m.getMatchNumber() == theMatchNumber).findFirst().get();

    int theTeamNumber = resultElm.getAttribute("teamNumber").getIntValue();
    TeamInfo team =
        teamCache.stream().filter(t -> t.getTeamNumber() == theTeamNumber).findFirst().get();

    Map<Category, Integer> scores = new HashMap<>();
    for (Category c : categories) {
      String score = resultElm.getAttributeValue(c.getName());
      if ((score != null) && (score.length() > 0)) {
        scores.put(c, Integer.valueOf(score));
      }
    }

    TeamResult tr = new TeamResult(match, team, scores);
    tr.setNotes(resultElm.getTextNormalize());

    return tr;
  }
コード例 #2
0
  File writeTeamResultXmlFile(final TeamResult result) {
    Element root = writeTeamResultXml(result);

    File outputFile =
        createTeamResultXmlFile(
            result.getMatch().getMatchNumber(), result.getTeam().getTeamNumber());
    deleteExistingFile(outputFile);
    writeFile(outputFile, new Document(root));
    return outputFile;
  }
コード例 #3
0
  @Override
  public List<MatchResult> fetchAllMatchResults() {
    Multimap<MatchInfo, TeamResult> resultsMap = ArrayListMultimap.create();
    for (TeamResult tr : fetchAllTeamResults()) {
      resultsMap.put(tr.getMatch(), tr);
    }

    List<MatchResult> matchResults = new ArrayList<>();
    for (MatchInfo match : fetchAllMatches()) {
      matchResults.add(new MatchResult(match, resultsMap.get(match)));
    }

    return matchResults;
  }
コード例 #4
0
  private Element writeTeamResultXml(final TeamResult result) {
    /*  example team result XML file content
    <result matchNumber="1" teamNumber="1" cat1="-1" cat2="-1" cat3="-1" ... >
        Specific notes about this team and this match
    </result>
    */

    Element rootElm = new Element("result");
    rootElm.setAttribute("matchNumber", Integer.toString(result.getMatch().getMatchNumber()));
    rootElm.setAttribute("teamNumber", Integer.toString(result.getTeam().getTeamNumber()));

    for (Category c : result.getScoringCategories()) {
      rootElm.setAttribute(c.getName(), result.getScore(c).toString());
    }

    rootElm.setText(result.getNotes());
    return rootElm;
  }