Ejemplo n.º 1
0
  File writeTeamXmlFile(final TeamInfo team) {
    Element root = writeTeamXml(team);

    File outputFile = createTeamXmlFile(team.getTeamNumber());
    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 TeamInfo readTeamXml(final Element team) throws Exception {
    /*  example team XML file content
    <team teamNumber="1329" name="RoboRebels" city="St Louis" state="MO" country="US">
        General notes about this team
    </team>
    */
    int theTeamNumber = team.getAttribute("teamNumber").getIntValue();
    String theTeamName = team.getAttribute("name").getValue();
    String theTeamCity = team.getAttribute("city").getValue();
    String theTeamState = team.getAttribute("state").getValue();
    String theTeamCountry = team.getAttribute("country").getValue();
    String theNotes = team.getTextNormalize();

    TeamInfo theTeam =
        new TeamInfo(theTeamNumber, theTeamName, theTeamCity, theTeamState, theTeamCountry, null);
    theTeam.setNotes(theNotes);
    theTeam.setImageFile(locateImageFile(theTeamNumber));

    return theTeam;
  }
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;
  }
Ejemplo n.º 5
0
 private Element writeTeamXml(final TeamInfo team) {
   /*  example team XML file content
   <team teamNumber="1329" name="RoboRebels" city="St Louis" state="MO" country="US">
       General notes about this team
   </team>
   */
   Element e = new Element("team");
   e.setAttribute("teamNumber", Integer.toString(team.getTeamNumber()));
   e.setAttribute("name", team.getTeamName());
   if (team.getCity().length() > 0) {
     e.setAttribute("city", team.getCity());
   }
   if (team.getState().length() > 0) {
     e.setAttribute("state", team.getState());
   }
   if (team.getCountry().length() > 0) {
     e.setAttribute("country", team.getCountry());
   }
   e.setText(team.getNotes());
   return e;
 }