Search in sources :

Example 81 with EnumMap

use of java.util.EnumMap in project jsql-injection by ron190.

the class AbstractStrategy method markVulnerable.

public void markVulnerable(Interaction message, int i) {
    Request request = new Request();
    request.setMessage(message);
    Map<Header, Object> msgHeader = new EnumMap<>(Header.class);
    msgHeader.put(Header.URL, ConnectionUtil.getUrlByUser());
    msgHeader.put(Header.SOURCE, i);
    request.setParameters(msgHeader);
    MediatorModel.model().sendToViews(request);
}
Also used : Header(com.jsql.model.bean.util.Header) Request(com.jsql.model.bean.util.Request) EnumMap(java.util.EnumMap)

Example 82 with EnumMap

use of java.util.EnumMap in project jsql-injection by ron190.

the class AbstractStrategy method markVulnerable.

public void markVulnerable(Interaction message) {
    Request request = new Request();
    request.setMessage(message);
    Map<Header, Object> msgHeader = new EnumMap<>(Header.class);
    msgHeader.put(Header.URL, ConnectionUtil.getUrlByUser());
    request.setParameters(msgHeader);
    MediatorModel.model().sendToViews(request);
}
Also used : Header(com.jsql.model.bean.util.Header) Request(com.jsql.model.bean.util.Request) EnumMap(java.util.EnumMap)

Example 83 with EnumMap

use of java.util.EnumMap in project MtgDesktopCompanion by nicho92.

the class MkmOnlineExport method exportStock.

@Override
public void exportStock(List<MagicCardStock> stock, File f) throws IOException {
    if (!getString("STOCK_USE").equals("true")) {
        MagicDeck d = new MagicDeck();
        d.setName(f.getName());
        for (MagicCardStock mcs : stock) {
            d.getMap().put(mcs.getMagicCard(), mcs.getQte());
        }
        export(d, f);
    } else {
        StockService serv = new StockService();
        ProductServices prods = new ProductServices();
        EnumMap<PRODUCT_ATTS, String> enumAtts = new EnumMap<>(PRODUCT_ATTS.class);
        enumAtts.put(PRODUCT_ATTS.idGame, "1");
        enumAtts.put(PRODUCT_ATTS.exact, "true");
        List<Article> list = new ArrayList<>();
        for (MagicCardStock mcs : stock) {
            Product p = MagicCardMarketPricer2.getProductFromCard(mcs.getMagicCard(), prods.findProduct(mcs.getMagicCard().getName(), enumAtts));
            Article a = new Article();
            a.setAltered(mcs.isAltered());
            a.setSigned(mcs.isSigned());
            a.setCount(mcs.getQte());
            a.setFoil(mcs.isFoil());
            a.setPrice(mcs.getPrice());
            a.setCondition(convert(mcs.getCondition()));
            a.setLanguage(convertLang(mcs.getLanguage()));
            a.setProduct(p);
            a.setIdProduct(p.getIdProduct());
            list.add(a);
        }
        serv.addArticles(list);
    }
}
Also used : PRODUCT_ATTS(org.api.mkm.modele.Product.PRODUCT_ATTS) Article(org.api.mkm.modele.Article) ArrayList(java.util.ArrayList) Product(org.api.mkm.modele.Product) ProductServices(org.api.mkm.services.ProductServices) StockService(org.api.mkm.services.StockService) EnumMap(java.util.EnumMap) MagicDeck(org.magic.api.beans.MagicDeck) MagicCardStock(org.magic.api.beans.MagicCardStock)

Example 84 with EnumMap

use of java.util.EnumMap in project MtgDesktopCompanion by nicho92.

the class MagicCardMarketPricer2 method getPrice.

