diff --git a/core/src/main/java/se/su/dsv/scipro/checklist/ChecklistAnswer.java b/core/src/main/java/se/su/dsv/scipro/checklist/ChecklistAnswer.java index 28e61ce945..704f907f40 100755 --- a/core/src/main/java/se/su/dsv/scipro/checklist/ChecklistAnswer.java +++ b/core/src/main/java/se/su/dsv/scipro/checklist/ChecklistAnswer.java @@ -2,6 +2,7 @@ package se.su.dsv.scipro.checklist; import java.util.Objects; +import jakarta.persistence.Basic; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; @@ -20,22 +21,34 @@ import se.su.dsv.scipro.system.User; @Entity @Table(name = "checklist_answer") public class ChecklistAnswer extends DomainObject { + // ---------------------------------------------------------------------------------- + // Basic JPA-mappings + // ---------------------------------------------------------------------------------- @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Enumerated(EnumType.STRING) + @Basic @Column(name = "answer", nullable = false) + @Enumerated(EnumType.STRING) private ChecklistAnswerEnum answer; - @ManyToOne(optional = false) - @JoinColumn(name = "user_id") - private User user; - + @Basic + @Column(name = "comment") @Lob - @Column private String comment; + // ---------------------------------------------------------------------------------- + // JPA-mappings of foreign keys in this table (checklist_answer) referencing other + // tables. + // ---------------------------------------------------------------------------------- + @ManyToOne(optional = false) + @JoinColumn(name = "user_id", referencedColumnName = "id") + private User user; + + // ---------------------------------------------------------------------------------- + // Constructors + // ---------------------------------------------------------------------------------- protected ChecklistAnswer() { } @@ -48,44 +61,45 @@ public class ChecklistAnswer extends DomainObject { this.answer = answer != null ? answer : ChecklistAnswerEnum.NO_ANSWER; } + // ---------------------------------------------------------------------------------- + // Properties (Getters and Setters) + // ---------------------------------------------------------------------------------- @Override public Long getId() { return this.id; } - public ChecklistAnswerEnum getAnswer() { - return this.answer; - } - - public User getUser() { - return this.user; - } - - public String getComment() { - return this.comment; - } - public void setId(Long id) { this.id = id; } + public ChecklistAnswerEnum getAnswer() { + return this.answer; + } + public void setAnswer(ChecklistAnswerEnum answer) { this.answer = answer; } - public void setUser(User user) { - this.user = user; + public String getComment() { + return this.comment; } public void setComment(String comment) { this.comment = comment; } - @Override - public String toString() { - return "ChecklistAnswer(id=" + this.getId() + ", answer=" + this.getAnswer() + ", user=" + this.getUser() + ", comment=" + this.getComment() + ")"; + public User getUser() { + return this.user; } + public void setUser(User user) { + this.user = user; + } + + // ---------------------------------------------------------------------------------- + // Methods Common To All Objects + // ---------------------------------------------------------------------------------- @Override public boolean equals(final Object o) { if (o == this) return true; @@ -95,12 +109,21 @@ public class ChecklistAnswer extends DomainObject { && Objects.equals(this.getId(), other.getId()); } - protected boolean canEqual(final Object other) { - return other instanceof ChecklistAnswer; - } - @Override public int hashCode() { return Objects.hashCode(this.getId()); } + + @Override + public String toString() { + return "ChecklistAnswer(id=" + this.getId() + ", answer=" + this.getAnswer() + ", user=" + this.getUser() + + ", comment=" + this.getComment() + ")"; + } + + // ---------------------------------------------------------------------------------- + // Other Methods + // ---------------------------------------------------------------------------------- + protected boolean canEqual(final Object other) { + return other instanceof ChecklistAnswer; + } } \ No newline at end of file diff --git a/core/src/main/resources/db/migration/V390__harmonize_table_attribute_name.sql b/core/src/main/resources/db/migration/V390__harmonize_table_attribute_name.sql index 03bd459f50..b6cbe5a000 100644 --- a/core/src/main/resources/db/migration/V390__harmonize_table_attribute_name.sql +++ b/core/src/main/resources/db/migration/V390__harmonize_table_attribute_name.sql @@ -1363,6 +1363,9 @@ alter table `checklist_answer` foreign key (user_id) references user (id) on delete cascade on update cascade; +-- update to NOT_APPLICABLE because of typo in code +update `checklist_answer` set answer = 'NOT_APPLICABLE' where answer = 'NOT_APLICABLE'; + -- table: checklist_question alter table `checklist_question` rename column `questionNumber` to `question_number`;