Search in sources :

Example 11 with Term

use of mom.trd.opentheso.bdd.datas.Term in project opentheso by miledrousset.

the class SelectedTerme method creerTermeSpe.

/**
 * *************************************** CREATION
 * ****************************************
 */
/**
 * Crée un nouveau terme spécifique au terme sélectionné
 *
 * @param selecedTerm
 * @return true or false
 */
public boolean creerTermeSpe(MyTreeNode selecedTerm) {
    ConceptHelper instance = new ConceptHelper();
    if (user.nodePreference == null)
        return false;
    instance.setNodePreference(user.getNodePreference());
    // 1 = domaine/Group, 2 = TT (top Term), 3 = Concept/term
    if (selecedTerm.isIsSubGroup() || selecedTerm.isIsGroup()) {
        // ici c'est le cas d'un Group ou Sous Group, on crée un TT Top Terme
        Concept concept = new Concept();
        concept.setIdGroup(selecedTerm.getIdConcept());
        concept.setIdThesaurus(idTheso);
        concept.setStatus("D");
        concept.setNotation("");
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(idlangue);
        terme.setLexical_value(valueEdit);
        terme.setSource("");
        terme.setStatus("");
        if (instance.addTopConcept(connect.getPoolConnexion(), idTheso, concept, terme, user.getUser().getId()) == null) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", instance.getMessage()));
            return false;
        }
        // instance.insertID_grouptoPermuted(connect.getPoolConnexion(), concept.getIdThesaurus(), concept.getIdConcept());
        ConceptHelper ch = new ConceptHelper();
        ArrayList<NodeConceptTree> tempNT = ch.getListTopConcepts(connect.getPoolConnexion(), idC, idTheso, idlangue);
        termesSpecifique = new ArrayList<>();
        HashMap<String, String> tempMap = new HashMap<>();
        for (NodeConceptTree nct : tempNT) {
            tempMap.put(nct.getIdConcept(), nct.getTitle());
        }
        termesSpecifique.addAll(tempMap.entrySet());
    } else {
        Concept concept = new Concept();
        concept.setIdGroup(selecedTerm.getIdCurrentGroup());
        concept.setIdThesaurus(idTheso);
        concept.setStatus("D");
        concept.setNotation("");
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(idlangue);
        terme.setLexical_value(valueEdit);
        terme.setSource("");
        terme.setStatus("");
        // String idTC = idTopConcept;
        String idP = idC;
        if (instance.addConcept(connect.getPoolConnexion(), idP, concept, terme, user.getUser().getId()) == null) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", instance.getMessage()));
            return false;
        }
        // instance.insertID_grouptoPermuted(connect.getPoolConnexion(), concept.getIdThesaurus(), concept.getIdConcept());
        concept.getUserName();
        ArrayList<NodeNT> tempNT = new RelationsHelper().getListNT(connect.getPoolConnexion(), idC, idTheso, idlangue);
        termesSpecifique = new ArrayList<>();
        HashMap<String, String> tempMap = new HashMap<>();
        for (NodeNT nnt : tempNT) {
            tempMap.put(nnt.getIdConcept(), nnt.getTitle() + " (" + nnt.getRole() + ")");
        }
        termesSpecifique.addAll(tempMap.entrySet());
    }
    vue.setAddTSpe(false);
    valueEdit = "";
    return true;
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HashMap(java.util.HashMap) Term(mom.trd.opentheso.bdd.datas.Term) PrefixString(com.k_int.IR.QueryModels.PrefixString) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) FacesMessage(javax.faces.application.FacesMessage) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 12 with Term

use of mom.trd.opentheso.bdd.datas.Term 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)

Example 13 with Term

use of mom.trd.opentheso.bdd.datas.Term in project opentheso by miledrousset.

the class SelectedTerme method modifierTraduction.

/**
 * Cette fontion permet de modifier une Traduction
 */
public void modifierTraduction() {
    int idUser = user.getUser().getId();
    Term term = new Term();
    term.setLexical_value(valueOfTraductionToModify);
    term.setId_term(idT);
    term.setId_thesaurus(idTheso);
    term.setLang(langEnTraduction);
    if (!new TermHelper().updateTermTraduction(connect.getPoolConnexion(), term, idUser)) {
    // erreur
    }
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.modifyLang")));
    majLangueConcept();
}
Also used : Term(mom.trd.opentheso.bdd.datas.Term) FacesMessage(javax.faces.application.FacesMessage) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 14 with Term

