use of com.github.hakko.musiccabinet.domain.model.aggr.NameSearchResult in project musiccabinet by hakko.
the class JdbcNameSearchDao method getArtists.
@Override
public NameSearchResult<Artist> getArtists(String userQuery, int offset, int limit) {
String sql = "select ma.id, ma.artist_name_capitalization" + " from library.artist la" + " inner join music.artist ma on la.artist_id = ma.id" + " where la.artist_name_search like ?" + " order by la.hasalbums desc, ma.artist_name" + " offset ? limit ?";
List<Artist> artists = jdbcTemplate.query(sql, new Object[] { getNameQuery(userQuery), offset, limit }, new ArtistRowMapper());
return new NameSearchResult<>(artists, offset);
}
use of com.github.hakko.musiccabinet.domain.model.aggr.NameSearchResult in project musiccabinet by hakko.
the class JdbcNameSearchDao method getAlbums.
@Override
public NameSearchResult<Album> getAlbums(String userQuery, int offset, int limit) {
String sql = "select mart.id, mart.artist_name_capitalization," + " malb.id, malb.album_name_capitalization, la.year," + " d1.path, f1.filename, d2.path, f2.filename, null, array[]::int[]" + " from library.album la" + " inner join music.album malb on la.album_id = malb.id" + " inner join music.artist mart on malb.artist_id = mart.id" + " left outer join library.file f1 on f1.id = la.embeddedcoverartfile_id" + " left outer join library.directory d1 on f1.directory_id = d1.id" + " left outer join library.file f2 on f2.id = la.coverartfile_id" + " left outer join library.directory d2 on f2.directory_id = d2.id" + " where la.album_name_search like ?" + " order by malb.album_name" + " offset ? limit ?";
List<Album> albums = jdbcTemplate.query(sql, new Object[] { getNameQuery(userQuery), offset, limit }, new AlbumRowMapper());
return new NameSearchResult<>(albums, offset);
}
use of com.github.hakko.musiccabinet.domain.model.aggr.NameSearchResult in project musiccabinet by hakko.
the class JdbcNameSearchDao method getTracks.
@Override
public NameSearchResult<Track> getTracks(String userQuery, int offset, int limit) {
String sql = "select mart.id, mart.artist_name_capitalization," + " malb.id, malb.album_name_capitalization," + " lt.id, mt.track_name_capitalization from library.track lt" + " inner join music.track mt on lt.track_id = mt.id" + " inner join music.album malb on lt.album_id = malb.id" + " inner join music.artist mart on mt.artist_id = mart.id" + " where lt.track_name_search like ?" + " order by mt.track_name" + " offset ? limit ?";
List<Track> albums = jdbcTemplate.query(sql, new Object[] { getNameQuery(userQuery), offset, limit }, new RowMapper<Track>() {
@Override
public Track mapRow(ResultSet rs, int rowNum) throws SQLException {
MetaData metaData = new MetaData();
metaData.setArtistId(rs.getInt(1));
metaData.setArtist(rs.getString(2));
metaData.setAlbumId(rs.getInt(3));
metaData.setAlbum(rs.getString(4));
return new Track(rs.getInt(5), rs.getString(6), metaData);
}
});
return new NameSearchResult<>(albums, offset);
}
Aggregations