Service for managing Game entities.
More...
|
| | GameService (GameRepository gameRepository, PlayerRepository playerRepository, GridRepository gridRepository, IGameMapper gameMapper, GridService gridService, GameLevelService gameLevelService, JakartaValidator jakartaValidator) |
| | Constructs a new GameService with the required infrastructure, service, and mapping dependencies.
|
| void | createNewGameWithCurrent (GameDto sourceDto, long playerId) |
| | Creates a new game by duplicating the grid of the source game.
|
| void | deleteGame (long gameId) |
| | Deletes a game entity.
|
| Collection< GameDto > | getGames (long playerId) |
| | Retrieves all non-selected games for a given player, sorted by update date in descending order.
|
| void | switchAndSelectNewGame (long oldGameId, long newGameId) |
| | Atomically switches the selected game status.
|
|
| Game | getGameOrThrow (long gameId) |
| | Internal utility to retrieve a game entity by its identifier.
|
| void | updateGameSelection (long gameId, boolean selected) |
| | Internal utility to update game selection state and persist changes.
|
Service for managing Game entities.
◆ GameService()
Constructs a new GameService with the required infrastructure, service, and mapping dependencies.
- Parameters
-
| gameRepository | the repository for Game entities |
| playerRepository | the repository for Player entities |
| gridRepository | the repository for Grid entities |
| gameMapper | the mapper used to convert Game entities to GameDto |
| gridService | the service providing Grid duplication logic |
| gameLevelService | the service providing GameLevel lookup logic |
| jakartaValidator | the validator used to ensure data integrity of processed DTOs |
◆ createNewGameWithCurrent()
| void fr.softsf.sudokufx.service.business.GameService.createNewGameWithCurrent |
( |
GameDto | sourceDto, |
|
|
long | playerId ) |
Creates a new game by duplicating the grid of the source game.
The process clones the Grid resource, associates it with the specified Player and GameLevel, and initializes a new game instance.
Business operations performed:
This method is fully transactional: all operations succeed or fail as a unit.
- Parameters
-
| sourceDto | the source game DTO; must not be null |
| playerId | the identifier of the owner player |
- Exceptions
-
| IllegalArgumentException | if required entities are not found in the database |
| jakarta.validation.ConstraintViolationException | if validation fails on the resulting entities |
◆ deleteGame()
| void fr.softsf.sudokufx.service.business.GameService.deleteGame |
( |
long | gameId | ) |
|
◆ getGameOrThrow()
| Game fr.softsf.sudokufx.service.business.GameService.getGameOrThrow |
( |
long | gameId | ) |
|
|
private |
Internal utility to retrieve a game entity by its identifier.
- Parameters
-
| gameId | the identifier of the game to retrieve |
- Returns
- the found game entity
- Exceptions
-
| IllegalArgumentException | if the game does not exist |
◆ getGames()
| Collection< GameDto > fr.softsf.sudokufx.service.business.GameService.getGames |
( |
long | playerId | ) |
|
Retrieves all non-selected games for a given player, sorted by update date in descending order.
- Parameters
-
| playerId | the unique identifier of the player. |
- Returns
- a sorted, validated collection of
GameDto.
- Exceptions
-
| jakarta.validation.ConstraintViolationException | if validation fails. |
◆ switchAndSelectNewGame()
| void fr.softsf.sudokufx.service.business.GameService.switchAndSelectNewGame |
( |
long | oldGameId, |
|
|
long | newGameId ) |
Atomically switches the selected game status.
Ensures data consistency by unselecting the previous game and selecting the new one within a single database transaction.
- Parameters
-
| oldGameId | the identifier of the game to be unselected |
| newGameId | the identifier of the game to be selected |
- Exceptions
-
| IllegalArgumentException | if either game is not found |
| jakarta.validation.ConstraintViolationException | if validation fails |
◆ updateGameSelection()
| void fr.softsf.sudokufx.service.business.GameService.updateGameSelection |
( |
long | gameId, |
|
|
boolean | selected ) |
|
private |
Internal utility to update game selection state and persist changes.
- Parameters
-
| gameId | the identifier of the game to update |
| selected | the new selection state |
◆ GAME_NOT_FOUND
| final String fr.softsf.sudokufx.service.business.GameService.GAME_NOT_FOUND = "Game not found: " |
|
static |
◆ gameLevelService
| final GameLevelService fr.softsf.sudokufx.service.business.GameService.gameLevelService |
|
private |
◆ gameMapper
| final IGameMapper fr.softsf.sudokufx.service.business.GameService.gameMapper |
|
private |
◆ gameRepository
| final GameRepository fr.softsf.sudokufx.service.business.GameService.gameRepository |
|
private |
◆ gridRepository
| final GridRepository fr.softsf.sudokufx.service.business.GameService.gridRepository |
|
private |
◆ gridService
| final GridService fr.softsf.sudokufx.service.business.GameService.gridService |
|
private |
◆ jakartaValidator
| final JakartaValidator fr.softsf.sudokufx.service.business.GameService.jakartaValidator |
|
private |
◆ playerRepository
| final PlayerRepository fr.softsf.sudokufx.service.business.GameService.playerRepository |
|
private |
The documentation for this class was generated from the following file: