Skip to content

Commit

Permalink
Merge pull request elimu-ai#1331 from elimu-ai/fix-#1339-Handle-DataI…
Browse files Browse the repository at this point in the history
…ntegrityViolationException-during-storybook-review

Fix elimu-ai#1339 handle data integrity violation exception during storybook review
  • Loading branch information
nya-elimu authored Jun 23, 2021
2 parents 529fb9f + ecfeb89 commit 04181e9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ai.elimu.model.BaseEntity;
import java.util.Calendar;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
Expand Down Expand Up @@ -36,6 +37,7 @@ public class StoryBookPeerReviewEvent extends BaseEntity {
* Any additional explanations. This field is mandatory only if the
* {@link #storyBookContributionEvent} was <i>not</i> approved.
*/
@Column(length = 1000)
private String comment;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Calendar;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
Expand Down Expand Up @@ -55,7 +56,7 @@ public String handleSubmit(
storyBookPeerReviewEvent.setContributor(contributor);
storyBookPeerReviewEvent.setStoryBookContributionEvent(storyBookContributionEvent);
storyBookPeerReviewEvent.setApproved(approved);
storyBookPeerReviewEvent.setComment(comment);
storyBookPeerReviewEvent.setComment(StringUtils.abbreviate(comment, 1000));
storyBookPeerReviewEvent.setTime(Calendar.getInstance());
storyBookPeerReviewEventDao.create(storyBookPeerReviewEvent);

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/jpa-schema-export.sql
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@
create table StoryBookPeerReviewEvent (
id bigint generated by default as identity (start with 1),
approved boolean,
comment varchar(255),
comment varchar(1000),
time timestamp,
contributor_id bigint,
storyBookContributionEvent_id bigint,
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/db/migration/2001201.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 2.1.201

# Increase comment length from 255 to 1000
ALTER TABLE StoryBookPeerReviewEvent MODIFY `comment` varchar(1000);
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/jsp/content/storybook/edit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@

<div id="peerReviewSubmitContainer" style="display: none;">
<label for="comment"><fmt:message key="comment" /></label>
<textarea id="comment" name="comment" class="materialize-textarea"></textarea>
<textarea id="comment" name="comment" class="materialize-textarea" maxlength="1000"></textarea>

<button class="btn waves-effect waves-light" type="submit">
<fmt:message key="submit" /> <i class="material-icons right">send</i>
Expand Down

0 comments on commit 04181e9

Please sign in to comment.