use of mom.trd.opentheso.bdd.helper.nodes.NodeUserGroupUser in project opentheso by miledrousset.
the class UserHelper2 method getAllGroupUserWithoutGroup.
/**
* cette fonction permet de retourner la liste des utilisateurs qui n'ont
* aucun groupe et qui ne sont pas des superAdmin.
*
* @param ds
* @param idLangSource
* @return #MR
*/
public ArrayList<NodeUserGroupUser> getAllGroupUserWithoutGroup(HikariDataSource ds, String idLangSource) {
Connection conn;
Statement stmt;
ResultSet resultSet;
ArrayList<NodeUserGroupUser> nodeUserGroupUsers = new ArrayList<>();
try {
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "SELECT" + " users.username," + " users.id_user" + " FROM" + " users" + " WHERE " + " users.issuperadmin != true" + " and" + " users.id_user not in" + " (select user_role_group.id_user from user_role_group)";
resultSet = stmt.executeQuery(query);
while (resultSet.next()) {
NodeUserGroupUser nodeUserGroupUser = new NodeUserGroupUser();
nodeUserGroupUser.setIdUser(resultSet.getString("id_user"));
nodeUserGroupUser.setUserName(resultSet.getString("username"));
nodeUserGroupUser.setIdGroup(-1);
nodeUserGroupUser.setGroupName("");
nodeUserGroupUsers.add(nodeUserGroupUser);
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException ex) {
Logger.getLogger(UserHelper2.class.getName()).log(Level.SEVERE, null, ex);
}
return nodeUserGroupUsers;
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUserGroupUser in project opentheso by miledrousset.
the class UserHelper2 method getAllGroupUser.
/**
* cette fonction permet de retourner la liste des utilisateurs avec les
* groupes correspondants on ignore les superAdmin et les utilisateurs sans
* groupes.
*
* @param ds
* @param idLangSource
* @return #MR
*/
public ArrayList<NodeUserGroupUser> getAllGroupUser(HikariDataSource ds, String idLangSource) {
Connection conn;
Statement stmt;
ResultSet resultSet;
ArrayList<NodeUserGroupUser> nodeUserGroupUsers = new ArrayList<>();
try {
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "SELECT" + " users.username," + " users.id_user," + " roles.name," + " user_group_label.label_group," + " user_group_label.id_group," + " roles.id" + " FROM" + " user_role_group," + " users," + " user_group_label," + " roles" + " WHERE" + " user_role_group.id_user = users.id_user AND" + " user_group_label.id_group = user_role_group.id_group AND" + " roles.id = user_role_group.id_role";
resultSet = stmt.executeQuery(query);
while (resultSet.next()) {
NodeUserGroupUser nodeUserGroupUser = new NodeUserGroupUser();
nodeUserGroupUser.setIdUser(resultSet.getString("id_user"));
nodeUserGroupUser.setUserName(resultSet.getString("username"));
nodeUserGroupUser.setIdGroup(resultSet.getInt("id_group"));
nodeUserGroupUser.setGroupName(resultSet.getString("label_group"));
nodeUserGroupUser.setIdRole(resultSet.getInt("id"));
nodeUserGroupUser.setRoleName(resultSet.getString("name"));
nodeUserGroupUsers.add(nodeUserGroupUser);
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException ex) {
Logger.getLogger(UserHelper2.class.getName()).log(Level.SEVERE, null, ex);
}
return nodeUserGroupUsers;
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUserGroupUser in project opentheso by miledrousset.
the class CurrentUser2 method listAllGroupUser.
private void listAllGroupUser() {
UserHelper2 userHelper = new UserHelper2();
listeAllGroupUser = userHelper.getAllGroupUser(connect.getPoolConnexion(), connect.getWorkLanguage());
// les users sans groupe en ignorant les superAdmin
ArrayList<NodeUserGroupUser> nodeUserGroupUser_wtihoutGroup = userHelper.getAllGroupUserWithoutGroup(connect.getPoolConnexion(), connect.getWorkLanguage());
if (nodeUserGroupUser_wtihoutGroup != null)
if (!nodeUserGroupUser_wtihoutGroup.isEmpty())
listeAllGroupUser.addAll(nodeUserGroupUser_wtihoutGroup);
}
Aggregations