use of org.magic.api.beans.MagicCollection in project MtgDesktopCompanion by nicho92.
the class PostgresqlDAO method listStocks.
@Override
public List<MagicCardStock> listStocks() throws SQLException {
try (PreparedStatement pst = con.prepareStatement("select * from stocks");
ResultSet rs = pst.executeQuery()) {
List<MagicCardStock> colls = new ArrayList<>();
while (rs.next()) {
MagicCardStock state = new MagicCardStock();
state.setComment(rs.getString("comments"));
state.setIdstock(rs.getInt("idstock"));
state.setMagicCard(readObject(MagicCard.class, rs.getBinaryStream(mcardField)));
state.setMagicCollection(new MagicCollection(rs.getString("collection")));
state.setCondition(EnumCondition.valueOf(rs.getString("conditions")));
state.setFoil(rs.getBoolean("foil"));
state.setSigned(rs.getBoolean("signedcard"));
state.setLanguage(rs.getString("langage"));
state.setQte(rs.getInt("qte"));
state.setPrice(rs.getDouble("price"));
colls.add(state);
}
return colls;
}
}
use of org.magic.api.beans.MagicCollection in project MtgDesktopCompanion by nicho92.
the class CSVExport method importStock.
@Override
public List<MagicCardStock> importStock(File f) throws IOException {
try (BufferedReader read = new BufferedReader(new FileReader(f))) {
List<MagicCardStock> stock = new ArrayList<>();
String line = read.readLine();
line = read.readLine();
while (line != null) {
String[] part = line.split(";");
MagicCardStock mcs = new MagicCardStock();
MagicCard mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", part[1], null, true).get(0);
for (MagicEdition ed : mc.getEditions()) if (ed.getSet().equals(part[2])) {
mc.getEditions().add(0, ed);
break;
}
mcs.setMagicCard(mc);
mcs.setLanguage(part[3]);
mcs.setQte(Integer.parseInt(part[4]));
mcs.setCondition(EnumCondition.valueOf(part[5]));
mcs.setFoil(Boolean.valueOf(part[6]));
mcs.setAltered(Boolean.valueOf(part[7]));
mcs.setSigned(Boolean.valueOf(part[8]));
mcs.setMagicCollection(new MagicCollection(part[9]));
mcs.setPrice(Double.valueOf(part[10]));
try {
mcs.setComment(part[11]);
} catch (ArrayIndexOutOfBoundsException aioob) {
mcs.setComment("");
}
mcs.setIdstock(-1);
mcs.setUpdate(true);
stock.add(mcs);
line = read.readLine();
}
return stock;
}
}
Aggregations