use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class StockPanelGUI method importFromWebSite.
private void importFromWebSite(MagicDeck deck) {
for (MagicCard mc : deck.getMap().keySet()) {
MagicCardStock stock = new MagicCardStock();
stock.setMagicCard(mc);
stock.setQte(deck.getMap().get(mc));
stock.setComment(MTGControler.getInstance().getLangService().getCapitalize("IMPORT_FROM", deck.getName()));
stock.setIdstock(-1);
stock.setUpdate(true);
model.add(stock);
}
}
use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class StockPanelGUI method importFromCollection.
private void importFromCollection(MagicCollection col) throws SQLException {
for (MagicCard mc : MTGControler.getInstance().getEnabledDAO().listCardsFromCollection(col)) {
MagicCardStock stock = new MagicCardStock();
stock.setMagicCard(mc);
stock.setMagicCollection(col);
stock.setQte(1);
stock.setComment(MTGControler.getInstance().getLangService().getCapitalize("IMPORT_FROM", col.getName()));
stock.setIdstock(-1);
stock.setUpdate(true);
model.add(stock);
}
model.fireTableDataChanged();
}
use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class CardStockPanel method initMagicCardStock.
public void initMagicCardStock(MagicCard mc, MagicCollection col) {
selectedCard = mc;
selectedCol = col;
content.removeAll();
content.setLayout(layout);
try {
for (MagicCardStock stat : MTGControler.getInstance().getEnabledDAO().listStocks(mc, col)) {
CardStockLinePanel pane = new CardStockLinePanel(mc, col);
pane.setMagicCardState(stat);
content.add(pane);
}
content.revalidate();
content.repaint();
} catch (Exception e) {
MTGLogger.printStackTrace(e);
}
}
use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class HsqlDAO method listStocks.
@Override
public List<MagicCardStock> listStocks(MagicCard mc, MagicCollection col) throws SQLException {
logger.debug("load stock for " + mc + " in " + col);
try (PreparedStatement pst = con.prepareStatement("select * from stocks where idmc=? and collection=?")) {
pst.setString(1, IDGenerator.generate(mc));
pst.setString(2, col.getName());
try (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(mc);
state.setMagicCollection(col);
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);
}
logger.debug("load " + colls.size() + " item from stock for " + mc);
return colls;
}
}
}
use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class MongoDbDAO method deleteStock.
@Override
public void deleteStock(List<MagicCardStock> state) throws SQLException {
logger.debug("remove " + state.size() + " items in stock");
for (MagicCardStock s : state) {
Bson filter = new Document("stockItem.idstock", s.getIdstock());
db.getCollection(colStocks).deleteOne(filter);
}
}
Aggregations