| 1 | package edu.ucsb.cs156.frontiers.entities; | |
| 2 | ||
| 3 | import com.fasterxml.jackson.annotation.JsonAlias; | |
| 4 | import com.fasterxml.jackson.databind.JsonNode; | |
| 5 | import jakarta.persistence.Entity; | |
| 6 | import jakarta.persistence.ForeignKey; | |
| 7 | import jakarta.persistence.GeneratedValue; | |
| 8 | import jakarta.persistence.Id; | |
| 9 | import jakarta.persistence.Index; | |
| 10 | import jakarta.persistence.JoinColumn; | |
| 11 | import jakarta.persistence.JoinColumns; | |
| 12 | import jakarta.persistence.ManyToOne; | |
| 13 | import jakarta.persistence.Table; | |
| 14 | import jakarta.persistence.UniqueConstraint; | |
| 15 | import jakarta.validation.constraints.NotNull; | |
| 16 | import java.time.Instant; | |
| 17 | import lombok.AllArgsConstructor; | |
| 18 | import lombok.Builder; | |
| 19 | import lombok.Data; | |
| 20 | import lombok.NoArgsConstructor; | |
| 21 | import org.hibernate.annotations.OnDelete; | |
| 22 | import org.hibernate.annotations.OnDeleteAction; | |
| 23 | ||
| 24 | @Data | |
| 25 | @AllArgsConstructor | |
| 26 | @NoArgsConstructor | |
| 27 | @Builder | |
| 28 | @Entity | |
| 29 | @Table( | |
| 30 | name = "commits", | |
| 31 | uniqueConstraints = {@UniqueConstraint(columnNames = {"org", "repo", "branch", "sha"})}, | |
| 32 | indexes = {@Index(name = "idx_commit_filtering", columnList = "org, repo, branch, commitTime")}) | |
| 33 | public class Commit { | |
| 34 | ||
| 35 | @Id | |
| 36 | @GeneratedValue(strategy = jakarta.persistence.GenerationType.IDENTITY) | |
| 37 | private Long id; | |
| 38 | ||
| 39 | @JoinColumns( | |
| 40 | value = { | |
| 41 | @JoinColumn(name = "org", referencedColumnName = "org"), | |
| 42 | @JoinColumn(name = "repo", referencedColumnName = "repo"), | |
| 43 | @JoinColumn(name = "branch", referencedColumnName = "branchName"), | |
| 44 | }, | |
| 45 | foreignKey = @ForeignKey(name = "fk_commits_branch")) | |
| 46 | @OnDelete(action = OnDeleteAction.CASCADE) | |
| 47 | @ManyToOne | |
| 48 | @NotNull | |
| 49 | private Branch branch; | |
| 50 | ||
| 51 | @JsonAlias("oid") | |
| 52 | @NotNull | |
| 53 | private String sha; | |
| 54 | ||
| 55 | private String url; | |
| 56 | ||
| 57 | @JsonAlias("messageHeadline") | |
| 58 | private String message; | |
| 59 | ||
| 60 | @JsonAlias("committedDate") | |
| 61 | private Instant commitTime; | |
| 62 | ||
| 63 | private String committerName; | |
| 64 | private String committerEmail; | |
| 65 | private String committerLogin; | |
| 66 | private String authorName; | |
| 67 | private String authorEmail; | |
| 68 | private String authorLogin; | |
| 69 | private boolean isMergeCommit; | |
| 70 | ||
| 71 | @JsonAlias("author") | |
| 72 | public void setAuthor(JsonNode node) { | |
| 73 |
1
1. setAuthor : negated conditional → KILLED |
if (node == null) return; |
| 74 | this.authorName = node.path("name").asText(); | |
| 75 | this.authorEmail = node.path("email").asText(); | |
| 76 | this.authorLogin = node.path("user").path("login").asText(); | |
| 77 | } | |
| 78 | ||
| 79 | @JsonAlias("committer") | |
| 80 | public void setCommitter(JsonNode node) { | |
| 81 |
1
1. setCommitter : negated conditional → KILLED |
if (node == null) return; |
| 82 | this.committerName = node.path("name").asText(); | |
| 83 | this.committerEmail = node.path("email").asText(); | |
| 84 | this.committerLogin = node.path("user").path("login").asText(); | |
| 85 | } | |
| 86 | ||
| 87 | @JsonAlias("parents") | |
| 88 | public void setIsMergeCommit(JsonNode node) { | |
| 89 |
1
1. setIsMergeCommit : negated conditional → KILLED |
if (node == null) return; |
| 90 |
2
1. setIsMergeCommit : negated conditional → KILLED 2. setIsMergeCommit : changed conditional boundary → KILLED |
this.isMergeCommit = node.path("totalCount").asInt() > 1; |
| 91 | } | |
| 92 | } | |
Mutations | ||
| 73 |
1.1 |
|
| 81 |
1.1 |
|
| 89 |
1.1 |
|
| 90 |
1.1 2.2 |