ng-tracker/src/main/java/ru/ulstu/paper/model/Paper.java
2018-11-09 10:04:50 +04:00

143 lines
3.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package ru.ulstu.paper.model;
import org.hibernate.validator.constraints.NotBlank;
import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.core.model.UserContainer;
import ru.ulstu.file.model.FileData;
import ru.ulstu.user.model.User;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Entity
public class Paper extends BaseEntity implements UserContainer {
public enum PaperStatus {
ATTENTION("Обратить внимание"), ON_PREPARATION("На подготовке"), DRAFT("Черновик"), COMPLETED("Завершена");
private String name;
PaperStatus(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
@NotBlank
private String title;
@Enumerated(value = EnumType.STRING)
private PaperStatus status = PaperStatus.DRAFT;
@Column(name = "create_date")
private Date createDate = new Date();
@Column(name = "update_date")
private Date updateDate = new Date();
@Column(name = "deadline_date")
@NotNull
private Date deadlineDate;
private String comment;
private Boolean locked = false;
@ManyToOne
@JoinColumn(name = "file_id")
private FileData fileData;
@ManyToMany(fetch = FetchType.EAGER)
private Set<User> authors = new HashSet<>();
public PaperStatus getStatus() {
return status;
}
public void setStatus(PaperStatus status) {
this.status = status;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public Date getDeadlineDate() {
return deadlineDate;
}
public void setDeadlineDate(Date deadlineDate) {
this.deadlineDate = deadlineDate;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public Boolean getLocked() {
return locked;
}
public void setLocked(Boolean locked) {
this.locked = locked;
}
public FileData getFileData() {
return fileData;
}
public void setFileData(FileData fileData) {
this.fileData = fileData;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Set<User> getAuthors() {
return authors;
}
public void setAuthors(Set<User> authors) {
this.authors = authors;
}
@Override
public Set<User> getUsers() {
return getAuthors();
}
}