Search in sources :

Example 6 with StringPlus

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

the class SkosToJsonld method addElementDocumentation.

private void addElementDocumentation(SKOSDocumentation sKOSDocumentation, String nameSpace) {
    StringPlus stringPlus = new StringPlus();
    String element = "      \"" + nameSpaceSkosCore + nameSpace + "\": {\n";
    element += "        \"@language\": \"" + sKOSDocumentation.getLanguage() + "\",\n";
    element += "        \"@value\": \"" + stringPlus.normalizeStringForXml(sKOSDocumentation.getText()) + "\"\n";
    element += "      }";
    jsonLd.append(element);
}
Also used : StringPlus(mom.trd.opentheso.bdd.tools.StringPlus)

Example 7 with StringPlus

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

the class SkosToJsonld method addIdConcept.

private void addIdConcept(String uri) {
    String conceptId;
    StringPlus stringPlus = new StringPlus();
    uri = stringPlus.normalizeStringForXml(uri);
    conceptId = "      \"@id\": \"" + uri + "\",\n";
    conceptId += "      \"@type\": \"" + nameSpaceSkosCore + "Concept" + "\"";
    jsonLd.append(conceptId);
}
Also used : StringPlus(mom.trd.opentheso.bdd.tools.StringPlus)

Example 8 with StringPlus

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

the class SkosToJsonld method addNote.

private void addNote(ArrayList<SKOSDocumentation> note, String noteType) {
    StringPlus stringPlus = new StringPlus();
    String labelString;
    if (!note.isEmpty()) {
        if (note.size() > 1) {
            endElement();
            labelString = "      \"" + nameSpaceSkosCore + noteType + "\": [\n";
            boolean first = true;
            for (SKOSDocumentation sKOSDocumentation : note) {
                if (!first)
                    labelString += ",\n";
                labelString += "        {\n";
                labelString += "          \"@language\": \"" + sKOSDocumentation.getLanguage() + "\",\n";
                labelString += "          \"@value\": \"" + stringPlus.normalizeStringForXml(sKOSDocumentation.getText()) + "\"\n";
                labelString += "        }";
                first = false;
            }
            labelString += "\n      ]";
        } else {
            endElement();
            labelString = "      \"" + nameSpaceSkosCore + noteType + "\": {\n";
            for (SKOSDocumentation sKOSDocumentation : note) {
                labelString += "        \"@language\": \"" + sKOSDocumentation.getLanguage() + "\",\n";
                labelString += "        \"@value\": \"" + stringPlus.normalizeStringForXml(sKOSDocumentation.getText()) + "\"\n";
                labelString += "      }";
            }
        }
        jsonLd.append(labelString);
    }
}
Also used : SKOSDocumentation(skos.SKOSDocumentation) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus)

Example 9 with StringPlus

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

the class SKOSResource 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 10 with StringPlus

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

the class ImagesHelper method addImage.

/**
 * Cette fonction permet d'ajouter une définition note à un Terme
 * à la table Term, en paramètre un objet Classe Term
 *
 * @param ds
 * @param idConcept
 * @param imageName
 * @param idThesausus
 * @param copyRight
 * @return
 */
public boolean addImage(HikariDataSource ds, String idConcept, String idThesausus, String imageName, String copyRight, int idUser) {
    Connection conn;
    Statement stmt;
    boolean status = false;
    copyRight = new StringPlus().convertString(copyRight);
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "Insert into images " + "(id_concept, id_thesaurus, image_name, image_copyright)" + " values (" + "'" + idConcept + "'" + ",'" + idThesausus + "'" + ",'" + imageName + "'" + ",'" + copyRight + "')";
                stmt.executeUpdate(query);
                status = true;
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while adding image of Concept : " + idConcept, sqle);
    }
    return status;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) Connection(java.sql.Connection)

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