Search in sources :

Example 1 with StringPlus

use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.

the class WritePdf method getIdFromUri.

public static String getIdFromUri(String uri) {
    if (uri.contains("idg=")) {
        if (uri.contains("&")) {
            uri = uri.substring(uri.indexOf("idg=") + 4, uri.indexOf("&"));
        } else {
            uri = uri.substring(uri.indexOf("idg=") + 4, uri.length());
        }
    } else {
        if (uri.contains("idc=")) {
            if (uri.contains("&")) {
                uri = uri.substring(uri.indexOf("idc=") + 4, uri.indexOf("&"));
            } else {
                uri = uri.substring(uri.indexOf("idc=") + 4, uri.length());
            }
        } else {
            if (uri.contains("#")) {
                uri = uri.substring(uri.indexOf("#") + 1, uri.length());
            } else {
                uri = uri.substring(uri.lastIndexOf("/") + 1, uri.length());
            }
        }
    }
    StringPlus stringPlus = new StringPlus();
    uri = stringPlus.normalizeStringForIdentifier(uri);
    return uri;
}
Also used : StringPlus(mom.trd.opentheso.bdd.tools.StringPlus)

Example 2 with StringPlus

use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.

the class ImportSkosHelper method getIdFromUri.

public String getIdFromUri(String uri) {
    if (uri.contains("idg=")) {
        if (uri.contains("&")) {
            uri = uri.substring(uri.indexOf("idg=") + 4, uri.indexOf("&"));
        } else {
            uri = uri.substring(uri.indexOf("idg=") + 4, uri.length());
        }
    } else {
        if (uri.contains("idc=")) {
            if (uri.contains("&")) {
                uri = uri.substring(uri.indexOf("idc=") + 4, uri.indexOf("&"));
            } else {
                uri = uri.substring(uri.indexOf("idc=") + 4, uri.length());
            }
        } else {
            if (uri.contains("#")) {
                uri = uri.substring(uri.indexOf("#") + 1, uri.length());
            } else {
                uri = uri.substring(uri.lastIndexOf("/") + 1, uri.length());
            }
        }
    }
    StringPlus stringPlus = new StringPlus();
    uri = stringPlus.normalizeStringForIdentifier(uri);
    return uri;
}
Also used : StringPlus(mom.trd.opentheso.bdd.tools.StringPlus)

Example 3 with StringPlus

use of mom.trd.opentheso.bdd.tools.StringPlus 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 4 with StringPlus

use of mom.trd.opentheso.bdd.tools.StringPlus 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 5 with StringPlus

use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.

the class ImportRdf4jHelper method getIdFromUri.

private static String getIdFromUri(String uri) {
    if (uri.contains("idg=")) {
        if (uri.contains("&")) {
            uri = uri.substring(uri.indexOf("idg=") + 4, uri.indexOf("&"));
        } else {
            uri = uri.substring(uri.indexOf("idg=") + 4, uri.length());
        }
    } else {
        if (uri.contains("idc=")) {
            if (uri.contains("&")) {
                uri = uri.substring(uri.indexOf("idc=") + 4, uri.indexOf("&"));
            } else {
                uri = uri.substring(uri.indexOf("idc=") + 4, uri.length());
            }
        } else {
            if (uri.contains("#")) {
                uri = uri.substring(uri.indexOf("#") + 1, uri.length());
            } else {
                uri = uri.substring(uri.lastIndexOf("/") + 1, uri.length());
            }
        }
    }
    StringPlus stringPlus = new StringPlus();
    uri = stringPlus.normalizeStringForIdentifier(uri);
    return uri;
}
Also used : StringPlus(mom.trd.opentheso.bdd.tools.StringPlus)

Aggregations

StringPlus (mom.trd.opentheso.bdd.tools.StringPlus)80 SQLException (java.sql.SQLException)63 Statement (java.sql.Statement)63 Connection (java.sql.Connection)56 ResultSet (java.sql.ResultSet)30 PreparedStatement (java.sql.PreparedStatement)19 ArrayList (java.util.ArrayList)12 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)6 NodeSearch (mom.trd.opentheso.bdd.helper.nodes.search.NodeSearch)6 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)4 FacesMessage (javax.faces.application.FacesMessage)2 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)2 NodeBT (mom.trd.opentheso.bdd.helper.nodes.NodeBT)2 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)2 NodePermute (mom.trd.opentheso.bdd.helper.nodes.NodePermute)2 NodeConcept (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConcept)2 PrefixString (com.k_int.IR.QueryModels.PrefixString)1 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 ConnexionTest (connexion.ConnexionTest)1 DcElement (fr.mom.arkeo.soap.DcElement)1