Search in sources :

Example 6 with NodeTermTraduction

use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.

the class SearchHelper method generatePermutedTable.

/**
 * Cette fonction permet de générer la table Permuted d'après les tables
 * PreferredTerm et NonPreferredTerm
 *
 * @param ds
 * @param idThesaurus
 * @return ArrayList de NodePermute
 */
public boolean generatePermutedTable(HikariDataSource ds, String idThesaurus) {
    ConceptHelper conceptHelper = new ConceptHelper();
    TermHelper termHelper = new TermHelper();
    ArrayList<NodeTermTraduction> nodeTermTraductionList;
    ArrayList<NodeEM> nodeEMList;
    // suppression des données de la table Permuted pour un thésaurus
    termHelper.deletePermutedTable(ds, idThesaurus);
    // Génération des Termes Préférés (PreferredTerm)
    ArrayList<String> tabIdConcept = conceptHelper.getAllIdConceptOfThesaurus(ds, idThesaurus);
    for (String idConcept : tabIdConcept) {
        nodeTermTraductionList = termHelper.getAllTraductionsOfConcept(ds, idConcept, idThesaurus);
        for (NodeTermTraduction nodeTermTraduction : nodeTermTraductionList) {
            // cette fonction permet de remplir la table Permutée
            termHelper.splitConceptForPermute(ds, idConcept, new ConceptHelper().getGroupIdOfConcept(ds, idConcept, idThesaurus), idThesaurus, nodeTermTraduction.getLang(), nodeTermTraduction.getLexicalValue());
        }
    }
    // Génération des Termes Synonymes (NonPreferredTerm)
    ArrayList<NodeTab2Levels> tabIdNonPreferredTerm = termHelper.getAllIdOfNonPreferredTerms(ds, idThesaurus);
    for (NodeTab2Levels nodeTab2Levels : tabIdNonPreferredTerm) {
        nodeEMList = termHelper.getAllNonPreferredTerms(ds, nodeTab2Levels.getIdTerm(), idThesaurus);
        for (NodeEM nodeEM : nodeEMList) {
            // cette fonction permet de remplir la table Permutée
            termHelper.splitConceptForNonPermuted(ds, nodeTab2Levels.getIdConcept(), new ConceptHelper().getGroupIdOfConcept(ds, nodeTab2Levels.getIdConcept(), idThesaurus), idThesaurus, nodeEM.getLang(), nodeEM.getLexical_value());
        }
    }
    return true;
}
Also used : NodeTab2Levels(mom.trd.opentheso.bdd.helper.nodes.NodeTab2Levels) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM)

Example 7 with NodeTermTraduction

use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.

the class SelectedTerme method majLangueConcept.

public void majLangueConcept() {
    langues = new ArrayList<>();
    ArrayList<NodeTermTraduction> tempNTT = new TermHelper().getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
    HashMap<String, String> tempMapL = new HashMap<>();
    for (NodeTermTraduction ntt : tempNTT) {
        tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
    }
    langues.addAll(tempMapL.entrySet());
}
Also used : HashMap(java.util.HashMap) PrefixString(com.k_int.IR.QueryModels.PrefixString) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 8 with NodeTermTraduction

use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.

the class SelectedTerme method creerTradterme.

/**
 * Ajoute une traduction au terme courant et met l'affichage à jour
 */
