diff --git a/src/main/java/ai/elimu/dao/LetterSoundPeerReviewEventDao.java b/src/main/java/ai/elimu/dao/LetterSoundPeerReviewEventDao.java index bcb61da88..b53858ff1 100644 --- a/src/main/java/ai/elimu/dao/LetterSoundPeerReviewEventDao.java +++ b/src/main/java/ai/elimu/dao/LetterSoundPeerReviewEventDao.java @@ -3,19 +3,19 @@ import ai.elimu.model.content.LetterSoundCorrespondence; import ai.elimu.model.contributor.Contributor; import ai.elimu.model.contributor.LetterSoundCorrespondenceContributionEvent; -import ai.elimu.model.contributor.LetterSoundCorrespondencePeerReviewEvent; +import ai.elimu.model.contributor.LetterSoundPeerReviewEvent; import java.util.List; import org.springframework.dao.DataAccessException; -public interface LetterSoundPeerReviewEventDao extends GenericDao { +public interface LetterSoundPeerReviewEventDao extends GenericDao { - List readAll(LetterSoundCorrespondenceContributionEvent letterSoundContributionEvent, Contributor contributor) throws DataAccessException; + List readAll(LetterSoundCorrespondenceContributionEvent letterSoundContributionEvent, Contributor contributor) throws DataAccessException; - List readAll(LetterSoundCorrespondence letterSoundCorrespondence) throws DataAccessException; + List readAll(LetterSoundCorrespondence letterSoundCorrespondence) throws DataAccessException; - List readAll(Contributor contributor) throws DataAccessException; + List readAll(Contributor contributor) throws DataAccessException; - List readAll(LetterSoundCorrespondenceContributionEvent letterSoundContributionEvent) throws DataAccessException; + List readAll(LetterSoundCorrespondenceContributionEvent letterSoundContributionEvent) throws DataAccessException; Long readCount(Contributor contributor) throws DataAccessException; } diff --git a/src/main/java/ai/elimu/dao/jpa/LetterSoundPeerReviewEventDaoJpa.java b/src/main/java/ai/elimu/dao/jpa/LetterSoundPeerReviewEventDaoJpa.java index 09fbd47ab..c9729f838 100644 --- a/src/main/java/ai/elimu/dao/jpa/LetterSoundPeerReviewEventDaoJpa.java +++ b/src/main/java/ai/elimu/dao/jpa/LetterSoundPeerReviewEventDaoJpa.java @@ -4,17 +4,17 @@ import ai.elimu.model.content.LetterSoundCorrespondence; import ai.elimu.model.contributor.Contributor; import ai.elimu.model.contributor.LetterSoundCorrespondenceContributionEvent; -import ai.elimu.model.contributor.LetterSoundCorrespondencePeerReviewEvent; +import ai.elimu.model.contributor.LetterSoundPeerReviewEvent; import java.util.List; import org.springframework.dao.DataAccessException; -public class LetterSoundPeerReviewEventDaoJpa extends GenericDaoJpa implements LetterSoundPeerReviewEventDao { +public class LetterSoundPeerReviewEventDaoJpa extends GenericDaoJpa implements LetterSoundPeerReviewEventDao { @Override - public List readAll(LetterSoundCorrespondenceContributionEvent letterSoundContributionEvent, Contributor contributor) throws DataAccessException { + public List readAll(LetterSoundCorrespondenceContributionEvent letterSoundContributionEvent, Contributor contributor) throws DataAccessException { return em.createQuery( "SELECT event " + - "FROM LetterSoundCorrespondencePeerReviewEvent event " + + "FROM LetterSoundPeerReviewEvent event " + "WHERE event.letterSoundContributionEvent = :letterSoundContributionEvent " + "AND event.contributor = :contributor " + "ORDER BY event.time DESC") @@ -24,10 +24,10 @@ public List readAll(LetterSoundCorresp } @Override - public List readAll(LetterSoundCorrespondence letterSound) throws DataAccessException { + public List readAll(LetterSoundCorrespondence letterSound) throws DataAccessException { return em.createQuery( "SELECT event " + - "FROM LetterSoundCorrespondencePeerReviewEvent event " + + "FROM LetterSoundPeerReviewEvent event " + "WHERE event.letterSoundContributionEvent.letterSound = :letterSound " + "ORDER BY event.time DESC") .setParameter("letterSound", letterSound) @@ -35,10 +35,10 @@ public List readAll(LetterSoundCorresp } @Override - public List readAll(Contributor contributor) throws DataAccessException { + public List readAll(Contributor contributor) throws DataAccessException { return em.createQuery( "SELECT event " + - "FROM LetterSoundCorrespondencePeerReviewEvent event " + + "FROM LetterSoundPeerReviewEvent event " + "WHERE event.contributor = :contributor " + "ORDER BY event.time DESC") .setParameter("contributor", contributor) @@ -46,10 +46,10 @@ public List readAll(Contributor contri } @Override - public List readAll(LetterSoundCorrespondenceContributionEvent letterSoundContributionEvent) throws DataAccessException { + public List readAll(LetterSoundCorrespondenceContributionEvent letterSoundContributionEvent) throws DataAccessException { return em.createQuery( "SELECT event " + - "FROM LetterSoundCorrespondencePeerReviewEvent event " + + "FROM LetterSoundPeerReviewEvent event " + "WHERE event.letterSoundContributionEvent = :letterSoundContributionEvent " + "ORDER BY event.time DESC") .setParameter("letterSoundContributionEvent", letterSoundContributionEvent) @@ -59,7 +59,7 @@ public List readAll(LetterSoundCorresp @Override public Long readCount(Contributor contributor) throws DataAccessException { return (Long) em.createQuery("SELECT COUNT(event) " + - "FROM LetterSoundCorrespondencePeerReviewEvent event " + + "FROM LetterSoundPeerReviewEvent event " + "WHERE event.contributor = :contributor") .setParameter("contributor", contributor) .getSingleResult(); diff --git a/src/main/java/ai/elimu/model/contributor/LetterSoundCorrespondencePeerReviewEvent.java b/src/main/java/ai/elimu/model/contributor/LetterSoundPeerReviewEvent.java similarity index 91% rename from src/main/java/ai/elimu/model/contributor/LetterSoundCorrespondencePeerReviewEvent.java rename to src/main/java/ai/elimu/model/contributor/LetterSoundPeerReviewEvent.java index 3e503a379..bd8d23722 100644 --- a/src/main/java/ai/elimu/model/contributor/LetterSoundCorrespondencePeerReviewEvent.java +++ b/src/main/java/ai/elimu/model/contributor/LetterSoundPeerReviewEvent.java @@ -8,7 +8,7 @@ * was added/edited by another {@link Contributor}. */ @Entity -public class LetterSoundCorrespondencePeerReviewEvent extends PeerReviewEvent { +public class LetterSoundPeerReviewEvent extends PeerReviewEvent { /** * The contribution event which is being peer-reviewed. diff --git a/src/main/java/ai/elimu/web/content/letter_sound/LetterSoundPeerReviewsController.java b/src/main/java/ai/elimu/web/content/letter_sound/LetterSoundPeerReviewsController.java index 36a4c2970..d8d7076c3 100644 --- a/src/main/java/ai/elimu/web/content/letter_sound/LetterSoundPeerReviewsController.java +++ b/src/main/java/ai/elimu/web/content/letter_sound/LetterSoundPeerReviewsController.java @@ -6,7 +6,7 @@ import ai.elimu.dao.LetterSoundPeerReviewEventDao; import ai.elimu.model.contributor.Contributor; import ai.elimu.model.contributor.LetterSoundCorrespondenceContributionEvent; -import ai.elimu.model.contributor.LetterSoundCorrespondencePeerReviewEvent; +import ai.elimu.model.contributor.LetterSoundPeerReviewEvent; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpSession; @@ -37,7 +37,7 @@ public class LetterSoundPeerReviewsController { private EmojiDao emojiDao; /** - * Get {@link LetterSoundCorrespondenceContributionEvent}s pending a {@link LetterSoundCorrespondencePeerReviewEvent} for the current {@link Contributor}. + * Get {@link LetterSoundCorrespondenceContributionEvent}s pending a {@link LetterSoundPeerReviewEvent} for the current {@link Contributor}. */ @RequestMapping(method = RequestMethod.GET) public String handleGetRequest(HttpSession session, Model model) { @@ -60,7 +60,7 @@ public String handleGetRequest(HttpSession session, Model model) { } // Check if the current Contributor has already peer-reviewed this LetterSoundCorrespondence contribution - List letterSoundPeerReviewEvents = letterSoundPeerReviewEventDao.readAll(mostRecentLetterSoundContributionEvent, contributor); + List letterSoundPeerReviewEvents = letterSoundPeerReviewEventDao.readAll(mostRecentLetterSoundContributionEvent, contributor); if (letterSoundPeerReviewEvents.isEmpty()) { letterSoundContributionEventsPendingPeerReview.add(mostRecentLetterSoundContributionEvent); } diff --git a/src/main/java/ai/elimu/web/content/peer_review/LetterSoundPeerReviewEventCreateController.java b/src/main/java/ai/elimu/web/content/peer_review/LetterSoundPeerReviewEventCreateController.java index 00bb9cb25..98a6cf181 100644 --- a/src/main/java/ai/elimu/web/content/peer_review/LetterSoundPeerReviewEventCreateController.java +++ b/src/main/java/ai/elimu/web/content/peer_review/LetterSoundPeerReviewEventCreateController.java @@ -8,7 +8,7 @@ import ai.elimu.model.contributor.Contributor; import org.apache.logging.log4j.Logger; import ai.elimu.model.contributor.LetterSoundCorrespondenceContributionEvent; -import ai.elimu.model.contributor.LetterSoundCorrespondencePeerReviewEvent; +import ai.elimu.model.contributor.LetterSoundPeerReviewEvent; import ai.elimu.model.enums.PeerReviewStatus; import ai.elimu.util.DiscordHelper; import ai.elimu.web.context.EnvironmentContextLoaderListener; @@ -54,7 +54,7 @@ public String handleSubmit( logger.info("letterSoundContributionEvent: " + letterSoundContributionEvent); // Store the peer review event - LetterSoundCorrespondencePeerReviewEvent letterSoundPeerReviewEvent = new LetterSoundCorrespondencePeerReviewEvent(); + LetterSoundPeerReviewEvent letterSoundPeerReviewEvent = new LetterSoundPeerReviewEvent(); letterSoundPeerReviewEvent.setContributor(contributor); letterSoundPeerReviewEvent.setLetterSoundContributionEvent(letterSoundContributionEvent); letterSoundPeerReviewEvent.setApproved(approved); @@ -76,7 +76,7 @@ public String handleSubmit( // Update the peer review status int approvedCount = 0; int notApprovedCount = 0; - for (LetterSoundCorrespondencePeerReviewEvent peerReviewEvent : letterSoundPeerReviewEventDao.readAll(letterSoundContributionEvent)) { + for (LetterSoundPeerReviewEvent peerReviewEvent : letterSoundPeerReviewEventDao.readAll(letterSoundContributionEvent)) { if (peerReviewEvent.isApproved()) { approvedCount++; } else { diff --git a/src/main/resources/META-INF/jpa-schema-export.sql b/src/main/resources/META-INF/jpa-schema-export.sql index ca81c418e..564175b21 100644 --- a/src/main/resources/META-INF/jpa-schema-export.sql +++ b/src/main/resources/META-INF/jpa-schema-export.sql @@ -63,7 +63,7 @@ drop table if exists LetterSoundCorrespondenceContributionEvent; - drop table if exists LetterSoundCorrespondencePeerReviewEvent; + drop table if exists LetterSoundPeerReviewEvent; drop table if exists Number; @@ -410,7 +410,7 @@ primary key (id) ) engine=MyISAM; - create table LetterSoundCorrespondencePeerReviewEvent ( + create table LetterSoundPeerReviewEvent ( id bigint not null auto_increment, approved bit, comment varchar(1000), @@ -907,13 +907,13 @@ foreign key (letterSound_id) references LetterSoundCorrespondence (id); - alter table LetterSoundCorrespondencePeerReviewEvent - add constraint FKnx18la2q9jr95bmprkttiymxc + alter table LetterSoundPeerReviewEvent + add constraint FK3wapf4y5anhgnjbqna2qjyie4 foreign key (contributor_id) references Contributor (id); - alter table LetterSoundCorrespondencePeerReviewEvent - add constraint FKff8dsceebikiyr8csxbxn6ml0 + alter table LetterSoundPeerReviewEvent + add constraint FK4ec0wl5mmi2uh5sg7ll20dyjk foreign key (letterSoundContributionEvent_id) references LetterSoundCorrespondenceContributionEvent (id); diff --git a/src/main/resources/db/migration/2004010.sql b/src/main/resources/db/migration/2004010.sql new file mode 100644 index 000000000..3a2ef8b56 --- /dev/null +++ b/src/main/resources/db/migration/2004010.sql @@ -0,0 +1,5 @@ +# 2.4.10 + +# "LetterSoundCorrespondencePeerReviewEvent" → "LetterSoundPeerReviewEvent" +DROP TABLE `LetterSoundPeerReviewEvent`; +ALTER TABLE `LetterSoundCorrespondencePeerReviewEvent` RENAME `LetterSoundPeerReviewEvent`;