@RequestMapping(value = "/movies/add", method = RequestMethod.POST) // aggiunge movie al db public Movie add( @RequestParam(value = "title", required = true) String title, @RequestParam(value = "genre", required = true) String genre, @RequestParam(value = "year", required = true) int year, @RequestParam(value = "language", required = true) String language) { Movie movie = new Movie(title, genre, year, language); serv.addElement(movie); return movie; }
@RequestMapping(value = "/movies/addtwo", method = RequestMethod.POST) public @ResponseBody Movie add(@RequestBody Movie movie, HttpServletRequest request) { MovieNotValidException mnve = MovieValidator.control(movie); if (mnve.getSize() == 0) { serv.addElement(movie); logger.debug("Film aggiunto"); } else { for (int i = 0; i < mnve.getSize(); i++) { mnve.getSingleException(i).echoMessage(); } } return movie; }
@RequestMapping(value = "/movies/ticket", method = RequestMethod.GET) // stampa ticket public void getTicket(@RequestParam(value = "id") int id, int numb, HttpServletResponse response) throws Exception { // numb=numeroBigliettiDaStampare,Id=specificoMovie byte[] xmlFile = serv.getPDF(id, numb); serv.streamReport(response, xmlFile, "report.pdf"); } // add
@RequestMapping(value = "/movies/addrole", method = RequestMethod.POST) public boolean addRole(int id_movie, int id_actor) { serv.addRole(new Role(id_movie, id_actor)); return true; }
@RequestMapping( value = "/movies/elem", method = RequestMethod.GET) // dato l'Id, recupera un movie public Movie getMovie(@RequestParam(value = "id", required = true) int id) { return serv.getElem(id); }
@RequestMapping( value = "/movies/id", method = RequestMethod.GET) // prende id di un movie dato il titolo public int id(@RequestParam(value = "title") String title) { return serv.getId(title); }
@RequestMapping(value = "/movies/listByID", method = RequestMethod.GET) public ArrayList<Movie> getListByID(@RequestParam(value = "id") int id) { return serv.getListByID(id); }
@RequestMapping( value = "/movies/list", method = RequestMethod.GET) // ritorna lista con tutti i movie del db public List<Movie> movies(@RequestParam(value = "id", defaultValue = "-1") int id) { return serv.getlist(); }
@RequestMapping( value = "/movies/{id}", method = RequestMethod.DELETE) // TODO,elimina movie dal db public void remove(@PathVariable(value = "id") int id) { serv.deleteFilm(id); }