From bc788241f9355fca38406f843ec76f6bb0d4f44f Mon Sep 17 00:00:00 2001 From: Christian 'ketura' McCarty Date: Mon, 31 Oct 2022 04:38:58 -0500 Subject: [PATCH] fixing import not working due to removed functions --- .../gempukku/lotro/db/DbCollectionDAO.java | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/DbCollectionDAO.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/DbCollectionDAO.java index 9495c6f1d..54e788216 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/DbCollectionDAO.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/db/DbCollectionDAO.java @@ -8,7 +8,8 @@ import org.sql2o.Query; import org.sql2o.Sql2o; import java.io.IOException; -import java.sql.SQLException; +import java.io.InputStream; +import java.sql.*; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -230,10 +231,37 @@ public class DbCollectionDAO implements CollectionDAO { } public void convertCollection(int playerId, String type) throws SQLException, IOException { - CardCollection oldCollection = getPlayerCollection(playerId, type); + CardCollection oldCollection = getOldPlayerCollection(playerId, type); overwriteCollectionContents(playerId, type, oldCollection, "Initial Convert"); } + public CardCollection getOldPlayerCollection(int playerId, String type) throws SQLException, IOException { + try (Connection connection = _dbAccess.getDataSource().getConnection()) { + try (PreparedStatement statement = connection.prepareStatement("select collection from collection where player_id=? and type=?")) { + statement.setInt(1, playerId); + statement.setString(2, type); + try (ResultSet rs = statement.executeQuery()) { + if (rs.next()) { + Blob blob = rs.getBlob(1); + return extractCollectionAndClose(blob); + } else { + return null; + } + } + } + } + } + + private CardCollection extractCollectionAndClose(Blob blob) throws SQLException, IOException { + try { + try (InputStream inputStream = blob.getBinaryStream()) { + return _collectionSerializer.deserializeCollection(inputStream); + } + } finally { + blob.free(); + } + } + @Override public void updateCollectionInfo(int playerId, String type, Map extraInformation) { upsertCollectionInfo(playerId, type, extraInformation);