Search in sources :

Example 1 with Ranking

use of net.jforum.entities.Ranking in project jforum2 by rafaelsteil.

the class GenericRankingDAO method buildRanking.

private Ranking buildRanking(ResultSet rs) throws SQLException {
    Ranking ranking = new Ranking();
    ranking.setId(rs.getInt("rank_id"));
    ranking.setTitle(rs.getString("rank_title"));
    ranking.setImage(rs.getString("rank_image"));
    ranking.setMin(rs.getInt("rank_min"));
    ranking.setSpecial(rs.getInt("rank_special") == 1);
    return ranking;
}
Also used : Ranking(net.jforum.entities.Ranking)

Example 2 with Ranking

use of net.jforum.entities.Ranking in project jforum2 by rafaelsteil.

the class RankingRepository method getRankTitleById.

private static String getRankTitleById(int rankId) {
    Ranking r = new Ranking();
    r.setId(rankId);
    List l = (List) cache.get(FQN, ENTRIES);
    int index = l.indexOf(r);
    return index > -1 ? ((Ranking) l.get(index)).getTitle() : null;
}
Also used : Ranking(net.jforum.entities.Ranking) List(java.util.List)

Example 3 with Ranking

use of net.jforum.entities.Ranking in project jforum2 by rafaelsteil.

the class RankingRepository method getRankTitleByPosts.

private static String getRankTitleByPosts(int total) {
    Ranking lastRank = new Ranking();
    List entries = (List) cache.get(FQN, ENTRIES);
    for (Iterator iter = entries.iterator(); iter.hasNext(); ) {
        Ranking r = (Ranking) iter.next();
        if (total == r.getMin() && !r.isSpecial()) {
            return r.getTitle();
        } else if (total > lastRank.getMin() && total < r.getMin()) {
            return lastRank.getTitle();
        }
        lastRank = r;
    }
    return lastRank.getTitle();
}
Also used : Ranking(net.jforum.entities.Ranking) Iterator(java.util.Iterator) List(java.util.List)

Example 4 with Ranking

use of net.jforum.entities.Ranking in project jforum2 by rafaelsteil.

the class RankingAction method editSave.

//  Save information
public void editSave() {
    Ranking r = new Ranking();
    r.setTitle(this.request.getParameter("rank_title"));
    r.setId(this.request.getIntParameter("rank_id"));
    boolean special = "1".equals(this.request.getParameter("rank_special"));
    r.setSpecial(special);
    if (!special) {
        r.setMin(this.request.getIntParameter("rank_min"));
    }
    DataAccessDriver.getInstance().newRankingDAO().update(r);
    RankingRepository.loadRanks();
    this.list();
}
Also used : Ranking(net.jforum.entities.Ranking)

Example 5 with Ranking

use of net.jforum.entities.Ranking in project jforum2 by rafaelsteil.

the class GenericRankingDAO method selectById.

/**
	 * @see net.jforum.dao.RankingDAO#selectById(int)
	 */
public Ranking selectById(int rankingId) {
    Ranking ranking = new Ranking();
    PreparedStatement p = null;
    ResultSet rs = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("RankingModel.selectById"));
        p.setInt(1, rankingId);
        rs = p.executeQuery();
        if (rs.next()) {
            ranking = this.buildRanking(rs);
        }
        return ranking;
    } catch (SQLException e) {
        throw new DatabaseException(e);
    } finally {
        DbUtils.close(rs, p);
    }
}
Also used : Ranking(net.jforum.entities.Ranking) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) DatabaseException(net.jforum.exceptions.DatabaseException)

Aggregations

Ranking (net.jforum.entities.Ranking)8 List (java.util.List)4 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 DatabaseException (net.jforum.exceptions.DatabaseException)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)1