private Board getSudokoBoardById(Integer id) { Board sudokoBoard = sudokoBoardRepository.getBoard(id); if (!sudokoBoard.getChached()) { return null; } return sudokoBoard; }
@Override public BasicSudokoDTO createSudokoBoard(BasicSudokoDTO sudoko) { Board sudokoBoard = sudokoBoardRepository.getBoard(sequencer.next()); sudokoBoard.create(sudoko.getSudokoBoardAsString()); boolean isValidBoard = solver.isValid(sudokoBoard.getSolutionArray()); if (isValidBoard) { Boolean solutionExist = solver.solve(sudokoBoard.getSolutionArray()); if (solutionExist) { sudokoBoard.setHavingSolution(solutionExist); sudoko.setIsValidBoard(isValidBoard); sudokoBoard.setChached(Boolean.TRUE); sudoko.setId(sudokoBoard.getId()); } } if (!sudoko.getIsValidBoard()) { throw new NotValidBoardException(sudoko.getSudokoBoardAsString()); } return sudoko; }