use of ai.elimu.model.v2.gson.content.EmojiGson in project webapp by elimu-ai.
the class JpaToGsonConverter method getEmojiGson.
public static EmojiGson getEmojiGson(Emoji emoji) {
if (emoji == null) {
return null;
} else {
EmojiGson emojiGson = new EmojiGson();
// BaseEntity
emojiGson.setId(emoji.getId());
// Content
emojiGson.setRevisionNumber(emoji.getRevisionNumber());
emojiGson.setUsageCount(emoji.getUsageCount());
// Emoji
emojiGson.setGlyph(emoji.getGlyph());
emojiGson.setUnicodeVersion(emoji.getUnicodeVersion());
emojiGson.setUnicodeEmojiVersion(emoji.getUnicodeEmojiVersion());
Set<WordGson> wordGsons = new HashSet<>();
for (Word word : emoji.getWords()) {
WordGson wordGson = new WordGson();
wordGson.setId(word.getId());
wordGsons.add(wordGson);
}
emojiGson.setWords(wordGsons);
return emojiGson;
}
}
use of ai.elimu.model.v2.gson.content.EmojiGson in project webapp by elimu-ai.
the class EmojisRestController method handleGetRequest.
@RequestMapping(method = RequestMethod.GET)
public String handleGetRequest(HttpServletRequest request) {
logger.info("handleGetRequest");
JSONArray emojisJsonArray = new JSONArray();
for (Emoji emoji : emojiDao.readAllOrdered()) {
EmojiGson emojiGson = JpaToGsonConverter.getEmojiGson(emoji);
String json = new Gson().toJson(emojiGson);
emojisJsonArray.put(new JSONObject(json));
}
String jsonResponse = emojisJsonArray.toString();
logger.info("jsonResponse: " + jsonResponse);
return jsonResponse;
}
Aggregations