use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class WordListController method getEmojisByWordId.
private Map<Long, String> getEmojisByWordId() {
logger.info("getEmojisByWordId");
Map<Long, String> emojisByWordId = new HashMap<>();
for (Word word : wordDao.readAll()) {
String emojiGlyphs = "";
List<Emoji> emojis = emojiDao.readAllLabeled(word);
for (Emoji emoji : emojis) {
emojiGlyphs += emoji.getGlyph();
}
if (StringUtils.isNotBlank(emojiGlyphs)) {
emojisByWordId.put(word.getId(), emojiGlyphs);
}
}
return emojisByWordId;
}
use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class WordEditController method handleSubmit.
@RequestMapping(value = "/{id}", method = RequestMethod.POST)
public String handleSubmit(HttpServletRequest request, HttpSession session, @Valid Word word, BindingResult result, Model model) {
logger.info("handleSubmit");
Word existingWord = wordDao.readByText(word.getText());
if ((existingWord != null) && !existingWord.getId().equals(word.getId())) {
result.rejectValue("text", "NonUnique");
}
if (StringUtils.containsAny(word.getText(), " ")) {
result.rejectValue("text", "WordSpace");
}
if (result.hasErrors()) {
model.addAttribute("word", word);
model.addAttribute("timeStart", request.getParameter("timeStart"));
// TODO: sort by letter(s) text
model.addAttribute("letterSoundCorrespondences", letterSoundCorrespondenceDao.readAllOrderedByUsage());
model.addAttribute("rootWords", wordDao.readAllOrdered());
model.addAttribute("emojisByWordId", getEmojisByWordId());
model.addAttribute("wordTypes", WordType.values());
model.addAttribute("spellingConsistencies", SpellingConsistency.values());
model.addAttribute("wordContributionEvents", wordContributionEventDao.readAll(word));
model.addAttribute("wordPeerReviewEvents", wordPeerReviewEventDao.readAll(word));
model.addAttribute("audios", audioDao.readAll(word));
// Look up variants of the same wordByTextMatch
model.addAttribute("wordInflections", wordDao.readInflections(word));
// Look up Multimedia content that has been labeled with this Word
// TODO: labeled Audios
List<Emoji> labeledEmojis = emojiDao.readAllLabeled(word);
model.addAttribute("labeledEmojis", labeledEmojis);
List<Image> labeledImages = imageDao.readAllLabeled(word);
model.addAttribute("labeledImages", labeledImages);
return "content/word/edit";
} else {
word.setTimeLastUpdate(Calendar.getInstance());
word.setRevisionNumber(word.getRevisionNumber() + 1);
wordDao.update(word);
WordContributionEvent wordContributionEvent = new WordContributionEvent();
wordContributionEvent.setContributor((Contributor) session.getAttribute("contributor"));
wordContributionEvent.setTime(Calendar.getInstance());
wordContributionEvent.setWord(word);
wordContributionEvent.setRevisionNumber(word.getRevisionNumber());
wordContributionEvent.setComment(StringUtils.abbreviate(request.getParameter("contributionComment"), 1000));
wordContributionEvent.setTimeSpentMs(System.currentTimeMillis() - Long.valueOf(request.getParameter("timeStart")));
wordContributionEvent.setPlatform(Platform.WEBAPP);
wordContributionEventDao.create(wordContributionEvent);
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/word/edit/" + word.getId();
DiscordHelper.sendChannelMessage("Word edited: " + contentUrl, "\"" + word.getText() + "\"", "Comment: \"" + wordContributionEvent.getComment() + "\"", null, null);
// Note: updating the list of Words in StoryBookParagraphs is handled by the ParagraphWordScheduler
// Delete syllables that are actual words
Syllable syllable = syllableDao.readByText(word.getText());
if (syllable != null) {
syllableDao.delete(syllable);
}
return "redirect:/content/word/list#" + word.getId();
}
}
use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class WordPeerReviewsController method getEmojisByWordId.
private Map<Long, String> getEmojisByWordId() {
logger.info("getEmojisByWordId");
Map<Long, String> emojisByWordId = new HashMap<>();
for (Word word : wordDao.readAll()) {
String emojiGlyphs = "";
List<Emoji> emojis = emojiDao.readAllLabeled(word);
for (Emoji emoji : emojis) {
emojiGlyphs += emoji.getGlyph();
}
if (StringUtils.isNotBlank(emojiGlyphs)) {
emojisByWordId.put(word.getId(), emojiGlyphs);
}
}
return emojisByWordId;
}
use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class ImageListController method getEmojisByWordId.
private Map<Long, String> getEmojisByWordId() {
logger.info("getEmojisByWordId");
Map<Long, String> emojisByWordId = new HashMap<>();
for (Word word : wordDao.readAll()) {
String emojiGlyphs = "";
List<Emoji> emojis = emojiDao.readAllLabeled(word);
for (Emoji emoji : emojis) {
emojiGlyphs += emoji.getGlyph();
}
if (StringUtils.isNotBlank(emojiGlyphs)) {
emojisByWordId.put(word.getId(), emojiGlyphs);
}
}
return emojisByWordId;
}
use of ai.elimu.model.content.Emoji 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