Search in sources :

Example 1 with NameSearchResult

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);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) NameSearchResult(com.github.hakko.musiccabinet.domain.model.aggr.NameSearchResult) ArtistRowMapper(com.github.hakko.musiccabinet.dao.jdbc.rowmapper.ArtistRowMapper)

Example 2 with NameSearchResult

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);
}
Also used : NameSearchResult(com.github.hakko.musiccabinet.domain.model.aggr.NameSearchResult) Album(com.github.hakko.musiccabinet.domain.model.music.Album) AlbumRowMapper(com.github.hakko.musiccabinet.dao.jdbc.rowmapper.AlbumRowMapper)

Example 3 with NameSearchResult

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);
}
Also used : NameSearchResult(com.github.hakko.musiccabinet.domain.model.aggr.NameSearchResult) SQLException(java.sql.SQLException) MetaData(com.github.hakko.musiccabinet.domain.model.library.MetaData) ResultSet(java.sql.ResultSet) Track(com.github.hakko.musiccabinet.domain.model.music.Track)

Aggregations

NameSearchResult (com.github.hakko.musiccabinet.domain.model.aggr.NameSearchResult)3 AlbumRowMapper (com.github.hakko.musiccabinet.dao.jdbc.rowmapper.AlbumRowMapper)1 ArtistRowMapper (com.github.hakko.musiccabinet.dao.jdbc.rowmapper.ArtistRowMapper)1 MetaData (com.github.hakko.musiccabinet.domain.model.library.MetaData)1 Album (com.github.hakko.musiccabinet.domain.model.music.Album)1 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)1 Track (com.github.hakko.musiccabinet.domain.model.music.Track)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1