-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create FeedbackResponse and FeedbackResponseComment entities #12135
Changes from 2 commits
2363f6b
4bd2bbd
d762867
5328dfd
abf2a63
9e24716
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,185 @@ | ||||||||||
package teammates.storage.sqlentity; | ||||||||||
|
||||||||||
import java.time.Instant; | ||||||||||
import java.util.ArrayList; | ||||||||||
import java.util.List; | ||||||||||
import java.util.Objects; | ||||||||||
import java.util.UUID; | ||||||||||
|
||||||||||
import org.hibernate.annotations.UpdateTimestamp; | ||||||||||
|
||||||||||
import teammates.common.datatransfer.questions.FeedbackQuestionType; | ||||||||||
|
||||||||||
import jakarta.persistence.Column; | ||||||||||
import jakarta.persistence.Convert; | ||||||||||
import jakarta.persistence.Entity; | ||||||||||
import jakarta.persistence.Id; | ||||||||||
import jakarta.persistence.Inheritance; | ||||||||||
import jakarta.persistence.InheritanceType; | ||||||||||
import jakarta.persistence.JoinColumn; | ||||||||||
import jakarta.persistence.ManyToOne; | ||||||||||
import jakarta.persistence.OneToMany; | ||||||||||
import jakarta.persistence.OneToOne; | ||||||||||
import jakarta.persistence.Table; | ||||||||||
|
||||||||||
/** | ||||||||||
* Represents a Feedback Response. | ||||||||||
*/ | ||||||||||
@Entity | ||||||||||
@Table(name = "FeedbackReponses") | ||||||||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) | ||||||||||
public abstract class FeedbackResponse extends BaseEntity { | ||||||||||
@Id | ||||||||||
private UUID id; | ||||||||||
|
||||||||||
@ManyToOne | ||||||||||
@JoinColumn(name = "questionId") | ||||||||||
private FeedbackQuestion feedbackQuestion; | ||||||||||
|
||||||||||
@Column(nullable = false) | ||||||||||
@Convert(converter = FeedbackParticipantTypeConverter.class) | ||||||||||
private FeedbackQuestionType type; | ||||||||||
|
||||||||||
@OneToMany(mappedBy = "feedbackResponse") | ||||||||||
private List<FeedbackResponseComment> feedbackResponseComments = new ArrayList<>(); | ||||||||||
|
||||||||||
@Column(nullable = false) | ||||||||||
private String giver; | ||||||||||
|
||||||||||
@OneToOne | ||||||||||
@JoinColumn(name = "giverSectionId") | ||||||||||
private Section giverSection; | ||||||||||
|
||||||||||
@Column(nullable = false) | ||||||||||
private String receiver; | ||||||||||
|
||||||||||
@OneToOne | ||||||||||
@JoinColumn(name = "receiverSectionId") | ||||||||||
private Section receiverSection; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed! |
||||||||||
|
||||||||||
@UpdateTimestamp | ||||||||||
private Instant updatedAt; | ||||||||||
|
||||||||||
protected FeedbackResponse() { | ||||||||||
// required by Hibernate | ||||||||||
} | ||||||||||
|
||||||||||
public FeedbackResponse( | ||||||||||
FeedbackQuestion feedbackQuestion, FeedbackQuestionType type, String giver, | ||||||||||
Section giverSection, String receiver, Section receiverSection | ||||||||||
) { | ||||||||||
this.setFeedbackQuestion(feedbackQuestion); | ||||||||||
this.setFeedbackQuestionType(type); | ||||||||||
this.setGiver(giver); | ||||||||||
this.setGiverSection(giverSection); | ||||||||||
this.setReceiver(receiver); | ||||||||||
this.setReceiverSection(receiverSection); | ||||||||||
} | ||||||||||
|
||||||||||
public UUID getId() { | ||||||||||
return id; | ||||||||||
} | ||||||||||
|
||||||||||
public void setId(UUID id) { | ||||||||||
this.id = id; | ||||||||||
} | ||||||||||
|
||||||||||
public FeedbackQuestion getFeedbackQuestion() { | ||||||||||
return feedbackQuestion; | ||||||||||
} | ||||||||||
|
||||||||||
public void setFeedbackQuestion(FeedbackQuestion feedbackQuestion) { | ||||||||||
this.feedbackQuestion = feedbackQuestion; | ||||||||||
} | ||||||||||
|
||||||||||
public FeedbackQuestionType getFeedbackQuestionType() { | ||||||||||
return type; | ||||||||||
} | ||||||||||
|
||||||||||
public void setFeedbackQuestionType(FeedbackQuestionType type) { | ||||||||||
this.type = type; | ||||||||||
} | ||||||||||
|
||||||||||
public List<FeedbackResponseComment> getFeedbackResponseComments() { | ||||||||||
return feedbackResponseComments; | ||||||||||
} | ||||||||||
|
||||||||||
public void setFeedbackResponseComments(List<FeedbackResponseComment> feedbackResponseComments) { | ||||||||||
this.feedbackResponseComments = feedbackResponseComments; | ||||||||||
} | ||||||||||
|
||||||||||
public String getGiver() { | ||||||||||
return giver; | ||||||||||
} | ||||||||||
|
||||||||||
public void setGiver(String giver) { | ||||||||||
this.giver = giver; | ||||||||||
} | ||||||||||
|
||||||||||
public Section getGiverSection() { | ||||||||||
return giverSection; | ||||||||||
} | ||||||||||
|
||||||||||
public void setGiverSection(Section giverSection) { | ||||||||||
this.giverSection = giverSection; | ||||||||||
} | ||||||||||
|
||||||||||
public String getReceiver() { | ||||||||||
return receiver; | ||||||||||
} | ||||||||||
|
||||||||||
public void setReceiver(String receiver) { | ||||||||||
this.receiver = receiver; | ||||||||||
} | ||||||||||
|
||||||||||
public Section getReceiverSection() { | ||||||||||
return receiverSection; | ||||||||||
} | ||||||||||
|
||||||||||
public void setReceiverSection(Section receiverSection) { | ||||||||||
this.receiverSection = receiverSection; | ||||||||||
} | ||||||||||
|
||||||||||
public Instant getUpdatedAt() { | ||||||||||
return updatedAt; | ||||||||||
} | ||||||||||
|
||||||||||
public void setUpdatedAt(Instant updatedAt) { | ||||||||||
this.updatedAt = updatedAt; | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public List<String> getInvalidityInfo() { | ||||||||||
/* | ||||||||||
* The old FeedbackResponse checks invalidity info for courseId and sessionName, | ||||||||||
* which do not exist on this new entity. | ||||||||||
*/ | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||||||||||
return new ArrayList<>(); | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public String toString() { | ||||||||||
return "FeedbackResponse [id=" + id + ", giver=" + giver + ", receiver=" + receiver | ||||||||||
+ ", createdAt=" + getCreatedAt() + ", updatedAt=" + updatedAt + "]"; | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public int hashCode() { | ||||||||||
// FeedbackQuestion ID uniquely identifies a Feedback Response. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed! |
||||||||||
return this.getId().hashCode(); | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public boolean equals(Object other) { | ||||||||||
if (other == null) { | ||||||||||
return false; | ||||||||||
} else if (this == other) { | ||||||||||
return true; | ||||||||||
} else if (this.getClass() == other.getClass()) { | ||||||||||
FeedbackResponse otherResponse = (FeedbackResponse) other; | ||||||||||
return Objects.equals(this.id, otherResponse.id); | ||||||||||
} else { | ||||||||||
return false; | ||||||||||
} | ||||||||||
} | ||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a OneToOne relationship. Multiple responses can have the same giverSection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, changed to
ManyToOne