use of mom.trd.opentheso.bdd.datas.Term in project opentheso by miledrousset.

the class AutoCompletBean method newSpecialTAsso.

/**
 * Ajoute un terme associé special
 */
public void newSpecialTAsso() {
    if (selectedAtt == null || selectedAtt.getIdConcept().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("autoComp.error1")));
    } else {
        Term laValeur = terme.getTerme(selectedAtt.getIdConcept());
        if (laValeur == null) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("autoComp.error2")));
        } else {
            terme.creerTermeAsso(selectedAtt.getIdConcept(), RTtag);
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", laValeur.getLexical_value() + " " + langueBean.getMsg("autoComp.info1")));
        }
        selectedAtt = new NodeAutoCompletion();
    }
}
Also used : Term(mom.trd.opentheso.bdd.datas.Term) FacesMessage(javax.faces.application.FacesMessage) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Example 15 with Term

use of mom.trd.opentheso.bdd.datas.Term in project opentheso by miledrousset.

the class GpsBeans method integreTraduction.

/**
 * Permet d'intégrer les traductions à un Concept venant de l'alignement
 * source On intègre que les traductions disponible pour le thésaurus en
 * cours
 *
 * @param idTerm
 * @return
 */
private boolean integreTraduction(String idTerm, String langEnCour) {
    boolean status = false;
    LanguageHelper languageHelper = new LanguageHelper();
    TermHelper termHelper = new TermHelper();
    // la liste des langues du thésaurus
    listLanguesInTheso = languageHelper.getLanguagesOfThesaurus(connect.getPoolConnexion(), id_theso);
    if (alignment_choisi.getAlltraductions() != null) {
        if (!alignment_choisi.getAlltraductions().isEmpty()) {
            ArrayList<String> langsOfTheso = new ArrayList<>();
            ArrayList<NodeLang> ourLangs = new ArrayList<>();
            // classer les langues dasn une liste
            for (Languages_iso639 languages_iso639 : listLanguesInTheso) {
                if (// on ignore la langue en cours
                !langEnCour.equalsIgnoreCase(languages_iso639.getId_iso639_1())) {
                    langsOfTheso.add(languages_iso639.getId_iso639_1());
                }
            }
            // filtrer les langues récupérées de l'alignement et qui sont dans notre thésaurus
            for (NodeLang traduction : alignment_choisi.getAlltraductions()) {
                if (langsOfTheso.contains(traduction.getCode())) {
                    ourLangs.add(traduction);
                }
            }
            Term termTemp = new Term();
            for (NodeLang ourLang : ourLangs) {
                termTemp.setLexical_value(ourLang.getValue());
                termTemp.setId_term(idTerm);
                termTemp.setId_thesaurus(id_theso);
                termTemp.setLang(ourLang.getCode());
                termTemp.setSource("");
                termTemp.setStatus("");
                if (termHelper.isTermExist(connect.getPoolConnexion(), termTemp.getLexical_value(), termTemp.getId_thesaurus(), termTemp.getLang())) {
                    if (remplacerTraduction) {
                        // si le terme existe et on a autorisé le remplacement, on remplace la traduction
                        termHelper.updateTermTraduction(connect.getPoolConnexion(), termTemp, theUser.getUser().getId());
                    }
                } else {
                    // on ajoute simplement la traduction
                    termHelper.addTraduction(connect.getPoolConnexion(), termTemp, theUser.getUser().getId());
                }
            }
        }
    }
    return status;
}
Also used : LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) ArrayList(java.util.ArrayList) Term(mom.trd.opentheso.bdd.datas.Term) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Aggregations

Term (mom.trd.opentheso.bdd.datas.Term)31 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)22 Concept (mom.trd.opentheso.bdd.datas.Concept)15 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)15 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)13 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)12 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)11 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)10 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)10 FacesMessage (javax.faces.application.FacesMessage)9 SQLException (java.sql.SQLException)8 Connection (java.sql.Connection)7 ArrayList (java.util.ArrayList)7 PrefixString (com.k_int.IR.QueryModels.PrefixString)5 HashMap (java.util.HashMap)5 NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)5 SKOSMapping (skos.SKOSMapping)5 SKOSTopConcept (skos.SKOSTopConcept)5 Statement (java.sql.Statement)4 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)4