#98 executors list added

pull/201/head
a.vasin 5 years ago
parent 8d1e410e83
commit 3b0a2dd964

@ -4,11 +4,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.format.annotation.DateTimeFormat;
import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.user.model.User;
import javax.persistence.Entity;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Entity
@ -20,7 +20,9 @@ public class Deadline extends BaseEntity {
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date date;
private Integer executor;
@OneToMany(targetEntity=User.class, fetch=FetchType.EAGER)
private List<User> executors;
private Boolean done;
public Deadline() {
@ -31,10 +33,10 @@ public class Deadline extends BaseEntity {
this.description = description;
}
public Deadline(Date deadlineDate, String description, Integer executor, Boolean done) {
public Deadline(Date deadlineDate, String description, List<User> executors, Boolean done) {
this.date = deadlineDate;
this.description = description;
this.executor = executor;
this.executors = executors;
this.done = done;
}
@ -42,12 +44,12 @@ public class Deadline extends BaseEntity {
public Deadline(@JsonProperty("id") Integer id,
@JsonProperty("description") String description,
@JsonProperty("date") Date date,
@JsonProperty("executor") Integer executor,
@JsonProperty("executors") List<User> executors,
@JsonProperty("done") Boolean done) {
this.setId(id);
this.description = description;
this.date = date;
this.executor = executor;
this.executors = executors;
this.done = done;
}
@ -67,12 +69,12 @@ public class Deadline extends BaseEntity {
this.date = date;
}
public Integer getExecutor() {
return executor;
public List<User> getExecutors() {
return executors;
}
public void setExecutor(Integer executor) {
this.executor = executor;
public void setExecutors(List<User> executors) {
this.executors = executors;
}
public Boolean getDone() {
@ -103,12 +105,12 @@ public class Deadline extends BaseEntity {
return getId().equals(deadline.getId()) &&
description.equals(deadline.description) &&
date.equals(deadline.date) &&
executor.equals(deadline.executor) &&
executors.equals(deadline.executors) &&
done.equals(deadline.done);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), description, date, executor, done);
return Objects.hash(super.hashCode(), description, date, executors, done);
}
}

@ -30,7 +30,7 @@ public class DeadlineService {
Deadline updateDeadline = deadlineRepository.findOne(deadline.getId());
updateDeadline.setDate(deadline.getDate());
updateDeadline.setDescription(deadline.getDescription());
updateDeadline.setExecutor(deadline.getExecutor());
updateDeadline.setExecutors(deadline.getExecutors());
updateDeadline.setDone(deadline.getDone());
deadlineRepository.save(updateDeadline);
return updateDeadline;
@ -41,7 +41,7 @@ public class DeadlineService {
Deadline newDeadline = new Deadline();
newDeadline.setDate(deadline.getDate());
newDeadline.setDescription(deadline.getDescription());
newDeadline.setExecutor(deadline.getExecutor());
newDeadline.setExecutors(deadline.getExecutors());
newDeadline.setDone(deadline.getDone());
newDeadline = deadlineRepository.save(newDeadline);
return newDeadline;

@ -27,7 +27,7 @@ import java.util.Set;
public class Project extends BaseEntity implements UserContainer {
public enum ProjectStatus {
TT("ТЗ"),
TECHNICAL_TASK("Техническое задание"),
OPEN("Открыт"),
IN_WORK("В работе"),
CERTIFICATE_ISSUED("Оформление свидетельства"),
@ -49,7 +49,7 @@ public class Project extends BaseEntity implements UserContainer {
private String title;
@Enumerated(value = EnumType.STRING)
private ProjectStatus status = ProjectStatus.TT;
private ProjectStatus status = ProjectStatus.TECHNICAL_TASK;
@NotNull
private String description;
@ -69,8 +69,8 @@ public class Project extends BaseEntity implements UserContainer {
@JoinColumn(name = "file_id")
private FileData application;
@ManyToMany(fetch = FetchType.EAGER)
private Set<User> executors = new HashSet<>();
@ManyToMany(fetch = FetchType.LAZY)
private List<User> executors = new ArrayList<>();
public String getTitle() {
return title;
@ -128,16 +128,17 @@ public class Project extends BaseEntity implements UserContainer {
this.application = application;
}
public Set<User> getExecutors() {
public List<User> getExecutors() {
return executors;
}
public void setExecutors(Set<User> executors) {
public void setExecutors(List<User> executors) {
this.executors = executors;
}
@Override
public Set<User> getUsers() {
return getExecutors();
Set<User> users = new HashSet<User>(getExecutors());
return users;
}
}

@ -6,9 +6,11 @@ import org.hibernate.validator.constraints.NotEmpty;
import org.thymeleaf.util.StringUtils;
import ru.ulstu.deadline.model.Deadline;
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.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@ -28,7 +30,7 @@ public class ProjectDto {
private String applicationFileName;
private List<Integer> removedDeadlineIds = new ArrayList<>();
private Set<Integer> executorIds;
private Set<UserDto> executors;
private List<UserDto> executors;
private boolean hasAge;
private boolean hasDegree;
@ -50,7 +52,7 @@ public class ProjectDto {
@JsonProperty("repository") String repository,
@JsonProperty("deadlines") List<Deadline> deadlines,
@JsonProperty("executorIds") Set<Integer> executorIds,
@JsonProperty("executors") Set<UserDto> executors,
@JsonProperty("executors") List<UserDto> executors,
@JsonProperty("hasAge") boolean hasAge,
@JsonProperty("hasDegree") boolean hasDegree) {
this.id = id;
@ -69,6 +71,7 @@ public class ProjectDto {
public ProjectDto(Project project) {
Set<User> users = new HashSet<User>(project.getExecutors());
this.id = project.getId();
this.title = project.getTitle();
this.status = project.getStatus();
@ -77,7 +80,7 @@ public class ProjectDto {
this.grant = project.getGrant() == null ? null : new GrantDto(project.getGrant());
this.repository = project.getRepository();
this.deadlines = project.getDeadlines();
this.executorIds = convert(project.getExecutors(), user -> user.getId());
this.executorIds = convert(users, user -> user.getId());
this.executors = convert(project.getExecutors(), UserDto::new);
}
@ -161,11 +164,11 @@ public class ProjectDto {
this.executorIds = executorIds;
}
public Set<UserDto> getExecutors() {
public List<UserDto> getExecutors() {
return executors;
}
public void setExecutors(Set<UserDto> executors) {
public void setExecutors(List<UserDto> executors) {
this.executors = executors;
}

@ -5,7 +5,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.thymeleaf.util.StringUtils;
import ru.ulstu.deadline.service.DeadlineService;
import ru.ulstu.file.service.FileService;
import ru.ulstu.grant.model.GrantDto;
import ru.ulstu.grant.repository.GrantRepository;
import ru.ulstu.project.model.Project;
import ru.ulstu.project.model.ProjectDto;
@ -19,7 +18,7 @@ import java.util.List;
import static org.springframework.util.ObjectUtils.isEmpty;
import static ru.ulstu.core.util.StreamApiUtils.convert;
import static ru.ulstu.project.model.Project.ProjectStatus.TT;
import static ru.ulstu.project.model.Project.ProjectStatus.TECHNICAL_TASK;
@Service
public class ProjectService {
@ -89,7 +88,7 @@ public class ProjectService {
private Project copyFromDto(Project project, ProjectDto projectDto) throws IOException {
project.setDescription(projectDto.getDescription());
project.setStatus(projectDto.getStatus() == null ? TT : projectDto.getStatus());
project.setStatus(projectDto.getStatus() == null ? TECHNICAL_TASK : projectDto.getStatus());
project.setTitle(projectDto.getTitle());
if (projectDto.getGrant() != null && projectDto.getGrant().getId() != null) {
project.setGrant(grantRepository.findOne(projectDto.getGrant().getId()));

@ -0,0 +1,11 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet author="anton" id="20190528_000000-1">
<renameColumn tableName="deadline"
columnDataType="integer"
newColumnName="executors"
oldColumnName="executor"/>
</changeSet>
</databaseChangeLog>

@ -0,0 +1,17 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet author="anton" id="20190528_000000-1">
<createTable tableName="deadline_executors">
<column name="deadline_id" type="integer"/>
<column name="executors" type="integer"/>
</createTable>
<addForeignKeyConstraint baseTableName="deadline_executors" baseColumnNames="deadline_id"
constraintName="fk_deadline_deadline_executors" referencedTableName="deadline"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="deadline_executors" baseColumnNames="executors"
constraintName="fk_user_deadline_executors" referencedTableName="users"
referencedColumnNames="id"/>
</changeSet>
</databaseChangeLog>

@ -47,4 +47,6 @@
<include file="db/changelog-20190517_000001-schema.xml"/>
<include file="db/changelog-20190520_000000-schema.xml"/>
<include file="db/changelog-20190523_000000-schema.xml"/>
<include file="db/changelog-20190528_000000-schema.xml"/>
<include file="db/changelog-20190528_000001-schema.xml"/>
</databaseChangeLog>

@ -6,7 +6,7 @@
<body>
<span th:fragment="projectStatus (projectStatus)" class="fa-stack fa-1x">
<th:block th:switch="${projectStatus.name()}">
<div th:case="'TT'">
<div th:case="'TECHNICAL_TASK'">
<i class="fa fa-circle fa-stack-2x text-draft"></i>
</div>
<div th:case="'OPEN'">

Loading…
Cancel
Save