125 lines
3.5 KiB
Java
125 lines
3.5 KiB
Java
package ru.ulstu.paper.model;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
import org.hibernate.validator.constraints.NotEmpty;
|
|
import ru.ulstu.user.model.UserDto;
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
import java.util.Date;
|
|
import java.util.Set;
|
|
|
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|
|
|
public class PaperDto {
|
|
private final Integer id;
|
|
@NotEmpty
|
|
private final String title;
|
|
private final Paper.PaperStatus status;
|
|
private final Date createDate;
|
|
private final Date updateDate;
|
|
@NotNull
|
|
private final Date deadlineDate;
|
|
private final String comment;
|
|
private final Boolean locked;
|
|
private final String tmpFileName;
|
|
private final Integer fileId;
|
|
private final String fileName;
|
|
private final Date fileCreateDate;
|
|
private final Set<UserDto> authors;
|
|
|
|
@JsonCreator
|
|
public PaperDto(@JsonProperty("id") Integer id,
|
|
@JsonProperty("title") String title,
|
|
@JsonProperty("status") Paper.PaperStatus status,
|
|
@JsonProperty("createDate") Date createDate,
|
|
@JsonProperty("updateDate") Date updateDate,
|
|
@JsonProperty("deadlineDate") Date deadlineDate,
|
|
@JsonProperty("comment") String comment,
|
|
@JsonProperty("locked") Boolean locked,
|
|
@JsonProperty("tmpFileName") String tmpFileName,
|
|
@JsonProperty("authors") Set<UserDto> authors) {
|
|
this.id = id;
|
|
this.title = title;
|
|
this.status = status;
|
|
this.createDate = createDate;
|
|
this.updateDate = updateDate;
|
|
this.deadlineDate = deadlineDate;
|
|
this.comment = comment;
|
|
this.locked = locked;
|
|
this.tmpFileName = tmpFileName;
|
|
this.fileId = null;
|
|
this.fileName = null;
|
|
this.fileCreateDate = null;
|
|
this.authors = authors;
|
|
}
|
|
|
|
public PaperDto(Paper paper) {
|
|
this.id = paper.getId();
|
|
this.title = paper.getTitle();
|
|
this.status = paper.getStatus();
|
|
this.createDate = paper.getCreateDate();
|
|
this.updateDate = paper.getUpdateDate();
|
|
this.deadlineDate = paper.getDeadlineDate();
|
|
this.comment = paper.getComment();
|
|
this.locked = paper.getLocked();
|
|
this.tmpFileName = null;
|
|
this.fileId = paper.getFileData() == null ? null : paper.getFileData().getId();
|
|
this.fileName = paper.getFileData() == null ? null : paper.getFileData().getName();
|
|
this.fileCreateDate = paper.getFileData() == null ? null : paper.getFileData().getCreateDate();
|
|
this.authors = convert(paper.getAuthors(), UserDto::new);
|
|
}
|
|
|
|
public Integer getId() {
|
|
return id;
|
|
}
|
|
|
|
public String getTitle() {
|
|
return title;
|
|
}
|
|
|
|
public Paper.PaperStatus getStatus() {
|
|
return status;
|
|
}
|
|
|
|
public Date getCreateDate() {
|
|
return createDate;
|
|
}
|
|
|
|
public Date getUpdateDate() {
|
|
return updateDate;
|
|
}
|
|
|
|
public Date getDeadlineDate() {
|
|
return deadlineDate;
|
|
}
|
|
|
|
public String getComment() {
|
|
return comment;
|
|
}
|
|
|
|
public Boolean getLocked() {
|
|
return locked;
|
|
}
|
|
|
|
public String getTmpFileName() {
|
|
return tmpFileName;
|
|
}
|
|
|
|
public Integer getFileId() {
|
|
return fileId;
|
|
}
|
|
|
|
public String getFileName() {
|
|
return fileName;
|
|
}
|
|
|
|
public Date getFileCreateDate() {
|
|
return fileCreateDate;
|
|
}
|
|
|
|
public Set<UserDto> getAuthors() {
|
|
return authors;
|
|
}
|
|
}
|