use of net.jforum.entities.Config in project jforum2 by rafaelsteil.
the class ForumRepository method updateMostUsersEverOnline.
/**
* Update the value of most online users ever.
*
* @param m MostUsersEverOnline The new value to store. Generally it
* will be a bigger one.
*/
public static void updateMostUsersEverOnline(MostUsersEverOnline m) {
ConfigDAO cm = DataAccessDriver.getInstance().newConfigDAO();
Config config = cm.selectByName(ConfigKeys.MOST_USERS_EVER_ONLINE);
if (config == null) {
// Total
config = new Config();
config.setName(ConfigKeys.MOST_USERS_EVER_ONLINE);
config.setValue(Integer.toString(m.getTotal()));
cm.insert(config);
// Date
config.setName(ConfigKeys.MOST_USER_EVER_ONLINE_DATE);
config.setValue(Long.toString(m.getTimeInMillis()));
cm.insert(config);
} else {
// Total
config.setValue(Integer.toString(m.getTotal()));
cm.update(config);
// Date
config.setName(ConfigKeys.MOST_USER_EVER_ONLINE_DATE);
config.setValue(Long.toString(m.getTimeInMillis()));
cm.update(config);
}
cache.add(FQN, MOST_USERS_ONLINE, m);
}
use of net.jforum.entities.Config in project jforum2 by rafaelsteil.
the class ForumRepository method loadMostUsersEverOnline.
private MostUsersEverOnline loadMostUsersEverOnline(ConfigDAO cm) {
Config config = cm.selectByName(ConfigKeys.MOST_USERS_EVER_ONLINE);
MostUsersEverOnline mostUsersEverOnline = new MostUsersEverOnline();
if (config != null) {
mostUsersEverOnline.setTotal(Integer.parseInt(config.getValue()));
// We're assuming that, if we have one key, the another one
// will always exist
config = cm.selectByName(ConfigKeys.MOST_USER_EVER_ONLINE_DATE);
mostUsersEverOnline.setTimeInMillis(Long.parseLong(config.getValue()));
}
cache.add(FQN, MOST_USERS_ONLINE, mostUsersEverOnline);
return mostUsersEverOnline;
}
use of net.jforum.entities.Config in project jforum2 by rafaelsteil.
the class GenericConfigDAO method selectByName.
/**
* @see net.jforum.dao.ConfigDAO#selectByName(java.lang.String)
*/
public Config selectByName(String name) {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("ConfigModel.selectByName"));
p.setString(1, name);
rs = p.executeQuery();
Config c = null;
if (rs.next()) {
c = this.makeConfig(rs);
}
return c;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
use of net.jforum.entities.Config in project jforum2 by rafaelsteil.
the class GenericConfigDAO method makeConfig.
protected Config makeConfig(ResultSet rs) throws SQLException {
Config c = new Config();
c.setId(rs.getInt("config_id"));
c.setName(rs.getString("config_name"));
c.setValue(rs.getString("config_value"));
return c;
}
Aggregations