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