use of com.github.hakko.musiccabinet.domain.model.library.MetaData 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);
}
use of com.github.hakko.musiccabinet.domain.model.library.MetaData in project musiccabinet by hakko.
the class JdbcLibraryAdditionDao method addMetadata.
private void addMetadata(Set<File> files) {
String sql = "insert into library.file_headertag_import (path, filename, extension," + "bitrate, vbr, duration, artist_name, album_artist_name, composer_name," + "album_name, track_name, track_nr, track_nrs, disc_nr, disc_nrs, year," + "tag_name, lyrics, coverart, artistsort_name, albumartistsort_name) values" + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
BatchSqlUpdate batch = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batch.declareParameter(new SqlParameter("path", Types.VARCHAR));
batch.declareParameter(new SqlParameter("filename", Types.VARCHAR));
batch.declareParameter(new SqlParameter("extension", Types.VARCHAR));
batch.declareParameter(new SqlParameter("bitrate", Types.SMALLINT));
batch.declareParameter(new SqlParameter("vbr", Types.BOOLEAN));
batch.declareParameter(new SqlParameter("duration", Types.SMALLINT));
batch.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("album_artist_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("composer_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("album_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("track_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("track_nr", Types.SMALLINT));
batch.declareParameter(new SqlParameter("track_nrs", Types.SMALLINT));
batch.declareParameter(new SqlParameter("disc_nr", Types.SMALLINT));
batch.declareParameter(new SqlParameter("disc_nrs", Types.SMALLINT));
batch.declareParameter(new SqlParameter("year", Types.SMALLINT));
batch.declareParameter(new SqlParameter("tag_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("lyrics", Types.VARCHAR));
batch.declareParameter(new SqlParameter("coverart", Types.BOOLEAN));
batch.declareParameter(new SqlParameter("artistsort_name", Types.VARCHAR));
batch.declareParameter(new SqlParameter("albumartistsort_name", Types.VARCHAR));
for (File file : files) {
MetaData md = file.getMetadata();
if (md != null) {
batch.update(new Object[] { file.getDirectory(), file.getFilename(), md.getMediaType().getFilesuffix(), md.getBitrate(), md.isVbr(), md.getDuration(), md.getArtist(), md.getAlbumArtist(), md.getComposer(), md.getAlbum(), md.getTitle(), md.getTrackNr(), md.getTrackNrs(), md.getDiscNr(), md.getDiscNrs(), md.getYear(), md.getGenre(), md.getLyrics(), md.isCoverArtEmbedded(), md.getArtistSort(), md.getAlbumArtistSort() });
}
}
batch.flush();
}
Aggregations