Search in sources :

Example 1 with NodeConcept

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

the class ExportTxtHelper method writeConceptsInfo.

/**
 * Permet d'écrire les concepts en bouclant par récursivité pour définir les
 * niveaux
 *
 * @return
 */
private void writeConceptsInfo(String idConcept, String indentation) {
    ConceptHelper conceptHelper = new ConceptHelper();
    NodeConcept nodeConcept = conceptHelper.getConcept(ds, idConcept, idTheso, selectedLang);
    StringPlus stringPlus = new StringPlus();
    boolean first = true;
    if (nodeConcept == null) {
        return;
    }
    // id numérique séquentiel
    txtBuff.append(++number);
    txtBuff.append("\t");
    // Id_concept
    txtBuff.append(idConcept);
    txtBuff.append("\t");
    // on écrit le Term_concept
    txtBuff.append(indentation);
    if (nodeConcept.getTerm().getLexical_value().isEmpty()) {
        txtBuff.append("(");
        txtBuff.append(idConcept);
        txtBuff.append(")");
    } else {
        txtBuff.append(nodeConcept.getTerm().getLexical_value());
    }
    int tot = StringUtils.countMatches(indentation, "\t");
    if (tot < indentationConcept) {
        addTabulate(indentationConcept - (tot + 1));
    }
    if (selectedOptions.contains("occ")) {
        // on écrit les occurences
        txtBuff.append("\t");
        txtBuff.append(totalOfNotices(idConcept));
    }
    first = true;
    if (selectedOptions.contains("nt")) {
        // on écrit la relation NT
        if (!nodeConcept.getNodeNT().isEmpty()) {
            txtBuff.append("\t");
            for (NodeNT nodeNT : nodeConcept.getNodeNT()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("NT: ");
                txtBuff.append(nodeNT.getTitle());
                first = false;
            }
        }
        if (nodeConcept.getNodeNT().size() < indentationNT) {
            addTabulate(indentationNT - nodeConcept.getNodeNT().size());
        }
    }
    first = true;
    // on écrit la relation UF
    if (selectedOptions.contains("uf")) {
        if (!nodeConcept.getNodeEM().isEmpty()) {
            txtBuff.append("\t");
            for (NodeEM nodeEm : nodeConcept.getNodeEM()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("UF: ");
                txtBuff.append(nodeEm.getLexical_value());
                first = false;
            }
        }
        if (nodeConcept.getNodeEM().size() < indentationUF) {
            addTabulate(indentationUF - nodeConcept.getNodeEM().size());
        }
    }
    first = true;
    if (selectedOptions.contains("bt")) {
        // on écrit la relation TG
        if (!nodeConcept.getNodeBT().isEmpty()) {
            txtBuff.append("\t");
            for (NodeBT nodeBT : nodeConcept.getNodeBT()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("BT: ");
                txtBuff.append(nodeBT.getTitle());
                first = false;
            }
        }
        if (nodeConcept.getNodeBT().size() < indentationBT) {
            addTabulate(indentationBT - nodeConcept.getNodeBT().size());
        }
    }
    first = true;
    // on écrit la relation RT
    if (selectedOptions.contains("rt")) {
        if (!nodeConcept.getNodeRT().isEmpty()) {
            txtBuff.append("\t");
            for (NodeRT nodeRT : nodeConcept.getNodeRT()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("RT: ");
                txtBuff.append(nodeRT.getTitle());
                first = false;
            }
        }
        if (nodeConcept.getNodeRT().size() < indentationRT) {
            addTabulate(indentationRT - nodeConcept.getNodeRT().size());
        }
    }
    first = true;
    // on écrit les Groupes
    if (selectedOptions.contains("groups")) {
        if (!nodeConcept.getNodeConceptGroup().isEmpty()) {
            txtBuff.append("\t");
            for (NodeGroup nodeGroup : nodeConcept.getNodeConceptGroup()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("MT: ");
                txtBuff.append(nodeGroup.getLexicalValue());
                first = false;
            }
        }
        if (nodeConcept.getNodeConceptGroup().size() < indentationGroups) {
            addTabulate(indentationGroups - nodeConcept.getNodeConceptGroup().size());
        }
    }
    first = true;
    // on écrit les traductions
    if (selectedOptions.contains("traductions")) {
        if (!nodeConcept.getNodeTermTraductions().isEmpty()) {
            txtBuff.append("\t");
            for (NodeTermTraduction nodeTermTraduction : nodeConcept.getNodeTermTraductions()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("Tr: ");
                txtBuff.append(nodeTermTraduction.getLexicalValue());
                txtBuff.append("(");
                txtBuff.append(nodeTermTraduction.getLang());
                txtBuff.append(")");
                first = false;
            }
        }
        if (nodeConcept.getNodeTermTraductions().size() < indentationTraductions) {
            addTabulate(indentationTraductions - nodeConcept.getNodeTermTraductions().size());
        }
    }
    first = true;
    // on écrit les notes de type Term
    if (selectedOptions.contains("notes")) {
        if ((!nodeConcept.getNodeNotesTerm().isEmpty()) || (!nodeConcept.getNodeNotesConcept().isEmpty())) {
            txtBuff.append("\t");
            for (NodeNote nodeNote : nodeConcept.getNodeNotesTerm()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("noteT: ");
                txtBuff.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
                first = false;
            }
            for (NodeNote nodeNote : nodeConcept.getNodeNotesConcept()) {
                if (!first)
                    txtBuff.append("\t");
                // txtBuff.append("noteC: ");
                txtBuff.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
                first = false;
            }
        }
        if (nodeConcept.getNodeNotesTerm().size() < indentationNotes) {
            addTabulate(indentationNotes - (nodeConcept.getNodeNotesConcept().size() + nodeConcept.getNodeNotesTerm().size()));
        }
    }
    txtBuff.append("\n");
}
Also used : NodeBT(mom.trd.opentheso.bdd.helper.nodes.NodeBT) NodeRT(mom.trd.opentheso.bdd.helper.nodes.NodeRT) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) NodeNT(mom.trd.opentheso.bdd.helper.nodes.NodeNT) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM) NodeGroup(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)

