Search in sources :

Example 1 with NodeUserGroupUser

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;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) NodeUserGroupUser(mom.trd.opentheso.bdd.helper.nodes.NodeUserGroupUser)

Example 2 with NodeUserGroupUser

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;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) NodeUserGroupUser(mom.trd.opentheso.bdd.helper.nodes.NodeUserGroupUser)

Example 3 with NodeUserGroupUser

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);
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) NodeUserGroupUser(mom.trd.opentheso.bdd.helper.nodes.NodeUserGroupUser)

Aggregations

NodeUserGroupUser (mom.trd.opentheso.bdd.helper.nodes.NodeUserGroupUser)3 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 ArrayList (java.util.ArrayList)2 UserHelper2 (mom.trd.opentheso.bdd.helper.UserHelper2)1