From 987f4120644ab84861c13b085fb3fa2135aedb89 Mon Sep 17 00:00:00 2001 From: venkatesh2k3 Date: Thu, 25 Jul 2024 16:58:17 +0530 Subject: [PATCH] Added LetterSound --- .../content/letter/LetterEditController.java | 38 ++++++++++++++----- .../WEB-INF/jsp/content/letter/edit.jsp | 5 ++- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/main/java/ai/elimu/web/content/letter/LetterEditController.java b/src/main/java/ai/elimu/web/content/letter/LetterEditController.java index 68dba699c..6266eab0a 100644 --- a/src/main/java/ai/elimu/web/content/letter/LetterEditController.java +++ b/src/main/java/ai/elimu/web/content/letter/LetterEditController.java @@ -1,20 +1,15 @@ package ai.elimu.web.content.letter; import java.util.Calendar; -import javax.validation.Valid; +import java.util.List; -import org.apache.logging.log4j.Logger; -import ai.elimu.dao.LetterContributionEventDao; -import ai.elimu.dao.LetterDao; -import ai.elimu.model.content.Letter; -import ai.elimu.model.contributor.Contributor; -import ai.elimu.model.contributor.LetterContributionEvent; -import ai.elimu.util.DiscordHelper; -import ai.elimu.web.context.EnvironmentContextLoaderListener; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import javax.validation.Valid; + import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -23,6 +18,16 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import ai.elimu.dao.LetterContributionEventDao; +import ai.elimu.dao.LetterDao; +import ai.elimu.dao.LetterSoundDao; +import ai.elimu.model.content.Letter; +import ai.elimu.model.content.LetterSoundCorrespondence; +import ai.elimu.model.contributor.Contributor; +import ai.elimu.model.contributor.LetterContributionEvent; +import ai.elimu.util.DiscordHelper; +import ai.elimu.web.context.EnvironmentContextLoaderListener; + @Controller @RequestMapping("/content/letter/edit") public class LetterEditController { @@ -32,6 +37,9 @@ public class LetterEditController { @Autowired private LetterDao letterDao; + @Autowired + private LetterSoundDao letterSoundDao; + @Autowired private LetterContributionEventDao letterContributionEventDao; @@ -46,7 +54,17 @@ public String handleRequest( model.addAttribute("timeStart", System.currentTimeMillis()); model.addAttribute("letterContributionEvents", letterContributionEventDao.readAll(letter)); - + + List letterSounds = letterSoundDao.readAllOrderedByUsage(); + model.addAttribute("letterSounds", letterSounds); + + int maxUsageCount = 0; + for (LetterSoundCorrespondence letterSound : letterSounds) { + if (letterSound.getUsageCount() > maxUsageCount) { + maxUsageCount = letterSound.getUsageCount(); + } + } + model.addAttribute("maxUsageCount", maxUsageCount); return "content/letter/edit"; } diff --git a/src/main/webapp/WEB-INF/jsp/content/letter/edit.jsp b/src/main/webapp/WEB-INF/jsp/content/letter/edit.jsp index 1fe242f9a..d6750576d 100644 --- a/src/main/webapp/WEB-INF/jsp/content/letter/edit.jsp +++ b/src/main/webapp/WEB-INF/jsp/content/letter/edit.jsp @@ -185,9 +185,9 @@ -
+
(${fn:length(letterSounds)})
- + @@ -222,6 +222,7 @@
+