Example 2 with NodeConcept

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

the class CompareConceptTest method testExportAllDatas.

/**
 * Test of Get datas for SiteMap.
 */
@org.junit.Test
public void testExportAllDatas() {
    ConnexionTest connexionTest = new ConnexionTest();
    HikariDataSource conn = connexionTest.getConnexionPool();
    String idTheso = "TH_1";
    String idLang = "fr";
    String idGroup = "6";
    ConceptHelper conceptHelper = new ConceptHelper();
    StringPlus stringPlus = new StringPlus();
    NodeConcept nodeConcept;
    SearchHelper searchHelper = new SearchHelper();
    ArrayList<NodeSearch> nodeSearchs;
    StringBuilder stringBuilder = new StringBuilder();
    // lecture du fichier tabulé /Users/Miled/
    String path = "/Users/Miled/Desktop/inist.csv";
    FileInputStream file = readFile(path);
    if (file == null)
        return;
    String line;
    String lineTmp;
    String[] lineOrigine;
    boolean first = true;
    stringBuilder.append("Numéro BDD\tnom d'origine\tnom PACTOLS\tId PACTOLS\tURL Ark\tDéfinition\tTerme générique\tSynonyme\n");
    BufferedReader bf = new BufferedReader(new InputStreamReader(file));
    try {
        while ((line = bf.readLine()) != null) {
            lineOrigine = line.split("\t");
            if (lineOrigine.length < 2)
                continue;
            lineTmp = removeStopWords(lineOrigine[1]);
            nodeSearchs = searchHelper.searchTerm(conn, lineTmp, idLang, idTheso, idGroup, 2, false);
            stringBuilder.append(lineOrigine[0]);
            stringBuilder.append("\t");
            stringBuilder.append(lineOrigine[1]);
            // stringBuilder.append(" #### ");
            stringBuilder.append("\t");
            first = true;
            for (NodeSearch nodeSearch : nodeSearchs) {
                if (!first) {
                    // stringBuilder.append(" $$$$ ");
                    stringBuilder.append("\n");
                    stringBuilder.append("\t");
                    stringBuilder.append("\t");
                }
                stringBuilder.append(nodeSearch.getLexical_value());
                stringBuilder.append("\t");
                stringBuilder.append(nodeSearch.getIdConcept());
                // récupération des données d'un Concept
                nodeConcept = conceptHelper.getConcept(conn, nodeSearch.getIdConcept(), idTheso, idLang);
                // URL
                stringBuilder.append("\t");
                if (nodeConcept.getConcept().getIdArk() != null || !nodeConcept.getConcept().getIdArk().isEmpty()) {
                    stringBuilder.append("http://ark.frantiq.fr/ark:/");
                    stringBuilder.append(nodeConcept.getConcept().getIdArk());
                }
                // définition
                stringBuilder.append("\t");
                for (NodeNote nodeNote : nodeConcept.getNodeNotesTerm()) {
                    if (nodeNote.getNotetypecode().equalsIgnoreCase("definition"))
                        stringBuilder.append(stringPlus.clearNewLine(nodeNote.getLexicalvalue()));
                }
                // BT
                stringBuilder.append("\t");
                for (NodeBT nodeBT : nodeConcept.getNodeBT()) {
                    stringBuilder.append(nodeBT.getTitle());
                }
                // UF
                stringBuilder.append("\t");
                for (NodeEM nodeEM : nodeConcept.getNodeEM()) {
                    stringBuilder.append(nodeEM.getLexical_value());
                }
                first = false;
            }
            System.out.println(stringBuilder.toString());
            stringBuilder.delete(0, stringBuilder.capacity());
        }
    } catch (IOException ex) {
        Logger.getLogger(CompareConceptTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    // ArrayList<NodeConceptArkId> allIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, idTheso);
    // StringBuilder file = new StringBuilder();
    /*  ArrayList<String> allIds = conceptHelper.getAllIdConceptOfThesaurusByGroup(conn, idTheso, idGroup);
        
        
        for (String idConcept : allIds) {

            nodeConcept = conceptHelper.getConcept(conn, idConcept, idTheso, idLang);
            System.out.println("idConcept = " + idConcept + "  " + nodeConcept.getTerm().getLexical_value());
            
        }*/
    conn.close();
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) ConnexionTest(connexion.ConnexionTest) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) InputStreamReader(java.io.InputStreamReader) NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) IOException(java.io.IOException) SearchHelper(mom.trd.opentheso.bdd.helper.SearchHelper) FileInputStream(java.io.FileInputStream) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM) NodeBT(mom.trd.opentheso.bdd.helper.nodes.NodeBT) BufferedReader(java.io.BufferedReader) NodeSearch(mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)