public List<MagicPrice> getPrice(MagicEdition me, MagicCard card) throws IOException {
    try {
        if (me == null)
            me = card.getEditions().get(0);
        lists = new ArrayList<>();
        logger.info(getName() + " looking for " + card + " " + me);
        if (me.getRarity() != null)
            if (!getBoolean("COMMONCHECK") && me.getRarity().equalsIgnoreCase("Common")) {
                MagicPrice mp = new MagicPrice();
                mp.setCurrency("EUR");
                mp.setValue(0.01);
                mp.setSite(getName());
                mp.setSeller("Not checked common");
                lists.add(mp);
                return lists;
            }
        ProductServices pService = new ProductServices();
        EnumMap<PRODUCT_ATTS, String> atts = new EnumMap<>(PRODUCT_ATTS.class);
        atts.put(PRODUCT_ATTS.idGame, "1");
        atts.put(PRODUCT_ATTS.exact, getString("IS_EXACT"));
        if (!getString("LANGUAGE_ID").equals(""))
            atts.put(PRODUCT_ATTS.idLanguage, getString("LANGUAGE_ID"));
        if (getString("USER_ARTICLE").equals("false")) {
            Product p = getProductFromCard(card, pService.findProduct(card.getName(), atts));
            if (p != null) {
                p = pService.getProductById(p.getIdProduct());
                MagicPrice mp = new MagicPrice();
                mp.setSeller(String.valueOf(p.getExpansionName()));
                mp.setValue(p.getPriceGuide().getLOW());
                mp.setQuality("");
                mp.setUrl("https://www.magiccardmarket.eu" + p.getWebsite());
                mp.setSite(getName());
                mp.setFoil(false);
                mp.setCurrency("EUR");
                mp.setLanguage(String.valueOf(p.getLocalization()));
                lists.add(mp);
            }
        } else {
            List<Product> list = pService.findProduct(card.getName(), atts);
            Product resultat = getProductFromCard(card, list);
            if (resultat == null) {
                logger.info(getName() + " found no item");
                return lists;
            }
            ArticleService aServ = new ArticleService();
            EnumMap<ARTICLES_ATT, String> aatts = new EnumMap<>(ARTICLES_ATT.class);
            aatts.put(ARTICLES_ATT.start, "0");
            aatts.put(ARTICLES_ATT.maxResults, getString("MAX"));
            if (!getString("LANGUAGE_ID").equals(""))
                aatts.put(ARTICLES_ATT.idLanguage, getString("LANGUAGE_ID"));
            if (!getString("MIN_CONDITION").equals(""))
                aatts.put(ARTICLES_ATT.minCondition, getString("MIN_CONDITION"));
            List<Article> articles = aServ.find(resultat, aatts);
            logger.debug(getName() + " found " + articles.size() + " items");
            for (Article a : articles) {
                MagicPrice mp = new MagicPrice();
                mp.setSeller(String.valueOf(a.getSeller()));
                mp.setCountry(String.valueOf(a.getSeller().getAddress().getCountry()));
                mp.setValue(a.getPrice());
                mp.setQuality(a.getCondition());
                mp.setUrl("https://www.magiccardmarket.eu" + resultat.getWebsite());
                mp.setSite("MagicCardMarket");
                mp.setFoil(a.isFoil());
                mp.setCurrency("EUR");
                mp.setLanguage(a.getLanguage().toString());
                mp.setShopItem(a);
                lists.add(mp);
            }
        }
    } catch (Exception e) {
        logger.error("Error retrieving prices for " + card, e);
        logger.error(e);
    }
    return lists;
}
Also used : ARTICLES_ATT(org.api.mkm.modele.Article.ARTICLES_ATT) MagicPrice(org.magic.api.beans.MagicPrice) Article(org.api.mkm.modele.Article) Product(org.api.mkm.modele.Product) ProductServices(org.api.mkm.services.ProductServices) IOException(java.io.IOException) MkmException(org.api.mkm.exceptions.MkmException) PRODUCT_ATTS(org.api.mkm.modele.Product.PRODUCT_ATTS) ArticleService(org.api.mkm.services.ArticleService) EnumMap(java.util.EnumMap)

Example 85 with EnumMap

use of java.util.EnumMap in project tetrad by cmu-phil.

the class GeneralAlgorithmEditor method refreshScoreList.

