2018-05-04 18:04:09 +04:00
|
|
|
|
package ru.ulstu.paper.model;
|
|
|
|
|
|
2018-05-05 00:24:48 +04:00
|
|
|
|
import org.hibernate.validator.constraints.NotBlank;
|
|
|
|
|
import ru.ulstu.core.model.BaseEntity;
|
2018-11-08 19:36:50 +04:00
|
|
|
|
import ru.ulstu.core.model.UserContainer;
|
2018-05-05 10:57:02 +04:00
|
|
|
|
import ru.ulstu.file.model.FileData;
|
2018-05-05 14:49:34 +04:00
|
|
|
|
import ru.ulstu.user.model.User;
|
2018-05-05 00:24:48 +04:00
|
|
|
|
|
2018-11-09 10:04:50 +04:00
|
|
|
|
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;
|
2018-05-05 00:24:48 +04:00
|
|
|
|
import java.util.Date;
|
2018-11-09 10:04:50 +04:00
|
|
|
|
import java.util.HashSet;
|
2018-05-05 14:49:34 +04:00
|
|
|
|
import java.util.List;
|
2018-11-09 10:04:50 +04:00
|
|
|
|
import java.util.Set;
|
2018-05-05 00:24:48 +04:00
|
|
|
|
|
|
|
|
|
@Entity
|
2018-11-08 19:36:50 +04:00
|
|
|
|
public class Paper extends BaseEntity implements UserContainer {
|
2018-05-05 00:24:48 +04:00
|
|
|
|
public enum PaperStatus {
|
2018-11-21 15:40:20 +04:00
|
|
|
|
ATTENTION("Обратить внимание"),
|
|
|
|
|
ON_PREPARATION("На подготовке"),
|
|
|
|
|
DRAFT("Черновик"),
|
|
|
|
|
COMPLETED("Завершена"),
|
|
|
|
|
FAILED("Провалены сроки");
|
2018-05-05 00:24:48 +04:00
|
|
|
|
|
|
|
|
|
private String name;
|
|
|
|
|
|
|
|
|
|
PaperStatus(String name) {
|
|
|
|
|
this.name = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@NotBlank
|
2018-05-04 18:04:09 +04:00
|
|
|
|
private String title;
|
|
|
|
|
|
2018-05-05 00:24:48 +04:00
|
|
|
|
@Enumerated(value = EnumType.STRING)
|
2018-11-08 19:36:50 +04:00
|
|
|
|
private PaperStatus status = PaperStatus.DRAFT;
|
2018-05-05 00:24:48 +04:00
|
|
|
|
|
|
|
|
|
@Column(name = "create_date")
|
2018-11-08 19:36:50 +04:00
|
|
|
|
private Date createDate = new Date();
|
2018-05-05 00:24:48 +04:00
|
|
|
|
|
|
|
|
|
@Column(name = "update_date")
|
2018-11-08 19:36:50 +04:00
|
|
|
|
private Date updateDate = new Date();
|
2018-05-05 00:24:48 +04:00
|
|
|
|
|
2018-10-27 22:24:10 +04:00
|
|
|
|
@Column(name = "deadline_date")
|
2018-11-09 10:04:50 +04:00
|
|
|
|
@NotNull
|
2018-10-27 22:24:10 +04:00
|
|
|
|
private Date deadlineDate;
|
|
|
|
|
|
2018-05-05 00:24:48 +04:00
|
|
|
|
private String comment;
|
|
|
|
|
|
2018-11-08 19:36:50 +04:00
|
|
|
|
private Boolean locked = false;
|
2018-05-05 00:24:48 +04:00
|
|
|
|
|
|
|
|
|
@ManyToOne
|
2018-05-05 10:57:02 +04:00
|
|
|
|
@JoinColumn(name = "file_id")
|
|
|
|
|
private FileData fileData;
|
2018-05-05 00:24:48 +04:00
|
|
|
|
|
2018-11-08 19:36:50 +04:00
|
|
|
|
@ManyToMany(fetch = FetchType.EAGER)
|
2018-11-09 10:04:50 +04:00
|
|
|
|
private Set<User> authors = new HashSet<>();
|
2018-05-05 14:49:34 +04:00
|
|
|
|
|
2018-05-05 00:24:48 +04:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-27 22:24:10 +04:00
|
|
|
|
public Date getDeadlineDate() {
|
|
|
|
|
return deadlineDate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDeadlineDate(Date deadlineDate) {
|
|
|
|
|
this.deadlineDate = deadlineDate;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-05 00:24:48 +04:00
|
|
|
|
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;
|
2018-05-04 18:04:09 +04:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-05 10:57:02 +04:00
|
|
|
|
public FileData getFileData() {
|
|
|
|
|
return fileData;
|
2018-05-04 18:04:09 +04:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-05 10:57:02 +04:00
|
|
|
|
public void setFileData(FileData fileData) {
|
|
|
|
|
this.fileData = fileData;
|
2018-05-04 18:04:09 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getTitle() {
|
|
|
|
|
return title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTitle(String title) {
|
|
|
|
|
this.title = title;
|
|
|
|
|
}
|
2018-05-05 14:49:34 +04:00
|
|
|
|
|
2018-11-09 10:04:50 +04:00
|
|
|
|
public Set<User> getAuthors() {
|
2018-05-05 14:49:34 +04:00
|
|
|
|
return authors;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-09 10:04:50 +04:00
|
|
|
|
public void setAuthors(Set<User> authors) {
|
2018-05-05 14:49:34 +04:00
|
|
|
|
this.authors = authors;
|
|
|
|
|
}
|
2018-11-08 19:36:50 +04:00
|
|
|
|
|
|
|
|
|
@Override
|
2018-11-09 10:04:50 +04:00
|
|
|
|
public Set<User> getUsers() {
|
2018-11-08 19:36:50 +04:00
|
|
|
|
return getAuthors();
|
|
|
|
|
}
|
2018-05-04 18:04:09 +04:00
|
|
|
|
}
|