Skip to content

Commit

Permalink
refactor(dao): LetterSoundCorrespondenceContributionEvent#letterSounds
Browse files Browse the repository at this point in the history
refs #1677
  • Loading branch information
jo-elimu committed Jul 13, 2024
1 parent a0d4964 commit 05cc2b5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ public class LetterSoundCorrespondenceContributionEvent extends ContributionEven

@NotNull
@ManyToOne
private LetterSoundCorrespondence letterSoundCorrespondence;
private LetterSoundCorrespondence letterSound;

public LetterSoundCorrespondence getLetterSoundCorrespondence() {
return letterSoundCorrespondence;
public LetterSoundCorrespondence getLetterSound() {
return letterSound;
}

public void setLetterSoundCorrespondence(LetterSoundCorrespondence letterSoundCorrespondence) {
this.letterSoundCorrespondence = letterSoundCorrespondence;
public void setLetterSound(LetterSoundCorrespondence letterSound) {
this.letterSound = letterSound;
}
}
2 changes: 1 addition & 1 deletion src/main/java/ai/elimu/util/db/DbContentImportHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public synchronized void performDatabaseContentImport(Environment environment, L

LetterSoundCorrespondenceContributionEvent letterSoundContributionEvent = new LetterSoundCorrespondenceContributionEvent();
letterSoundContributionEvent.setContributor(contributor);
letterSoundContributionEvent.setLetterSoundCorrespondence(letterSound);
letterSoundContributionEvent.setLetterSound(letterSound);
letterSoundContributionEvent.setRevisionNumber(1);
letterSoundContributionEvent.setTime(Calendar.getInstance());
letterSoundContributionEvent.setTimeSpentMs((long)(Math.random() * 10) * 60000L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public String handleSubmit(
LetterSoundCorrespondenceContributionEvent letterSoundContributionEvent = new LetterSoundCorrespondenceContributionEvent();
letterSoundContributionEvent.setContributor((Contributor) session.getAttribute("contributor"));
letterSoundContributionEvent.setTime(Calendar.getInstance());
letterSoundContributionEvent.setLetterSoundCorrespondence(letterSound);
letterSoundContributionEvent.setLetterSound(letterSound);
letterSoundContributionEvent.setRevisionNumber(letterSound.getRevisionNumber());
letterSoundContributionEvent.setComment(StringUtils.abbreviate(request.getParameter("contributionComment"), 1000));
letterSoundContributionEvent.setTimeSpentMs(System.currentTimeMillis() - Long.valueOf(request.getParameter("timeStart")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public String handleSubmit(
LetterSoundCorrespondenceContributionEvent letterSoundContributionEvent = new LetterSoundCorrespondenceContributionEvent();
letterSoundContributionEvent.setContributor((Contributor) session.getAttribute("contributor"));
letterSoundContributionEvent.setTime(Calendar.getInstance());
letterSoundContributionEvent.setLetterSoundCorrespondence(letterSound);
letterSoundContributionEvent.setLetterSound(letterSound);
letterSoundContributionEvent.setRevisionNumber(letterSound.getRevisionNumber());
letterSoundContributionEvent.setComment(StringUtils.abbreviate(request.getParameter("contributionComment"), 1000));
letterSoundContributionEvent.setTimeSpentMs(System.currentTimeMillis() - Long.valueOf(request.getParameter("timeStart")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public String handleSubmit(
letterSoundPeerReviewEventDao.create(letterSoundPeerReviewEvent);

if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/letterSoundCorrespondence/edit/" + letterSoundContributionEvent.getLetterSoundCorrespondence().getId();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/letterSoundCorrespondence/edit/" + letterSoundContributionEvent.getLetterSound().getId();
DiscordHelper.sendChannelMessage(
"Letter-sound correspondence peer-reviewed: " + contentUrl,
"\"" + letterSoundContributionEvent.getLetterSoundCorrespondence().getLetters().stream().map(Letter::getText).collect(Collectors.joining()) + "\"",
"\"" + letterSoundContributionEvent.getLetterSound().getLetters().stream().map(Letter::getText).collect(Collectors.joining()) + "\"",
"Comment: \"" + letterSoundPeerReviewEvent.getComment() + "\"",
letterSoundPeerReviewEvent.isApproved(),
null
Expand All @@ -85,14 +85,14 @@ public String handleSubmit(
}
logger.info("approvedCount: " + approvedCount);
logger.info("notApprovedCount: " + notApprovedCount);
LetterSoundCorrespondence letterSound = letterSoundContributionEvent.getLetterSoundCorrespondence();
LetterSoundCorrespondence letterSound = letterSoundContributionEvent.getLetterSound();
if (approvedCount >= notApprovedCount) {
letterSound.setPeerReviewStatus(PeerReviewStatus.APPROVED);
} else {
letterSound.setPeerReviewStatus(PeerReviewStatus.NOT_APPROVED);
}
letterSoundDao.update(letterSound);

return "redirect:/content/letter-sound/edit/" + letterSoundContributionEvent.getLetterSoundCorrespondence().getId() + "#contribution-events";
return "redirect:/content/letter-sound/edit/" + letterSoundContributionEvent.getLetterSound().getId() + "#contribution-events";
}
}
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/jpa-schema-export.sql
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@
time datetime,
timeSpentMs bigint,
contributor_id bigint,
letterSoundCorrespondence_id bigint,
letterSound_id bigint,
primary key (id)
) engine=MyISAM;

Expand Down Expand Up @@ -903,8 +903,8 @@
references Contributor (id);

alter table LetterSoundCorrespondenceContributionEvent
add constraint FKm1rttrlv6gxibd85a5sc3c4js
foreign key (letterSoundCorrespondence_id)
add constraint FKmgdglk92d302rk5e2fokfc77b
foreign key (letterSound_id)
references LetterSoundCorrespondence (id);

alter table LetterSoundCorrespondencePeerReviewEvent
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/db/migration/2004008.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 2.4.8

# "letterSoundCorrespondence" → "letterSound"
ALTER TABLE `LetterSoundCorrespondenceContributionEvent` DROP COLUMN `letterSound_id`;
ALTER TABLE `LetterSoundCorrespondenceContributionEvent` CHANGE `letterSoundCorrespondence_id` `letterSound_id` bigint(20) NOT NULL;

0 comments on commit 05cc2b5

Please sign in to comment.