Search in sources :

Example 1 with NodeUri

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

the class ExportRdf4jHelper method addConcept.

public void addConcept(String idThesaurus, DownloadBean downloadBean, List<NodeLang> selectedLanguages) {
    // récupération de tous les concepts
    for (NodeUri nodeTT1 : nodeTTs) {
        SKOSResource sKOSResource = new SKOSResource();
        sKOSResource.addRelation(getUriFromId(idTheso), SKOSProperty.topConceptOf);
        // fils top concept
        addFilsConceptRecursif(idThesaurus, nodeTT1.getIdConcept(), sKOSResource, downloadBean, selectedLanguages);
    }
}
Also used : SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri)

Example 2 with NodeUri

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

the class ExportTabulateHelper method writeConcepts.

private boolean writeConcepts() {
    ArrayList<NodeConceptExport> nodeConceptExports = thesaurusDatas.getNodeConceptExports();
    boolean first = true;
    ArrayList<NodeNote> nodeNoteDefinition = new ArrayList<>();
    ArrayList<NodeNote> nodeNoteScope = new ArrayList<>();
    ArrayList<NodeNote> nodeNoteHistory = new ArrayList<>();
    ArrayList<NodeNote> nodeNoteEditorial = new ArrayList<>();
    ArrayList<String> listLangues = new ArrayList<>();
    for (NodeLang selectedLanguage : selectedLanguages) {
        listLangues.add(selectedLanguage.getCode());
    }
    for (NodeConceptExport nodeConceptExport : nodeConceptExports) {
        nodeNoteDefinition.clear();
        nodeNoteScope.clear();
        nodeNoteHistory.clear();
        nodeNoteEditorial.clear();
        // id
        tabulateBuff.append(nodeConceptExport.getConcept().getIdConcept());
        tabulateBuff.append(";");
        // idArk
        if (nodeConceptExport.getConcept().getIdArk() == null) {
            tabulateBuff.append("");
        } else {
            tabulateBuff.append(nodeConceptExport.getConcept().getIdArk());
        }
        tabulateBuff.append(";");
        // type
        if (nodeConceptExport.getConcept().isTopConcept()) {
            tabulateBuff.append("TT");
        } else {
            tabulateBuff.append("DE");
        }
        tabulateBuff.append(";");
        // preflabel
        for (NodeTermTraduction nodeTermTraduction : nodeConceptExport.getNodeTermTraductions()) {
            if (listLangues.contains(nodeTermTraduction.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeTermTraduction.getLexicalValue());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeTermTraduction.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // altLabel
        first = true;
        for (NodeEM nodeEM : nodeConceptExport.getNodeEM()) {
            if (listLangues.contains(nodeEM.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeEM.getLexical_value());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeEM.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // inScheme
        first = true;
        for (NodeUri nodeUri : nodeConceptExport.getNodeListIdsOfConceptGroup()) {
            if (!first) {
                tabulateBuff.append("##");
            }
            tabulateBuff.append(nodeUri.getIdConcept());
            first = false;
        }
        tabulateBuff.append(";");
        // broader
        first = true;
        for (NodeHieraRelation node : nodeConceptExport.getNodeListOfBT()) {
            if (!first) {
                tabulateBuff.append("##");
            }
            tabulateBuff.append(node.getUri().getIdConcept());
            first = false;
        }
        tabulateBuff.append(";");
        // narrower
        first = true;
        for (NodeHieraRelation node : nodeConceptExport.getNodeListOfNT()) {
            if (!first) {
                tabulateBuff.append("##");
            }
            tabulateBuff.append(node.getUri().getIdConcept());
            first = false;
        }
        tabulateBuff.append(";");
        // related
        first = true;
        for (NodeHieraRelation nodeUri : nodeConceptExport.getNodeListIdsOfRT()) {
            if (!first) {
                tabulateBuff.append("##");
            }
            tabulateBuff.append(nodeUri.getUri().getIdConcept());
            first = false;
        }
        tabulateBuff.append(";");
        // alignment
        first = true;
        for (NodeAlignment nodeAlignment : nodeConceptExport.getNodeAlignmentsList()) {
            if (!first) {
                tabulateBuff.append("##");
            }
            if (nodeAlignment.getAlignement_id_type() == 1) {
                tabulateBuff.append("exactMatch::");
                tabulateBuff.append(nodeAlignment.getUri_target());
            }
            if (nodeAlignment.getAlignement_id_type() == 2) {
                tabulateBuff.append("closeMatch::");
                tabulateBuff.append(nodeAlignment.getUri_target());
            }
            first = false;
        }
        tabulateBuff.append(";");
        // types : definition; editorialNote; historyNote ; scopeNote
        for (NodeNote nodeNote : nodeConceptExport.getNodeNoteConcept()) {
            nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\r', ' '));
            nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\n', ' '));
            if (nodeNote.getNotetypecode().equalsIgnoreCase("definition")) {
                nodeNoteDefinition.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("editorialNote")) {
                nodeNoteEditorial.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("historyNote")) {
                nodeNoteHistory.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("scopeNote")) {
                nodeNoteScope.add(nodeNote);
            }
        }
        // types : definition; editorialNote; historyNote ; scopeNote
        for (NodeNote nodeNote : nodeConceptExport.getNodeNoteTerm()) {
            nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\r', ' '));
            nodeNote.setLexicalvalue(nodeNote.getLexicalvalue().replace('\n', ' '));
            if (nodeNote.getNotetypecode().equalsIgnoreCase("definition")) {
                nodeNoteDefinition.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("editorialNote")) {
                nodeNoteEditorial.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("historyNote")) {
                nodeNoteHistory.add(nodeNote);
            }
            if (nodeNote.getNotetypecode().equalsIgnoreCase("scopeNote")) {
                nodeNoteScope.add(nodeNote);
            }
        }
        // definition
        first = true;
        for (NodeNote nodeNote : nodeNoteDefinition) {
            if (listLangues.contains(nodeNote.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeNote.getLexicalvalue());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeNote.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // scopeNote
        first = true;
        for (NodeNote nodeNote : nodeNoteScope) {
            if (listLangues.contains(nodeNote.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeNote.getLexicalvalue());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeNote.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // historyNote
        first = true;
        for (NodeNote nodeNote : nodeNoteHistory) {
            if (listLangues.contains(nodeNote.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeNote.getLexicalvalue());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeNote.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // editorialNote
        first = true;
        for (NodeNote nodeNote : nodeNoteEditorial) {
            if (listLangues.contains(nodeNote.getLang())) {
                if (!first) {
                    tabulateBuff.append("##");
                }
                tabulateBuff.append(nodeNote.getLexicalvalue());
                tabulateBuff.append("::");
                tabulateBuff.append(nodeNote.getLang());
                first = false;
            }
        }
        tabulateBuff.append(";");
        // dates
        tabulateBuff.append(nodeConceptExport.getConcept().getCreated());
        tabulateBuff.append(";");
        tabulateBuff.append(nodeConceptExport.getConcept().getModified());
        tabulateBuff.append("\n");
        first = true;
    }
    return true;
}
Also used : NodeConceptExport(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport) ArrayList(java.util.ArrayList) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM) NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Example 3 with NodeUri

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

the class ConceptHelper method getConceptForExport.

/**
 * Cette fonction permet de récupérer toutes les informations concernant un
 * Concept par son id et son thésaurus et la langue On récupère aussi les
 * IdArk si Ark est actif
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @param isArkActive
 * @return Objet class NodeConcept
 */
public NodeConceptExport getConceptForExport(HikariDataSource ds, String idConcept, String idThesaurus, boolean isArkActive) {
    NodeConceptExport nodeConceptExport = new NodeConceptExport();
    // récupération des BT
    RelationsHelper relationsHelper = new RelationsHelper();
    ArrayList<NodeHieraRelation> nodeListOfBT_Ark = relationsHelper.getListBT(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeListOfBT(nodeListOfBT_Ark);
    // récupération du Concept
    Concept concept = getThisConcept(ds, idConcept, idThesaurus);
    /**
     * Attention si on passe par le null, ca veut dire qu'il y a une
     * incohérence dans la base à corriger !!!!!
     */
    if (concept == null) {
        return null;
    }
    nodeConceptExport.setConcept(concept);
    AlignmentHelper alignmentHelper = new AlignmentHelper();
    ArrayList<NodeAlignment> nodeAlignmentList = alignmentHelper.getAllAlignmentOfConcept(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeAlignmentsList(nodeAlignmentList);
    // récupération des termes spécifiques
    ArrayList<NodeHieraRelation> nodeListIdsOfNT_Ark = relationsHelper.getListNT(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeListOfNT(nodeListIdsOfNT_Ark);
    // récupération des termes associés
    ArrayList<NodeHieraRelation> nodeListIdsOfRT_Ark = relationsHelper.getListRT(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeListIdsOfRT(nodeListIdsOfRT_Ark);
    // récupération des Non Prefered Term
    nodeConceptExport.setNodeEM(new TermHelper().getAllNonPreferredTerms(ds, new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus), idThesaurus));
    // récupération des traductions
    nodeConceptExport.setNodeTermTraductions(new TermHelper().getAllTraductionsOfConcept(ds, idConcept, idThesaurus));
    // récupération des Groupes ou domaines
    ArrayList<NodeUri> nodeListIdsOfConceptGroup_Ark = getListIdArkOfGroup(ds, new GroupHelper().getListIdGroupOfConcept(ds, idThesaurus, idConcept), idThesaurus);
    nodeConceptExport.setNodeListIdsOfConceptGroup(nodeListIdsOfConceptGroup_Ark);
    // récupération des notes du Terme
    String idTerm = new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus);
    nodeConceptExport.setNodeNoteTerm(new NoteHelper().getListNotesTermAllLang(ds, idTerm, idThesaurus));
    // récupération des Notes du Concept
    nodeConceptExport.setNodeNoteConcept(new NoteHelper().getListNotesConceptAllLang(ds, idConcept, idThesaurus));
    // récupération des coordonnées GPS
    GpsHelper gpsHelper = new GpsHelper();
    NodeGps nodeGps = gpsHelper.getCoordinate(ds, idConcept, idThesaurus);
    if (nodeGps != null) {
        nodeConceptExport.setNodeGps(nodeGps);
    }
    return nodeConceptExport;
}
Also used : NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) Concept(mom.trd.opentheso.bdd.datas.Concept) NodeConceptExport(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport) NodeGps(mom.trd.opentheso.bdd.helper.nodes.NodeGps) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation)

Example 4 with NodeUri

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

the class ExportFromBDD method exportBranchOfConcept.

/**
 * Fonction permet d'exporter une branche complète d'un thésaurus
 * en partant de n'importe quel concept, mais pas d'un Domaine
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @return
 */
public StringBuffer exportBranchOfConcept(HikariDataSource ds, String idThesaurus, String idConcept) {
    WriteFileSKOS writeFileSKOS = new WriteFileSKOS();
    // inititialisation des URI
    writeFileSKOS.setServerArk(serverArk);
    writeFileSKOS.setServerAdress(serverAdress);
    writeFileSKOS.setNodePreference(nodePreference);
    writeFileSKOS.writeHeader();
    NodeUri nodeUri = new NodeUri();
    nodeUri.setIdConcept(idConcept);
    exportAllConcepts(ds, nodeUri.getIdConcept(), idThesaurus, writeFileSKOS);
    writeFileSKOS.endSkos();
    return writeFileSKOS.getSkosBuff();
}
Also used : NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri)

Example 5 with NodeUri

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

the class ExportFromBDD_Frantiq method exportThesaurus.

/**
 * Fonction récursive permettant d'exporter le thésaurus de la tête jusqu'au
 * dernier descripteur
 *
 * @param ds
 * @param idThesaurus
 * @return
 */
public StringBuffer exportThesaurus(HikariDataSource ds, String idThesaurus) {
    /*
         * Ecriture du thésaurus
         */
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    NodeThesaurus nodeThesaurus = thesaurusHelper.getNodeThesaurus(ds, idThesaurus);
    WriteFileSKOS_Frantiq writeFileSKOS = new WriteFileSKOS_Frantiq();
    // inititialisation des URI
    writeFileSKOS.setServerArk(serverArk);
    writeFileSKOS.setServerAdress(serverAdress);
    writeFileSKOS.writeHeader();
    String idArk = thesaurusHelper.getIdArkOfThesaurus(ds, idThesaurus);
    if (idArk == null || idArk.trim().isEmpty()) {
        writeFileSKOS.setURI(serverAdress);
    } else {
        writeFileSKOS.setURI(serverArk);
    }
    // writeFileSKOS.setURI("http://opentheso.frantiq.fr/" + nodeThesaurus.getListThesaurusTraduction().get(0).getTitle());
    // thesaurus.description);
    writeFileSKOS.writeThesaurus(nodeThesaurus);
    // ecriture des TopConcept
    GroupHelper conceptGroupHelper = new GroupHelper();
    ArrayList<String> tabIdGroup = conceptGroupHelper.getListIdOfGroup(ds, idThesaurus);
    for (String tabIdGroup1 : tabIdGroup) {
        writeFileSKOS.writeTopConcepts(tabIdGroup1);
    }
    writeFileSKOS.writeEndOfMicroThesaurusList();
    // fin du bloc thésaurus et id of TopConcept
    // écriture des Domaines et Descripteurs avec traductions
    ArrayList<NodeUri> idOfTopConcept;
    for (String tabIdGroup1 : tabIdGroup) {
        NodeGroupLabel nodeGroupLabel = conceptGroupHelper.getNodeGroupLabel(ds, tabIdGroup1, idThesaurus);
        idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
        writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept);
    }
    for (String tabIdGroup1 : tabIdGroup) {
        idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, tabIdGroup1, idThesaurus);
        for (NodeUri idOfTopConcept1 : idOfTopConcept) {
            exportAllConcepts(ds, idOfTopConcept1.getIdConcept(), idThesaurus, writeFileSKOS);
        }
    }
    writeFileSKOS.endSkos();
    return writeFileSKOS.getSkosBuff();
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Aggregations

NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)20 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)9 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)8 NodeGroupLabel (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel)8 ArrayList (java.util.ArrayList)5 NodeHieraRelation (mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation)4 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)3 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)3 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)3 NodeThesaurus (mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)3 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 Concept (mom.trd.opentheso.bdd.datas.Concept)2 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)2 NodeConcept (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept)2 SKOSResource (skos.SKOSResource)2 PrefixString (com.k_int.IR.QueryModels.PrefixString)1