use of mom.trd.opentheso.bdd.helper.nodes.NodeUserRoleGroup in project opentheso by miledrousset.
the class EditionBean method init.
@PostConstruct
public void init() {
editTheso = new Thesaurus();
userRoleGroups = new LinkedHashMap();
ArrayList<NodeUserRoleGroup> nodeUserRoleGroups = new UserHelper2().getUserRoleGroup(connect.getPoolConnexion(), currentUser.getUser().getIdUser());
for (NodeUserRoleGroup nodeUserRoleGroup : nodeUserRoleGroups) {
if (nodeUserRoleGroup.getIdRole() < 3) {
userRoleGroups.put("" + nodeUserRoleGroup.getIdGroup(), nodeUserRoleGroup.getGroupName());
selectedUserGroup = "" + nodeUserRoleGroup.getIdGroup();
}
}
vue.setCreat(false);
vue.setTrad(false);
vue.setEdit(false);
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUserRoleGroup in project opentheso by miledrousset.
the class UserHelper2 method getUserRoleOnThisGroup.
/**
* cette fonction permet de retourner le role de l'utilisateur sur ce groupe
*
* @param ds
* @param idUser
* @param idGroup
* @return
*/
public NodeUserRoleGroup getUserRoleOnThisGroup(HikariDataSource ds, int idUser, int idGroup) {
NodeUserRoleGroup nodeUserRoleGroup = null;
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 + " AND \n" + " user_role_group.id_group = " + idGroup;
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 getUserRoleOnThisGroupForSuperAdmin.
/**
* cette fonction permet de retourner le role de l'utilisateur sur ce groupe
*
* @param ds
* @param idUser
* @param idGroup
* @return
*/
public NodeUserRoleGroup getUserRoleOnThisGroupForSuperAdmin(HikariDataSource ds, int idUser, int idGroup) {
NodeUserRoleGroup nodeUserRoleGroup = null;
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.id_group, \n" + " user_group_label.label_group\n" + " FROM \n" + " public.roles, \n" + " public.user_group_label\n" + " WHERE \n" + " roles.id = " + idUser + " AND \n" + " user_group_label.id_group = " + idGroup;
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"));
}
} 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 RoleOnThesoBean method setUserRoleGroup.
/**
* permet de récuperer le role de l'utilisateur sur le group
* applelé en cas où le group n'a aucun thésaurus pour que l'utilisateur
* puisse créer des thésaurus et gérer les utilisateur pour le group
* il faut être Admin
*/
private void setUserRoleGroup() {
UserHelper2 userHelper = new UserHelper2();
ArrayList<NodeUserRoleGroup> nodeUserRoleGroups = userHelper.getUserRoleGroup(connect.getPoolConnexion(), user.getUser().getIdUser());
for (NodeUserRoleGroup nodeUserRoleGroup1 : nodeUserRoleGroups) {
if (nodeUserRoleGroup1.isIsAdmin())
setIsAdminOnThisTheso(true);
}
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeUserRoleGroup in project opentheso by miledrousset.
the class UserHelper2 method getUserRoleGroup.
/**
* cette fonction permet de retourner la liste des groupes - roles pour un
* un utilisateur
*
* @param ds
* @param idUser
* @return #MR
*/
public ArrayList<NodeUserRoleGroup> getUserRoleGroup(HikariDataSource ds, int idUser) {
Connection conn;
Statement stmt;
ResultSet resultSet;
ArrayList<NodeUserRoleGroup> nodeUserRoleGroups = new ArrayList<>();
try {
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "SELECT " + " user_role_group.id_role," + " roles.name," + " user_role_group.id_group," + " user_group_label.label_group" + " FROM user_role_group, roles, user_group_label" + " WHERE" + " user_role_group.id_role = roles.id AND" + " user_group_label.id_group = user_role_group.id_group AND" + " user_role_group.id_user =" + idUser;
resultSet = stmt.executeQuery(query);
while (resultSet.next()) {
NodeUserRoleGroup nodeUserRoleGroup = new NodeUserRoleGroup();
nodeUserRoleGroup.setIdRole(resultSet.getInt("id_role"));
nodeUserRoleGroup.setRoleName(resultSet.getString("name"));
nodeUserRoleGroup.setIdGroup(resultSet.getInt("id_group"));
nodeUserRoleGroup.setGroupName(resultSet.getString("label_group"));
if (resultSet.getInt("id_role") == 2) {
nodeUserRoleGroup.setIsAdmin(true);
}
if (resultSet.getInt("id_role") == 3) {
nodeUserRoleGroup.setIsManager(true);
}
if (resultSet.getInt("id_role") == 4) {
nodeUserRoleGroup.setIsContributor(true);
}
nodeUserRoleGroups.add(nodeUserRoleGroup);
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException ex) {
Logger.getLogger(UserHelper2.class.getName()).log(Level.SEVERE, null, ex);
}
return nodeUserRoleGroups;
}
Aggregations