@Transactional public MDOAuthor getAuthor( Long authorSid ) { MDOAuthor author = this.daoauthor.get( authorSid ); if ( author.getOwner().getAllowDLNA() ) { return author; } else { return null; } }
@Transactional public List<MDOAuthor> getUserAuthors( Long userSid ) { MDOUser user = this.daoUsers.getUserById( userSid ); List<MDOAuthor> authors = new ArrayList<MDOAuthor>(); if ( user != null ) { authors = this.daoauthor.getAll( user.getLogin() ); } return authors; }
@Transactional public List<Author> findSimilar( User user, String authorName, boolean contains, boolean copyAlbums, boolean copySongs ) { List<MDOAuthor> authors = daoAuthor.findSimilarAuthors( authorName, contains, user.getLogin() ); return Author.transform( authors, copyAlbums, copySongs ); }
@Transactional public void remove( User user, Long authorSid ) throws IOException { MDOAuthor author = daoAuthor.get( user.getLogin(), authorSid ); if ( author != null ) { String path = author.calculateAbsolutePath( daoSettings.getSettings() ); daoAuthor.remove( author ); FileUtils.deleteDirectory( new File( path ) ); } }
mdoAuthor = daoAuthor.get( user.getLogin(), album.getAuthor().getSid() ); mdoAuthor = daoAuthor.getByName( album.getAuthor().getName(), user.getLogin() ); daoAuthor.save( mdoAuthor ); if ( mdoGenre != null ) daoAuthor.flush(); daoAuthor.remove( oldAuthor ); String oldAuthorPath = oldAuthor.calculateAbsolutePath( daoSettings.getSettings() ); FileUtils.deleteDirectory( new File( oldAuthorPath ) );
authors = this.daoauthor.getAll( username ); authors = this.daoauthor.getAllDLNA();
@Override public RandomList getRandomList( User user ) { // second list, getting all the songs of an author List<MDOAuthor> randomAuthorList = daoAuthor.getRandomAuthors( user.getLogin(), 1 ); if ( randomAuthorList != null && randomAuthorList.size() > 0 ) { RandomList rl = new RandomList( "RandomListName-Author", "RandomListTitle-Author" ); rl.addDetail( randomAuthorList.get( 0 ).getName() ); Iterator<MDOAlbum> albumsit = randomAuthorList.get( 0 ).getAlbums().iterator(); while ( albumsit.hasNext() ) { MDOAlbum album = albumsit.next(); List<MDOSong> songs = album.getSongs(); for ( int i = 0; i < songs.size() && rl.getSongs().size() < MAX_ELEMENTS; i++ ) { MDOSong mdoSong = songs.get( i ); 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; }
@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; }
MDOAuthor author = daoAuthor.getAuthorByLocation( faufolder.getName(), user.getLogin() );
daoAuthor.save( author ); String newPath = author.calculateAbsolutePath( daoSettings.getSettings() ); FileUtils.moveDirectory( new File( authorPath ), new File( newPath ) );
@Transactional public Author getAuthor( User user, long authorSid, boolean copyAlbums, boolean copySongs ) { MDOAuthor author = daoAuthor.get( user.getLogin(), authorSid ); return Author.transform( author, copyAlbums, copySongs ); }
@Transactional public List<Author> getAll( User user, boolean copyAlbums, boolean copySongs ) { List<MDOAuthor> authors = daoAuthor.getAll( user.getLogin() ); return Author.transform( authors, copyAlbums, copySongs ); }
@Transactional public byte[] getAuthorCover( User mdouser, Long authorSid, Integer preferredWidth, Integer preferredHeight ) throws SidNotFoundMessicException, ResourceNotFoundMessicException, IOException { MDOAuthor author = daoAuthor.get( mdouser.getLogin(), authorSid ); if ( author.getAlbums().size() > 0 ) { MDOAlbum album = author.getAlbums().iterator().next(); return apiAlbum.getAlbumCover( mdouser, album.getSid(), preferredWidth, preferredHeight ); } else { return null; } }
public List<Song> getSongsOfAuthor( User user, long authorSid, boolean includeAlbumInfo, boolean includeAuthorInfo ) throws SidNotFoundMessicException { MDOAuthor mdoauthor = daoAuthor.get( user.getLogin(), authorSid ); if ( mdoauthor != null ) { List<Song> result = new ArrayList<Song>(); Set<MDOAlbum> albums = mdoauthor.getAlbums(); for ( MDOAlbum mdoalbum : albums ) { 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(); } }
Set<MDOAlbum> setalbums = this.daoauthor.get( sid ).getAlbums(); for ( MDOAlbum mdoAlbum : setalbums )