diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/LocalDbAdapterService.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/LocalDbAdapterService.java index 4dec875..acf4692 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/LocalDbAdapterService.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/LocalDbAdapterService.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import xyz.veronie.bgg.result.Thing; import xyz.veronie.bgg.result.ThingMetaData; public class LocalDbAdapterService { @@ -23,7 +24,7 @@ public class LocalDbAdapterService { /// add a list of things with the given name - public void storeThingList(List things, String name) { + public void storeThingList(List things, String name) { sqliteController.openThingList(name); sqliteController.addToThingList(name, things); } diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/SqliteController.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/SqliteController.java index ffc309e..eee89ad 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/SqliteController.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/SqliteController.java @@ -8,6 +8,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.List; +import xyz.veronie.bgg.result.Thing; import xyz.veronie.bgg.result.ThingMetaData; public class SqliteController { @@ -91,7 +92,7 @@ public class SqliteController { } } - public void addToThingList(String name, List things) { + public void addToThingList(String name, List things) { try { Statement stmt = connection.createStatement(); @@ -103,13 +104,14 @@ public class SqliteController { PreparedStatement listToThingStatement = connection .prepareStatement("INSERT INTO ThingListToThing VALUES (?, ?)"); - for (ThingMetaData thing : things) { - thingStatement.setInt(1, thing.getId()); - thingStatement.setString(2, thing.getName()); - thingStatement.setString(3, thing.getImgURL()); - thingStatement.setString(4, thing.getThumbURL()); - thingStatement.setString(5, thing.getComment()); - thingStatement.setInt(6, thing.getNumPlays()); + for (Thing thing : things) { + ThingMetaData metaData = thing.getMetaData(); + thingStatement.setInt(1, metaData.getId()); + thingStatement.setString(2, metaData.getName()); + thingStatement.setString(3, metaData.getImgURL()); + thingStatement.setString(4, metaData.getThumbURL()); + thingStatement.setString(5, metaData.getComment()); + thingStatement.setInt(6, metaData.getNumPlays()); thingStatement.addBatch(); // get generated id ResultSet keys = thingStatement.getGeneratedKeys(); diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java index bc9bf0f..970f364 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java @@ -17,16 +17,13 @@ public class ThingProvider { private LocalDbAdapterService localDbAdapterService; /// list of things. Each ID is expected to exist exactly once. - private List thingMetas; - - public ThingProvider() {} - private List things; + + public ThingProvider() {} @PostConstruct public void init() { localDbAdapterService = new LocalDbAdapterService(); - thingMetas = new ArrayList(); things = new ArrayList(); } @@ -79,7 +76,7 @@ public class ThingProvider { /// store current list in DB public void storeList() { - localDbAdapterService.storeThingList(this.thingMetas, "TestList"); + localDbAdapterService.storeThingList(this.things, "TestList"); }