Преглед на файлове

Finishing merge...

pull/2/head
veronie преди 4 години
родител
ревизия
8eff2f5d31
променени са 3 файла, в които са добавени 15 реда и са изтрити 15 реда
  1. +2
    -1
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/LocalDbAdapterService.java
  2. +10
    -8
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/SqliteController.java
  3. +3
    -6
      xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java

+ 2
- 1
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<ThingMetaData> things, String name) {
public void storeThingList(List<Thing> things, String name) {
sqliteController.openThingList(name);
sqliteController.addToThingList(name, things);
}


+ 10
- 8
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<ThingMetaData> things) {
public void addToThingList(String name, List<Thing> 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();


+ 3
- 6
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<ThingMetaData> thingMetas;
public ThingProvider() {}
private List<Thing> things;
public ThingProvider() {}
@PostConstruct
public void init() {
localDbAdapterService = new LocalDbAdapterService();
thingMetas = new ArrayList<ThingMetaData>();
things = new ArrayList<Thing>();
}
@@ -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");
}


Loading…
Отказ
Запис