Interface MatchDao


public interface MatchDao
Interface describing the operations allowed with matches on database.
Author:
andresbustamante
  • Method Details

    • isCodeAlreadyRegistered

      boolean isCodeAlreadyRegistered(@Param("code") String code)
      Verifies if the code passed as parameter has already been used for another match.
      Parameters:
      code - Code to check
      Returns:
      True or false if the code is already in use or not
    • findMatchByCode

      Match findMatchByCode(@Param("code") String code)
      Loads a match and its details by using its unique code.
      Parameters:
      code - Code to look for
      Returns:
      The match using the code and its details
    • findMatchesByPlayer

      List<Match> findMatchesByPlayer(@Param("player") Player player, @Param("sport") SportEnum sport, @Param("status") MatchStatusEnum status, @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate)
      Find the list of matches associated to a player by optionally using a date interval.
      Parameters:
      player - Player to use for the research
      sport - Sport to search in the list of matches
      status - Match status to search
      startDate - Start date for the research
      endDate - Limit date for the research
      Returns:
      List of matches returned by the research
    • findMatchById

      Match findMatchById(@Param("id") Integer id)
      Loads a match and its details by using its unique numeric identifier.
      Parameters:
      id - Match technical ID
      Returns:
      The match identified by this number and its details
    • saveMatch

      void saveMatch(@Param("match") Match match)
      Creates a match on database.
      Parameters:
      match - Match to create
    • registerPlayer

      int registerPlayer(@Param("player") Player player, @Param("match") Match match, @Param("car") Car car, @Param("carConfirmation") Boolean isCarConfirmed)
      Registers a player to an existing match.
      Parameters:
      player - Player to register
      match - Match to update
      car - Car used to go to the match (optional)
      isCarConfirmed - Indicates if there's a confirmation for assisting to a match with the selected car
      Returns:
      Number of registered players. It should be 0 or 1
    • isPlayerRegistered

      boolean isPlayerRegistered(@Param("player") Player player, @Param("match") Match match)
      Checks if a player is already registered to a match.
      Parameters:
      player - Player to search
      match - Match to search
      Returns:
      True if the player is already registered
    • unregisterPlayer

      void unregisterPlayer(@Param("player") Player player, @Param("match") Match match)
      Unregisters a player from a match.
      Parameters:
      player - Player to unregister
      match - Match to update
    • unregisterPlayerFromAllMatches

      int unregisterPlayerFromAllMatches(@Param("player") Player player)
      Unregisters a player from all the matches where he/her was registered even past matches.
      Parameters:
      player - Player to unregister
      Returns:
      Number of updated matches
    • updateCarForRegistration

      int updateCarForRegistration(@Param("match") Match match, @Param("player") Player player, @Param("car") Car car, @Param("confirmed") boolean isCarConfirmed)
      Updates and confirms a car for a player registered into a match.
      Parameters:
      match - Match to search
      player - Player to search
      car - Car to set
      isCarConfirmed - Is the car confirmed or not
      Returns:
      Number of updated cars. It should be 0 or 1
    • loadRegistration

      Registration loadRegistration(@Param("match") Match match, @Param("player") Player player)
      Loads registration details for a player in a specific match.
      Parameters:
      match - Match to search
      player - Player to search
      Returns:
      Registration details
    • findPassengerRegistrationsByCar

      List<Registration> findPassengerRegistrationsByCar(@Param("match") Match match, @Param("car") Car car)
      Finds the list of passenger registrations for a given car.
      Parameters:
      match - Match to search
      car - Car to search
      Returns:
      List of registrations made with the given car for a match
    • resetCarDetails

      int resetCarDetails(@Param("match") Match match, @Param("player") Player player)
      Resets car details for a player registration in a given match.
      Parameters:
      match - Match to search
      player - Player to search
      Returns:
      Number of lines touched by this operation
    • updateMatchStatus

      void updateMatchStatus(@Param("match") Match match)
      Update a match with new status details.
      Parameters:
      match - Match to update