public void creerTradterme() {
    if (valueEdit == null || valueEdit.trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error3")));
        return;
    }
    boolean tradExist = false;
    // c'est le cas ou le concept n'a pas de traduction dans la langue en cours, il faut le mettre a jour dans l'arbre
    boolean newTraduction = false;
    for (Entry<String, String> e : langues) {
        if (e.getKey().equals(langueEdit)) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            tradExist = true;
            break;
        }
    }
    ConceptHelper ch = new ConceptHelper();
    TermHelper termHelper = new TermHelper();
    if (idT.isEmpty()) {
        newTraduction = true;
        String tmp = termHelper.getIdTermOfConcept(connect.getPoolConnexion(), idC, idTheso);
        if (tmp != null) {
            idT = tmp;
        }
    }
    // traduction du domaine
    if (type == 1 && !tradExist) {
        ConceptGroupLabel cgl = new ConceptGroupLabel();
        cgl.setLexicalvalue(valueEdit);
        cgl.setIdgroup(idDomaine);
        cgl.setIdthesaurus(idTheso);
        cgl.setLang(langueEdit);
        GroupHelper cgh = new GroupHelper();
        if (cgh.isDomainExist(connect.getPoolConnexion(), cgl.getLexicalvalue(), cgl.getIdthesaurus(), cgl.getLang())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            return;
        }
        if (!cgh.addGroupTraduction(connect.getPoolConnexion(), cgl, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
            return;
        }
        ArrayList<NodeGroupTraductions> tempNGT = new GroupHelper().getGroupTraduction(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
        langues = new ArrayList<>();
        HashMap<String, String> tempMapL = new HashMap<>();
        for (NodeGroupTraductions ngt : tempNGT) {
            tempMapL.put(ngt.getIdLang(), ngt.getTitle());
        }
        if (newTraduction) {
            nom = cgh.getLexicalValueOfGroup(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
        }
        langues.addAll(tempMapL.entrySet());
    // traduction du TT
    } else if (type == 2 && !tradExist) {
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(langueEdit);
        terme.setLexical_value(valueEdit);
        terme.setId_term(idT);
        terme.setContributor(user.getUser().getId());
        terme.setCreator(user.getUser().getId());
        terme.setSource("");
        terme.setStatus("");
        if (termHelper.isTermExist(connect.getPoolConnexion(), terme.getLexical_value(), terme.getId_thesaurus(), terme.getLang())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            return;
        }
        if (!ch.addTopConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
            return;
        }
        ArrayList<NodeTermTraduction> tempNTT = termHelper.getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
        langues = new ArrayList<>();
        HashMap<String, String> tempMapL = new HashMap<>();
        for (NodeTermTraduction ntt : tempNTT) {
            tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
        }
        if (newTraduction) {
            nom = termHelper.getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue).getLexical_value();
        }
        langues.addAll(tempMapL.entrySet());
    // traduction des concepts
    } else if (type == 3 && !tradExist) {
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(langueEdit);
        terme.setLexical_value(valueEdit);
        terme.setId_term(idT);
        terme.setContributor(user.getUser().getId());
        terme.setCreator(user.getUser().getId());
        terme.setSource("");
        terme.setStatus("");
        if (termHelper.isTermExist(connect.getPoolConnexion(), terme.getLexical_value(), terme.getId_thesaurus(), terme.getLang())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            return;
        }
        if (!ch.addConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
            return;
        }
        ArrayList<NodeTermTraduction> tempNTT = termHelper.getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
        langues = new ArrayList<>();
        HashMap<String, String> tempMapL = new HashMap<>();
        for (NodeTermTraduction ntt : tempNTT) {
            tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
        }
        langues.addAll(tempMapL.entrySet());
        if (newTraduction) {
            nom = termHelper.getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue).getLexical_value();
        }
    }
    langueEdit = "";
    valueEdit = "";
    if (!tradExist) {
        vue.setAddTrad(0);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info2")));
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HashMap(java.util.HashMap) ConceptGroupLabel(mom.trd.opentheso.bdd.datas.ConceptGroupLabel) ArrayList(java.util.ArrayList) PrefixString(com.k_int.IR.QueryModels.PrefixString) Term(mom.trd.opentheso.bdd.datas.Term) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions) FacesMessage(javax.faces.application.FacesMessage) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 9 with NodeTermTraduction

use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.

the class GetAllArkTest method testExportAllDatas.

/**
 * Test of Get datas for SiteMap.
 */
@org.junit.Test
public void testExportAllDatas() {
    HikariDataSource conn = openConnexionPool();
    String idTheso = "TH_1";
    ConceptHelper conceptHelper = new ConceptHelper();
    ArrayList<NodeConceptArkId> allIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, idTheso);
    StringBuilder file = new StringBuilder();
    TermHelper termHelper = new TermHelper();
    NoteHelper noteHelper = new NoteHelper();
    ArrayList<NodeTermTraduction> nodeTermTraductions;
    String idTerme;
    ArrayList<NodeNote> nodeNote;
    boolean passed = false;
    boolean notePassed = false;
    String note = "";
    for (NodeConceptArkId ids : allIds) {
        file.append(ids.getIdConcept());
        file.append("\t");
        if (ids.getIdArk() == null || ids.getIdArk().isEmpty()) {
            file.append("");
        } else {
            file.append(ids.getIdArk().substring(ids.getIdArk().indexOf("/") + 1));
        }
        nodeTermTraductions = termHelper.getAllTraductionsOfConcept(conn, ids.getIdConcept(), idTheso);
        if (!nodeTermTraductions.isEmpty()) {
            for (NodeTermTraduction nodeTermTraduction : nodeTermTraductions) {
                if (nodeTermTraduction.getLang().equalsIgnoreCase("fr")) {
                    file.append("\t");
                    file.append(nodeTermTraduction.getLexicalValue());
                // file.append("(");
                // file.append(nodeTermTraduction.getLang());
                // file.append(")");
                }
            }
        }
        idTerme = termHelper.getIdTermOfConcept(conn, ids.getIdConcept(), idTheso);
        nodeNote = noteHelper.getListNotesTerm(conn, idTerme, idTheso, "fr");
        for (NodeNote nodeNote1 : nodeNote) {
            if (nodeNote1.getLang().equalsIgnoreCase("fr")) {
                if (nodeNote1.getNotetypecode().equalsIgnoreCase("definition")) {
                    note = nodeNote1.getLexicalvalue().replace('\r', ' ');
                    note = note.replace('\n', ' ');
                    if (!notePassed) {
                        file.append("\t");
                    } else {
                        file.append(" ## ");
                    }
                    file.append(note);
                    passed = true;
                    notePassed = true;
                }
            }
        }
        if (!passed) {
            file.append("\t");
            file.append(" ");
        }
        passed = false;
        notePassed = false;
        file.append("\n");
    }
    System.out.println(file.toString());
    conn.close();
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeConceptArkId(mom.trd.opentheso.bdd.helper.nodes.NodeConceptArkId) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 10 with NodeTermTraduction

use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.

the class ExportRdf4jHelper method writeConceptInfo.

private void writeConceptInfo(ConceptHelper conceptHelper, SKOSResource sKOSResource, String idThesaurus, String idOfConceptChildren, DownloadBean downloadBean, List<NodeLang> selectedLanguages) {
    NodeConceptExport nodeConcept = conceptHelper.getConceptForExport(ds, idOfConceptChildren, idThesaurus, false);
    if (nodeConcept == null) {
        return;
    }
    sKOSResource.setUri(getUri(nodeConcept));
    sKOSResource.setProperty(SKOSProperty.Concept);
    // prefLabel
    for (NodeTermTraduction traduction : nodeConcept.getNodeTermTraductions()) {
        boolean isInselectedLanguages = false;
        for (NodeLang nodeLang : selectedLanguages) {
            if (nodeLang.getCode().equals(traduction.getLang())) {
                isInselectedLanguages = true;
                break;
            }
        }
        if (isInselectedLanguages) {
            sKOSResource.addLabel(traduction.getLexicalValue(), traduction.getLang(), SKOSProperty.prefLabel);
        }
    }
    // altLabel
    for (NodeEM nodeEM : nodeConcept.getNodeEM()) {
        boolean isInselectedLanguages = false;
        for (NodeLang nodeLang : selectedLanguages) {
            if (nodeLang.getCode().equals(nodeEM.getLang())) {
                isInselectedLanguages = true;
                break;
            }
        }
        if (isInselectedLanguages) {
            sKOSResource.addLabel(nodeEM.getLexical_value(), nodeEM.getLang(), SKOSProperty.altLabel);
        }
    }
    ArrayList<NodeNote> nodeNotes = nodeConcept.getNodeNoteConcept();
    nodeNotes.addAll(nodeConcept.getNodeNoteTerm());
    addNoteGiven(nodeNotes, sKOSResource, selectedLanguages);
    addGPSGiven(nodeConcept.getNodeGps(), sKOSResource);
    addAlignementGiven(nodeConcept.getNodeAlignmentsList(), sKOSResource);
    addRelationGiven(nodeConcept.getNodeListOfBT(), nodeConcept.getNodeListOfNT(), nodeConcept.getNodeListIdsOfRT(), sKOSResource, nodeConcept.getConcept().getIdThesaurus());
    String notation = nodeConcept.getConcept().getNotation();
    String created = nodeConcept.getConcept().getCreated().toString();
    String modified = nodeConcept.getConcept().getModified().toString();
    if (notation != null && !notation.equals("null")) {
        sKOSResource.addNotation(notation);
    }
    if (created != null) {
        sKOSResource.addDate(created, SKOSProperty.created);
    }
    if (modified != null) {
        sKOSResource.addDate(modified, SKOSProperty.modified);
    }
    sKOSResource.addRelation(getUriFromId(idTheso), SKOSProperty.inScheme);
    sKOSResource.addIdentifier(nodeConcept.getConcept().getIdConcept(), SKOSProperty.identifier);
    downloadBean.setProgress_abs(downloadBean.getProgress_abs() + 1);
    double progress = (downloadBean.getProgress_abs() / downloadBean.getSizeOfTheso()) * 100;
    if (progress > 100) {
        progress = 100;
    }
    downloadBean.setProgress_per_100((int) progress);
    skosXmlDocument.addconcept(sKOSResource);
}
Also used : NodeConceptExport(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM)

Aggregations

NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)19 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)11 ArrayList (java.util.ArrayList)10 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)9 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)8 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)7 Connection (java.sql.Connection)5 SQLException (java.sql.SQLException)5 Term (mom.trd.opentheso.bdd.datas.Term)5 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)5 Concept (mom.trd.opentheso.bdd.datas.Concept)4 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)4 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)4 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)4 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)4 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)3 SKOSAnnotation (org.semanticweb.skos.SKOSAnnotation)3 SKOSConcept (org.semanticweb.skos.SKOSConcept)3 PrefixString (com.k_int.IR.QueryModels.PrefixString)2 ResultSet (java.sql.ResultSet)2