Search in sources :

Example 36 with MagicCardStock

use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.

the class JsonExport method importStock.

@Override
public List<MagicCardStock> importStock(File f) throws IOException {
    JsonReader reader = new JsonReader(new FileReader(f));
    JsonArray root = new JsonParser().parse(reader).getAsJsonArray();
    List<MagicCardStock> list = new ArrayList<>();
    for (int i = 0; i < root.size(); i++) {
        JsonObject line = root.get(i).getAsJsonObject();
        MagicCardStock mc = new Gson().fromJson(line, MagicCardStock.class);
        list.add(mc);
    }
    return list;
}
Also used : JsonArray(com.google.gson.JsonArray) ArrayList(java.util.ArrayList) JsonReader(com.google.gson.stream.JsonReader) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) FileReader(java.io.FileReader) JsonParser(com.google.gson.JsonParser) MagicCardStock(org.magic.api.beans.MagicCardStock)

Example 37 with MagicCardStock

use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.

the class MkmOnlineExport method importStock.

@Override
public List<MagicCardStock> importStock(File f) throws IOException {
    if (!getString("STOCK_USE").equals("true"))
        return importFromDeck(importDeck(f));
    StockService serv = new StockService();
    List<Article> list = serv.getStock();
    List<MagicCardStock> stock = new ArrayList<>();
    for (Article a : list) {
        MagicCardStock mcs = new MagicCardStock();
        mcs.setUpdate(true);
        mcs.setIdstock(-1);
        mcs.setComment(a.getComments());
        mcs.setLanguage(a.getLanguage().getLanguageName());
        mcs.setQte(a.getCount());
        mcs.setFoil(a.isFoil());
        mcs.setSigned(a.isSigned());
        mcs.setAltered(a.isAltered());
        mcs.setPrice(a.getPrice());
        MagicCard mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", a.getProduct().getEnName(), null, true).get(0);
        MagicCardMarketPricer2.selectEditionCard(mc, a.getProduct().getExpansionName());
        mcs.setMagicCard(mc);
        mcs.setCondition(convert(a.getCondition()));
        stock.add(mcs);
    }
    return stock;
}
Also used : MagicCard(org.magic.api.beans.MagicCard) Article(org.api.mkm.modele.Article) ArrayList(java.util.ArrayList) StockService(org.api.mkm.services.StockService) MagicCardStock(org.magic.api.beans.MagicCardStock)

Example 38 with MagicCardStock

use of org.magic.api.beans.MagicCardStock in project MtgDesktopCompanion by nicho92.

the class OCTGNDeckExport 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);
}
Also used : MagicDeck(org.magic.api.beans.MagicDeck) MagicCardStock(org.magic.api.beans.MagicCardStock)

Aggregations

MagicCardStock (org.magic.api.beans.MagicCardStock)38 ArrayList (java.util.ArrayList)17 MagicDeck (org.magic.api.beans.MagicDeck)14 PreparedStatement (java.sql.PreparedStatement)9 MagicCard (org.magic.api.beans.MagicCard)9 ResultSet (java.sql.ResultSet)6 MagicCollection (org.magic.api.beans.MagicCollection)6 File (java.io.File)5 IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 Statement (java.sql.Statement)3 Gson (com.google.gson.Gson)2 FileReader (java.io.FileReader)2 Article (org.api.mkm.modele.Article)2 Document (org.bson.Document)2 Bson (org.bson.conversions.Bson)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 JsonReader (com.google.gson.stream.JsonReader)1