use of mom.trd.opentheso.core.alignment.SelectedResource in project opentheso by miledrousset.
the class Alignment method addDefinitions__.
private boolean addDefinitions__(String idTheso, String idConcept, int idUser) {
NoteHelper noteHelper = new NoteHelper();
TermHelper termHelper = new TermHelper();
String idTerm = termHelper.getIdTermOfConcept(connect.getPoolConnexion(), idConcept, idTheso);
if (idTerm == null)
return false;
// ajout de la note avec prefix de la source (wikidata)
for (SelectedResource selectedResource : descriptionsOfAlignment) {
if (selectedResource.isSelected()) {
if (!noteHelper.addTermNote(connect.getPoolConnexion(), idTerm, selectedResource.getIdLang(), idTheso, selectedResource.getGettedValue() + " (" + selectedAlignement + ")", "definition", idUser)) {
error = true;
alignementResult = alignementResult + ": Erreur dans l'ajout des définitions";
}
}
}
alignementResult = alignementResult + " Définitions ajoutées ##";
return true;
}
use of mom.trd.opentheso.core.alignment.SelectedResource in project opentheso by miledrousset.
the class GemetHelper method getDescriptions.
/**
* permet de récupérer les descriptions de wikidata
*
* @param jsonDatas
* @param entity
* @param languages
* @return
*/
private ArrayList<SelectedResource> getDescriptions(String jsonDatas, ArrayList<String> languages) {
ArrayList<SelectedResource> descriptions = new ArrayList<>();
String lang;
String value;
// lecture du fichier Json des langues
JsonArray dataArray;
JsonObject dataObject;
try (JsonReader reader = Json.createReader(new StringReader(jsonDatas))) {
dataArray = reader.readArray();
for (int i = 0; i < dataArray.size(); ++i) {
dataObject = dataArray.getJsonObject(i);
SelectedResource selectedResource = new SelectedResource();
lang = dataObject.getString("language");
value = dataObject.getString("string");
if (lang == null || value == null || lang.isEmpty() || value.isEmpty())
continue;
if (languages.contains(lang)) {
selectedResource.setIdLang(lang);
selectedResource.setGettedValue(value);
descriptions.add(selectedResource);
}
}
}
return descriptions;
}
use of mom.trd.opentheso.core.alignment.SelectedResource in project opentheso by miledrousset.
the class GemetHelper method getTraductions.
/**
* récupération des traductions
*
* @param jsonDatas
* @param entity
* @param languages
* @return
*/
private ArrayList<SelectedResource> getTraductions(String jsonDatas, ArrayList<String> languages) {
ArrayList<SelectedResource> traductions = new ArrayList<>();
String lang;
String value;
// lecture du fichier Json des langues
JsonArray dataArray;
JsonObject dataObject;
try (JsonReader reader = Json.createReader(new StringReader(jsonDatas))) {
dataArray = reader.readArray();
for (int i = 0; i < dataArray.size(); ++i) {
dataObject = dataArray.getJsonObject(i);
lang = dataObject.getString("language");
value = dataObject.getString("string");
if (lang == null || value == null || lang.isEmpty() || value.isEmpty())
continue;
if (languages.contains(lang)) {
SelectedResource selectedResource = new SelectedResource();
selectedResource.setIdLang(lang);
selectedResource.setGettedValue(value);
traductions.add(selectedResource);
}
}
}
return traductions;
}
use of mom.trd.opentheso.core.alignment.SelectedResource in project opentheso by miledrousset.
the class WikidataHelper method getTraductions.
/**
* récupération des traductions
* @param jsonDatas
* @param entity
* @param languages
* @return
*/
private ArrayList<SelectedResource> getTraductions(String jsonDatas, String entity, ArrayList<String> languages) {
ArrayList<SelectedResource> traductions = new ArrayList<>();
JsonHelper jsonHelper = new JsonHelper();
JsonObject jsonObject = jsonHelper.getJsonObject(jsonDatas);
// JsonObject test = jsonObject.getJsonObject("entities");
JsonObject jsonObject1;
JsonValue jsonValue;
String lang;
String value;
try {
jsonObject1 = jsonObject.getJsonObject("entities").getJsonObject(entity).getJsonObject("labels");
} catch (Exception e) {
// System.err.println(e.toString());
return null;
}
for (String language : languages) {
try {
SelectedResource selectedResource = new SelectedResource();
jsonValue = jsonObject1.getJsonObject(language).get("language");
lang = jsonValue.toString().replace("\"", "");
selectedResource.setIdLang(lang);
jsonValue = jsonObject1.getJsonObject(language).get("value");
value = jsonValue.toString().replace("\"", "");
selectedResource.setGettedValue(value);
traductions.add(selectedResource);
} catch (Exception e) {
}
}
return traductions;
}
Aggregations