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);
}
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);
}
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);
}
}
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;
}
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;
}
Aggregations