Search in sources :

Example 11 with ThesaurusHelper

use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.

the class SelectedThesaurus method getThisTheso.

/**
 * *************************************** AUTRE
 * ****************************************
 */
/**
 * Récupère le thésaurus courant
 *
 * @return le thésaurus s'il existe, null sinon
 */
public Thesaurus getThisTheso() {
    String idTemp = "", lTemp = "";
    if (thesaurus == null || thesaurus.getLanguage() == null || thesaurus.getId_thesaurus() == null) {
        return null;
    }
    if (thesaurus.getLanguage() != null) {
        lTemp = thesaurus.getLanguage();
    }
    if (thesaurus.getId_thesaurus() != null) {
        idTemp = thesaurus.getId_thesaurus();
    }
    Thesaurus tempT = new ThesaurusHelper().getThisThesaurus(connect.getPoolConnexion(), idTemp, lTemp);
    return tempT;
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper)

Example 12 with ThesaurusHelper

use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.

the class skosExportBean method init.

public void init(String idTheso, String idLang) {
    this.idTheso = idTheso;
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    languagesOfTheso = thesaurusHelper.getAllUsedLanguagesOfThesaurusNode(connect.getPoolConnexion(), idTheso);
    GroupHelper groupHelper = new GroupHelper();
    groupList = groupHelper.getListRootConceptGroup(connect.getPoolConnexion(), idTheso, idLang);
    selectedLanguages = new ArrayList<>();
    selectedGroups = new ArrayList<>();
    selectedLanguages = new ArrayList<>();
    for (NodeLang nodeLang : languagesOfTheso) {
        selectedLanguages.add(nodeLang);
    }
    selectedGroups = new ArrayList<>();
    for (NodeGroup nodeGroup : groupList) {
        selectedGroups.add(nodeGroup);
    }
}
Also used : ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 13 with ThesaurusHelper

use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.

the class SelectedThesaurus method StartDefaultThesauriTree.

/**
 * Met à jour le thésaurus courant lors d'un changement de thésaurus
 */
public void StartDefaultThesauriTree() {
    tree.getSelectedTerme().getUser().setIdTheso(thesaurus.getId_thesaurus());
    if (connect.getPoolConnexion() == null) {
        System.err.println("!!!!! Opentheso n'a pas pu se connecter à la base de données 2!!!!!!! ");
        return;
    }
    tree.getSelectedTerme().reInitTerme();
    tree.reInit();
    tree.initTree(null, null);
    statBean.reInit();
    uTree.reInit();
    if (selectedTerme != null) {
        selectedTerme.initTerme();
    }
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    if (thesaurusHelper.isThesaurusExiste(connect.getPoolConnexion(), defaultThesaurusId)) {
        thesaurus = thesaurusHelper.getThisThesaurus(connect.getPoolConnexion(), defaultThesaurusId, workLanguage);
        if (thesaurus == null) {
            return;
        }
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        uTree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        candidat.maj(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        vue.setCreat(false);
        nodePreference = tree.getSelectedTerme().getUser().getThesaurusPreferences(thesaurus.getId_thesaurus(), workLanguage);
        tree.setIdThesoSelected(thesaurus.getId_thesaurus());
        tree.setDefaultLanguage(thesaurus.getLanguage());
    }
    user.initUserNodePref(thesaurus.getId_thesaurus());
    majPref();
}
Also used : LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper)

Example 14 with ThesaurusHelper

use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.

the class SelectedThesaurus method ajouterTheso.

/**
 * Création d'un nouveau thésaurus avec le role
 *
 * @param idUser
 * @param idRole
 */
