#98 project completion added

pull/201/head
Васин Антон 5 years ago
parent 4bab980f62
commit 4025aa67ca

@ -5,17 +5,22 @@ import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.file.model.FileData;
import ru.ulstu.grant.model.Grant;
import ru.ulstu.user.model.User;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Entity
public class Project extends BaseEntity {
@ -62,6 +67,9 @@ public class Project extends BaseEntity {
@JoinColumn(name = "file_id")
private FileData application;
@ManyToMany(fetch = FetchType.EAGER)
private Set<User> executors = new HashSet<>();
public String getTitle() {
return title;
}
@ -117,4 +125,12 @@ public class Project extends BaseEntity {
public void setApplication(FileData application) {
this.application = application;
}
public Set<User> getExecutors() {
return executors;
}
public void setExecutors(Set<User> executors) {
this.executors = executors;
}
}

@ -3,11 +3,17 @@ package ru.ulstu.project.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
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.UserDto;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static ru.ulstu.core.util.StreamApiUtils.convert;
public class ProjectDto {
private Integer id;
@ -21,6 +27,10 @@ public class ProjectDto {
private String repository;
private String applicationFileName;
private List<Integer> removedDeadlineIds = new ArrayList<>();
private Set<Integer> executorIds;
private Set<UserDto> executors;
private final static int MAX_EXECUTORS_LENGTH = 40;
public ProjectDto() {
}
@ -36,7 +46,9 @@ public class ProjectDto {
@JsonProperty("description") String description,
@JsonProperty("grant") GrantDto grant,
@JsonProperty("repository") String repository,
@JsonProperty("deadlines") List<Deadline> deadlines) {
@JsonProperty("deadlines") List<Deadline> deadlines,
@JsonProperty("executorIds") Set<Integer> executorIds,
@JsonProperty("executors") Set<UserDto> executors) {
this.id = id;
this.title = title;
this.status = status;
@ -45,6 +57,8 @@ public class ProjectDto {
this.repository = repository;
this.deadlines = deadlines;
this.applicationFileName = null;
this.executorIds = executorIds;
this.executors = executors;
}
@ -57,6 +71,8 @@ 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.executors = convert(project.getExecutors(), UserDto::new);
}
public Integer getId() {
@ -130,4 +146,27 @@ public class ProjectDto {
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 Set<UserDto> getExecutors() {
return executors;
}
public void setExecutors(Set<UserDto> executors) {
this.executors = executors;
}
public String getExecutorsString() {
return StringUtils.abbreviate(executors
.stream()
.map(executor -> executor.getLastName())
.collect(Collectors.joining(", ")), MAX_EXECUTORS_LENGTH);
}
}

@ -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="20190506_000000-2">
<createTable tableName="project_executors">
<column name="project_id" type="integer"/>
<column name="executors_id" type="integer"/>
</createTable>
<addForeignKeyConstraint baseTableName="project_executors" baseColumnNames="project_id"
constraintName="fk_project_project_executors" referencedTableName="project"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="project_executors" baseColumnNames="executors_id"
constraintName="fk_user_project_executors" referencedTableName="users"
referencedColumnNames="id"/>
</changeSet>
</databaseChangeLog>

@ -39,4 +39,5 @@
<include file="db/changelog-20190430_000000-schema.xml"/>
<include file="db/changelog-20190505_000000-schema.xml"/>
<include file="db/changelog-20190506_000000-schema.xml"/>
<include file="db/changelog-20190506_000001-schema.xml"/>
</databaseChangeLog>

@ -0,0 +1,5 @@
.div-deadline-done {
width: 60%;
height: 100%;
float: right;
}

@ -3,7 +3,7 @@
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
<head>
<link rel="stylesheet" href="../css/project.css"/>
</head>
<body>
@ -90,17 +90,18 @@
aria-hidden="true"><i class="fa fa-times"/></span>
</a>
</div>
</div>
<p th:if="${#fields.hasErrors('deadlines')}" th:errors="*{deadlines}"
class="alert alert-danger">Incorrect title</p>
</div>
<div class="form-group">
<div class="row" th:each="deadline, rowStat : *{deadlines}">
<div class="col-12" style="margin-bottom: 15px;"></div>
<div class="col-10 div-deadline-executor">
<input class="form-control" type="text" placeholder="Исполнитель"
th:field="*{deadlines[__${rowStat.index}__].executor}"/>
</div>
<div class="col-2">
<input class="form-control div-deadline-done" type="checkbox"
th:field="*{deadlines[__${rowStat.index}__].done}"/>
</div>
</div>
<p th:if="${#fields.hasErrors('deadlines')}" th:errors="*{deadlines}"
class="alert alert-danger">Incorrect title</p>
</div>
<div class="form-group">
<input type="submit" id="addDeadline" name="addDeadline" class="btn btn-primary"

Loading…
Cancel
Save