use of org.magic.api.beans.MagicCollection 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.MagicCollection in project MtgDesktopCompanion by nicho92.
the class DAOProviderTests method createCards.
@Before
public void createCards() {
mc = new MagicCard();
mc.setName("Black Lotus");
mc.setLayout("normal");
mc.setCost("{0}");
mc.setCmc(0);
mc.getTypes().add("Artifact");
mc.setReserved(true);
mc.setText("{T}, Sacrifice Black Lotus: Add three mana of any one color to your mana pool.");
mc.setRarity("Rare");
mc.setArtist("Christopher Rush");
mc.setId("c944c7dc960c4832604973844edee2a1fdc82d98");
mc.setMciNumber("232");
MagicEdition ed = new MagicEdition();
ed.setId("lea");
ed.setSet("Limited Edition Alpha");
ed.setBorder("Black");
ed.setRarity("Rare");
ed.setArtist("Christopher Rush");
ed.setMultiverse_id("3");
ed.setNumber("232");
mc.getEditions().add(ed);
col = new MagicCollection("TEST");
MTGLogger.changeLevel(Level.ERROR);
}
use of org.magic.api.beans.MagicCollection in project MtgDesktopCompanion by nicho92.
the class FileDAO method listCollectionFromCards.
@Override
public List<MagicCollection> listCollectionFromCards(MagicCard mc) throws SQLException {
String id = IDGenerator.generate(mc);
File f = new File(directory, CARDSDIR);
List<MagicCollection> ret = new ArrayList<>();
Collection<File> res = FileUtils.listFiles(f, new NameFileFilter(id), TrueFileFilter.INSTANCE);
for (File result : res) ret.add(new MagicCollection(result.getParentFile().getParentFile().getName()));
return ret;
}
use of org.magic.api.beans.MagicCollection in project MtgDesktopCompanion by nicho92.
the class HsqlDAO method listStocks.
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((MagicCard) rs.getObject(cardField));
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);
}
logger.debug("load " + colls.size() + " item(s) from stock");
return colls;
}
}
use of org.magic.api.beans.MagicCollection in project MtgDesktopCompanion by nicho92.
the class MongoDbDAO method removeCollection.
@Override
public void removeCollection(MagicCollection c) throws SQLException {
logger.debug("remove collection " + c);
BasicDBObject query = new BasicDBObject();
query.put(dbColIDField, c.getName());
DeleteResult dr = db.getCollection(colCards).deleteMany(query);
logger.trace(dr);
MongoCollection<MagicCollection> collection = db.getCollection(colCollects, MagicCollection.class);
collection.deleteOne(Filters.eq("name", c.getName()));
}
Aggregations