mirror of
https://github.com/theonedev/onedev.git
synced 2025-12-08 18:26:30 +00:00
Add fork relationship and auto-sync tables.
This commit is contained in:
parent
cccd09195e
commit
081104ae0e
@ -0,0 +1,51 @@
|
||||
package com.pmease.gitop.core.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.pmease.commons.hibernate.AbstractEntity;
|
||||
|
||||
@Entity
|
||||
@Table(uniqueConstraints={
|
||||
@UniqueConstraint(columnNames={"from", "to"})
|
||||
})
|
||||
@SuppressWarnings("serial")
|
||||
public class AutoPull extends AbstractEntity {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable=false)
|
||||
private Branch from;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable=false)
|
||||
private Branch to;
|
||||
|
||||
public Branch getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(Branch from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public Branch getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setBranch(Branch to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("from", getFrom())
|
||||
.add("to", getTo())
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.pmease.gitop.core.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.pmease.commons.hibernate.AbstractEntity;
|
||||
|
||||
@Entity
|
||||
@Table(uniqueConstraints={
|
||||
@UniqueConstraint(columnNames={"from", "to"})
|
||||
})
|
||||
@SuppressWarnings("serial")
|
||||
public class AutoPush extends AbstractEntity {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable=false)
|
||||
private Branch from;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable=false)
|
||||
private Branch to;
|
||||
|
||||
public Branch getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(Branch from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public Branch getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setBranch(Branch to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("from", getFrom())
|
||||
.add("to", getTo())
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,6 +7,7 @@ import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.pmease.commons.hibernate.AbstractEntity;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@ -39,4 +40,11 @@ public class Branch extends AbstractEntity {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("name", getName())
|
||||
.add("project", getProject())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +40,10 @@ public class Project extends AbstractEntity implements UserBelonging {
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable=false)
|
||||
private User owner;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable=true)
|
||||
private Project forkedFrom;
|
||||
|
||||
@Column(nullable=false)
|
||||
private String name;
|
||||
@ -59,6 +63,9 @@ public class Project extends AbstractEntity implements UserBelonging {
|
||||
@OneToMany(mappedBy="project", cascade=CascadeType.REMOVE)
|
||||
private Collection<Authorization> authorizations = new ArrayList<Authorization>();
|
||||
|
||||
@OneToMany(mappedBy="forkedFrom", cascade=CascadeType.REMOVE)
|
||||
private Collection<Project> forks = new ArrayList<Project>();
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
@ -139,6 +146,22 @@ public class Project extends AbstractEntity implements UserBelonging {
|
||||
this.authorizations = authorizations;
|
||||
}
|
||||
|
||||
public Project getForkedFrom() {
|
||||
return forkedFrom;
|
||||
}
|
||||
|
||||
public void setForkedFrom(Project forkedFrom) {
|
||||
this.forkedFrom = forkedFrom;
|
||||
}
|
||||
|
||||
public Collection<Project> getForks() {
|
||||
return forks;
|
||||
}
|
||||
|
||||
public void setForks(Collection<Project> forks) {
|
||||
this.forks = forks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(ProtectedObject object) {
|
||||
if (object instanceof Project) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user