Search in sources :

Example 1 with MagicNews

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

the class HsqlDAO method listNews.

@Override
public List<MagicNews> listNews() {
    try (PreparedStatement pst = con.prepareStatement("select * from news")) {
        List<MagicNews> news = new ArrayList<>();
        try (ResultSet rs = pst.executeQuery()) {
            while (rs.next()) {
                MagicNews n = new MagicNews();
                n.setCategorie(rs.getString("categorie"));
                n.setName(rs.getString("name"));
                n.setUrl(rs.getString("url"));
                n.setType(NEWS_TYPE.valueOf(rs.getString("typeNews")));
                n.setId(rs.getInt("id"));
                news.add(n);
            }
            return news;
        }
    } catch (Exception e) {
        logger.error(e);
        return new ArrayList<>();
    }
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) MagicNews(org.magic.api.beans.MagicNews) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 2 with MagicNews

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

the class MysqlDAO method listNews.

@Override
public List<MagicNews> listNews() {
    try (PreparedStatement pst = con.prepareStatement("select * from news")) {
        List<MagicNews> news = new ArrayList<>();
        try (ResultSet rs = pst.executeQuery()) {
            while (rs.next()) {
                MagicNews n = new MagicNews();
                n.setCategorie(rs.getString("categorie"));
                n.setName(rs.getString("name"));
                n.setUrl(rs.getString("url"));
                n.setId(rs.getInt("id"));
                n.setType(NEWS_TYPE.valueOf(rs.getString("typeNews")));
                news.add(n);
            }
            return news;
        }
    } catch (Exception e) {
        logger.error(e);
        return new ArrayList<>();
    }
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) MagicNews(org.magic.api.beans.MagicNews) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 3 with MagicNews

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

the class PostgresqlDAO method listNews.

@Override
public List<MagicNews> listNews() {
    try (PreparedStatement pst = con.prepareStatement("select * from news")) {
        List<MagicNews> news = new ArrayList<>();
        try (ResultSet rs = pst.executeQuery()) {
            while (rs.next()) {
                MagicNews n = new MagicNews();
                n.setCategorie(rs.getString("categorie"));
                n.setName(rs.getString("name"));
                n.setUrl(rs.getString("url"));
                n.setType(NEWS_TYPE.valueOf(rs.getString("typeNews")));
                n.setId(rs.getInt("id"));
                news.add(n);
            }
            return news;
        }
    } catch (Exception e) {
        logger.error(e);
        return new ArrayList<>();
    }
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) MagicNews(org.magic.api.beans.MagicNews) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 4 with MagicNews

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

the class RssGUI method initTree.

private void initTree() {
    rootNode.removeAllChildren();
    List<MagicNews> rss = MTGControler.getInstance().getEnabledDAO().listNews();
    for (MagicNews cat : rss) add(cat.getCategorie(), cat);
    ((DefaultTreeModel) tree.getModel()).reload();
    for (int i = 0; i < tree.getRowCount(); i++) tree.expandRow(i + 1);
}
Also used : DefaultTreeModel(javax.swing.tree.DefaultTreeModel) MagicNews(org.magic.api.beans.MagicNews)

Aggregations

MagicNews (org.magic.api.beans.MagicNews)4 IOException (java.io.IOException)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 ArrayList (java.util.ArrayList)3 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1