Search in sources :

Example 31 with Track

use of com.github.hakko.musiccabinet.domain.model.music.Track in project musiccabinet by hakko.

the class JdbcUserLovedTracksDao method batchInsert.

private void batchInsert(String lastFmUsername, List<Track> lovedTracks) {
    String sql = "insert into music.lovedtrack_import" + " (lastfm_user, artist_name, track_name) values (?,?,?)";
    BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
    batchUpdate.setBatchSize(1000);
    batchUpdate.declareParameter(new SqlParameter("lastfm_user", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("track_name", Types.VARCHAR));
    for (Track track : lovedTracks) {
        batchUpdate.update(new Object[] { lastFmUsername, track.getArtist().getName(), track.getName() });
    }
    batchUpdate.flush();
}
Also used : SqlParameter(org.springframework.jdbc.core.SqlParameter) BatchSqlUpdate(org.springframework.jdbc.object.BatchSqlUpdate) Track(com.github.hakko.musiccabinet.domain.model.music.Track) UserStarredTrack(com.github.hakko.musiccabinet.domain.model.aggr.UserStarredTrack)

Example 32 with Track

use of com.github.hakko.musiccabinet.domain.model.music.Track in project musiccabinet by hakko.

the class TrackRowMapper method mapRow.

@Override
public Track mapRow(ResultSet rs, int rowNum) throws SQLException {
    Track track = new Track();
    track.setId(rs.getInt(1));
    track.setName(rs.getString(2));
    return track;
}
Also used : Track(com.github.hakko.musiccabinet.domain.model.music.Track)

Example 33 with Track

use of com.github.hakko.musiccabinet.domain.model.music.Track in project musiccabinet by hakko.

the class TrackWithMetadataRowMapper method mapRow.

@Override
public Track mapRow(ResultSet rs, int rowNum) throws SQLException {
    String trackName = rs.getString(1);
    MetaData md = new MetaData();
    md.setAlbum(rs.getString(2));
    md.setArtist(rs.getString(3));
    md.setAlbumArtist(rs.getString(4));
    md.setComposer(rs.getString(5));
    md.setTrackNr(rs.getShort(6));
    md.setTrackNrs(rs.getShort(7));
    md.setDiscNr(rs.getShort(8));
    md.setDiscNrs(rs.getShort(9));
    md.setYear(rs.getShort(10));
    md.setHasLyrics(rs.getBoolean(11));
    md.setBitrate(rs.getShort(12));
    md.setVbr(rs.getBoolean(13));
    md.setDuration(rs.getShort(14));
    md.setMediaType(Mediatype.values()[rs.getShort(15)]);
    md.setPath(rs.getString(16) + separatorChar + rs.getString(17));
    md.setSize(rs.getInt(18));
    md.setModified(rs.getTimestamp(19).getTime());
    int trackId = rs.getInt(20);
    md.setAlbumId(rs.getInt(21));
    md.setArtistId(rs.getInt(22));
    return new Track(trackId, trackName, md);
}
Also used : MetaData(com.github.hakko.musiccabinet.domain.model.library.MetaData) Track(com.github.hakko.musiccabinet.domain.model.music.Track)

Example 34 with Track

use of com.github.hakko.musiccabinet.domain.model.music.Track in project musiccabinet by hakko.

the class UserStarredTrackRowMapper method mapRow.

@Override
public UserStarredTrack mapRow(ResultSet rs, int rowNum) throws SQLException {
    String username = rs.getString(1);
    String sessionKey = rs.getString(2);
    String artistName = rs.getString(3);
    String trackName = rs.getString(4);
    return new UserStarredTrack(new LastFmUser(username, sessionKey), new Track(artistName, trackName));
}
Also used : UserStarredTrack(com.github.hakko.musiccabinet.domain.model.aggr.UserStarredTrack) LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser) Track(com.github.hakko.musiccabinet.domain.model.music.Track) UserStarredTrack(com.github.hakko.musiccabinet.domain.model.aggr.UserStarredTrack)

Example 35 with Track

use of com.github.hakko.musiccabinet.domain.model.music.Track in project musiccabinet by hakko.

the class TrackSimilarityHandler method startElement.

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    if (TAG_SIMILAR_TRACKS.equals(qName)) {
        artistName = attributes.getValue(TAG_ARTIST);
        trackName = attributes.getValue(TAG_TRACK);
        sourceTrack = new Track(artistName, trackName);
    } else if (TAG_TRACK.equals(qName)) {
        scope = TRACK;
        currentTrackRelation = new TrackRelation();
        currentTrackRelation.setTarget(new Track());
    } else if (TAG_ARTIST.equals(qName)) {
        scope = ARTIST;
    } else {
        state = xmlToStateMap.get(qName);
        if (state != null) {
            characterData = new StringBuilder();
        }
    }
}
Also used : TrackRelation(com.github.hakko.musiccabinet.domain.model.music.TrackRelation) Track(com.github.hakko.musiccabinet.domain.model.music.Track)

Aggregations

Track (com.github.hakko.musiccabinet.domain.model.music.Track)40 Test (org.junit.Test)23 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)9 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)9 UserStarredTrack (com.github.hakko.musiccabinet.domain.model.aggr.UserStarredTrack)6 File (com.github.hakko.musiccabinet.domain.model.library.File)5 Album (com.github.hakko.musiccabinet.domain.model.music.Album)5 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)5 UserLovedTracks (com.github.hakko.musiccabinet.domain.model.aggr.UserLovedTracks)4 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)4 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)4 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)4 ArrayList (java.util.ArrayList)4 NameValuePair (org.apache.http.NameValuePair)4 Before (org.junit.Before)4 MetaData (com.github.hakko.musiccabinet.domain.model.library.MetaData)3 Calltype (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype)3 UserLovedTracksParserImpl (com.github.hakko.musiccabinet.parser.lastfm.UserLovedTracksParserImpl)3 UnittestLibraryUtil.submitFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.submitFile)3 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)3