use of mom.trd.opentheso.core.json.helper.JsonHelper in project opentheso by miledrousset.
the class GettyAATHelper 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;
}
use of mom.trd.opentheso.core.json.helper.JsonHelper in project opentheso by miledrousset.
the class OpenthesoHelper method getDescriptions.
/**
* permet de récupérer les descriptions de wikidata
*
* @param jsonDatas
* @param entity
* @param languages
* @return
*/
private ArrayList<SelectedResource> getDescriptions(String jsonDatas, String entity, ArrayList<String> languages) {
ArrayList<SelectedResource> descriptions = 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("descriptions");
} 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);
descriptions.add(selectedResource);
} catch (Exception e) {
}
}
return descriptions;
}
use of mom.trd.opentheso.core.json.helper.JsonHelper 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;
}
use of mom.trd.opentheso.core.json.helper.JsonHelper in project opentheso by miledrousset.
the class WikidataTest method getDescriptions.
private void getDescriptions(String jsonDatas, String entity) {
JsonHelper jsonHelper = new JsonHelper();
JsonObject jsonObject = jsonHelper.getJsonObject(jsonDatas);
// JsonObject test = jsonObject.getJsonObject("entities");
JsonObject jsonObject1;
JsonValue jsonValue;
try {
jsonObject1 = jsonObject.getJsonObject("entities").getJsonObject(entity).getJsonObject("descriptions");
} catch (Exception e) {
System.err.println(e.toString());
return;
}
try {
jsonValue = jsonObject1.getJsonObject("en").get("language");
System.out.println(jsonValue.toString().replace("\"", ""));
jsonValue = jsonObject1.getJsonObject("en").get("value");
System.out.println(jsonValue.toString().replace("\"", ""));
} catch (Exception e) {
}
try {
jsonValue = jsonObject1.getJsonObject("fr").get("language");
System.out.println(jsonValue.toString().replace("\"", ""));
jsonValue = jsonObject1.getJsonObject("fr").get("value");
System.out.println(jsonValue.toString().replace("\"", ""));
} catch (Exception e) {
}
try {
jsonValue = jsonObject1.getJsonObject("ar").get("language");
System.out.println(jsonValue.toString().replace("\"", ""));
jsonValue = jsonObject1.getJsonObject("ar").get("value");
System.out.println(jsonValue.toString().replace("\"", ""));
} catch (Exception e) {
}
}
Aggregations