Pārlūkot izejas kodu

Finishing merge...

pull/2/head
veronie pirms 4 gadiem
vecāks
revīzija
8eff2f5d31
3 mainītis faili ar 15 papildinājumiem un 15 dzēšanām
  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 Parādīt failu

@@ -4,6 +4,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import xyz.veronie.bgg.result.Thing;
import xyz.veronie.bgg.result.ThingMetaData; import xyz.veronie.bgg.result.ThingMetaData;
public class LocalDbAdapterService { public class LocalDbAdapterService {
@@ -23,7 +24,7 @@ public class LocalDbAdapterService {
/// add a list of things with the given name /// 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.openThingList(name);
sqliteController.addToThingList(name, things); sqliteController.addToThingList(name, things);
} }


+ 10
- 8
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/localdb/SqliteController.java Parādīt failu

@@ -8,6 +8,7 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.List; import java.util.List;
import xyz.veronie.bgg.result.Thing;
import xyz.veronie.bgg.result.ThingMetaData; import xyz.veronie.bgg.result.ThingMetaData;
public class SqliteController { 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 { try {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
@@ -103,13 +104,14 @@ public class SqliteController {
PreparedStatement listToThingStatement = connection PreparedStatement listToThingStatement = connection
.prepareStatement("INSERT INTO ThingListToThing VALUES (?, ?)"); .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(); thingStatement.addBatch();
// get generated id // get generated id
ResultSet keys = thingStatement.getGeneratedKeys(); ResultSet keys = thingStatement.getGeneratedKeys();


+ 3
- 6
xyz.veronie.bgg.ui/src/xyz/veronie/bgg/result/ThingProvider.java Parādīt failu

@@ -17,16 +17,13 @@ public class ThingProvider {
private LocalDbAdapterService localDbAdapterService; private LocalDbAdapterService localDbAdapterService;
/// list of things. Each ID is expected to exist exactly once. /// list of things. Each ID is expected to exist exactly once.
private List<ThingMetaData> thingMetas;
public ThingProvider() {}
private List<Thing> things; private List<Thing> things;
public ThingProvider() {}
@PostConstruct @PostConstruct
public void init() { public void init() {
localDbAdapterService = new LocalDbAdapterService(); localDbAdapterService = new LocalDbAdapterService();
thingMetas = new ArrayList<ThingMetaData>();
things = new ArrayList<Thing>(); things = new ArrayList<Thing>();
} }
@@ -79,7 +76,7 @@ public class ThingProvider {
/// store current list in DB /// store current list in DB
public void storeList() { public void storeList() {
localDbAdapterService.storeThingList(this.thingMetas, "TestList");
localDbAdapterService.storeThingList(this.things, "TestList");
} }


Notiek ielāde…
Atcelt
Saglabāt