private void refreshScoreList() {
    updatingScoreModels = true;
    scoreComboBox.removeAllItems();
    AlgorithmModel algoModel = algorithmList.getSelectedValue();
    if (algoModel != null && algoModel.isRequiredScore()) {
        boolean linear = linearVarChkBox.isSelected();
        boolean gaussian = gaussianVarChkBox.isSelected();
        List<ScoreModel> models = ScoreModels.getInstance().getModels(dataType);
        List<ScoreModel> scoreModels = new LinkedList<>();
        if (linear && gaussian) {
            models.stream().filter(e -> e.getScore().getClazz().isAnnotationPresent(Linear.class)).filter(e -> e.getScore().getClazz().isAnnotationPresent(Gaussian.class)).forEach(e -> scoreModels.add(e));
        } else if (linear) {
            models.stream().filter(e -> e.getScore().getClazz().isAnnotationPresent(Linear.class)).filter(e -> !e.getScore().getClazz().isAnnotationPresent(Gaussian.class)).forEach(e -> scoreModels.add(e));
        } else if (gaussian) {
            models.stream().filter(e -> !e.getScore().getClazz().isAnnotationPresent(Linear.class)).filter(e -> e.getScore().getClazz().isAnnotationPresent(Gaussian.class)).forEach(e -> scoreModels.add(e));
        } else {
            models.stream().forEach(e -> scoreModels.add(e));
        }
        // or BDeu score for discrete data
        if (TsImages.class.equals(algoModel.getAlgorithm().getClazz())) {
            switch(dataType) {
                case Continuous:
                    scoreModels.stream().filter(e -> e.getScore().getClazz().equals(SemBicScore.class)).forEach(e -> scoreComboBox.addItem(e));
                    break;
                case Discrete:
                    scoreModels.stream().filter(e -> e.getScore().getClazz().equals(BdeuScore.class)).forEach(e -> scoreComboBox.addItem(e));
                    break;
            }
        } else {
            scoreModels.forEach(e -> scoreComboBox.addItem(e));
        }
    }
    updatingScoreModels = false;
    if (scoreComboBox.getItemCount() > 0) {
        scoreComboBox.setEnabled(true);
        Map<DataType, ScoreModel> map = defaultScoreModels.get(algoModel);
        if (map == null) {
            map = new EnumMap<>(DataType.class);
            defaultScoreModels.put(algoModel, map);
        }
        ScoreModel scoreModel = map.get(dataType);
        if (scoreModel == null) {
            scoreModel = ScoreModels.getInstance().getDefaultModel(dataType);
            if (scoreModel == null) {
                scoreModel = scoreComboBox.getItemAt(0);
            }
        }
        scoreComboBox.setSelectedItem(scoreModel);
    } else {
        scoreComboBox.setEnabled(false);
    }
}
Also used : Enumeration(java.util.Enumeration) JDialog(javax.swing.JDialog) TetradDesktop(edu.cmu.tetradapp.app.TetradDesktop) LoggerFactory(org.slf4j.LoggerFactory) Parameters(edu.cmu.tetrad.util.Parameters) Node(edu.cmu.tetrad.graph.Node) PaddingPanel(edu.cmu.tetradapp.ui.PaddingPanel) StringUtils(org.apache.commons.lang3.StringUtils) Linear(edu.cmu.tetrad.annotation.Linear) AlgorithmModel(edu.cmu.tetradapp.ui.model.AlgorithmModel) Map(java.util.Map) ScoreModel(edu.cmu.tetradapp.ui.model.ScoreModel) ICovarianceMatrix(edu.cmu.tetrad.data.ICovarianceMatrix) HpcJobActivityAction(edu.cmu.tetradapp.app.hpc.action.HpcJobActivityAction) BorderLayout(java.awt.BorderLayout) ButtonModel(javax.swing.ButtonModel) JComboBox(javax.swing.JComboBox) GraphSelectionWrapper(edu.cmu.tetradapp.model.GraphSelectionWrapper) Method(java.lang.reflect.Method) Path(java.nio.file.Path) GeneralAlgorithmRunner(edu.cmu.tetradapp.model.GeneralAlgorithmRunner) BdeuScore(edu.cmu.tetrad.algcomparison.score.BdeuScore) HpcJobManager(edu.cmu.tetradapp.app.hpc.manager.HpcJobManager) Frame(java.awt.Frame) HpcAccountManager(edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager) WatchedProcess(edu.cmu.tetradapp.util.WatchedProcess) EnumMap(java.util.EnumMap) AlgType(edu.cmu.tetrad.annotation.AlgType) HpcParameter(edu.pitt.dbmi.tetrad.db.entity.HpcParameter) Set(java.util.Set) BorderFactory(javax.swing.BorderFactory) ComboBoxModel(javax.swing.ComboBoxModel) Gaussian(edu.cmu.tetrad.annotation.Gaussian) Nonexecutable(edu.cmu.tetrad.annotation.Nonexecutable) JsonWebToken(edu.pitt.dbmi.ccd.rest.client.dto.user.JsonWebToken) HpcJobInfo(edu.pitt.dbmi.tetrad.db.entity.HpcJobInfo) JRadioButton(javax.swing.JRadioButton) DataModel(edu.cmu.tetrad.data.DataModel) InvocationTargetException(java.lang.reflect.InvocationTargetException) Box(javax.swing.Box) Dimension(java.awt.Dimension) List(java.util.List) DataSet(edu.cmu.tetrad.data.DataSet) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) MessageDigestHash(edu.pitt.dbmi.ccd.commons.file.MessageDigestHash) JPanel(javax.swing.JPanel) Toolkit(java.awt.Toolkit) CardLayout(java.awt.CardLayout) JOptionUtils(edu.cmu.tetrad.util.JOptionUtils) HashMap(java.util.HashMap) AlgorithmModels(edu.cmu.tetradapp.ui.model.AlgorithmModels) FinalizingEditor(edu.cmu.tetradapp.util.FinalizingEditor) AlgorithmParamRequest(edu.pitt.dbmi.tetrad.db.entity.AlgorithmParamRequest) SwingConstants(javax.swing.SwingConstants) ArrayList(java.util.ArrayList) SingleGraphAlg(edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.SingleGraphAlg) HashSet(java.util.HashSet) HasKnowledge(edu.cmu.tetrad.algcomparison.utils.HasKnowledge) SemBicScore(edu.cmu.tetrad.algcomparison.score.SemBicScore) DataType(edu.cmu.tetrad.data.DataType) JsonUtils(edu.cmu.tetrad.util.JsonUtils) IndependenceTestModel(edu.cmu.tetradapp.ui.model.IndependenceTestModel) IndependenceTestModels(edu.cmu.tetradapp.ui.model.IndependenceTestModels) TsImages(edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.TsImages) LinkedList(java.util.LinkedList) AlgorithmFactory(edu.cmu.tetrad.algcomparison.algorithm.AlgorithmFactory) Algorithm(edu.cmu.tetrad.algcomparison.algorithm.Algorithm) JButton(javax.swing.JButton) Logger(org.slf4j.Logger) AlgorithmParameter(edu.pitt.dbmi.tetrad.db.entity.AlgorithmParameter) Files(java.nio.file.Files) ButtonGroup(javax.swing.ButtonGroup) TakesInitialGraph(edu.cmu.tetrad.algcomparison.utils.TakesInitialGraph) Window(java.awt.Window) JList(javax.swing.JList) DesktopController(edu.cmu.tetradapp.util.DesktopController) Graph(edu.cmu.tetrad.graph.Graph) HpcAccountUtils(edu.cmu.tetradapp.app.hpc.util.HpcAccountUtils) JvmOptions(edu.pitt.dbmi.tetrad.db.entity.JvmOptions) IOException(java.io.IOException) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) JScrollPane(javax.swing.JScrollPane) LayoutStyle(javax.swing.LayoutStyle) DataModelList(edu.cmu.tetrad.data.DataModelList) ScoreModels(edu.cmu.tetradapp.ui.model.ScoreModels) DefaultListModel(javax.swing.DefaultListModel) JLabel(javax.swing.JLabel) GroupLayout(javax.swing.GroupLayout) HpcAccount(edu.pitt.dbmi.tetrad.db.entity.HpcAccount) JTextArea(javax.swing.JTextArea) Knowledge2(edu.cmu.tetrad.data.Knowledge2) DataType(edu.cmu.tetrad.data.DataType) AlgorithmModel(edu.cmu.tetradapp.ui.model.AlgorithmModel) ScoreModel(edu.cmu.tetradapp.ui.model.ScoreModel) LinkedList(java.util.LinkedList) Linear(edu.cmu.tetrad.annotation.Linear)

Aggregations

EnumMap (java.util.EnumMap)389 Map (java.util.Map)73 ArrayList (java.util.ArrayList)70 List (java.util.List)61 HashMap (java.util.HashMap)60 Test (org.junit.Test)46 IOException (java.io.IOException)38 Collection (java.util.Collection)35 DecodeHintType (com.google.zxing.DecodeHintType)30 HashSet (java.util.HashSet)26 Set (java.util.Set)26 EncodeHintType (com.google.zxing.EncodeHintType)17 File (java.io.File)17 BitMatrix (com.google.zxing.common.BitMatrix)15 BookID (biblemulticonverter.data.BookID)14 Iterator (java.util.Iterator)14 URL (java.net.URL)12 TreeMap (java.util.TreeMap)12 Header (com.jsql.model.bean.util.Header)10 Request (com.jsql.model.bean.util.Request)10