public Resolution save() { song.setAlbum(musicFacade.getAlbumById(album)); song.setArtist(musicFacade.getArtistById(artist)); song.setGenre(musicFacade.getGenreById(genre)); musicFacade.update(song); return new RedirectResolution(this.getClass(), "list"); }
public Resolution edit() { albums = musicFacade.getAllAlbums(); genres = musicFacade.getAllGenres(); artists = musicFacade.getAllArtists(); HttpSession session = getContext().getRequest().getSession(); playlists = musicFacade.getPlaylistsByAccount((String) session.getAttribute("username")); return new ForwardResolution("/song/edit.jsp"); }
public Resolution delete() { song = musicFacade.getSongById(song.getId()); try { musicFacade.delete(song); } catch (DataAccessException ex) { } return new RedirectResolution(this.getClass(), "list"); }
@Override public Resolution handleValidationErrors(ValidationErrors errors) throws Exception { songs = musicFacade.getAllSongs(); albums = musicFacade.getAllAlbums(); genres = musicFacade.getAllGenres(); artists = musicFacade.getAllArtists(); HttpSession session = getContext().getRequest().getSession(); playlists = musicFacade.getPlaylistsByAccount((String) session.getAttribute("username")); return null; }
@Before( stages = LifecycleStage.BindingAndValidation, on = {"edit", "save", "details"}) public void loadSongFromDatabase() { String ids = getContext().getRequest().getParameter("song.id"); if (ids == null) { return; } song = musicFacade.getSongById(Long.parseLong(ids)); }