Example 3 with NodeConcept

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

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

Example 5 with NodeConcept

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

the class ConceptHelper method prepareToAddArkId.

/**
 * Pour préparer les données pour la création d'un idArk
 *
 * @param ds
 * @param url
 * @param idConcept
 * @param idLang
 * @param idTheso
 * @param idUser
 * @return
 */
private boolean prepareToAddArkId(HikariDataSource ds, String idConcept, String idLang, String idTheso) {
    ArrayList<DcElement> dc = new ArrayList<>();
    NodeConcept nodeConcept;
    nodeConcept = getConcept(ds, idConcept, idTheso, idLang);
    NodeMetaData nodeMetaData = new NodeMetaData();
    nodeMetaData.setCreator(nodeConcept.getTerm().getSource());
    nodeMetaData.setTitle(nodeConcept.getTerm().getLexical_value());
    nodeMetaData.setDcElementsList(new ArrayList<>());
    Connection conn;
    try {
        conn = ds.getConnection();
        conn.setAutoCommit(false);
        if (!addIdArk(conn, idConcept, idTheso, nodeMetaData)) {
            conn.rollback();
            conn.close();
            return false;
        }
        conn.commit();
        conn.close();
        return true;
    } catch (SQLException ex) {
        Logger.getLogger(ConceptHelper.class.getName()).log(Level.SEVERE, null, ex);
    }
    return true;
}
Also used : DcElement(fr.mom.arkeo.soap.DcElement) NodeMetaData(mom.trd.opentheso.bdd.helper.nodes.NodeMetaData) SQLException(java.sql.SQLException) NodeConcept(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept) ArrayList(java.util.ArrayList) Connection(java.sql.Connection)

Aggregations

NodeConcept (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept)6 Concept (mom.trd.opentheso.bdd.datas.Concept)3 NodeBT (mom.trd.opentheso.bdd.helper.nodes.NodeBT)3 ArrayList (java.util.ArrayList)2 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)2 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)2 NodeHieraRelation (mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation)2 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)2 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)2 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)2 NodeSearch (mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch)2 StringPlus (mom.trd.opentheso.bdd.tools.StringPlus)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 ConnexionTest (connexion.ConnexionTest)1 DcElement (fr.mom.arkeo.soap.DcElement)1 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 Connection (java.sql.Connection)1