use of net.jforum.entities.Group in project jforum2 by rafaelsteil.
the class GenericGroupDAO method selectById.
/**
* @see net.jforum.dao.GroupDAO#selectById(int)
*/
public Group selectById(int groupId) {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("GroupModel.selectById"));
p.setInt(1, groupId);
rs = p.executeQuery();
Group g = new Group();
if (rs.next()) {
g = this.getGroup(rs);
}
return g;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
use of net.jforum.entities.Group in project jforum2 by rafaelsteil.
the class GenericUserDAO method selectById.
/**
* @see net.jforum.dao.UserDAO#selectById(int)
*/
public User selectById(int userId) {
String q = SystemGlobals.getSql("UserModel.selectById");
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(q);
p.setInt(1, userId);
rs = p.executeQuery();
User u = new User();
if (rs.next()) {
this.fillUserFromResultSet(u, rs);
u.setPrivateMessagesCount(rs.getInt("private_messages"));
rs.close();
p.close();
// User groups
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("UserModel.selectGroups"));
p.setInt(1, userId);
rs = p.executeQuery();
while (rs.next()) {
Group g = new Group();
g.setName(rs.getString("group_name"));
g.setId(rs.getInt("group_id"));
u.getGroupsList().add(g);
}
}
return u;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
use of net.jforum.entities.Group in project jforum2 by rafaelsteil.
the class GroupAction method insertSave.
// Saves a new group
public void insertSave() {
GroupDAO gm = DataAccessDriver.getInstance().newGroupDAO();
Group g = new Group();
g.setDescription(this.request.getParameter("group_description"));
g.setParentId(this.request.getIntParameter("parent_id"));
g.setName(this.request.getParameter("group_name"));
gm.addNew(g);
this.list();
}
use of net.jforum.entities.Group in project jforum2 by rafaelsteil.
the class GroupAction method editSave.
// Save information for an existing group
public void editSave() {
int groupId = this.request.getIntParameter("group_id");
Group g = new Group();
g.setDescription(this.request.getParameter("group_description"));
g.setId(groupId);
int parentId = this.request.getIntParameter("parent_id");
if (parentId == g.getId()) {
parentId = 0;
}
g.setParentId(parentId);
g.setName(this.request.getParameter("group_name"));
DataAccessDriver.getInstance().newGroupDAO().update(g);
this.list();
}
use of net.jforum.entities.Group in project jforum2 by rafaelsteil.
the class UserAction method groups.
// Groups
public void groups() {
int userId = this.request.getIntParameter("id");
UserDAO um = DataAccessDriver.getInstance().newUserDAO();
User u = um.selectById(userId);
List selectedList = new ArrayList();
for (Iterator iter = u.getGroupsList().iterator(); iter.hasNext(); ) {
selectedList.add(new Integer(((Group) iter.next()).getId()));
}
this.context.put("selectedList", selectedList);
this.context.put("groups", new TreeGroup().getNodes());
this.context.put("user", u);
this.context.put("userId", new Integer(userId));
this.setTemplateName(TemplateKeys.USER_ADMIN_GROUPS);
this.context.put("groupFor", I18n.getMessage("User.GroupsFor", new String[] { u.getUsername() }));
}
Aggregations