Ejemplo n.º 1
0
  File writeMatchXmlFile(final MatchInfo match) {
    Element root = writeMatchXml(match);

    File outputFile = createMatchXmlFile(match.getMatchNumber());
    deleteExistingFile(outputFile);
    writeFile(outputFile, new Document(root));
    return outputFile;
  }
Ejemplo n.º 2
0
  @Override
  public List<TeamResult> fetchTeamResults(final MatchInfo theMatch) {
    List<MatchInfo> matchCache = Arrays.asList(theMatch);
    List<TeamInfo> teamCache = theMatch.getTeams();
    List<Category> categories = fetchAllScoringCategories();

    List<TeamResult> results = new ArrayList<>();
    for (TeamInfo theTeam : theMatch.getTeams()) {
      File inputFile = createTeamResultXmlFile(theMatch.getMatchNumber(), theTeam.getTeamNumber());
      if (inputFile.exists()) {
        results.add(readTeamResultXmlFile(matchCache, teamCache, categories, inputFile));
      } else {
        results.add(new TeamResult(theMatch, theTeam));
      }
    }

    return results;
  }
Ejemplo n.º 3
0
  private Element writeMatchXml(final MatchInfo match) {
    /*  example match XML file content
    <match matchNumber="1">
        <alliance color="BLUE" team1="1" team2="2" team3="3" />
        <alliance color="RED"  team1="4" team2="5" team3="6" />
    </match>
    */

    Element rootElm = new Element("match");
    rootElm.setAttribute("matchNumber", Integer.toString(match.getMatchNumber()));

    // Output match results for the blue alliance
    TeamAlliance alliance = match.getBlueAlliance();
    Element allianceElm = new Element("alliance");

    allianceElm.setAttribute("color", alliance.getAllianceColor().name());
    int counter = 1;
    for (Integer teamNum : alliance.getTeamNumbers()) {
      allianceElm.setAttribute("team" + counter, Integer.toString(teamNum));
      counter++;
    }

    rootElm.addContent(allianceElm);

    // Output match results for the red alliance
    alliance = match.getRedAlliance();
    allianceElm = new Element("alliance");

    allianceElm.setAttribute("color", alliance.getAllianceColor().name());
    counter = 1;
    for (Integer teamNum : alliance.getTeamNumbers()) {
      allianceElm.setAttribute("team" + counter, Integer.toString(teamNum));
      counter++;
    }

    rootElm.addContent(allianceElm);
    return rootElm;
  }
Ejemplo n.º 4
0
  @Override
  public List<TeamResult> fetchAllTeamResults() {
    List<MatchInfo> matchCache = fetchAllMatches();
    List<TeamInfo> teamCache = fetchAllTeams();
    List<Category> categories = fetchAllScoringCategories();

    List<TeamResult> results = new ArrayList<>();
    for (MatchInfo theMatch : matchCache) {
      for (TeamInfo theTeam : theMatch.getTeams()) {
        File inputFile =
            createTeamResultXmlFile(theMatch.getMatchNumber(), theTeam.getTeamNumber());
        if (inputFile.exists()) {
          results.add(readTeamResultXmlFile(matchCache, teamCache, categories, inputFile));
        } else {
          results.add(new TeamResult(theMatch, theTeam));
        }
      }
    }

    Comparator<TeamResult> byMatchNumber =
        (e1, e2) -> Integer.compare(e1.getMatch().getMatchNumber(), e2.getMatch().getMatchNumber());
    Collections.sort(results, byMatchNumber);
    return results;
  }