예제 #1
0
 /**
  * Searches albums.
  *
  * @param album album name or part of it.
  * @return a view displaying search results.
  */
 ModelAndView handleSearchAlbums(String album) {
   ModelAndView mav = new ModelAndView(ALBUM_RESULTS_VIEW);
   mav.addObject(SEARCH_TERM_KEY, album);
   List<Album> results = albumDao.findAlbumByNameLike(album);
   if (!results.isEmpty()) {
     mav.addObject(ALBUM_RESULTS_KEY, results);
   }
   return mav;
 }
예제 #2
0
 /**
  * Displays artist albums.
  *
  * @param artistId artist identifier.
  * @return a view displaying all albums for the artist.
  */
 @RequestMapping(value = "/artistAlbums", method = RequestMethod.GET)
 public ModelAndView handleArtistAlbums(@RequestParam Long artistId) {
   ModelAndView mav = new ModelAndView(ALBUM_RESULTS_VIEW);
   Artist artist = artistDao.loadArtist(artistId);
   mav.addObject(ARTIST_ID_KEY, artist.getId());
   mav.addObject(ARTIST_NAME_KEY, artist.getName());
   List<Album> results = albumDao.findAlbumByArtistId(artistId);
   if (!results.isEmpty()) {
     mav.addObject(ALBUM_RESULTS_KEY, results);
   }
   return mav;
 }