use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class AudioEditController 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 ImageEditController 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 EmojiEditController method handleRemoveContentLabelRequest.
@RequestMapping(value = "/{id}/remove-content-label", method = RequestMethod.POST)
@ResponseBody
public String handleRemoveContentLabelRequest(HttpServletRequest request, @PathVariable Long id) {
logger.info("handleRemoveContentLabelRequest");
logger.info("id: " + id);
Emoji emoji = emojiDao.read(id);
String wordIdParameter = request.getParameter("wordId");
logger.info("wordIdParameter: " + wordIdParameter);
if (StringUtils.isNotBlank(wordIdParameter)) {
Long wordId = Long.valueOf(wordIdParameter);
Word word = wordDao.read(wordId);
Set<Word> words = emoji.getWords();
Iterator<Word> iterator = words.iterator();
while (iterator.hasNext()) {
Word existingWord = iterator.next();
if (existingWord.getId().equals(word.getId())) {
iterator.remove();
}
}
emoji.setRevisionNumber(emoji.getRevisionNumber() + 1);
emojiDao.update(emoji);
}
return "success";
}
use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class EmojiEditController method handleSubmit.
@RequestMapping(value = "/{id}", method = RequestMethod.POST)
public String handleSubmit(@Valid Emoji emoji, BindingResult result, Model model) {
logger.info("handleSubmit");
Emoji existingEmoji = emojiDao.readByGlyph(emoji.getGlyph());
if ((existingEmoji != null) && !existingEmoji.getId().equals(emoji.getId())) {
result.rejectValue("glyph", "NonUnique");
}
if (emoji.getUnicodeVersion() > 9) {
result.rejectValue("glyph", "emoji.unicode.version");
}
if (result.hasErrors()) {
model.addAttribute("emoji", emoji);
List<Word> words = wordDao.readAllOrdered();
model.addAttribute("words", words);
model.addAttribute("emojisByWordId", getEmojisByWordId());
return "content/emoji/edit";
} else {
emoji.setTimeLastUpdate(Calendar.getInstance());
emoji.setRevisionNumber(emoji.getRevisionNumber() + 1);
emojiDao.update(emoji);
return "redirect:/content/emoji/list#" + emoji.getId();
}
}
use of ai.elimu.model.content.Emoji in project webapp by elimu-ai.
the class EmojiEditController method handleRequest.
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String handleRequest(Model model, @PathVariable Long id) {
logger.info("handleRequest");
Emoji emoji = emojiDao.read(id);
model.addAttribute("emoji", emoji);
List<Word> words = wordDao.readAllOrdered();
model.addAttribute("words", words);
model.addAttribute("emojisByWordId", getEmojisByWordId());
return "content/emoji/edit";
}
Aggregations