This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #404 from JWGmeligMeyling/develop
Develop
- Loading branch information
Showing
70 changed files
with
12,220 additions
and
202 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
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
39 changes: 39 additions & 0 deletions
39
src/main/java/nl/tudelft/ewi/devhub/server/backend/IssueBackend.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,39 @@ | ||
package nl.tudelft.ewi.devhub.server.backend; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.google.inject.Inject; | ||
import com.google.inject.persist.Transactional; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import nl.tudelft.ewi.devhub.server.database.controllers.Issues; | ||
import nl.tudelft.ewi.devhub.server.database.entities.issues.Issue; | ||
import nl.tudelft.ewi.git.web.api.RepositoryApi; | ||
|
||
/** | ||
* | ||
* @author Aron Zwaan | ||
* | ||
*/ | ||
@Slf4j | ||
public class IssueBackend { | ||
|
||
private final Issues issues; | ||
|
||
@Inject | ||
public IssueBackend(final Issues issues){ | ||
Preconditions.checkNotNull(issues); | ||
this.issues = issues; | ||
} | ||
|
||
/** | ||
* Creates a new Issue for a repository | ||
* @param repository Repository that contains the issue | ||
* @param issue The Issue to create | ||
*/ | ||
@Transactional | ||
public void createIssue(RepositoryApi repository, Issue issue){ | ||
log.info("Persisting issue {}", issue); | ||
issues.persist(issue); | ||
} | ||
|
||
} |
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
23 changes: 23 additions & 0 deletions
23
src/main/java/nl/tudelft/ewi/devhub/server/database/controllers/IssueComments.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,23 @@ | ||
package nl.tudelft.ewi.devhub.server.database.controllers; | ||
|
||
import java.util.List; | ||
|
||
import javax.persistence.EntityManager; | ||
|
||
import com.google.inject.Inject; | ||
|
||
import nl.tudelft.ewi.devhub.server.database.entities.RepositoryEntity; | ||
import nl.tudelft.ewi.devhub.server.database.entities.comments.IssueComment; | ||
import nl.tudelft.ewi.devhub.server.database.entities.issues.Issue; | ||
|
||
import static nl.tudelft.ewi.devhub.server.database.entities.comments.QIssueComment.issueComment; | ||
|
||
public class IssueComments extends Controller<IssueComment> { | ||
|
||
@Inject | ||
public IssueComments(EntityManager entityManager) { | ||
super(entityManager); | ||
} | ||
|
||
|
||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/nl/tudelft/ewi/devhub/server/database/controllers/Issues.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,58 @@ | ||
package nl.tudelft.ewi.devhub.server.database.controllers; | ||
|
||
import java.util.List; | ||
|
||
import javax.persistence.EntityManager; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.persist.Transactional; | ||
|
||
import nl.tudelft.ewi.devhub.server.database.entities.RepositoryEntity; | ||
import nl.tudelft.ewi.devhub.server.database.entities.User; | ||
import nl.tudelft.ewi.devhub.server.database.entities.issues.Issue; | ||
|
||
import static nl.tudelft.ewi.devhub.server.database.entities.issues.QIssue.issue; | ||
|
||
public class Issues extends Controller<Issue> { | ||
|
||
@Inject | ||
public Issues(EntityManager em) { | ||
super(em); | ||
} | ||
|
||
@Transactional | ||
public List<Issue> findAssignedIssues(final RepositoryEntity repo, User user){ | ||
return query().from(issue) | ||
.where(issue.repository.eq(repo).and(issue.assignee.eq(user))) | ||
.list(issue); | ||
} | ||
|
||
@Transactional | ||
public List<Issue> findOpenIssues(final RepositoryEntity repo){ | ||
return query().from(issue) | ||
.where(issue.repository.eq(repo).and(issue.open.isTrue())) | ||
.list(issue); | ||
} | ||
|
||
@Transactional | ||
public List<Issue> findClosedIssues(final RepositoryEntity repo){ | ||
return query().from(issue) | ||
.where(issue.repository.eq(repo).and(issue.open.isFalse())) | ||
.list(issue); | ||
} | ||
|
||
@Transactional | ||
public List<Issue> findUnassignedIssues(final RepositoryEntity repo){ | ||
return query().from(issue) | ||
.where(issue.repository.eq(repo).and(issue.assignee.isNull())) | ||
.list(issue); | ||
} | ||
|
||
@Transactional | ||
public List<Issue> findIssueById(final RepositoryEntity repo, final long id){ | ||
return query().from(issue) | ||
.where(issue.repository.eq(repo).and(issue.issueId.eq(id))) | ||
.list(issue); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/nl/tudelft/ewi/devhub/server/database/entities/comments/IssueComment.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,37 @@ | ||
package nl.tudelft.ewi.devhub.server.database.entities.comments; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
import nl.tudelft.ewi.devhub.server.database.entities.RepositoryEntity; | ||
import nl.tudelft.ewi.devhub.server.database.entities.issues.Issue; | ||
import nl.tudelft.ewi.devhub.server.database.entities.issues.PullRequest; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.JoinColumns; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.Table; | ||
import javax.validation.constraints.NotNull; | ||
|
||
@Data | ||
@Entity | ||
@ToString(exclude="issue", callSuper = true) | ||
@Table(name = "repository_issue_comments") | ||
@EqualsAndHashCode(callSuper = true) | ||
public class IssueComment extends Comment { | ||
|
||
@NotNull | ||
@ManyToOne(fetch=FetchType.LAZY) | ||
@JoinColumns({ | ||
@JoinColumn(name="repository_id", referencedColumnName="repository_id"), | ||
@JoinColumn(name="issue_id", referencedColumnName="issue_id") | ||
}) | ||
private Issue issue; | ||
|
||
@Override | ||
public RepositoryEntity getRepository() { | ||
return getIssue().getRepository(); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
src/main/java/nl/tudelft/ewi/devhub/server/database/entities/issues/Issue.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,37 @@ | ||
package nl.tudelft.ewi.devhub.server.database.entities.issues; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
|
||
import javax.persistence.CascadeType; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.OneToMany; | ||
import javax.persistence.OrderBy; | ||
import javax.persistence.Table; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import nl.tudelft.ewi.devhub.server.database.entities.comments.IssueComment; | ||
|
||
|
||
@Data | ||
@Entity | ||
@Table(name="repository_issues") | ||
@NoArgsConstructor | ||
@EqualsAndHashCode(callSuper = true) | ||
@ToString(callSuper=true, includeFieldNames=true) | ||
public class Issue extends AbstractIssue { | ||
|
||
@Override | ||
public URI getURI() { | ||
return getRepository().getURI().resolve("issue/" + getIssueId() + "/"); | ||
} | ||
|
||
@OrderBy("timestamp ASC") | ||
@OneToMany(mappedBy = "issue", fetch = FetchType.LAZY, cascade = {CascadeType.DETACH, CascadeType.REMOVE}, orphanRemoval = true) | ||
private List<IssueComment> comments; | ||
|
||
} |
Oops, something went wrong.