use of mom.trd.opentheso.bdd.helper.nodes.NodeUserRoleGroup in project opentheso by miledrousset.
the class UserHelper2 method getUserRoleWithoutGroup.
/**
* cette fonction permet de retourner un objet vide de type
* NodeUserRoleGroup pour un utilisateur qui n'a aucun role encore sur aucun
* groupe
*
* @param ds
* @return
*/
public NodeUserRoleGroup getUserRoleWithoutGroup(HikariDataSource ds) {
// NodeUserRoleGroup nodeUserRoleGroup = null;
NodeUserRoleGroup nodeUserRoleGroup = new NodeUserRoleGroup();
nodeUserRoleGroup.setIdRole(-1);
nodeUserRoleGroup.setRoleName("");
nodeUserRoleGroup.setGroupName("");
nodeUserRoleGroup.setIdGroup(-1);
nodeUserRoleGroup.setIsAdmin(false);
nodeUserRoleGroup.setIsManager(false);
nodeUserRoleGroup.setIsContributor(false);
/*
Connection conn;
Statement stmt;
ResultSet resultSet;
try {
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "SELECT \n" +
" roles.id, \n" +
" roles.name, \n" +
" user_group_label.label_group, \n" +
" user_group_label.id_group\n" +
" FROM \n" +
" user_role_group, \n" +
" roles, \n" +
" user_group_label\n" +
" WHERE \n" +
" user_role_group.id_role = roles.id AND\n" +
" user_group_label.id_group = user_role_group.id_group AND\n" +
" user_role_group.id_user = " + idUser;
resultSet = stmt.executeQuery(query);
if(resultSet.next()) {
nodeUserRoleGroup = new NodeUserRoleGroup();
nodeUserRoleGroup.setIdRole(resultSet.getInt("id"));
nodeUserRoleGroup.setRoleName(resultSet.getString("name"));
nodeUserRoleGroup.setGroupName(resultSet.getString("label_group"));
nodeUserRoleGroup.setIdGroup(resultSet.getInt("id_group"));
if(resultSet.getInt("id") == 2)
nodeUserRoleGroup.setIsAdmin(true);
if(resultSet.getInt("id") == 3)
nodeUserRoleGroup.setIsManager(true);
if(resultSet.getInt("id") == 4)
nodeUserRoleGroup.setIsContributor(true);
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException ex) {
Logger.getLogger(UserHelper2.class.getName()).log(Level.SEVERE, null, ex);
}*/
return nodeUserRoleGroup;
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUserRoleGroup in project opentheso by miledrousset.
the class UserHelper2 method getUserRoleForSuperAdmin.
/**
* cette fonction permet de retourner le role du superAdmin
*
* @param ds
* @return
*/
public NodeUserRoleGroup getUserRoleForSuperAdmin(HikariDataSource ds) {
NodeUserRoleGroup nodeUserRoleGroup = null;
Connection conn;
Statement stmt;
ResultSet resultSet;
try {
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "SELECT " + " roles.id, " + " roles.name " + " FROM " + " public.roles " + " WHERE " + " roles.id = 1";
resultSet = stmt.executeQuery(query);
if (resultSet.next()) {
nodeUserRoleGroup = new NodeUserRoleGroup();
nodeUserRoleGroup.setIdRole(resultSet.getInt("id"));
nodeUserRoleGroup.setRoleName(resultSet.getString("name"));
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException ex) {
Logger.getLogger(UserHelper2.class.getName()).log(Level.SEVERE, null, ex);
}
return nodeUserRoleGroup;
}
Aggregations