Search in sources :

Example 16 with ThesaurusHelper

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

the class SelectedThesaurus method editerTheso.

/**
 * Modification d'un thésaurus
 */
public void editerTheso() {
    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 {
        new ThesaurusHelper().UpdateThesaurus(connect.getPoolConnexion(), editTheso);
        vue.setEdit(false);
    }
}
Also used : ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) FacesMessage(javax.faces.application.FacesMessage)

Example 17 with ThesaurusHelper

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

the class SelectedThesaurus method maj.

/**
 * ************************************ MISE A JOUR
 * *************************************
 */
/**
 * Met à jour le thésaurus courant lors d'un changement de thésaurus
 */
public void maj() {
    tree.getSelectedTerme().reInitTerme();
    tree.reInit();
    tree.initTree(null, null);
    statBean.reInit();
    ThesaurusHelper th = new ThesaurusHelper();
    nodePreference = tree.getSelectedTerme().getUser().getThesaurusPreferences(thesaurus.getId_thesaurus(), workLanguage);
    if (th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), nodePreference.getSourceLang()) != null) {
        thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), nodePreference.getSourceLang());
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
        tree.setIdThesoSelected(thesaurus.getId_thesaurus());
        tree.setDefaultLanguage(thesaurus.getLanguage());
    } else {
        thesaurus.setLanguage("");
    }
    uTree.reInit();
    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());
    if (tree != null) {
        tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
    }
    vue.setCreat(false);
    // #jm pour la page de statistiques
    vue.setStatTheso(false);
    // idem
    vue.setStatCpt(false);
    majPref();
    if (selectedTerme != null) {
        selectedTerme.initTerme();
    }
    tree.getSelectedTerme().getUser().setIdTheso(thesaurus.getId_thesaurus());
    if ((user.getUser().getName() != null) && (user.isIsHaveWriteToCurrentThesaurus())) {
        String message = "drag & dop activé !";
        FacesContext context = FacesContext.getCurrentInstance();
        context.addMessage(null, new FacesMessage("", "info : " + message));
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) FacesMessage(javax.faces.application.FacesMessage)

Example 18 with ThesaurusHelper

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

the class CurrentUser method connect.

/**
 * Connect l'utilisateur si le compte existe
 *
 * @return le lien de l'index si le compte existe, un message d'erreur sinon
 * init c'est une parametre que viens du "isUserExist" ou return une 1 si on
 * fait le login normal (usuaire, pass), une 2 si on fait le login avec le
 * motpasstemp (et nous sommes dirigées a la page web de changer le
 * motpasstemp)
 */
public String connect() {
    UserHelper userHelper = new UserHelper();
    if (userHelper.isUserExist(connect.getPoolConnexion(), name, MD5Password.getEncodedPassword(pwd))) {
        try {
            // on vérifie si l'utilisateur est SuperAdmin, on lui donne tout les droits
            if (userHelper.isAdminUser(connect.getPoolConnexion(), name)) {
                user = userHelper.getInfoAdmin(connect.getPoolConnexion(), name);
                if (user == null) {
                    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.roleError")));
                    return "";
                }
                user.setIdThesaurus(idTheso);
                authorizedTheso = new ThesaurusHelper().getAllIdOfThesaurus(connect.getPoolConnexion());
                FacesContext context = FacesContext.getCurrentInstance();
                String version_Opentheso = context.getExternalContext().getInitParameter("version");
                BaseDeDoneesHelper baseDeDonnesHelper = new BaseDeDoneesHelper();
                baseDeDonnesHelper.updateVersionOpentheso(connect.getPoolConnexion(), version_Opentheso);
            } else // on récupère ses droits par rapport au thésaurus en cours
            {
                NodeUser nodeUserTemp = userHelper.getInfoUser(connect.getPoolConnexion(), name, idTheso);
                if (nodeUserTemp == null) {
                    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("info") + " :", langueBean.getMsg("user.roleErrorAll")));
                    nodeUserTemp = userHelper.getInfoUser(connect.getPoolConnexion(), name);
                    if (nodeUserTemp == null) {
                        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error1")));
                        return "";
                    }
                } else {
                    user = userHelper.getInfoUser(connect.getPoolConnexion(), name, idTheso);
                }
                authorizedTheso = userHelper.getAuthorizedThesaurus(connect.getPoolConnexion(), user.getId());
            }
            isLogged = true;
            if (userEdit != null) {
                isActive = userEdit.isIsActive();
            }
            if (userHelper.isChangeToPass(connect.getPoolConnexion(), name)) {
                // nouvelle pass web pour changer le motpasstemp
                return "changePass.xhtml?faces-redirect=true";
            }
            name = null;
            pwd = null;
            return "index.xhtml?faces-redirect=true";
        } catch (SQLException ex) {
            Logger.getLogger(CurrentUser.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    // utilisateur ou mot de passe n'existent pas
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error1")));
    return "";
}
Also used : FacesContext(javax.faces.context.FacesContext) UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) SQLException(java.sql.SQLException) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) BaseDeDoneesHelper(mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper) NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) FacesMessage(javax.faces.application.FacesMessage)

Example 19 with ThesaurusHelper

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

the class SelectedThesaurus method reorganizing.

/* ******************** EDITION THESO BDD * ******************** */
/**
 * Cette fonction permet de nettoyer et réorganiser le thésaurus
 *
 * @return
 */
public boolean reorganizing() {
    if (thesaurus.getId_thesaurus().isEmpty()) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error1")));
        return false;
    }
    try {
        ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
        Connection conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        if (!thesaurusHelper.reorganizingTheso(conn, thesaurus.getId_thesaurus())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
            conn.rollback();
            conn.close();
            return false;
        }
        conn.commit();
        conn.close();
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("theso.infoReorganizing")));
        regenerateOrphan();
        // permet de supprimer les BT pour un TopTerm, c'est incohérent
        removeBTofTopTerm();
        // permet de supprimer les relations en boucle (100 -> BT -> 100) ou  (100 -> NT -> 100)ou (100 -> RT -> 100)
        removeLoopRelations();
        return true;
    } catch (SQLException ex) {
        Logger.getLogger(CurrentUser.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
}
Also used : SQLException(java.sql.SQLException) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) Connection(java.sql.Connection) FacesMessage(javax.faces.application.FacesMessage)

Example 20 with ThesaurusHelper

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

the class SelectedThesaurus method ajouterTraduction.

/**
 * Création d'une traduction d'un thésaurus
 */
public void ajouterTraduction() {
    if (nomTrad.trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error1")));
    } else {
        vue.setTrad(false);
        String id = editTheso.getId_thesaurus();
        Thesaurus thesoTemp = new Thesaurus();
        thesoTemp.setId_thesaurus(id);
        thesoTemp.setLanguage(langueTrad);
        thesoTemp.setTitle(nomTrad);
        new ThesaurusHelper().addThesaurusTraduction(connect.getPoolConnexion(), thesoTemp);
        remplirArrayTrad(editTheso.getId_thesaurus());
    }
    nomTrad = "";
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) 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