use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CsvImportHelper method createTheso.
/**
* Cette fonction permet de créer un thésaurus avec ses traductions (Import)
* elle retourne l'identifiant du thésaurus, sinon Null
*
* @return
*/
private String createTheso(HikariDataSource ds, String thesoName) {
try {
Thesaurus thesaurus = new Thesaurus();
thesaurus.setCreator("");
thesaurus.setContributor("");
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
thesaurusHelper.setIdentifierType("2");
Connection conn = ds.getConnection();
conn.setAutoCommit(false);
String idTheso1;
if (thesaurus.getLanguage() == null) {
thesaurus.setLanguage(langueSource);
}
if ((idTheso1 = thesaurusHelper.addThesaurusRollBack(conn, "", false)) == null) {
conn.rollback();
conn.close();
return null;
}
thesaurus.setId_thesaurus(idTheso1);
if (thesoName.isEmpty()) {
thesoName = "theso_" + idTheso1;
}
thesaurus.setTitle(thesoName);
if (!thesaurusHelper.addThesaurusTraductionRollBack(conn, thesaurus)) {
conn.rollback();
conn.close();
return null;
}
// ajouter le thésaurus dans le group de l'utilisateur
if (idGroupUser != -1) {
// si le groupeUser = - 1, c'est le cas d'un SuperAdmin, alors on n'intègre pas le thésaurus dans un groupUser
UserHelper2 userHelper = new UserHelper2();
if (!userHelper.addThesoToGroup(conn, thesaurus.getId_thesaurus(), idGroupUser)) {
conn.rollback();
conn.close();
return null;
}
}
conn.commit();
conn.close();
return idTheso1;
} catch (SQLException ex) {
Logger.getLogger(CsvImportHelper.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class RoleOnThesoBean method setOwnerThesos.
/**
* fonction pour sortir une liste (sous forme de hashMap ) de thesaurus
* correspondant à l'utilisateur connecté
* permet de charger les thésaurus autorisés pour l'utilisateur en cours
* on récupère les id puis les tradcutions (ceci permet de récupérer les thésaurus non traduits)
* #MR
*/
private void setOwnerThesos() {
if (user.getUser() == null) {
this.listTheso = new HashMap();
return;
}
authorizedTheso = new ArrayList<>();
ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
UserHelper2 userHelper = new UserHelper2();
if (user.getUser().isIsSuperAdmin()) {
boolean withPrivateTheso = true;
authorizedTheso = thesaurusHelper.getAllIdOfThesaurus(connect.getPoolConnexion(), withPrivateTheso);
} else {
authorizedTheso = userHelper.getThesaurusOfUser(connect.getPoolConnexion(), user.getUser().getIdUser());
}
addAuthorizedThesoToHM();
// permet de définir le role de l'utilisateur sur le group
if (authorizedTheso.isEmpty())
setUserRoleGroup();
// setUserRoleOnThisTheso();
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class UserHelperTest method getLabelGroup.
@Test
public void getLabelGroup() {
UserHelper2 userHelper2 = new UserHelper2();
ConnexionTest connexionTest = new ConnexionTest();
HikariDataSource conn = connexionTest.getConnexionPool();
String label = userHelper2.getGroupName(conn, 1);
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class UserHelperTest method getUser.
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
@Test
public void getUser() {
int idUser = 15;
ConnexionTest connexionTest = new ConnexionTest();
HikariDataSource conn = connexionTest.getConnexionPool();
UserHelper2 userHelper2 = new UserHelper2();
NodeUser2 nodeUser = userHelper2.getUser(conn, idUser);
conn.close();
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class UserHelperTest method getAuthorizedRoles.
@Test
public void getAuthorizedRoles() {
UserHelper2 userHelper2 = new UserHelper2();
ConnexionTest connexionTest = new ConnexionTest();
HikariDataSource conn = connexionTest.getConnexionPool();
ArrayList<Map.Entry<String, String>> authorizedRols = userHelper2.getAuthorizedRoles(conn, 3);
}
Aggregations