Search in sources :

Example 1 with NodeHieraRelation

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

the class ExportRdf4jHelper method addMember.

private void addMember(String id, String idThesaurus, SKOSResource resource) {
    RelationsHelper relationsHelper = new RelationsHelper();
    ArrayList<NodeHieraRelation> listChildren = relationsHelper.getListNT(ds, id, idThesaurus);
    for (NodeHieraRelation idChildren : listChildren) {
        // System.out.println(idChildren.getUri().getIdConcept());
        resource.addRelation(getUriFromNodeUri(idChildren.getUri(), idThesaurus), SKOSProperty.member);
        addMember(idChildren.getUri().getIdConcept(), idThesaurus, resource);
    }
}
Also used : NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 2 with NodeHieraRelation

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

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

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

the class RelationsHelper method getListNT.

/**
 * Cette fonction permet de récupérer la liste des Id des termes
 * spécifiques d'un concept avec les identifiants pérennes (Ark, Handle)
 * sert à l'export des données
 *
 * @param ds
 * @param idConcept
 * @param idThesaurus
 * @return Objet class Concept
 * #MR
 */
public ArrayList<NodeHieraRelation> getListNT(HikariDataSource ds, String idConcept, String idThesaurus) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeHieraRelation> nodeListIdOfConcept = new ArrayList<>();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select id_concept2, role, id_ark, id_handle " + " from hierarchical_relationship as hr" + " left join concept as con on id_concept = id_concept2" + " and hr.id_thesaurus = con.id_thesaurus" + " where hr.id_thesaurus = '" + idThesaurus + "'" + " and id_concept1 = '" + idConcept + "'" + " and role LIKE 'NT%'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                while (resultSet.next()) {
                    NodeHieraRelation nodeHieraRelation = new NodeHieraRelation();
                    NodeUri nodeUri = new NodeUri();
                    if ((resultSet.getString("id_ark") == null) || (resultSet.getString("id_ark").trim().isEmpty())) {
                        nodeUri.setIdArk("");
                    } else {
                        nodeUri.setIdArk(resultSet.getString("id_ark"));
                    }
                    if ((resultSet.getString("id_handle") == null) || (resultSet.getString("id_handle").trim().isEmpty())) {
                        nodeUri.setIdHandle("");
                    } else {
                        nodeUri.setIdHandle(resultSet.getString("id_handle"));
                    }
                    nodeUri.setIdConcept(resultSet.getString("id_concept2"));
                    nodeHieraRelation.setRole(resultSet.getString("role"));
                    nodeHieraRelation.setUri(nodeUri);
                    nodeListIdOfConcept.add(nodeHieraRelation);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting Liste ID of NT Concept with ark and handle : " + idConcept, sqle);
    }
    return nodeListIdOfConcept;
}
Also used : NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri)

Example 5 with NodeHieraRelation

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

the class ConceptHelper method getMultiConceptForExport.

/**
 * Cette fonction permet de récupérer toutes les informations concernant un
 * ou plusieurs Concept par une chaîne de caractère, suivant le thésaurus,
 * la langue et le group
 *
 * @param ds
 * @param value
 * @param idThesaurus
 * @param idGroup
 * @param idLang
 * @param isArkActif
 * @return Objet class NodeConcept
 */
public ArrayList<NodeConceptExport> getMultiConceptForExport(HikariDataSource ds, String value, String idLang, String idGroup, String idThesaurus, boolean isArkActif) {
    ArrayList<NodeConceptExport> listNce = new ArrayList<>();
    // Récupération des concept
    ArrayList<NodeSearch> listRes = new SearchHelper().searchTerm(ds, value, idLang, idThesaurus, idGroup, 1, false);
    for (NodeSearch ns : listRes) {
        Concept concept = getThisConcept(ds, ns.getIdConcept(), idThesaurus);
        NodeConceptExport nce = new NodeConceptExport();
        nce.setConcept(concept);
        listNce.add(nce);
    }
    for (NodeConceptExport nce : listNce) {
        String idConcept = nce.getConcept().getIdConcept();
        RelationsHelper relationsHelper = new RelationsHelper();
        // récupération des BT
        ArrayList<NodeHieraRelation> nodeListIdOfBT_Ark = relationsHelper.getListBT(ds, idConcept, idThesaurus);
        nce.setNodeListOfBT(nodeListIdOfBT_Ark);
        // récupération des termes spécifiques
        ArrayList<NodeHieraRelation> nodeListIdOfNT_Ark = relationsHelper.getListNT(ds, idConcept, idThesaurus);
        nce.setNodeListOfNT(nodeListIdOfNT_Ark);
        // récupération des termes associés
        ArrayList<NodeHieraRelation> nodeListIdOfRT_Ark = relationsHelper.getListRT(ds, idConcept, idThesaurus);
        nce.setNodeListIdsOfRT(nodeListIdOfRT_Ark);
        // récupération des Non Prefered Term
        nce.setNodeEM(new TermHelper().getAllNonPreferredTerms(ds, new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus), idThesaurus));
        // récupération des traductions
        nce.setNodeTermTraductions(new TermHelper().getAllTraductionsOfConcept(ds, idConcept, idThesaurus));
        // récupération des Groupes
        ArrayList<NodeUri> nodeListIdsOfConceptGroup_Ark = getListIdArkOfGroup(ds, new GroupHelper().getListIdGroupOfConcept(ds, idThesaurus, idConcept), idThesaurus);
        nce.setNodeListIdsOfConceptGroup(nodeListIdsOfConceptGroup_Ark);
        // récupération des notes du Terme
        String idTerm = new TermHelper().getIdTermOfConcept(ds, idConcept, idThesaurus);
        nce.setNodeNoteTerm(new NoteHelper().getListNotesTermAllLang(ds, idTerm, idThesaurus));
        // récupération des Notes du Concept
        nce.setNodeNoteConcept(new NoteHelper().getListNotesConceptAllLang(ds, idConcept, idThesaurus));
        // récupération des Alignements
        nce.setNodeAlignmentsList(new AlignmentHelper().getAllAlignmentOfConcept(ds, idConcept, idThesaurus));
    }
    return listNce;
}
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) ArrayList(java.util.ArrayList) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation) NodeSearch(mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch)

Aggregations

NodeHieraRelation (mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation)6 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)4 ArrayList (java.util.ArrayList)3 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)3 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 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)1 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)1 NodeGps (mom.trd.opentheso.bdd.helper.nodes.NodeGps)1 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)1 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)1 NodeSearch (mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch)1 NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)1