use of ai.elimu.model.gson.content.SyllableGson in project webapp by elimu-ai.
the class JavaToGsonConverter method getSyllableGson.
public static SyllableGson getSyllableGson(Syllable syllable) {
if (syllable == null) {
return null;
} else {
SyllableGson syllableGson = new SyllableGson();
syllableGson.setId(syllable.getId());
syllableGson.setLocale(syllable.getLocale());
syllableGson.setTimeLastUpdate(syllable.getTimeLastUpdate());
syllableGson.setRevisionNumber(syllable.getRevisionNumber());
syllableGson.setContentStatus(syllable.getContentStatus());
syllableGson.setText(syllable.getText());
List<AllophoneGson> allophones = new ArrayList<>();
for (Allophone allophone : syllable.getAllophones()) {
AllophoneGson allophoneGson = getAllophoneGson(allophone);
allophones.add(allophoneGson);
}
syllableGson.setAllophones(allophones);
syllableGson.setUsageCount(syllable.getUsageCount());
return syllableGson;
}
}
use of ai.elimu.model.gson.content.SyllableGson in project webapp by elimu-ai.
the class SyllableRestController method list.
@RequestMapping("/list")
public String list(HttpServletRequest request, @RequestParam String deviceId, // TODO: checksum,
@RequestParam Locale locale) {
logger.info("list");
logger.info("request.getQueryString(): " + request.getQueryString());
JSONArray syllables = new JSONArray();
for (Syllable syllable : syllableDao.readAllOrdered(locale)) {
SyllableGson syllableGson = JavaToGsonConverter.getSyllableGson(syllable);
String json = new Gson().toJson(syllableGson);
syllables.put(new JSONObject(json));
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("result", "success");
jsonObject.put("syllables", syllables);
logger.info("jsonObject: " + jsonObject);
return jsonObject.toString();
}
Aggregations