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;
}
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;
}
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();
}
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();
}
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);
}
}
Aggregations