Ejemplo n.º 1
0
  private void nextRace() {
    // Pull results for old week, then set new week.
    NascarConfig config = NascarConfigSingleton.get();
    Race race = config.getRace();
    DatastoreManager.populateResults(race);
    config.goToNextWeek();
    Race newRace = config.getRace();

    // Pull drivers for new week.
    DatastoreManager.populateDriverData(newRace.getYear(), newRace.getWeek());
    LAST_OPERATION_MESSAGE = "Went to next race";
  }
 public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
   Owner owner = DatastoreManager.getCurrentOwner();
   if (owner == null) {
     UserService userService = UserServiceFactory.getUserService();
     resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
     return;
   }
   resp.sendRedirect("/driverselection.jsp");
 }
 public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
   String[] driverStrings = null;
   if (req.getParameterValues("driver") != null) {
     driverStrings = req.getParameterValues("driver");
   }
   if (driverStrings != null && driverStrings.length > 5) {
     resp.setStatus(400);
   } else {
     NascarConfig config = NascarConfigSingleton.get();
     List<Driver> drivers =
         DatastoreManager.getDriversByNamesAndRace(driverStrings, config.getRaceKey());
     Owner owner = DatastoreManager.getCurrentOwner();
     Lineup lineup = new Lineup(config.getRaceKey());
     boolean driversAdded = lineup.setDrivers(drivers);
     if (driversAdded) {
       Team team = owner.getTeam();
       team.setLineup(lineup);
       DatastoreManager.persistObject(team);
     }
   }
   resp.sendRedirect(req.getRequestURI());
 }