|
|
@ -3,11 +3,19 @@ package ru.ulstu.project.model;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
import org.hibernate.validator.constraints.NotEmpty;
|
|
|
|
import org.hibernate.validator.constraints.NotEmpty;
|
|
|
|
|
|
|
|
import org.thymeleaf.util.StringUtils;
|
|
|
|
import ru.ulstu.deadline.model.Deadline;
|
|
|
|
import ru.ulstu.deadline.model.Deadline;
|
|
|
|
import ru.ulstu.grant.model.GrantDto;
|
|
|
|
import ru.ulstu.grant.model.GrantDto;
|
|
|
|
|
|
|
|
import ru.ulstu.user.model.User;
|
|
|
|
|
|
|
|
import ru.ulstu.user.model.UserDto;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|
|
|
|
|
|
|
|
|
|
|
public class ProjectDto {
|
|
|
|
public class ProjectDto {
|
|
|
|
private Integer id;
|
|
|
|
private Integer id;
|
|
|
@ -20,6 +28,11 @@ public class ProjectDto {
|
|
|
|
private GrantDto grant;
|
|
|
|
private GrantDto grant;
|
|
|
|
private String repository;
|
|
|
|
private String repository;
|
|
|
|
private String applicationFileName;
|
|
|
|
private String applicationFileName;
|
|
|
|
|
|
|
|
private List<Integer> removedDeadlineIds = new ArrayList<>();
|
|
|
|
|
|
|
|
private Set<Integer> executorIds;
|
|
|
|
|
|
|
|
private List<UserDto> executors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final static int MAX_EXECUTORS_LENGTH = 40;
|
|
|
|
|
|
|
|
|
|
|
|
public ProjectDto() {
|
|
|
|
public ProjectDto() {
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -35,7 +48,9 @@ public class ProjectDto {
|
|
|
|
@JsonProperty("description") String description,
|
|
|
|
@JsonProperty("description") String description,
|
|
|
|
@JsonProperty("grant") GrantDto grant,
|
|
|
|
@JsonProperty("grant") GrantDto grant,
|
|
|
|
@JsonProperty("repository") String repository,
|
|
|
|
@JsonProperty("repository") String repository,
|
|
|
|
@JsonProperty("deadlines") List<Deadline> deadlines) {
|
|
|
|
@JsonProperty("deadlines") List<Deadline> deadlines,
|
|
|
|
|
|
|
|
@JsonProperty("executorIds") Set<Integer> executorIds,
|
|
|
|
|
|
|
|
@JsonProperty("executors") List<UserDto> executors) {
|
|
|
|
this.id = id;
|
|
|
|
this.id = id;
|
|
|
|
this.title = title;
|
|
|
|
this.title = title;
|
|
|
|
this.status = status;
|
|
|
|
this.status = status;
|
|
|
@ -44,10 +59,13 @@ public class ProjectDto {
|
|
|
|
this.repository = repository;
|
|
|
|
this.repository = repository;
|
|
|
|
this.deadlines = deadlines;
|
|
|
|
this.deadlines = deadlines;
|
|
|
|
this.applicationFileName = null;
|
|
|
|
this.applicationFileName = null;
|
|
|
|
|
|
|
|
this.executorIds = executorIds;
|
|
|
|
|
|
|
|
this.executors = executors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ProjectDto(Project project) {
|
|
|
|
public ProjectDto(Project project) {
|
|
|
|
|
|
|
|
Set<User> users = new HashSet<User>(project.getExecutors());
|
|
|
|
this.id = project.getId();
|
|
|
|
this.id = project.getId();
|
|
|
|
this.title = project.getTitle();
|
|
|
|
this.title = project.getTitle();
|
|
|
|
this.status = project.getStatus();
|
|
|
|
this.status = project.getStatus();
|
|
|
@ -56,6 +74,8 @@ public class ProjectDto {
|
|
|
|
this.grant = project.getGrant() == null ? null : new GrantDto(project.getGrant());
|
|
|
|
this.grant = project.getGrant() == null ? null : new GrantDto(project.getGrant());
|
|
|
|
this.repository = project.getRepository();
|
|
|
|
this.repository = project.getRepository();
|
|
|
|
this.deadlines = project.getDeadlines();
|
|
|
|
this.deadlines = project.getDeadlines();
|
|
|
|
|
|
|
|
this.executorIds = convert(users, user -> user.getId());
|
|
|
|
|
|
|
|
this.executors = convert(project.getExecutors(), UserDto::new);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Integer getId() {
|
|
|
|
public Integer getId() {
|
|
|
@ -121,4 +141,35 @@ public class ProjectDto {
|
|
|
|
public void setApplicationFileName(String applicationFileName) {
|
|
|
|
public void setApplicationFileName(String applicationFileName) {
|
|
|
|
this.applicationFileName = applicationFileName;
|
|
|
|
this.applicationFileName = applicationFileName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Integer> getRemovedDeadlineIds() {
|
|
|
|
|
|
|
|
return removedDeadlineIds;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setRemovedDeadlineIds(List<Integer> removedDeadlineIds) {
|
|
|
|
|
|
|
|
this.removedDeadlineIds = removedDeadlineIds;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Set<Integer> getExecutorIds() {
|
|
|
|
|
|
|
|
return executorIds;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setExecutorIds(Set<Integer> executorIds) {
|
|
|
|
|
|
|
|
this.executorIds = executorIds;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<UserDto> getExecutors() {
|
|
|
|
|
|
|
|
return executors;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setExecutors(List<UserDto> executors) {
|
|
|
|
|
|
|
|
this.executors = executors;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getExecutorsString() {
|
|
|
|
|
|
|
|
return StringUtils.abbreviate(executors
|
|
|
|
|
|
|
|
.stream()
|
|
|
|
|
|
|
|
.map(executor -> executor.getLastName())
|
|
|
|
|
|
|
|
.collect(Collectors.joining(", ")), MAX_EXECUTORS_LENGTH);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|