public void ajouterTheso(int idUser, int idRole) {
    if (editTheso.getTitle() == null || editTheso.getTitle().trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error1")));
    } else {
        ThesaurusHelper th = new ThesaurusHelper();
        th.setIdentifierType(identifierType);
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            String idThesaurus = th.addThesaurusRollBack(conn, null, arkActive);
            if (idThesaurus == null) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error1")));
                conn.rollback();
                conn.close();
                return;
            }
            if (editTheso.getTitle().isEmpty()) {
                thesaurus.setTitle("theso_" + idThesaurus);
            }
            if (editTheso.getLanguage() == null) {
                editTheso.setLanguage(workLanguage);
            }
            editTheso.setId_thesaurus(idThesaurus);
            if (!th.addThesaurusTraductionRollBack(conn, editTheso)) {
                conn.rollback();
                conn.close();
                return;
            }
            // ajout de role pour le thésaurus à l'utilisateur en cours
            UserHelper userHelper = new UserHelper();
            if (!userHelper.addRole(conn, idUser, idRole, idThesaurus, "")) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
                conn.rollback();
                conn.close();
                return;
            }
            conn.commit();
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(CurrentUser.class.getName()).log(Level.SEVERE, null, ex);
        }
        maj();
        arrayTheso = new ArrayList<>(th.getListThesaurus(connect.getPoolConnexion(), langueSource).entrySet());
        tree.getSelectedTerme().getUser().updateAuthorizedTheso();
        vue.setCreat(false);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("theso.info1.1") + " " + editTheso.getTitle() + " " + langueBean.getMsg("theso.info1.2")));
    // editTheso = new Thesaurus();
    }
// tree.getSelectedTerme().getUser().getUser().getId();
}
Also used : UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) SQLException(java.sql.SQLException) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) Connection(java.sql.Connection) FacesMessage(javax.faces.application.FacesMessage)

Example 15 with ThesaurusHelper

use of mom.trd.opentheso.bdd.helper.ThesaurusHelper in project opentheso by miledrousset.

the class SelectedThesaurus method supprimerTheso.

/**
 * Suppréssion d'un thésaurus
 *
 * @param id
 */
public void supprimerTheso(String id) {
    ThesaurusHelper th = new ThesaurusHelper();
    // on vérifie si l'utilisateur n'a plus aucun thésaurus, on garde son dernier role sans thésaurus
    // cette action est temporaire le temps de mettre en place une gestion complète des users et des groupes
    UserHelper userHelper = new UserHelper();
    Connection conn;
    try {
        conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        if (userHelper.isLastThesoOfUser(connect.getPoolConnexion(), tree.getSelectedTerme().getUser().getUser().getId())) {
            if (!userHelper.deleteOnlyTheThesoFromRole(conn, id)) {
                conn.rollback();
                conn.close();
                return;
            }
        } else {
            if (!userHelper.deleteThisRoleForThisThesaurus(conn, tree.getSelectedTerme().getUser().getUser().getId(), id)) {
                conn.rollback();
                conn.close();
                return;
            }
        }
        conn.commit();
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(SelectedThesaurus.class.getName()).log(Level.SEVERE, null, ex);
    }
    ConceptHelper conceptHelper = new ConceptHelper();
    conceptHelper.setNodePreference(nodePreference);
    conceptHelper.deleteAllIdHandle(connect.getPoolConnexion(), id);
    th.deleteThesaurus(connect.getPoolConnexion(), id);
    arrayTheso = new ArrayList<>(th.getListThesaurus(connect.getPoolConnexion(), langueSource).entrySet());
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, langueBean.getMsg("info") + " :", conceptHelper.getMessage()));
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) SQLException(java.sql.SQLException) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) Connection(java.sql.Connection) FacesMessage(javax.faces.application.FacesMessage)

Aggregations

ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)31 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)10 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)9 FacesMessage (javax.faces.application.FacesMessage)7 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)7 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)6 NodeThesaurus (mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)6 Connection (java.sql.Connection)5 SQLException (java.sql.SQLException)5 NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)4 LanguageHelper (mom.trd.opentheso.bdd.helper.LanguageHelper)3 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)3 NodeGroupLabel (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel)3 FacesContext (javax.faces.context.FacesContext)2 BaseDeDoneesHelper (mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper)2 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)2 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)2 SKOSResource (mom.trd.opentheso.skosapi.SKOSResource)2 Concept (mom.trd.opentheso.bdd.datas.Concept)1 DcElement (mom.trd.opentheso.bdd.datas.DcElement)1