Update dao layer to use update spring-jdbc 3/4 api
Signed-off-by: Andrew DeMaria <lostonamountain@gmail.com>
This commit is contained in:
@@ -29,7 +29,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.commons.lang.ObjectUtils;
|
import org.apache.commons.lang.ObjectUtils;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
|
||||||
|
|
||||||
import org.libresonic.player.domain.Album;
|
import org.libresonic.player.domain.Album;
|
||||||
import org.libresonic.player.domain.MediaFile;
|
import org.libresonic.player.domain.MediaFile;
|
||||||
@@ -346,7 +345,7 @@ public class AlbumDao extends AbstractDao {
|
|||||||
return queryForDate("select created from starred_album where album_id=? and username=?", null, albumId, username);
|
return queryForDate("select created from starred_album where album_id=? and username=?", null, albumId, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AlbumMapper implements ParameterizedRowMapper<Album> {
|
private static class AlbumMapper implements RowMapper<Album> {
|
||||||
public Album mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public Album mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new Album(
|
return new Album(
|
||||||
rs.getInt(1),
|
rs.getInt(1),
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import org.libresonic.player.domain.Artist;
|
|||||||
import org.libresonic.player.domain.MusicFolder;
|
import org.libresonic.player.domain.MusicFolder;
|
||||||
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -199,7 +198,7 @@ public class ArtistDao extends AbstractDao {
|
|||||||
return queryForDate("select created from starred_artist where artist_id=? and username=?", null, artistId, username);
|
return queryForDate("select created from starred_artist where artist_id=? and username=?", null, artistId, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ArtistMapper implements ParameterizedRowMapper<Artist> {
|
private static class ArtistMapper implements RowMapper<Artist> {
|
||||||
public Artist mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public Artist mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new Artist(
|
return new Artist(
|
||||||
rs.getInt(1),
|
rs.getInt(1),
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
package org.libresonic.player.dao;
|
package org.libresonic.player.dao;
|
||||||
|
|
||||||
import org.libresonic.player.domain.Avatar;
|
import org.libresonic.player.domain.Avatar;
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -85,11 +85,11 @@ public class AvatarDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AvatarRowMapper implements ParameterizedRowMapper<Avatar> {
|
private static class AvatarRowMapper implements RowMapper<Avatar> {
|
||||||
public Avatar mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public Avatar mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new Avatar(rs.getInt(1), rs.getString(2), rs.getTimestamp(3), rs.getString(4),
|
return new Avatar(rs.getInt(1), rs.getString(2), rs.getTimestamp(3), rs.getString(4),
|
||||||
rs.getInt(5), rs.getInt(6), rs.getBytes(7));
|
rs.getInt(5), rs.getInt(6), rs.getBytes(7));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.libresonic.player.dao;
|
package org.libresonic.player.dao;
|
||||||
|
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
|
||||||
|
|
||||||
import org.libresonic.player.domain.Bookmark;
|
import org.libresonic.player.domain.Bookmark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,7 +81,7 @@ public class BookmarkDao extends AbstractDao {
|
|||||||
update("delete from bookmark where username=? and media_file_id=?", username, mediaFileId);
|
update("delete from bookmark where username=? and media_file_id=?", username, mediaFileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class BookmarkRowMapper implements ParameterizedRowMapper<Bookmark> {
|
private static class BookmarkRowMapper implements RowMapper<Bookmark> {
|
||||||
public Bookmark mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public Bookmark mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new Bookmark(rs.getInt(1), rs.getInt(2), rs.getLong(3), rs.getString(4),
|
return new Bookmark(rs.getInt(1), rs.getInt(2), rs.getLong(3), rs.getString(4),
|
||||||
rs.getString(5), rs.getTimestamp(6), rs.getTimestamp(7));
|
rs.getString(5), rs.getTimestamp(6), rs.getTimestamp(7));
|
||||||
|
|||||||
@@ -19,12 +19,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.libresonic.player.dao;
|
package org.libresonic.player.dao;
|
||||||
|
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
|
||||||
|
|
||||||
import org.libresonic.player.Logger;
|
import org.libresonic.player.Logger;
|
||||||
import org.libresonic.player.domain.InternetRadio;
|
import org.libresonic.player.domain.InternetRadio;
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ public class InternetRadioDao extends AbstractDao {
|
|||||||
update(sql, radio.getName(), radio.getStreamUrl(), radio.getHomepageUrl(), radio.isEnabled(), radio.getChanged(), radio.getId());
|
update(sql, radio.getName(), radio.getStreamUrl(), radio.getHomepageUrl(), radio.isEnabled(), radio.getChanged(), radio.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class InternetRadioRowMapper implements ParameterizedRowMapper<InternetRadio> {
|
private static class InternetRadioRowMapper implements RowMapper<InternetRadio> {
|
||||||
public InternetRadio mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public InternetRadio mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new InternetRadio(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getBoolean(5), rs.getTimestamp(6));
|
return new InternetRadio(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getBoolean(5), rs.getTimestamp(6));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,22 +19,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.libresonic.player.dao;
|
package org.libresonic.player.dao;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
|
||||||
|
|
||||||
import org.libresonic.player.domain.Genre;
|
import org.libresonic.player.domain.Genre;
|
||||||
import org.libresonic.player.domain.MediaFile;
|
import org.libresonic.player.domain.MediaFile;
|
||||||
import org.libresonic.player.domain.MusicFolder;
|
import org.libresonic.player.domain.MusicFolder;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import static org.libresonic.player.domain.MediaFile.MediaType;
|
import static org.libresonic.player.domain.MediaFile.MediaType;
|
||||||
import static org.libresonic.player.domain.MediaFile.MediaType.*;
|
import static org.libresonic.player.domain.MediaFile.MediaType.*;
|
||||||
@@ -568,7 +561,7 @@ public class MediaFileDao extends AbstractDao {
|
|||||||
update("checkpoint");
|
update("checkpoint");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MediaFileMapper implements ParameterizedRowMapper<MediaFile> {
|
private static class MediaFileMapper implements RowMapper<MediaFile> {
|
||||||
public MediaFile mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public MediaFile mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new MediaFile(
|
return new MediaFile(
|
||||||
rs.getInt(1),
|
rs.getInt(1),
|
||||||
@@ -604,7 +597,7 @@ public class MediaFileDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MusicFileInfoMapper implements ParameterizedRowMapper<MediaFile> {
|
private static class MusicFileInfoMapper implements RowMapper<MediaFile> {
|
||||||
public MediaFile mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public MediaFile mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
MediaFile file = new MediaFile();
|
MediaFile file = new MediaFile();
|
||||||
file.setPlayCount(rs.getInt(1));
|
file.setPlayCount(rs.getInt(1));
|
||||||
@@ -614,7 +607,7 @@ public class MediaFileDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class GenreMapper implements ParameterizedRowMapper<Genre> {
|
private static class GenreMapper implements RowMapper<Genre> {
|
||||||
public Genre mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public Genre mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new Genre(rs.getString(1), rs.getInt(2), rs.getInt(3));
|
return new Genre(rs.getString(1), rs.getInt(2), rs.getInt(3));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,16 +19,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.libresonic.player.dao;
|
package org.libresonic.player.dao;
|
||||||
|
|
||||||
|
import org.libresonic.player.Logger;
|
||||||
|
import org.libresonic.player.domain.MusicFolder;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
|
||||||
|
|
||||||
import org.libresonic.player.Logger;
|
|
||||||
import org.libresonic.player.domain.MusicFolder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides database services for music folders.
|
* Provides database services for music folders.
|
||||||
*
|
*
|
||||||
@@ -99,7 +98,7 @@ public class MusicFolderDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MusicFolderRowMapper implements ParameterizedRowMapper<MusicFolder> {
|
private static class MusicFolderRowMapper implements RowMapper<MusicFolder> {
|
||||||
public MusicFolder mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public MusicFolder mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new MusicFolder(rs.getInt(1), new File(rs.getString(2)), rs.getString(3), rs.getBoolean(4), rs.getTimestamp(5));
|
return new MusicFolder(rs.getInt(1), new File(rs.getString(2)), rs.getString(3), rs.getBoolean(4), rs.getTimestamp(5));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
|
||||||
|
|
||||||
import org.libresonic.player.domain.SavedPlayQueue;
|
import org.libresonic.player.domain.SavedPlayQueue;
|
||||||
|
|
||||||
@@ -60,7 +59,7 @@ public class PlayQueueDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PlayQueueMapper implements ParameterizedRowMapper<SavedPlayQueue> {
|
private static class PlayQueueMapper implements RowMapper<SavedPlayQueue> {
|
||||||
public SavedPlayQueue mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public SavedPlayQueue mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new SavedPlayQueue(rs.getInt(1),
|
return new SavedPlayQueue(rs.getInt(1),
|
||||||
rs.getString(2),
|
rs.getString(2),
|
||||||
|
|||||||
@@ -19,22 +19,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.libresonic.player.dao;
|
package org.libresonic.player.dao;
|
||||||
|
|
||||||
|
import org.libresonic.player.Logger;
|
||||||
|
import org.libresonic.player.domain.*;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Calendar;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
|
||||||
|
|
||||||
import org.libresonic.player.Logger;
|
|
||||||
import org.libresonic.player.domain.CoverArtScheme;
|
|
||||||
import org.libresonic.player.domain.Player;
|
|
||||||
import org.libresonic.player.domain.PlayerTechnology;
|
|
||||||
import org.libresonic.player.domain.PlayQueue;
|
|
||||||
import org.libresonic.player.domain.TranscodeScheme;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides player-related database services.
|
* Provides player-related database services.
|
||||||
@@ -95,7 +86,7 @@ public class PlayerDao extends AbstractDao {
|
|||||||
* @param player The player to create.
|
* @param player The player to create.
|
||||||
*/
|
*/
|
||||||
public synchronized void createPlayer(Player player) {
|
public synchronized void createPlayer(Player player) {
|
||||||
int id = getJdbcTemplate().queryForInt("select max(id) from player") + 1;
|
int id = getJdbcTemplate().queryForObject("select max(id) from player", Integer.class) + 1;
|
||||||
player.setId(String.valueOf(id));
|
player.setId(String.valueOf(id));
|
||||||
String sql = "insert into player (" + COLUMNS + ") values (" + questionMarks(COLUMNS) + ")";
|
String sql = "insert into player (" + COLUMNS + ") values (" + questionMarks(COLUMNS) + ")";
|
||||||
update(sql, player.getId(), player.getName(), player.getType(), player.getUsername(),
|
update(sql, player.getId(), player.getName(), player.getType(), player.getUsername(),
|
||||||
@@ -169,7 +160,7 @@ public class PlayerDao extends AbstractDao {
|
|||||||
player.setPlayQueue(playQueue);
|
player.setPlayQueue(playQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PlayerRowMapper implements ParameterizedRowMapper<Player> {
|
private class PlayerRowMapper implements RowMapper<Player> {
|
||||||
public Player mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public Player mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
Player player = new Player();
|
Player player = new Player();
|
||||||
int col = 1;
|
int col = 1;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import org.libresonic.player.Logger;
|
|||||||
import org.libresonic.player.domain.MediaFile;
|
import org.libresonic.player.domain.MediaFile;
|
||||||
import org.libresonic.player.domain.Playlist;
|
import org.libresonic.player.domain.Playlist;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -125,7 +124,7 @@ public class PlaylistDao extends AbstractDao {
|
|||||||
new Date(), playlist.getImportedFrom(), playlist.getId());
|
new Date(), playlist.getImportedFrom(), playlist.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PlaylistMapper implements ParameterizedRowMapper<Playlist> {
|
private static class PlaylistMapper implements RowMapper<Playlist> {
|
||||||
public Playlist mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public Playlist mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new Playlist(
|
return new Playlist(
|
||||||
rs.getInt(1),
|
rs.getInt(1),
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
|
||||||
|
|
||||||
import org.libresonic.player.domain.PodcastChannel;
|
import org.libresonic.player.domain.PodcastChannel;
|
||||||
import org.libresonic.player.domain.PodcastEpisode;
|
import org.libresonic.player.domain.PodcastEpisode;
|
||||||
@@ -55,7 +54,7 @@ public class PodcastDao extends AbstractDao {
|
|||||||
update(sql, null, channel.getUrl(), channel.getTitle(), channel.getDescription(), channel.getImageUrl(),
|
update(sql, null, channel.getUrl(), channel.getTitle(), channel.getDescription(), channel.getImageUrl(),
|
||||||
channel.getStatus().name(), channel.getErrorMessage());
|
channel.getStatus().name(), channel.getErrorMessage());
|
||||||
|
|
||||||
return getJdbcTemplate().queryForInt("select max(id) from podcast_channel");
|
return getJdbcTemplate().queryForObject("select max(id) from podcast_channel", Integer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -182,7 +181,7 @@ public class PodcastDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PodcastEpisodeRowMapper implements ParameterizedRowMapper<PodcastEpisode> {
|
private static class PodcastEpisodeRowMapper implements RowMapper<PodcastEpisode> {
|
||||||
public PodcastEpisode mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public PodcastEpisode mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new PodcastEpisode(rs.getInt(1), rs.getInt(2), rs.getString(3), rs.getString(4), rs.getString(5),
|
return new PodcastEpisode(rs.getInt(1), rs.getInt(2), rs.getString(3), rs.getString(4), rs.getString(5),
|
||||||
rs.getString(6), rs.getTimestamp(7), rs.getString(8), (Long) rs.getObject(9),
|
rs.getString(6), rs.getTimestamp(7), rs.getString(8), (Long) rs.getObject(9),
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
import org.libresonic.player.domain.MusicFolder;
|
import org.libresonic.player.domain.MusicFolder;
|
||||||
import org.libresonic.player.domain.Share;
|
import org.libresonic.player.domain.Share;
|
||||||
@@ -53,7 +53,7 @@ public class ShareDao extends AbstractDao {
|
|||||||
update(sql, null, share.getName(), share.getDescription(), share.getUsername(), share.getCreated(),
|
update(sql, null, share.getName(), share.getDescription(), share.getUsername(), share.getCreated(),
|
||||||
share.getExpires(), share.getLastVisited(), share.getVisitCount());
|
share.getExpires(), share.getLastVisited(), share.getVisitCount());
|
||||||
|
|
||||||
int id = getJdbcTemplate().queryForInt("select max(id) from share");
|
int id = getJdbcTemplate().queryForObject("select max(id) from share", Integer.class);
|
||||||
share.setId(id);
|
share.setId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,14 +129,14 @@ public class ShareDao extends AbstractDao {
|
|||||||
update("delete from share where id=?", id);
|
update("delete from share where id=?", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ShareRowMapper implements ParameterizedRowMapper<Share> {
|
private static class ShareRowMapper implements RowMapper<Share> {
|
||||||
public Share mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public Share mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new Share(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getTimestamp(5),
|
return new Share(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getTimestamp(5),
|
||||||
rs.getTimestamp(6), rs.getTimestamp(7), rs.getInt(8));
|
rs.getTimestamp(6), rs.getTimestamp(7), rs.getInt(8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ShareFileRowMapper implements ParameterizedRowMapper<String> {
|
private static class ShareFileRowMapper implements RowMapper<String> {
|
||||||
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return rs.getString(1);
|
return rs.getString(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
import org.libresonic.player.Logger;
|
import org.libresonic.player.Logger;
|
||||||
import org.libresonic.player.domain.Transcoding;
|
import org.libresonic.player.domain.Transcoding;
|
||||||
@@ -82,7 +82,7 @@ public class TranscodingDao extends AbstractDao {
|
|||||||
* @param transcoding The transcoding to create.
|
* @param transcoding The transcoding to create.
|
||||||
*/
|
*/
|
||||||
public synchronized void createTranscoding(Transcoding transcoding) {
|
public synchronized void createTranscoding(Transcoding transcoding) {
|
||||||
int id = getJdbcTemplate().queryForInt("select max(id) + 1 from transcoding2");
|
int id = getJdbcTemplate().queryForObject("select max(id) + 1 from transcoding2", Integer.class);
|
||||||
transcoding.setId(id);
|
transcoding.setId(id);
|
||||||
String sql = "insert into transcoding2 (" + COLUMNS + ") values (" + questionMarks(COLUMNS) + ")";
|
String sql = "insert into transcoding2 (" + COLUMNS + ") values (" + questionMarks(COLUMNS) + ")";
|
||||||
update(sql, transcoding.getId(), transcoding.getName(), transcoding.getSourceFormats(),
|
update(sql, transcoding.getId(), transcoding.getName(), transcoding.getSourceFormats(),
|
||||||
@@ -115,7 +115,7 @@ public class TranscodingDao extends AbstractDao {
|
|||||||
transcoding.getStep3(), transcoding.isDefaultActive(), transcoding.getId());
|
transcoding.getStep3(), transcoding.isDefaultActive(), transcoding.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TranscodingRowMapper implements ParameterizedRowMapper<Transcoding> {
|
private static class TranscodingRowMapper implements RowMapper<Transcoding> {
|
||||||
public Transcoding mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public Transcoding mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new Transcoding(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5),
|
return new Transcoding(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5),
|
||||||
rs.getString(6), rs.getString(7), rs.getBoolean(8));
|
rs.getString(6), rs.getString(7), rs.getBoolean(8));
|
||||||
|
|||||||
@@ -19,20 +19,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.libresonic.player.dao;
|
package org.libresonic.player.dao;
|
||||||
|
|
||||||
|
import org.libresonic.player.Logger;
|
||||||
|
import org.libresonic.player.domain.*;
|
||||||
|
import org.libresonic.player.util.StringUtil;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
|
||||||
|
|
||||||
import org.libresonic.player.Logger;
|
|
||||||
import org.libresonic.player.domain.AlbumListType;
|
|
||||||
import org.libresonic.player.domain.AvatarScheme;
|
|
||||||
import org.libresonic.player.domain.TranscodeScheme;
|
|
||||||
import org.libresonic.player.domain.User;
|
|
||||||
import org.libresonic.player.domain.UserSettings;
|
|
||||||
import org.libresonic.player.util.StringUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides user-related database services.
|
* Provides user-related database services.
|
||||||
*
|
*
|
||||||
@@ -296,7 +291,7 @@ public class UserDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UserRowMapper implements ParameterizedRowMapper<User> {
|
private class UserRowMapper implements RowMapper<User> {
|
||||||
public User mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public User mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
User user = new User(rs.getString(1), decrypt(rs.getString(2)), rs.getString(3), rs.getBoolean(4),
|
User user = new User(rs.getString(1), decrypt(rs.getString(2)), rs.getString(3), rs.getBoolean(4),
|
||||||
rs.getLong(5), rs.getLong(6), rs.getLong(7));
|
rs.getLong(5), rs.getLong(6), rs.getLong(7));
|
||||||
@@ -305,7 +300,7 @@ public class UserDao extends AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class UserSettingsRowMapper implements ParameterizedRowMapper<UserSettings> {
|
private static class UserSettingsRowMapper implements RowMapper<UserSettings> {
|
||||||
public UserSettings mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public UserSettings mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
int col = 1;
|
int col = 1;
|
||||||
UserSettings settings = new UserSettings(rs.getString(col++));
|
UserSettings settings = new UserSettings(rs.getString(col++));
|
||||||
|
|||||||
Reference in New Issue
Block a user