@DELETE @RolesAllowed({Role.TEACHER}) @Path("/spell/{id}") @Produces(MediaType.TEXT_PLAIN) public String deleteGame(@PathParam("id") int id) { gameManager.delete(id); return "ok"; }
@GET @RolesAllowed({Role.STUDENT, Role.TEACHER}) @Path("/spells") @Produces(MediaType.APPLICATION_JSON) public GameTOs getAllGames(@HeaderParam("login") String login) { List<Game> allGames = gameManager.getAllGames(login, SpellGame.class); GameTOs gameTOs = TOsGameManager.processGames(allGames); return gameTOs; }
@GET @RolesAllowed({Role.TEACHER}) @Path("/spell/{id}") @Produces(MediaType.APPLICATION_JSON) public SpellGameTO getGame(@PathParam("id") int id) { SpellGame spellGame = gameManager.getSpellGameByID(id); SpellGameTO spellGameTO = TOsGameManager.convertSpellGame(spellGame); return spellGameTO; }
@POST @RolesAllowed({Role.TEACHER}) @Path("/spell") @Produces(MediaType.TEXT_PLAIN) public Integer insertGame(SpellGameTO spellGameTO, @HeaderParam("login") String login) { SpellGame spellGame = TOsGameManager.covertSpellGameTO(spellGameTO); Integer id = gameManager.insertGame(spellGame, login); return id; }
@GET @Path("/student/spell/{id}") @RolesAllowed({Role.STUDENT}) @Produces(MediaType.APPLICATION_JSON) public SpellGameStudentTO getGameForStudent( @HeaderParam("login") String login, @PathParam("id") int id) { SpellGame spellGame = gameManager.getSpellGameByID(id); SpellGameStudentTO spellGameStudentTO = CurrentGameCreator.createAndStartCurrSpellGame(spellGame, login); return spellGameStudentTO; }