use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.
the class SkosToJsonld method addElementInScheme.
private void addElementInScheme(ArrayList<SKOSTopConcept> sKOSTopConcepts, String nameSpace) {
String element;
String uri;
StringPlus stringPlus = new StringPlus();
if (sKOSTopConcepts.size() > 1) {
endElement();
element = " \"" + nameSpaceSkosCore + nameSpace + "\": [\n";
boolean first = true;
for (SKOSTopConcept sKOSTopConcept : sKOSTopConcepts) {
if (!first)
element += " },\n";
element += " {\n";
uri = stringPlus.normalizeStringForXml(sKOSTopConcept.getTopConcept());
element += " \"@id\": \"" + uri + "\"\n";
first = false;
}
element += " }\n";
element += " ]";
} else {
endElement();
element = " \"" + nameSpaceSkosCore + nameSpace + "\": {\n";
for (SKOSTopConcept sKOSTopConcept : sKOSTopConcepts) {
uri = stringPlus.normalizeStringForXml(sKOSTopConcept.getTopConcept());
element += " \"@id\": \"" + uri + "\"\n";
element += " }";
}
}
jsonLd.append(element);
}
use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.
the class SkosToJsonld method addLabels.
private void addLabels(ArrayList<SKOSLabel> sKOSLabels) {
ArrayList<SKOSLabel> prefLabel = new ArrayList<>();
ArrayList<SKOSLabel> altLabel = new ArrayList<>();
StringPlus stringPlus = new StringPlus();
for (SKOSLabel sKOSLabel : sKOSLabels) {
switch(sKOSLabel.getProperty()) {
case SKOSProperty.prefLabel:
prefLabel.add(sKOSLabel);
break;
case SKOSProperty.altLabel:
altLabel.add(sKOSLabel);
break;
default:
break;
}
}
// prefLabls
String prefLabelString;
if (!prefLabel.isEmpty()) {
if (prefLabel.size() > 1) {
endElement();
prefLabelString = " \"" + nameSpaceSkosCore + "prefLabel" + "\": [\n";
boolean first = true;
for (SKOSLabel prefLabel1 : prefLabel) {
if (!first)
prefLabelString += ",\n";
prefLabelString += " {\n";
prefLabelString += " \"@language\": \"" + prefLabel1.getLanguage() + "\",\n";
prefLabelString += " \"@value\": \"" + stringPlus.normalizeStringForXml(prefLabel1.getLabel()) + "\"\n";
prefLabelString += " }";
first = false;
}
prefLabelString += "\n ]";
} else {
endElement();
prefLabelString = " \"" + nameSpaceSkosCore + "prefLabel" + "\": {\n";
for (SKOSLabel prefLabel1 : prefLabel) {
prefLabelString += " \"@language\": \"" + prefLabel1.getLanguage() + "\",\n";
prefLabelString += " \"@value\": \"" + stringPlus.normalizeStringForXml(prefLabel1.getLabel()) + "\"\n";
prefLabelString += " }";
}
}
jsonLd.append(prefLabelString);
}
// altLables
String altLabelString;
if (!altLabel.isEmpty()) {
if (altLabel.size() > 1) {
endElement();
altLabelString = " \"" + nameSpaceSkosCore + "altLabel" + "\": [\n";
boolean first = true;
for (SKOSLabel altLabel1 : altLabel) {
if (!first)
altLabelString += ",\n";
altLabelString += " {\n";
altLabelString += " \"@language\": \"" + altLabel1.getLanguage() + "\",\n";
altLabelString += " \"@value\": \"" + stringPlus.normalizeStringForXml(altLabel1.getLabel()) + "\"\n";
altLabelString += " }";
first = false;
}
altLabelString += "\n ]";
} else {
endElement();
altLabelString = " \"" + nameSpaceSkosCore + "altLabel" + "\": {\n";
for (SKOSLabel altLabel1 : altLabel) {
altLabelString += " \"@language\": \"" + altLabel1.getLanguage() + "\",\n";
altLabelString += " \"@value\": \"" + stringPlus.normalizeStringForXml(altLabel1.getLabel()) + "\"\n";
altLabelString += " }";
}
}
jsonLd.append(altLabelString);
}
}
use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.
the class SkosToJsonld method addElementMapping.
private void addElementMapping(ArrayList<SKOSMapping> skosRelation, String nameSpace) {
String element;
String uri;
StringPlus stringPlus = new StringPlus();
if (skosRelation.size() > 1) {
boolean first = true;
endElement();
element = " \"" + nameSpaceSkosCore + nameSpace + "\": [\n";
for (SKOSMapping skosRelation1 : skosRelation) {
if (!first)
element += " },\n";
element += " {\n";
uri = stringPlus.normalizeStringForXml(skosRelation1.getTargetUri());
element += " \"@id\": \"" + uri + "\"\n";
first = false;
}
element += " }\n";
element += " ]";
} else {
endElement();
element = " \"" + nameSpaceSkosCore + nameSpace + "\": {\n";
for (SKOSMapping skosRelation1 : skosRelation) {
uri = stringPlus.normalizeStringForXml(skosRelation1.getTargetUri());
element += " \"@id\": \"" + uri + "\"\n";
element += " }";
}
}
jsonLd.append(element);
}
use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.
the class SkosToJsonld method addElementRelation.
private void addElementRelation(ArrayList<SKOSRelation> skosRelation, String nameSpace) {
String element;
String uri;
StringPlus stringPlus = new StringPlus();
if (skosRelation.size() > 1) {
endElement();
element = " \"" + nameSpaceSkosCore + nameSpace + "\": [\n";
boolean first = true;
for (SKOSRelation skosRelation1 : skosRelation) {
if (!first)
element += " },\n";
element += " {\n";
uri = stringPlus.normalizeStringForXml(skosRelation1.getTargetUri());
element += " \"@id\": \"" + uri + "\"\n";
first = false;
}
element += " }\n";
element += " ]";
} else {
endElement();
element = " \"" + nameSpaceSkosCore + nameSpace + "\": {\n";
for (SKOSRelation skosRelation1 : skosRelation) {
uri = stringPlus.normalizeStringForXml(skosRelation1.getTargetUri());
element += " \"@id\": \"" + uri + "\"\n";
element += " }";
}
}
jsonLd.append(element);
}
use of mom.trd.opentheso.bdd.tools.StringPlus in project opentheso by miledrousset.
the class SearchHelper method getListPermuteNonPreferredTerm.
/**
* Cette fonction permet de récupérer une liste des concepts Synonymes sous
* forme permutée
*
* @param ds
* @param idThesaurus
* @param idLang
* @param value
* @return ArrayList de NodePermute
*/
public ArrayList<NodePermute> getListPermuteNonPreferredTerm(HikariDataSource ds, String idThesaurus, String idLang, String value) {
Connection conn;
Statement stmt;
ResultSet resultSet;
ArrayList<NodePermute> nodePermuteList = null;
value = new StringPlus().convertString(value);
try {
// Get connection from pool
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "SELECT DISTINCT ord, id_concept, " + " id_lang, lexical_value, id_group" + " FROM permuted WHERE" + " id_lang = '" + idLang + "'" + " and id_thesaurus = '" + idThesaurus + "'" + " and ispreferredterm = " + false + " and unaccent_string(lexical_value) ilike" + " unaccent_string('" + value + "%')" + " order by lexical_value ASC LIMIT 200";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
nodePermuteList = new ArrayList<>();
while (resultSet.next()) {
NodePermute nodePermute = new NodePermute();
nodePermute.setIdThesaurus(idThesaurus);
nodePermute.setIdConcept(resultSet.getString("id_concept"));
nodePermute.setIdLang(resultSet.getString("id_lang"));
nodePermute.setSearchedValue(resultSet.getString("lexical_value"));
nodePermute.setIndexOfValue(resultSet.getInt("ord"));
nodePermute.setIdGroup(resultSet.getString("id_group"));
nodePermute.setIsPreferredTerm(false);
// cas où le terme recherché est égal au terme retrouvé, on le place en premier
if (value.trim().equalsIgnoreCase(nodePermute.getSearchedValue().trim())) {
nodePermuteList.add(0, nodePermute);
} else {
nodePermuteList.add(nodePermute);
}
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException sqle) {
// Log exception
log.error("Error while getting List Permute of Value : " + value, sqle);
}
if (nodePermuteList != null) {
nodePermuteList = addColumnsToPermute(ds, idThesaurus, nodePermuteList);
}
return nodePermuteList;
}
Aggregations