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

81 lines
2.2 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.file.model.FileData;
import ru.ulstu.user.model.UserDto;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.Set;
import java.util.stream.Collectors;
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;
@NotNull
private final Date deadlineDate;
private final String comment;
private final String applicationFileName;
private final Integer projectId;
@JsonCreator
public GrantDto(@JsonProperty("id") Integer id,
@JsonProperty("title") String title,
@JsonProperty("status") Grant.GrantStatus status,
@JsonProperty("deadlineDate") Date deadlineDate,
@JsonProperty("comment") String comment,
@JsonProperty("projectId") Integer projectId){
this.id = id;
this.title = title;
this.status = status;
this.deadlineDate = deadlineDate;
this.comment = comment;
this.applicationFileName = null;
this.projectId = projectId;
}
public GrantDto(Grant grant) {
this.id = grant.getId();
this.title = grant.getTitle();
this.status = grant.getStatus();
this.deadlineDate = grant.getDeadlineDate();
this.comment = grant.getComment();
this.projectId = grant.getProjectId();
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;
}
public Date getDeadlineDate() {
return deadlineDate;
}
public String getComment() {
return comment;
}
public Integer getProjectId() {
return projectId;
}
public String getApplicationFileName() {
return applicationFileName;
}
}