use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class UserFactoryImpl method getUsers.
@SuppressWarnings("unchecked")
@Override
public List<User> getUsers() {
return (List<User>) template.execute(new JDBCCallback() {
@Override
public Object execute(Connection connection) throws SQLException {
List<User> result = new ArrayList<User>();
Statement st = connection.createStatement();
PreparedStatement groups = connection.prepareStatement("SELECT * FROM users_groups WHERE \"login\"=? ORDER BY group_name");
ResultSet rs = st.executeQuery("SELECT * FROM users ORDER BY \"login\"");
PreparedStatement groupQualifiers = template.getConnection().prepareStatement("SELECT qualifier_id FROM group_qualifier_access WHERE group_name=? ORDER BY qualifier_id");
while (rs.next()) {
User user = createUser(groups, rs, groupQualifiers);
result.add(user);
}
groupQualifiers.close();
groups.close();
rs.close();
st.close();
return result;
}
});
}
use of com.ramussoft.net.common.User in project ramus by Vitaliy-Yakovchuk.
the class UserFactoryImpl method createUser.
private User createUser(PreparedStatement groups, ResultSet rs, PreparedStatement groupQualifiers) throws SQLException {
User user = new User();
user.setName(rs.getString("name").trim());
String login = rs.getString("login").trim();
user.setLogin(login);
user.setPassword(rs.getString("password").trim());
groups.setString(1, login);
ResultSet grs = groups.executeQuery();
while (grs.next()) {
Group group = new Group();
group.setName(grs.getString("group_name").trim());
fillGroup(group, groupQualifiers);
user.getGroups().add(group);
}
grs.close();
return user;
}
Aggregations