ng-tracker/src/main/java/ru/ulstu/grant/model/GrantDto.java

100 lines
2.8 KiB
Java
Raw Normal View History

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