Search in sources :

Example 1 with ConfigDAO

use of net.jforum.dao.ConfigDAO 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);
}
Also used : Config(net.jforum.entities.Config) ConfigDAO(net.jforum.dao.ConfigDAO)

Example 2 with ConfigDAO

use of net.jforum.dao.ConfigDAO in project jforum2 by rafaelsteil.

the class ForumStartup method startForumRepository.

/**
	 * Starts the cache control for forums and categories.
	 * @throws RepositoryStartupException is something were wrong.
	 */
public static void startForumRepository() {
    try {
        ForumDAO fm = DataAccessDriver.getInstance().newForumDAO();
        CategoryDAO cm = DataAccessDriver.getInstance().newCategoryDAO();
        ConfigDAO configModel = DataAccessDriver.getInstance().newConfigDAO();
        ForumRepository.start(fm, cm, configModel);
    } catch (Exception e) {
        log.error("Unable to bootstrap JForum repository.", e);
        throw new RepositoryStartupException("Error while trying to start ForumRepository: " + e, e);
    }
}
Also used : ForumDAO(net.jforum.dao.ForumDAO) CategoryDAO(net.jforum.dao.CategoryDAO) ConfigDAO(net.jforum.dao.ConfigDAO) DatabaseException(net.jforum.exceptions.DatabaseException) RepositoryStartupException(net.jforum.exceptions.RepositoryStartupException) RepositoryStartupException(net.jforum.exceptions.RepositoryStartupException)

Aggregations

ConfigDAO (net.jforum.dao.ConfigDAO)2 CategoryDAO (net.jforum.dao.CategoryDAO)1 ForumDAO (net.jforum.dao.ForumDAO)1 Config (net.jforum.entities.Config)1 DatabaseException (net.jforum.exceptions.DatabaseException)1 RepositoryStartupException (net.jforum.exceptions.RepositoryStartupException)1