use of net.jforum.dao.DataAccessDriver in project jforum2 by rafaelsteil.
the class ConfigLoader method loadDaoImplementation.
public static void loadDaoImplementation() {
// Start the dao.driver implementation
String driver = SystemGlobals.getValue(ConfigKeys.DAO_DRIVER);
logger.info("Loading JDBC driver " + driver);
try {
Class c = Class.forName(driver);
DataAccessDriver d = (DataAccessDriver) c.newInstance();
DataAccessDriver.init(d);
} catch (Exception e) {
throw new ForumException(e);
}
}
use of net.jforum.dao.DataAccessDriver in project jforum2 by rafaelsteil.
the class HottestTopicsAction method showTopicsByUser.
public void showTopicsByUser() {
DataAccessDriver da = DataAccessDriver.getInstance();
UserDAO udao = da.newUserDAO();
User u = udao.selectById(this.request.getIntParameter("user_id"));
if (u.getId() == 0) {
this.context.put("message", I18n.getMessage("User.notFound"));
this.setTemplateName(TemplateKeys.USER_NOT_FOUND);
return;
}
TopicsCommon.topicListingBase();
int start = ViewCommon.getStartPage();
int topicsPerPage = SystemGlobals.getIntValue(ConfigKeys.TOPICS_PER_PAGE);
int postsPerPage = SystemGlobals.getIntValue(ConfigKeys.POSTS_PER_PAGE);
this.setTemplateName(TemplateKeys.HOTTEST_USER_TOPICS_SHOW);
int totalTopics = da.newTopicDAO().countUserTopics(u.getId());
this.context.put("u", u);
this.context.put("pageTitle", I18n.getMessage("ForumListing.userTopics") + " " + u.getUsername());
this.context.put("postsPerPage", new Integer(postsPerPage));
List topics = da.newTopicDAO().selectByUserByLimit(u.getId(), start, topicsPerPage);
List l = TopicsCommon.prepareTopics(topics);
Map forums = new HashMap();
for (Iterator iter = l.iterator(); iter.hasNext(); ) {
Topic t = (Topic) iter.next();
Forum f = ForumRepository.getForum(t.getForumId());
if (f == null) {
iter.remove();
totalTopics--;
continue;
}
forums.put(new Integer(t.getForumId()), f);
}
this.context.put("topics", l);
this.context.put("forums", forums);
ViewCommon.contextToPagination(start, totalTopics, topicsPerPage);
}
use of net.jforum.dao.DataAccessDriver in project jforum2 by rafaelsteil.
the class RecentTopicsAction method showTopicsByUser.
public void showTopicsByUser() {
DataAccessDriver da = DataAccessDriver.getInstance();
UserDAO udao = da.newUserDAO();
User u = udao.selectById(this.request.getIntParameter("user_id"));
if (u.getId() == 0) {
this.context.put("message", I18n.getMessage("User.notFound"));
this.setTemplateName(TemplateKeys.USER_NOT_FOUND);
return;
}
TopicsCommon.topicListingBase();
int start = ViewCommon.getStartPage();
int topicsPerPage = SystemGlobals.getIntValue(ConfigKeys.TOPICS_PER_PAGE);
int postsPerPage = SystemGlobals.getIntValue(ConfigKeys.POSTS_PER_PAGE);
this.setTemplateName(TemplateKeys.RECENT_USER_TOPICS_SHOW);
int totalTopics = da.newTopicDAO().countUserTopics(u.getId());
this.context.put("u", u);
this.context.put("pageTitle", I18n.getMessage("ForumListing.userTopics") + " " + u.getUsername());
this.context.put("postsPerPage", new Integer(postsPerPage));
List topics = da.newTopicDAO().selectByUserByLimit(u.getId(), start, topicsPerPage);
List l = TopicsCommon.prepareTopics(topics);
Map forums = new HashMap();
for (Iterator iter = l.iterator(); iter.hasNext(); ) {
Topic t = (Topic) iter.next();
Forum f = ForumRepository.getForum(t.getForumId());
if (f == null) {
iter.remove();
totalTopics--;
continue;
}
forums.put(new Integer(t.getForumId()), f);
}
this.context.put("topics", l);
this.context.put("forums", forums);
ViewCommon.contextToPagination(start, totalTopics, topicsPerPage);
}
use of net.jforum.dao.DataAccessDriver in project jforum2 by rafaelsteil.
the class TestCaseUtils method initDatabaseImplementation.
/**
* Inits the database stuff.
* Must be called <b>after</b> #loadEnvironment
*
* @throws Exception
*/
public static void initDatabaseImplementation() throws Exception {
SystemGlobals.loadAdditionalDefaults(SystemGlobals.getValue(ConfigKeys.DATABASE_DRIVER_CONFIG));
SystemGlobals.loadQueries(SystemGlobals.getValue(ConfigKeys.SQL_QUERIES_GENERIC));
SystemGlobals.loadQueries(SystemGlobals.getValue(ConfigKeys.SQL_QUERIES_DRIVER));
// Start the dao.driver implementation
String driver = SystemGlobals.getValue(ConfigKeys.DAO_DRIVER);
Class c = Class.forName(driver);
DataAccessDriver d = (DataAccessDriver) c.newInstance();
DataAccessDriver.init(d);
DBConnection.createInstance();
DBConnection.getImplementation().init();
}
use of net.jforum.dao.DataAccessDriver in project jforum2 by rafaelsteil.
the class UserAction method profile.
public void profile() {
DataAccessDriver da = DataAccessDriver.getInstance();
UserDAO udao = da.newUserDAO();
User u = udao.selectById(this.request.getIntParameter("user_id"));
if (u.getId() == 0) {
this.userNotFound();
} else {
this.setTemplateName(TemplateKeys.USER_PROFILE);
this.context.put("karmaEnabled", SecurityRepository.canAccess(SecurityConstants.PERM_KARMA_ENABLED));
this.context.put("rank", new RankingRepository());
this.context.put("u", u);
this.context.put("avatarAllowExternalUrl", SystemGlobals.getBoolValue(ConfigKeys.AVATAR_ALLOW_EXTERNAL_URL));
int loggedId = SessionFacade.getUserSession().getUserId();
int count = 0;
List bookmarks = da.newBookmarkDAO().selectByUser(u.getId());
for (Iterator iter = bookmarks.iterator(); iter.hasNext(); ) {
Bookmark b = (Bookmark) iter.next();
if (b.isPublicVisible() || loggedId == u.getId()) {
count++;
}
}
this.context.put("pageTitle", I18n.getMessage("UserProfile.allAbout") + " " + u.getUsername());
this.context.put("nbookmarks", new Integer(count));
this.context.put("ntopics", new Integer(da.newTopicDAO().countUserTopics(u.getId())));
this.context.put("nposts", new Integer(da.newPostDAO().countUserPosts(u.getId())));
}
}
Aggregations