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-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 {
|
|
|
|
private final Integer id;
|
|
|
|
@NotEmpty
|
|
|
|
private final String title;
|
|
|
|
private final Grant.GrantStatus status;
|
2018-12-11 15:08:35 +04:00
|
|
|
private final List<DeadlineDto> deadlines;
|
2018-12-08 23:53:38 +04:00
|
|
|
private final String comment;
|
|
|
|
private final String applicationFileName;
|
2018-12-11 15:08:35 +04:00
|
|
|
private final ProjectDto project;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTitle() {
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Grant.GrantStatus getStatus() {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2018-12-11 15:08:35 +04:00
|
|
|
public List<DeadlineDto> getDeadlines() {
|
|
|
|
return deadlines;
|
2018-12-08 23:53:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getComment() {
|
|
|
|
return comment;
|
|
|
|
}
|
|
|
|
|
2018-12-11 15:08:35 +04:00
|
|
|
public ProjectDto getProject() {
|
|
|
|
return project;
|
2018-12-08 23:53:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getApplicationFileName() {
|
|
|
|
return applicationFileName;
|
|
|
|
}
|
|
|
|
}
|