Search in sources :

Example 1 with PrimeFaces

use of org.primefaces.PrimeFaces in project opentheso by miledrousset.

the class AutoCompletBean method newTSpe.

/**
 * Permet de créer un nouveau concept en vérifiant sa validité
 */
public void newTSpe() {
    createValid = false;
    terme.setValueEdit(terme.getSelectedTermComp().getTermLexicalValue());
    if (terme.getValueEdit().trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("tree.error1")));
        return;
    }
    String valueEdit = terme.getValueEdit().trim();
    // vérification si c'est le même nom, on fait rien
    if (valueEdit.equalsIgnoreCase(terme.getNom())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("autoComp.impossible")));
        return;
    }
    // vérification si le term à ajouter existe déjà
    if (terme.isTermExist(valueEdit) != null) {
        duplicate = true;
        // FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error6")));
        return;
    }
    if (!terme.creerTermeSpe(((MyTreeNode) tree.getSelectedNode()))) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
        return;
    } else {
        tree.reInit();
        tree.reExpand();
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", valueEdit + " " + langueBean.getMsg("tree.info1")));
    }
    terme.setSelectedTermComp(new NodeAutoCompletion());
    createValid = true;
    PrimeFaces pf = PrimeFaces.current();
    if (pf.isAjaxRequest()) {
        pf.ajax().update("idNtEditDlg");
    }
// RequestContext.getCurrentInstance().update("idNtEditDlg");
}
Also used : PrimeFaces(org.primefaces.PrimeFaces) FacesMessage(javax.faces.application.FacesMessage) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Example 2 with PrimeFaces

use of org.primefaces.PrimeFaces in project opentheso by miledrousset.

the class SelectedTerme method creerTermeSyno.

/**
 * permet de créer des termes synonymes avec un type défini
 */
public void creerTermeSyno() {
    editPassed = false;
    if (valueEdit == null || valueEdit.trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error1")));
        return;
    }
    if (idT != null && !idT.equals("")) {
        if (!duplicate) {
            // on controle si a accepté un doublon ou non
            if (new TermHelper().isTermExist(connect.getPoolConnexion(), valueEdit, idTheso, idlangue)) {
                // FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error6")));
                duplicate = true;
                return;
            }
            if (new TermHelper().isAltLabelExist(connect.getPoolConnexion(), valueEdit, idTheso, idlangue)) {
                // FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error7")));
                duplicate = true;
                return;
            }
        }
        String leNom = valueEdit;
        Term temp = new Term();
        temp.setId_term(idT);
        temp.setId_thesaurus(idTheso);
        temp.setLang(idlangue);
        temp.setLexical_value(valueEdit);
        if (statutEdit.equalsIgnoreCase("Hidden")) {
            temp.setHidden(true);
        } else {
            temp.setHidden(false);
        }
        temp.setStatus(statutEdit);
        temp.setSource(String.valueOf(user.getUser().getName()));
        if (!new TermHelper().addNonPreferredTerm(connect.getPoolConnexion(), temp, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
            return;
        }
        ArrayList<NodeEM> tempEM = new TermHelper().getNonPreferredTerms(connect.getPoolConnexion(), idT, idTheso, idlangue);
        termesSynonymesE = new ArrayList<>();
        termesSynonymesP = new ArrayList<>();
        latitudLongitud = null;
        for (NodeEM nem : tempEM) {
            if (nem.getStatus().equalsIgnoreCase("USE")) {
                termesSynonymesE.add(nem.getLexical_value());
            }
            if (nem.getStatus().equalsIgnoreCase("Hidden")) {
                termesSynonymesP.add(nem.getLexical_value());
            }
            if (nem.getLexical_value().contains("WKT:")) {
                latitudLongitud = nem.getLexical_value().substring(nem.getLexical_value().indexOf(":") + 1, nem.getLexical_value().length()).trim();
            }
        }
        valueEdit = "";
        nomEdit = "";
        vue.setAddTSyno(0);
        init();
        PrimeFaces pf = PrimeFaces.current();
        if (pf.isAjaxRequest()) {
            pf.ajax().update("idTermeSynonymesEditDlg");
        }
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", leNom + " " + langueBean.getMsg("sTerme.info1")));
    } else {
        vue.setAddTSyno(0);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error2")));
    }
}
Also used : PrimeFaces(org.primefaces.PrimeFaces) PrefixString(com.k_int.IR.QueryModels.PrefixString) Term(mom.trd.opentheso.bdd.datas.Term) FacesMessage(javax.faces.application.FacesMessage) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM)

Aggregations

FacesMessage (javax.faces.application.FacesMessage)2 PrimeFaces (org.primefaces.PrimeFaces)2 PrefixString (com.k_int.IR.QueryModels.PrefixString)1 Term (mom.trd.opentheso.bdd.datas.Term)1 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)1 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)1 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)1