@ -104,12 +104,11 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . VIDEO . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
put ( "count" , count ) ;
put ( "offset" , offset ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . VIDEO . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
args . put ( "count" , count ) ;
args . put ( "offset" , offset ) ;
return namedQuery ( "select " + QUERY_COLUMNS
+ " from media_file where type = :type and present and folder in (:folders) " +
"order by title limit :count offset :offset" , rowMapper , args ) ;
@ -119,11 +118,10 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return null ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . DIRECTORY . name ( ) ) ;
put ( "name" , name ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . DIRECTORY . name ( ) ) ;
args . put ( "name" , name ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
return namedQueryOne ( "select " + QUERY_COLUMNS + " from media_file where type = :type and artist = :name " +
"and present and folder in (:folders)" , rowMapper , args ) ;
}
@ -233,12 +231,11 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
put ( "count" , count ) ;
put ( "offset" , offset ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
args . put ( "count" , count ) ;
args . put ( "offset" , offset ) ;
return namedQuery ( "select " + QUERY_COLUMNS
+ " from media_file where type = :type and play_count > 0 and present and folder in (:folders) " +
@ -257,12 +254,11 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
put ( "count" , count ) ;
put ( "offset" , offset ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
args . put ( "count" , count ) ;
args . put ( "offset" , offset ) ;
return namedQuery ( "select " + QUERY_COLUMNS
+ " from media_file where type = :type and last_played is not null and present " +
"and folder in (:folders) order by last_played desc limit :count offset :offset" , rowMapper , args ) ;
@ -280,12 +276,11 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
put ( "count" , count ) ;
put ( "offset" , offset ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
args . put ( "count" , count ) ;
args . put ( "offset" , offset ) ;
return namedQuery ( "select " + QUERY_COLUMNS
+ " from media_file where type = :type and folder in (:folders) and present " +
@ -305,12 +300,11 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
put ( "count" , count ) ;
put ( "offset" , offset ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
args . put ( "count" , count ) ;
args . put ( "offset" , offset ) ;
String orderBy = byArtist ? "artist, album" : "album" ;
return namedQuery ( "select " + QUERY_COLUMNS
@ -333,14 +327,13 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
put ( "fromYear" , fromYear ) ;
put ( "toYear" , toYear ) ;
put ( "count" , count ) ;
put ( "offset" , offset ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
args . put ( "fromYear" , fromYear ) ;
args . put ( "toYear" , toYear ) ;
args . put ( "count" , count ) ;
args . put ( "offset" , offset ) ;
if ( fromYear < = toYear ) {
return namedQuery ( "select " + QUERY_COLUMNS
@ -369,13 +362,12 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
put ( "genre" , genre ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
put ( "count" , count ) ;
put ( "offset" , offset ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
args . put ( "genre" , genre ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
args . put ( "count" , count ) ;
args . put ( "offset" , offset ) ;
return namedQuery ( "select " + QUERY_COLUMNS + " from media_file where type = :type and folder in (:folders) " +
"and present and genre = :genre limit :count offset :offset" , rowMapper , args ) ;
}
@ -384,13 +376,12 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "types" , Arrays . asList ( MediaFile . MediaType . MUSIC . name ( ) , MediaFile . MediaType . PODCAST . name ( ) , MediaFile . MediaType . AUDIOBOOK . name ( ) ) ) ;
put ( "genre" , genre ) ;
put ( "count" , count ) ;
put ( "offset" , offset ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "types" , Arrays . asList ( MediaFile . MediaType . MUSIC . name ( ) , MediaFile . MediaType . PODCAST . name ( ) , MediaFile . MediaType . AUDIOBOOK . name ( ) ) ) ;
args . put ( "genre" , genre ) ;
args . put ( "count" , count ) ;
args . put ( "offset" , offset ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
return namedQuery ( "select " + QUERY_COLUMNS + " from media_file where type in (:types) and genre = :genre " +
"and present and folder in (:folders) limit :count offset :offset" ,
rowMapper , args ) ;
@ -406,12 +397,11 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) | | StringUtils . isBlank ( title ) | | StringUtils . isBlank ( artist ) ) {
return null ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "artist" , artist ) ;
put ( "title" , title ) ;
put ( "type" , MediaFile . MediaType . MUSIC . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "artist" , artist ) ;
args . put ( "title" , title ) ;
args . put ( "type" , MediaFile . MediaType . MUSIC . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
return namedQueryOne ( "select " + QUERY_COLUMNS + " from media_file where artist = :artist " +
"and title = :title and type = :type and present and folder in (:folders)" ,
rowMapper , args ) ;
@ -431,13 +421,12 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
put ( "username" , username ) ;
put ( "count" , count ) ;
put ( "offset" , offset ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
args . put ( "username" , username ) ;
args . put ( "count" , count ) ;
args . put ( "offset" , offset ) ;
return namedQuery ( "select " + prefix ( QUERY_COLUMNS , "media_file" ) + " from starred_media_file, media_file where media_file.id = starred_media_file.media_file_id and " +
"media_file.present and media_file.type = :type and media_file.folder in (:folders) and starred_media_file.username = :username " +
"order by starred_media_file.created desc limit :count offset :offset" ,
@ -458,13 +447,12 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . DIRECTORY . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
put ( "username" , username ) ;
put ( "count" , count ) ;
put ( "offset" , offset ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . DIRECTORY . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
args . put ( "username" , username ) ;
args . put ( "count" , count ) ;
args . put ( "offset" , offset ) ;
return namedQuery ( "select " + prefix ( QUERY_COLUMNS , "media_file" ) + " from starred_media_file, media_file " +
"where media_file.id = starred_media_file.media_file_id and " +
"media_file.present and media_file.type = :type and starred_media_file.username = :username and " +
@ -487,13 +475,12 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "types" , Arrays . asList ( MediaFile . MediaType . MUSIC . name ( ) , MediaFile . MediaType . PODCAST . name ( ) , MediaFile . MediaType . AUDIOBOOK . name ( ) , MediaFile . MediaType . VIDEO . name ( ) ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
put ( "username" , username ) ;
put ( "count" , count ) ;
put ( "offset" , offset ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "types" , Arrays . asList ( MediaFile . MediaType . MUSIC . name ( ) , MediaFile . MediaType . PODCAST . name ( ) , MediaFile . MediaType . AUDIOBOOK . name ( ) , MediaFile . MediaType . VIDEO . name ( ) ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
args . put ( "username" , username ) ;
args . put ( "count" , count ) ;
args . put ( "offset" , offset ) ;
return namedQuery ( "select " + prefix ( QUERY_COLUMNS , "media_file" ) + " from starred_media_file, media_file where media_file.id = starred_media_file.media_file_id and " +
"media_file.present and media_file.type in (:types) and starred_media_file.username = :username and " +
"media_file.folder in (:folders) " +
@ -506,22 +493,21 @@ public class MediaFileDao extends AbstractDao {
return Collections . emptyList ( ) ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "folders" , MusicFolder . toPathList ( criteria . getMusicFolders ( ) ) ) ;
put ( "username" , username ) ;
put ( "fromYear" , criteria . getFromYear ( ) ) ;
put ( "toYear" , criteria . getToYear ( ) ) ;
put ( "genre" , criteria . getGenre ( ) ) ;
put ( "minLastPlayed" , criteria . getMinLastPlayedDate ( ) ) ;
put ( "maxLastPlayed" , criteria . getMaxLastPlayedDate ( ) ) ;
put ( "minAlbumRating" , criteria . getMinAlbumRating ( ) ) ;
put ( "maxAlbumRating" , criteria . getMaxAlbumRating ( ) ) ;
put ( "minPlayCount" , criteria . getMinPlayCount ( ) ) ;
put ( "maxPlayCount" , criteria . getMaxPlayCount ( ) ) ;
put ( "starred" , criteria . isShowStarredSongs ( ) ) ;
put ( "unstarred" , criteria . isShowUnstarredSongs ( ) ) ;
put ( "format" , criteria . getFormat ( ) ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "folders" , MusicFolder . toPathList ( criteria . getMusicFolders ( ) ) ) ;
args . put ( "username" , username ) ;
args . put ( "fromYear" , criteria . getFromYear ( ) ) ;
args . put ( "toYear" , criteria . getToYear ( ) ) ;
args . put ( "genre" , criteria . getGenre ( ) ) ;
args . put ( "minLastPlayed" , criteria . getMinLastPlayedDate ( ) ) ;
args . put ( "maxLastPlayed" , criteria . getMaxLastPlayedDate ( ) ) ;
args . put ( "minAlbumRating" , criteria . getMinAlbumRating ( ) ) ;
args . put ( "maxAlbumRating" , criteria . getMaxAlbumRating ( ) ) ;
args . put ( "minPlayCount" , criteria . getMinPlayCount ( ) ) ;
args . put ( "maxPlayCount" , criteria . getMaxPlayCount ( ) ) ;
args . put ( "starred" , criteria . isShowStarredSongs ( ) ) ;
args . put ( "unstarred" , criteria . isShowUnstarredSongs ( ) ) ;
args . put ( "format" , criteria . getFormat ( ) ) ;
boolean joinAlbumRating = ( criteria . getMinAlbumRating ( ) ! = null | | criteria . getMaxAlbumRating ( ) ! = null ) ;
boolean joinStarred = ( criteria . isShowStarredSongs ( ) ^ criteria . isShowUnstarredSongs ( ) ) ;
@ -612,10 +598,9 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return 0 ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
return namedQueryForInt ( "select count(*) from media_file where type = :type and folder in (:folders) and present" , 0 , args ) ;
}
@ -623,10 +608,9 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return 0 ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
return namedQueryForInt ( "select count(*) from media_file where type = :type " +
"and play_count > 0 and present and folder in (:folders)" , 0 , args ) ;
}
@ -635,11 +619,10 @@ public class MediaFileDao extends AbstractDao {
if ( musicFolders . isEmpty ( ) ) {
return 0 ;
}
Map < String , Object > args = new HashMap < String , Object > ( ) { {
put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
put ( "username" , username ) ;
} } ;
Map < String , Object > args = new HashMap < > ( ) ;
args . put ( "type" , MediaFile . MediaType . ALBUM . name ( ) ) ;
args . put ( "folders" , MusicFolder . toPathList ( musicFolders ) ) ;
args . put ( "username" , uername ) ;
return namedQueryForInt ( "select count(*) from starred_media_file, media_file " +
"where media_file.id = starred_media_file.media_file_id " +
"and media_file.type = :type " +