-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Reviews to PullRequest entities (#76)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Felix T.J. Dietrich <[email protected]>
- Loading branch information
1 parent
5cf278d
commit 23c3967
Showing
25 changed files
with
483 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...r/application-server/src/main/java/de/tum/in/www1/hephaestus/codereview/base/Comment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package de.tum.in.www1.hephaestus.codereview.base; | ||
|
||
import de.tum.in.www1.hephaestus.codereview.user.User; | ||
import jakarta.persistence.Basic; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.Lob; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.MappedSuperclass; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@MappedSuperclass | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@ToString(callSuper = true) | ||
public abstract class Comment extends BaseGitServiceEntity { | ||
@Lob | ||
@Basic(fetch = FetchType.EAGER) | ||
protected String body; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "author_id") | ||
@ToString.Exclude | ||
protected User author; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...in/java/de/tum/in/www1/hephaestus/codereview/comment/review/PullRequestReviewComment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package de.tum.in.www1.hephaestus.codereview.comment.review; | ||
|
||
import org.springframework.lang.NonNull; | ||
|
||
import de.tum.in.www1.hephaestus.codereview.base.Comment; | ||
import de.tum.in.www1.hephaestus.codereview.pullrequest.review.PullRequestReview; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Entity | ||
@Table(name = "pull_request_review_comment") | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@ToString(callSuper = true) | ||
public class PullRequestReviewComment extends Comment { | ||
@ManyToOne(optional = false) | ||
@JoinColumn(name = "review_id", referencedColumnName = "id") | ||
@ToString.Exclude | ||
private PullRequestReview review; | ||
|
||
@NonNull | ||
private String commit; | ||
} |
22 changes: 22 additions & 0 deletions
22
...e/tum/in/www1/hephaestus/codereview/comment/review/PullRequestReviewCommentConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package de.tum.in.www1.hephaestus.codereview.comment.review; | ||
|
||
import org.kohsuke.github.GHPullRequestReviewComment; | ||
import org.springframework.lang.NonNull; | ||
import org.springframework.stereotype.Component; | ||
|
||
import de.tum.in.www1.hephaestus.codereview.base.BaseGitServiceEntityConverter; | ||
|
||
@Component | ||
public class PullRequestReviewCommentConverter | ||
extends BaseGitServiceEntityConverter<GHPullRequestReviewComment, PullRequestReviewComment> { | ||
|
||
@Override | ||
public PullRequestReviewComment convert(@NonNull GHPullRequestReviewComment source) { | ||
PullRequestReviewComment comment = new PullRequestReviewComment(); | ||
convertBaseFields(source, comment); | ||
comment.setBody(source.getBody()); | ||
comment.setCommit(source.getCommitId()); | ||
return comment; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
.../tum/in/www1/hephaestus/codereview/comment/review/PullRequestReviewCommentRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package de.tum.in.www1.hephaestus.codereview.comment.review; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface PullRequestReviewCommentRepository extends JpaRepository<PullRequestReviewComment, Long> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
.../main/java/de/tum/in/www1/hephaestus/codereview/pullrequest/review/PullRequestReview.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package de.tum.in.www1.hephaestus.codereview.pullrequest.review; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.springframework.lang.NonNull; | ||
|
||
import de.tum.in.www1.hephaestus.codereview.base.BaseGitServiceEntity; | ||
import de.tum.in.www1.hephaestus.codereview.comment.review.PullRequestReviewComment; | ||
import de.tum.in.www1.hephaestus.codereview.pullrequest.PullRequest; | ||
import de.tum.in.www1.hephaestus.codereview.user.User; | ||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Entity | ||
@Table(name = "pull_request_review") | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@ToString(callSuper = true) | ||
public class PullRequestReview extends BaseGitServiceEntity { | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "author_id") | ||
@ToString.Exclude | ||
private User author; | ||
|
||
@NonNull | ||
private PullRequestReviewState state; | ||
|
||
private OffsetDateTime submittedAt; | ||
|
||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "review") | ||
@ToString.Exclude | ||
private Set<PullRequestReviewComment> comments = new HashSet<>(); | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumn(name = "pullrequest_id", referencedColumnName = "id") | ||
@ToString.Exclude | ||
private PullRequest pullRequest; | ||
|
||
public void addComment(PullRequestReviewComment comment) { | ||
comments.add(comment); | ||
} | ||
} |
Oops, something went wrong.