@Transactional public List<Album> findSimilar( MDOUser user, String albumName, boolean authorInfo, boolean songsInfo, boolean resourcesInfo ) { List<MDOAlbum> albums = daoAlbum.findSimilarAlbums( albumName, user.getLogin() ); return Album.transform( albums, authorInfo, songsInfo, resourcesInfo ); }
@Transactional public MDOAlbum getAlbum( Long albumSid ) { MDOAlbum album = this.daoalbum.get( albumSid ); if ( album.getOwner().getAllowDLNA() ) { return album; } else { return null; } }
@Transactional public Album getAlbum( User user, long albumSid, boolean authorInfo, boolean songsInfo, boolean resourcesInfo ) { MDOAlbum album = daoAlbum.getAlbum( albumSid, user.getLogin() ); return Album.transform( album, authorInfo, songsInfo, resourcesInfo ); }
mdoAlbum = daoAlbum.getAlbum( album.getSid(), user.getLogin() ); if ( mdoAlbum != null ) mdoAlbum = daoAlbum.getByName( mdoAuthor.getName(), album.getName(), user.getLogin() ); List<MDOAlbum> albumsSameName = daoAlbum.findAlbum( album.getName(), user.getLogin() ); if ( albumsSameName.size() > 0 ) daoAlbum.save( mdoAlbum ); mdoAlbum = daoAlbum.merge( mdoAlbum ); sidResult = mdoAlbum.getSid(); daoAlbum.save( mdoAlbum ); daoAlbum.save( mdoAlbum );
@Transactional public boolean remove( User user, Long albumSid ) throws IOException { MDOAlbum album = this.daoAlbum.getAlbum( albumSid, user.getLogin() ); if ( album != null ) { MDOAuthor author = album.getAuthor(); if ( author.getAlbums().size() <= 1 ) { File fpath = new File( author.calculateAbsolutePath( daoSettings.getSettings() ) ); FileUtils.deleteDirectory( fpath ); // after, removing the author data from database daoAuthor.remove( album.getAuthor() ); return true; } else { // first, removing the album folder File fpath = new File( album.calculateAbsolutePath( daoSettings.getSettings() ) ); FileUtils.deleteDirectory( fpath ); // after, removing the album data from database this.daoAlbum.remove( album ); return false; } } return false; }
int fromYear = Util.randInt( daoAlbum.findOldestAlbum( user.getLogin() ), currentYear ); int toYear = fromYear + Util.randInt( 1, 5 );// fromYear + 10;// Util.randInt( fromYear, year ); if ( toYear > currentYear ) List<MDOAlbum> albums = daoAlbum.findAlbumsBasedOnDate( user.getLogin(), fromYear, toYear );
public byte[] getAlbumCover( User mdouser, Long albumSid, Integer preferredWidth, Integer preferredHeight ) throws SidNotFoundMessicException, ResourceNotFoundMessicException, IOException MDOArtwork cover = daoAlbum.getAlbumCover( albumSid, mdouser.getLogin() ); if ( cover != null ) + daoAlbum.getAlbum( albumSid, mdouser.getLogin() ).getName() + "'. Error:" + e.getMessage() );
public long fuseGenres( User user, List<Long> genreSids, String newGenreName ) { MDOUser mdouser = daoUser.getUserByLogin( user.getLogin() ); // 1st, creating the new genre MDOGenre newGenre = new MDOGenre( newGenreName, mdouser ); daoGenre.save( newGenre ); for ( int i = 0; i < genreSids.size(); i++ ) { // second, replacing current genre by the new one MDOGenre genre = this.daoGenre.getGenre( user.getLogin(), genreSids.get( i ) ); List<MDOAlbum> albums = this.daoAlbum.getAll( user.getLogin(), genre ); for ( MDOAlbum mdoAlbum : albums ) { mdoAlbum.setGenre( newGenre ); daoAlbum.save( mdoAlbum ); } // third, removing all olds genres daoGenre.remove( genre ); } return daoGenre.getByName( user.getLogin(), newGenreName ).getSid(); } }
@Transactional public List<Album> getAll( MDOUser user, boolean authorInfo, boolean songsInfo, boolean resourcesInfo, int fromResult, int maxResults, boolean orderDesc, boolean orderByAuthor ) { List<MDOAlbum> albums = this.daoAlbum.getAll( user.getLogin(), fromResult, maxResults, orderDesc, orderByAuthor ); return Album.transform( albums, authorInfo, songsInfo, resourcesInfo ); }
@Transactional public List<Album> getAllOfGenre( MDOUser user, long genreSid, boolean authorInfo, boolean songsInfo, boolean resourcesInfo, int fromResult, int maxResults, boolean orderDesc, boolean orderByAuthor ) { List<MDOAlbum> albums = daoAlbum.getAllOfGenre( genreSid, user.getLogin(), fromResult, maxResults, orderDesc, orderByAuthor ); return Album.transform( albums, authorInfo, songsInfo, resourcesInfo ); }
albums = this.daoalbum.getAllDLNA();
@Transactional public List<Album> getAll( MDOUser user, long authorSid, boolean authorInfo, boolean songsInfo, boolean resourcesInfo, int fromResult, int maxResults, boolean orderDesc, boolean orderByAuthor ) { List<MDOAlbum> albums = daoAlbum.getAll( authorSid, user.getLogin(), fromResult, maxResults, orderDesc, orderByAuthor ); return Album.transform( albums, authorInfo, songsInfo, resourcesInfo ); }
@Override public RandomList getRandomList( User user ) { List<MDOGenre> randomGenreList = daoGenre.getRandomGenre( user.getLogin(), 1 ); if ( randomGenreList != null && randomGenreList.size() > 0 ) { List<MDOAlbum> albumList = daoAlbum.getAll( user.getLogin(), randomGenreList.get( 0 ) ); RandomList rl = new RandomList( "RandomListName-Genre", "RandomListTitle-Genre" ); rl.addDetail( randomGenreList.get( 0 ).getName() ); for ( int i = 0; i < albumList.size() && i < MAX_ELEMENTS; i++ ) { for ( MDOSong mdoSong : albumList.get( i ).getSongs() ) { Song song = new Song( mdoSong, true, true ); rl.addSong( song ); } } long seed = System.nanoTime(); if ( rl.getSongs() != null ) { Collections.shuffle( rl.getSongs(), new Random( seed ) ); } return rl; } return null; }
public List<Song> getSongsOfAlbum( User user, long albumSid, boolean includeAlbumInfo, boolean includeAuthorInfo ) throws SidNotFoundMessicException { MDOAlbum mdoalbum = daoAlbum.getAlbum( albumSid, user.getLogin() ); if ( mdoalbum != null ) { List<Song> result = new ArrayList<Song>(); List<MDOSong> songs = mdoalbum.getSongs(); for ( MDOSong mdoSong : songs ) { Song song = new Song( mdoSong, includeAlbumInfo, includeAuthorInfo ); result.add( song ); } return result; } else { throw new SidNotFoundMessicException(); } }
@Transactional public List<Album> findSimilar( MDOUser user, int authorSid, String albumName, boolean authorInfo, boolean songsInfo, boolean resourcesInfo, int fromResult, int maxResults, boolean orderDesc, boolean orderByAuthor ) { List<MDOAlbum> albums = daoAlbum.findSimilarAlbums( authorSid, albumName, user.getLogin(), fromResult, maxResults, orderDesc, orderByAuthor ); return Album.transform( albums, authorInfo, songsInfo, resourcesInfo ); }
songs = this.daoalbum.get( sid ).getSongs();
@Transactional public void getAlbumZip( User user, Long albumSid, OutputStream os ) throws IOException { MDOAlbum album = this.daoAlbum.getAlbum( albumSid, user.getLogin() ); if ( album != null ) { String basePath = album.calculateAbsolutePath( daoSettings.getSettings() ); Util.zipFolder( basePath + File.separatorChar, album.getAuthor().getName() + "-" + album.getName(), os ); } else { throw new IOException( "Album not found!" ); } }