Interface MatchDao
public interface MatchDao
Interface describing the operations allowed with matches on database.
- Author:
- andresbustamante
-
Method Summary
Modifier and TypeMethodDescriptionfindMatchByCode
(String code) Loads a match and its details by using its unique code.findMatchById
(Integer id) Loads a match and its details by using its unique numeric identifier.findMatchesByPlayer
(Player player, SportEnum sport, MatchStatusEnum status, LocalDateTime startDate, LocalDateTime endDate) Find the list of matches associated to a player by optionally using a date interval.findPassengerRegistrationsByCar
(Match match, Car car) Finds the list of passenger registrations for a given car.boolean
Verifies if the code passed as parameter has already been used for another match.boolean
isPlayerRegistered
(Player player, Match match) Checks if a player is already registered to a match.loadRegistration
(Match match, Player player) Loads registration details for a player in a specific match.int
registerPlayer
(Player player, Match match, Car car, Boolean isCarConfirmed) Registers a player to an existing match.int
resetCarDetails
(Match match, Player player) Resets car details for a player registration in a given match.void
Creates a match on database.void
unregisterPlayer
(Player player, Match match) Unregisters a player from a match.int
unregisterPlayerFromAllMatches
(Player player) Unregisters a player from all the matches where he/her was registered even past matches.int
updateCarForRegistration
(Match match, Player player, Car car, boolean isCarConfirmed) Updates and confirms a car for a player registered into a match.void
updateMatchStatus
(Match match) Update a match with new status details.
-
Method Details
-
isCodeAlreadyRegistered
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
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 researchsport
- Sport to search in the list of matchesstatus
- Match status to searchstartDate
- Start date for the researchendDate
- Limit date for the research- Returns:
- List of matches returned by the research
-
findMatchById
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
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 registermatch
- Match to updatecar
- 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
Checks if a player is already registered to a match.- Parameters:
player
- Player to searchmatch
- Match to search- Returns:
- True if the player is already registered
-
unregisterPlayer
Unregisters a player from a match.- Parameters:
player
- Player to unregistermatch
- Match to update
-
unregisterPlayerFromAllMatches
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 searchplayer
- Player to searchcar
- Car to setisCarConfirmed
- Is the car confirmed or not- Returns:
- Number of updated cars. It should be 0 or 1
-
loadRegistration
Loads registration details for a player in a specific match.- Parameters:
match
- Match to searchplayer
- 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 searchcar
- Car to search- Returns:
- List of registrations made with the given car for a match
-
resetCarDetails
Resets car details for a player registration in a given match.- Parameters:
match
- Match to searchplayer
- Player to search- Returns:
- Number of lines touched by this operation
-
updateMatchStatus
Update a match with new status details.- Parameters:
match
- Match to update
-