2018-12-08 23:53:38 +04:00
|
|
|
package ru.ulstu.grant.model;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
import org.hibernate.validator.constraints.NotEmpty;
|
2018-12-11 15:08:35 +04:00
|
|
|
import ru.ulstu.deadline.model.DeadlineDto;
|
|
|
|
import ru.ulstu.project.model.ProjectDto;
|
2018-12-08 23:53:38 +04:00
|
|
|
|
2018-12-24 15:20:57 +04:00
|
|
|
import java.util.ArrayList;
|
2018-12-11 15:08:35 +04:00
|
|
|
import java.util.List;
|
2018-12-08 23:53:38 +04:00
|
|
|
|
|
|
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|
|
|
|
|
|
|
public class GrantDto {
|
2018-12-22 03:31:43 +04:00
|
|
|
private Integer id;
|
2018-12-08 23:53:38 +04:00
|
|
|
@NotEmpty
|
2018-12-22 03:31:43 +04:00
|
|
|
private String title;
|
|
|
|
private Grant.GrantStatus status;
|
2018-12-24 15:20:57 +04:00
|
|
|
private List<DeadlineDto> deadlines = new ArrayList<>();
|
2018-12-22 03:31:43 +04:00
|
|
|
private String comment;
|
|
|
|
private String applicationFileName;
|
|
|
|
private ProjectDto project;
|
2018-12-08 23:53:38 +04:00
|
|
|
|
2018-12-23 02:22:24 +04:00
|
|
|
public GrantDto() {
|
|
|
|
deadlines.add(new DeadlineDto());
|
|
|
|
}
|
|
|
|
|
2018-12-08 23:53:38 +04:00
|
|
|
@JsonCreator
|
|
|
|
public GrantDto(@JsonProperty("id") Integer id,
|
|
|
|
@JsonProperty("title") String title,
|
|
|
|
@JsonProperty("status") Grant.GrantStatus status,
|
2018-12-11 15:08:35 +04:00
|
|
|
@JsonProperty("deadlines") List<DeadlineDto> deadlines,
|
2018-12-08 23:53:38 +04:00
|
|
|
@JsonProperty("comment") String comment,
|
2018-12-11 15:08:35 +04:00
|
|
|
@JsonProperty("project") ProjectDto project) {
|
2018-12-08 23:53:38 +04:00
|
|
|
this.id = id;
|
|
|
|
this.title = title;
|
|
|
|
this.status = status;
|
2018-12-11 15:08:35 +04:00
|
|
|
this.deadlines = deadlines;
|
2018-12-08 23:53:38 +04:00
|
|
|
this.comment = comment;
|
|
|
|
this.applicationFileName = null;
|
2018-12-11 15:08:35 +04:00
|
|
|
this.project = project;
|
2018-12-08 23:53:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public GrantDto(Grant grant) {
|
|
|
|
this.id = grant.getId();
|
|
|
|
this.title = grant.getTitle();
|
|
|
|
this.status = grant.getStatus();
|
2018-12-11 15:08:35 +04:00
|
|
|
this.deadlines = convert(grant.getDeadlines(), DeadlineDto::new);
|
2018-12-08 23:53:38 +04:00
|
|
|
this.comment = grant.getComment();
|
2018-12-11 15:08:35 +04:00
|
|
|
this.project = grant.getProject() == null ? null : new ProjectDto(grant.getProject());
|
2018-12-08 23:53:38 +04:00
|
|
|
this.applicationFileName = grant.getApplication() == null ? null : grant.getApplication().getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Integer getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2019-03-04 10:24:30 +04:00
|
|
|
public void setId(Integer id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
2018-12-22 03:31:43 +04:00
|
|
|
|
2018-12-08 23:53:38 +04:00
|
|
|
public String getTitle() {
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
2019-03-04 10:24:30 +04:00
|
|
|
public void setTitle(String title) {
|
|
|
|
this.title = title;
|
|
|
|
}
|
2018-12-22 03:31:43 +04:00
|
|
|
|
2018-12-08 23:53:38 +04:00
|
|
|
public Grant.GrantStatus getStatus() {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2018-12-22 03:31:43 +04:00
|
|
|
public void setStatus(Grant.GrantStatus status) {
|
|
|
|
this.status = status;
|
|
|
|
}
|
|
|
|
|
2018-12-11 15:08:35 +04:00
|
|
|
public List<DeadlineDto> getDeadlines() {
|
|
|
|
return deadlines;
|
2018-12-08 23:53:38 +04:00
|
|
|
}
|
|
|
|
|
2018-12-22 03:31:43 +04:00
|
|
|
public void setDeadlines(List<DeadlineDto> deadlines) {
|
|
|
|
this.deadlines = deadlines;
|
|
|
|
}
|
|
|
|
|
2018-12-08 23:53:38 +04:00
|
|
|
public String getComment() {
|
|
|
|
return comment;
|
|
|
|
}
|
|
|
|
|
2019-03-04 10:24:30 +04:00
|
|
|
public void setComment(String comment) {
|
|
|
|
this.comment = comment;
|
|
|
|
}
|
2018-12-22 03:31:43 +04:00
|
|
|
|
2018-12-11 15:08:35 +04:00
|
|
|
public ProjectDto getProject() {
|
|
|
|
return project;
|
2018-12-08 23:53:38 +04:00
|
|
|
}
|
|
|
|
|
2019-03-04 10:24:30 +04:00
|
|
|
public void setProject(ProjectDto project) {
|
|
|
|
this.project = project;
|
|
|
|
}
|
2018-12-22 03:31:43 +04:00
|
|
|
|
2018-12-08 23:53:38 +04:00
|
|
|
public String getApplicationFileName() {
|
|
|
|
return applicationFileName;
|
|
|
|
}
|
2018-12-22 03:31:43 +04:00
|
|
|
|
|
|
|
public void setApplicationFileName(String applicationFileName) {
|
2019-03-04 10:24:30 +04:00
|
|
|
this.applicationFileName = applicationFileName;
|
|
|
|
}
|
2018-12-08 23:53:38 +04:00
|
|
|
}
|