@Override public void modifyTournament( @WebParam(name = "tournamentId") String tournamentId, @WebParam(name = "date") String date, @WebParam(name = "location") String location, @WebParam(name = "surface") String surface, @WebParam(name = "draw") String draw, @WebParam(name = "numberOfSeeds") String numberOfSeeds) throws InvalidInputException { Tournament tournament = tournamentService.getTournament(Integer.parseInt(tournamentId)); DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date tournamentDate; try { tournamentDate = format.parse(date); } catch (ParseException e) { throw new InvalidInputException(e.getMessage(), "Invalid date format"); } tournament.setTournamentDate(tournamentDate); }
@Override @WebMethod(operationName = "addTournament") public void addTournament( @WebParam(name = "date") String date, @WebParam(name = "location") String location, @WebParam(name = "surface") String surface, @WebParam(name = "draw") String draw, @WebParam(name = "numberOfSeeds") String numberOfSeeds) throws InvalidInputException { Tournament tournament = new Tournament(); DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date tournamentDate; try { tournamentDate = format.parse(date); } catch (ParseException e) { throw new InvalidInputException(e.getMessage(), "Invalid date format"); } tournament.setTournamentDate(tournamentDate); tournament.setLocation(location); tournament.setSurface(surface); int seedsNumber = Integer.parseInt(numberOfSeeds); tournament.setNumberOfSeeds(seedsNumber); tournament.setSeeds(seedsNumber != 0); tournamentService.addTournament(tournament); }