use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class WebsiteImportExport method importStock.
@Override
public List<MagicCardStock> importStock(File f) throws IOException {
MagicDeck d = importDeck(f);
List<MagicCardStock> ret = new ArrayList<>();
for (MagicCard mc : d.getMap().keySet()) {
MagicCardStock stock = new MagicCardStock();
stock.setMagicCard(mc);
stock.setQte(d.getMap().get(mc));
stock.setUpdate(true);
stock.setIdstock(-1);
ret.add(stock);
}
return ret;
}
use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class XMageDeckExport method exportStock.
@Override
public void exportStock(List<MagicCardStock> stock, File f) throws IOException {
MagicDeck d = new MagicDeck();
d.setName(f.getName());
for (MagicCardStock mcs : stock) {
d.getMap().put(mcs.getMagicCard(), mcs.getQte());
}
export(d, f);
}
use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class AbstractCardExport method importFromDeck.
protected List<MagicCardStock> importFromDeck(MagicDeck deck) {
List<MagicCardStock> mcs = new ArrayList<>();
for (MagicCard mc : deck.getMap().keySet()) {
MagicCardStock stock = new MagicCardStock();
stock.setMagicCard(mc);
stock.setQte(deck.getMap().get(mc));
stock.setComment("import from " + deck.getName());
stock.setIdstock(-1);
stock.setUpdate(true);
mcs.add(stock);
}
return mcs;
}
use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class ExportsProviderTests method testExports.
public void testExports(MTGCardsExport p) {
System.out.println("*****************************" + p.getName());
System.out.println("EXT " + p.getFileExtension());
System.out.println("STAT " + p.getStatut());
System.out.println("PROP " + p.getProperties());
System.out.println("TYPE " + p.getType());
System.out.println("ENAB " + p.isEnable());
System.out.println("ICON " + p.getIcon());
System.out.println("VERS " + p.getVersion());
MagicDeck d = new MagicDeck();
d.setDateCreation(new Date());
d.setDescription("Test of " + p);
d.setTags(Arrays.asList("test", p.getName(), "mtgdesktopcompanion"));
d.setName("TEST " + p);
d.getMap().put(mc, 40);
d.getMapSideBoard().put(mc, 10);
File destD = new File("target", d.getName() + " DECK " + p.getFileExtension());
File destL = new File("target", d.getName() + " LIST " + p.getFileExtension());
try {
p.export(d, destD);
System.out.println(p + " export Deck OK");
} catch (Exception e) {
System.out.println(p + " export Deck ERROR " + e);
}
try {
p.export(d.getAsList(), destL);
System.out.println(p + " export List OK");
} catch (Exception e) {
System.out.println(p + " export List ERROR " + e);
}
File destS = new File("target", d.getName() + " STOCK " + p.getFileExtension());
List<MagicCardStock> stocks = new ArrayList<>();
MagicCardStock s = new MagicCardStock();
s.setMagicCard(mc);
s.setAltered(false);
s.setFoil(false);
s.setSigned(false);
s.setCondition(EnumCondition.LIGHTLY_PLAYED);
s.setLanguage("English");
s.setMagicCollection(new MagicCollection("TEST"));
s.setQte(8);
s.setPrice(9999.0);
s.setComment("Test");
stocks.add(s);
try {
p.exportStock(stocks, destS);
System.out.println(p + " export Stock OK");
} catch (Exception e) {
e.printStackTrace();
System.out.println(p + " export Stock ERROR" + e);
}
MagicDeck d2;
try {
d2 = p.importDeck(destD);
System.out.println(d2 + " " + " import deck OK");
} catch (Exception e) {
System.out.println(p + " import deck ERROR " + e);
}
try {
System.out.println(p.importStock(destS));
System.out.println(p + " " + " import stock OK");
} catch (Exception e) {
System.out.println(p + " " + " import stock ERROR " + e);
}
}
use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.
the class FileDAO method deleteStock.
@Override
public void deleteStock(List<MagicCardStock> state) throws SQLException {
for (MagicCardStock s : state) {
File f = Paths.get(directory.getAbsolutePath(), STOCKDIR, s.getIdstock() + "-" + IDGenerator.generate(s.getMagicCard())).toFile();
logger.debug("Delete " + f);
FileUtils.deleteQuietly(f);
}
}
Aggregations