Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #404 from JWGmeligMeyling/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jwgmeligmeyling authored Jun 15, 2016
2 parents 7806db9 + a89c426 commit 6bb4f5b
Show file tree
Hide file tree
Showing 70 changed files with 12,220 additions and 202 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@
[submodule "src/main/resources/static/vendor/angular-chart"]
path = src/main/resources/static/vendor/angular-chart
url = https://github.com/jtblin/angular-chart.js.git
[submodule "src/main/resources/static/vendor/twemoji"]
path = src/main/resources/static/vendor/twemoji
url = https://github.com/twitter/twemoji.git
[submodule "src/main/resources/static/vendor/jquery-textcomplete"]
path = src/main/resources/static/vendor/jquery-textcomplete
url = https://github.com/yuku-t/jquery-textcomplete.git
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<liquibase.slf4j.version>1.7.7</liquibase.slf4j.version>
<querydsl.version>3.6.0</querydsl.version>
<logback.version>1.0.13</logback.version>
<selenium.version>2.52.0</selenium.version>
<selenium.version>2.53.0</selenium.version>
<build.server.version>1.2.0</build.server.version>
<git.server.version>1.0.10</git.server.version>
</properties>
Expand Down Expand Up @@ -262,6 +262,11 @@
<artifactId>commons-csv</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>3.1.3</version>
</dependency>

<!-- Backend services -->
<dependency>
Expand Down Expand Up @@ -415,6 +420,11 @@
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
<dependency>
<groupId>org.pegdown</groupId>
<artifactId>pegdown</artifactId>
<version>1.6.0</version>
</dependency>
</dependencies>

<build>
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/nl/tudelft/ewi/devhub/server/DevhubModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import org.eclipse.jetty.util.component.LifeCycle;
import org.jboss.resteasy.plugins.guice.ext.JaxrsModule;
import org.pegdown.PegDownProcessor;
import org.reflections.Reflections;

import javax.persistence.EntityNotFoundException;
Expand Down Expand Up @@ -93,6 +94,8 @@ protected void configureServlets() {

findResourcesWith(Path.class);
findResourcesWith(Provider.class);

bindConstant().annotatedWith(Names.named("pegdown.timeout")).to(2000l);
}

private void bindWarningGenerators() {
Expand Down Expand Up @@ -136,4 +139,10 @@ public Group provideCurrentGroup() {
throw new IllegalStateException("Group must be manually seeded");
}

@Provides
@RequestScoped
public PegDownProcessor getProcessor(@Named("pegdown.timeout") long timeout) {
return new PegDownProcessor(timeout);
}

}
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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ public PullRequestBackend(final Commits commits,
public void createPullRequest(RepositoryApi repository, PullRequest pullRequest) {
updateCommitPointers(repository, pullRequest);
log.info("Persisisting pull-request {}", pullRequest);
// Set a dummy title to avoid exceptions because of the @NotEmpy annotations
pullRequest.setTitle(pullRequest.getBranchName());
pullRequests.persist(pullRequest);
pullRequest.setTitle(String.format("Pull request #%d: %s",
pullRequest.getIssueId(),
pullRequest.getBranchName()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public T delete(T entity) {
return entity;
}

JPAQuery query() {
public JPAQuery query() {
return new JPAQuery(entityManager);
}

Expand Down
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);
}


}
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);
}

}
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import nl.tudelft.ewi.devhub.server.database.Base;
import nl.tudelft.ewi.devhub.server.database.entities.Event;
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.identity.FKSegmentedIdentifierGenerator;

import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.NotEmpty;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
Expand All @@ -29,6 +34,7 @@
*/
@Data
@MappedSuperclass
@ToString(of = {"repository", "issueId"})
@EqualsAndHashCode(of = {"repository", "issueId"})
@IdClass(AbstractIssue.IssueId.class)
public abstract class AbstractIssue implements Event, Base {
Expand Down Expand Up @@ -71,6 +77,18 @@ public static class IssueId implements Serializable {
@Temporal(TemporalType.TIMESTAMP)
private Date closed;

@NotEmpty
@Column(name="title")
private String title;

@Column(name="description", nullable=true)
@Type(type = "org.hibernate.type.TextType")
private String description;

@ManyToOne(cascade={CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "assignee")
private User assignee;

/**
* @return true if the pull request is closed
*/
Expand Down
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;

}
Loading

0 comments on commit 6bb4f5b

Please sign in to comment.