Search in sources :

Example 6 with NodeLang

use of mom.trd.opentheso.bdd.helper.nodes.NodeLang 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 7 with NodeLang

use of mom.trd.opentheso.bdd.helper.nodes.NodeLang 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)

Example 8 with NodeLang

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

the class ExportRdf4jHelper method writeGroupInfo.

private void writeGroupInfo(SKOSResource sKOSResource, String idThesaurus, String idOfGroupChildren, List<NodeLang> selectedLanguages) {
    NodeGroupLabel nodeGroupLabel;
    nodeGroupLabel = new GroupHelper().getNodeGroupLabel(ds, idOfGroupChildren, idThesaurus);
    sKOSResource.setUri(getUriFromId(idOfGroupChildren));
    sKOSResource.setProperty(SKOSProperty.ConceptGroup);
    for (NodeGroupTraductions traduction : nodeGroupLabel.getNodeGroupTraductionses()) {
        boolean isInSelectedLanguages = false;
        for (NodeLang nodeLang : selectedLanguages) {
            if (nodeLang.getCode().equals(traduction.getIdLang())) {
                isInSelectedLanguages = true;
                break;
            }
        }
        if (!isInSelectedLanguages) {
            continue;
        }
        sKOSResource.addLabel(traduction.getTitle(), traduction.getIdLang(), SKOSProperty.prefLabel);
        // dates
        String created;
        String modified;
        created = traduction.getCreated().toString();
        modified = traduction.getModified().toString();
        if (created != null) {
            sKOSResource.addDate(created, SKOSProperty.created);
        }
        if (modified != null) {
            sKOSResource.addDate(modified, SKOSProperty.modified);
        }
    }
    ArrayList<String> childURI = new GroupHelper().getListGroupChildIdOfGroup(ds, idOfGroupChildren, idThesaurus);
    ArrayList<NodeUri> nodeUris = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, idOfGroupChildren, idThesaurus);
    for (NodeUri nodeUri : nodeUris) {
        sKOSResource.addRelation(getUriFromNodeUri(nodeUri, idThesaurus), SKOSProperty.member);
        addMember(nodeUri.getIdConcept(), idThesaurus, sKOSResource);
    }
    for (String id : childURI) {
        sKOSResource.addRelation(getUriFromId(id), SKOSProperty.subGroup);
        superGroupHashMap.put(id, idOfGroupChildren);
    }
    // addNotes(idOfGroupChildren, group, selectedLanguages);
    // addGPS(idOfGroupChildren, group);
    // addAlignement(idOfGroupChildren, group);
    // addRelation(idOfGroupChildren, group);
    String idSuperGroup = superGroupHashMap.get(idOfGroupChildren);
    if (idSuperGroup != null) {
        sKOSResource.addRelation(getUriFromId(idSuperGroup), SKOSProperty.superGroup);
        superGroupHashMap.remove(idOfGroupChildren);
    }
    skosXmlDocument.addGroup(sKOSResource);
    // liste top concept
    nodeTTs.addAll(nodeUris);
    for (NodeUri topConcept : nodeTTs) {
        skosXmlDocument.getConceptScheme().addRelation(getUriFromNodeUri(topConcept, idThesaurus), SKOSProperty.hasTopConcept);
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions)

Example 9 with NodeLang

use of mom.trd.opentheso.bdd.helper.nodes.NodeLang 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)

Example 10 with NodeLang

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

the class BackgroundTimeJob method synchroSparql.

private Runnable synchroSparql(int key) {
    SynchroSparql run = new SynchroSparql();
    run.setSparqlStruct(this.SparqlSyn.get(key));
    ArrayList<Languages_iso639> listeLang = new LanguageHelper().getLanguagesOfThesaurus(this.connect.getPoolConnexion(), this.SparqlSyn.get(key).getThesaurus());
    ArrayList<NodeLang> nol = new ArrayList<>();
    for (Languages_iso639 lang : listeLang) {
        NodeLang nd = new NodeLang();
        nd.setValue(lang.getId_iso639_1());
        nd.setCode(lang.getId_iso639_1());
        nol.add(nd);
    }
    run.setListe_lang(nol);
    ArrayList<String> nog = new GroupHelper().getListIdOfGroup(this.connect.getPoolConnexion(), this.SparqlSyn.get(key).getThesaurus());
    ArrayList<NodeGroup> groupes = new ArrayList<>();
    for (String group : nog) {
        NodeGroup ng1 = new NodeGroup();
        ng1.setId_group(group);
        ConceptGroup cg = new ConceptGroup();
        cg.setIdgroup(group);
        ng1.setConceptGroup(cg);
        groupes.add(ng1);
    }
    run.setListe_group(groupes);
    run.setConn(this.connect);
    return run;
}
Also used : LanguageHelper(mom.trd.opentheso.bdd.helper.LanguageHelper) ArrayList(java.util.ArrayList) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) ConceptGroup(mom.trd.opentheso.bdd.datas.ConceptGroup) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Aggregations

NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)12 ArrayList (java.util.ArrayList)5 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)4 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)3 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)3 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)3 Languages_iso639 (mom.trd.opentheso.bdd.datas.Languages_iso639)2 LanguageHelper (mom.trd.opentheso.bdd.helper.LanguageHelper)2 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)2 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)2 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)2 NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)2 NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)2 SKOSResource (skos.SKOSResource)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 StringReader (java.io.StringReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HttpURLConnection (java.net.HttpURLConnection)1