2021-04-12 10:53:33 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
|
|
|
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
|
|
|
*/
|
|
|
|
|
2021-03-19 11:45:03 +04:00
|
|
|
package ru.ulstu.extractor.model;
|
2021-02-19 16:00:09 +04:00
|
|
|
|
2021-03-29 11:38:27 +04:00
|
|
|
import org.hibernate.annotations.Fetch;
|
|
|
|
import org.hibernate.annotations.FetchMode;
|
|
|
|
|
|
|
|
import javax.persistence.CascadeType;
|
|
|
|
import javax.persistence.Entity;
|
|
|
|
import javax.persistence.FetchType;
|
|
|
|
import javax.persistence.JoinColumn;
|
|
|
|
import javax.persistence.ManyToOne;
|
|
|
|
import javax.persistence.OneToMany;
|
|
|
|
import java.util.ArrayList;
|
2021-02-19 16:00:09 +04:00
|
|
|
import java.util.Date;
|
2021-03-29 11:38:27 +04:00
|
|
|
import java.util.List;
|
2021-02-19 16:00:09 +04:00
|
|
|
|
2021-03-29 11:38:27 +04:00
|
|
|
@Entity
|
|
|
|
public class Commit extends BaseEntity {
|
|
|
|
private String hash;
|
2021-02-19 16:00:09 +04:00
|
|
|
private Date date;
|
2021-03-29 11:38:27 +04:00
|
|
|
private String message;
|
2021-04-20 12:26:43 +04:00
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
2021-03-29 11:38:27 +04:00
|
|
|
private Author author;
|
|
|
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
2021-04-22 09:08:56 +04:00
|
|
|
@JoinColumn(name = "commit_id")
|
2021-03-29 11:38:27 +04:00
|
|
|
@Fetch(FetchMode.SUBSELECT)
|
|
|
|
private List<FileChange> fileChanges = new ArrayList<>();
|
2021-04-22 09:08:56 +04:00
|
|
|
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
2021-03-29 15:38:54 +04:00
|
|
|
private Branch branch;
|
2021-02-19 16:00:09 +04:00
|
|
|
|
2021-03-29 11:38:27 +04:00
|
|
|
public Commit() {
|
|
|
|
}
|
|
|
|
|
2021-03-29 14:40:20 +04:00
|
|
|
public Commit(String message, Author author, Date date, String hash) {
|
2021-02-19 16:00:09 +04:00
|
|
|
this.message = message;
|
2021-03-09 15:54:59 +04:00
|
|
|
this.author = author;
|
|
|
|
this.date = date;
|
2021-03-29 14:40:20 +04:00
|
|
|
this.hash = hash;
|
2021-02-19 16:00:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getMessage() {
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Date getDate() {
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
2021-03-29 11:38:27 +04:00
|
|
|
public String getHash() {
|
|
|
|
return hash;
|
2021-02-19 16:00:09 +04:00
|
|
|
}
|
2021-03-10 14:47:43 +04:00
|
|
|
|
2021-03-29 11:38:27 +04:00
|
|
|
public void setHash(String hash) {
|
|
|
|
this.hash = hash;
|
2021-03-10 14:47:43 +04:00
|
|
|
}
|
|
|
|
|
2021-03-29 11:38:27 +04:00
|
|
|
public void setDate(Date date) {
|
|
|
|
this.date = date;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMessage(String message) {
|
|
|
|
this.message = message;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAuthor(Author author) {
|
|
|
|
this.author = author;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<FileChange> getFileChanges() {
|
|
|
|
return fileChanges;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFileChanges(List<FileChange> fileChanges) {
|
|
|
|
this.fileChanges = fileChanges;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Author getAuthor() {
|
|
|
|
return author;
|
2021-03-10 14:47:43 +04:00
|
|
|
}
|
2021-03-29 15:38:54 +04:00
|
|
|
|
|
|
|
public Branch getBranch() {
|
|
|
|
return branch;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setBranch(Branch branch) {
|
|
|
|
this.branch = branch;
|
|
|
|
}
|
2021-04-12 10:53:33 +04:00
|
|
|
|
|
|
|
public boolean containsEntity() {
|
2021-04-12 11:01:59 +04:00
|
|
|
return fileChanges != null && fileChanges.stream().anyMatch(
|
|
|
|
fileChange -> fileChange != null
|
|
|
|
&& fileChange.isContainsEntity() != null
|
|
|
|
&& fileChange.isContainsEntity()
|
|
|
|
);
|
2021-04-12 10:53:33 +04:00
|
|
|
}
|
2021-02-19 16:00:09 +04:00
|
|
|
}
|