From 255692d6ea7d125e526266d706474adbf943aef7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=92=D0=B0=D1=81=D0=B8=D0=BD=20=D0=90=D0=BD=D1=82=D0=BE?=
=?UTF-8?q?=D0=BD?=
Date: Wed, 17 Apr 2019 14:38:07 +0300
Subject: [PATCH] #96 project status added
---
.../project/controller/ProjectController.java | 5 ++++
.../java/ru/ulstu/project/model/Project.java | 29 +++++++++++++++++++
.../ru/ulstu/project/model/ProjectDto.java | 12 ++++++++
.../ulstu/project/service/ProjectService.java | 4 +++
.../resources/templates/projects/project.html | 9 ++++++
5 files changed, 59 insertions(+)
diff --git a/src/main/java/ru/ulstu/project/controller/ProjectController.java b/src/main/java/ru/ulstu/project/controller/ProjectController.java
index b71fc1d..88d2612 100644
--- a/src/main/java/ru/ulstu/project/controller/ProjectController.java
+++ b/src/main/java/ru/ulstu/project/controller/ProjectController.java
@@ -46,4 +46,9 @@ public class ProjectController {
modelMap.put("projectDto", new ProjectDto());
}
}
+
+ @ModelAttribute("allStatuses")
+ public List getProjectStatuses() {
+ return projectService.getProjectStatuses();
+ }
}
diff --git a/src/main/java/ru/ulstu/project/model/Project.java b/src/main/java/ru/ulstu/project/model/Project.java
index 07a8108..de2db7a 100644
--- a/src/main/java/ru/ulstu/project/model/Project.java
+++ b/src/main/java/ru/ulstu/project/model/Project.java
@@ -10,10 +10,31 @@ import java.util.List;
@Entity
public class Project extends BaseEntity {
+ public enum ProjectStatus {
+ APPLICATION("Заявка"),
+ ON_COMPETITION("Отправлен на конкурс"),
+ SUCCESSFUL_PASSAGE("Успешное прохождение"),
+ IN_WORK("В работе"),
+ COMPLETED("Завершен"),
+ FAILED("Провалены сроки");
+
+ private String statusName;
+
+ ProjectStatus(String statusName) {
+ this.statusName = statusName;
+ }
+
+ public String getStatusName() {
+ return statusName;
+ }
+ }
@NotBlank
private String title;
+ @Enumerated(value = EnumType.STRING)
+ private ProjectStatus status = ProjectStatus.APPLICATION;
+
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "project_id")
private List deadlines = new ArrayList<>();
@@ -26,6 +47,14 @@ public class Project extends BaseEntity {
this.title = title;
}
+ public ProjectStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(ProjectStatus status) {
+ this.status = status;
+ }
+
public List getDeadlines() {
return deadlines;
}
diff --git a/src/main/java/ru/ulstu/project/model/ProjectDto.java b/src/main/java/ru/ulstu/project/model/ProjectDto.java
index 8549994..adb8979 100644
--- a/src/main/java/ru/ulstu/project/model/ProjectDto.java
+++ b/src/main/java/ru/ulstu/project/model/ProjectDto.java
@@ -13,6 +13,7 @@ public class ProjectDto {
@NotEmpty
private String title;
+ private Project.ProjectStatus status;
private List deadlines = new ArrayList<>();
public ProjectDto() {
@@ -25,9 +26,11 @@ public class ProjectDto {
@JsonCreator
public ProjectDto(@JsonProperty("id") Integer id,
@JsonProperty("title") String title,
+ @JsonProperty("status") Project.ProjectStatus status,
@JsonProperty("deadlines") List deadlines) {
this.id = id;
this.title = title;
+ this.status = status;
this.deadlines = deadlines;
}
@@ -35,6 +38,7 @@ public class ProjectDto {
public ProjectDto(Project project) {
this.id = project.getId();
this.title = project.getTitle();
+ this.status = project.getStatus();
this.deadlines = project.getDeadlines();
}
@@ -54,6 +58,14 @@ public class ProjectDto {
this.title = title;
}
+ public Project.ProjectStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(Project.ProjectStatus status) {
+ this.status = status;
+ }
+
public List getDeadlines() {
return deadlines;
}
diff --git a/src/main/java/ru/ulstu/project/service/ProjectService.java b/src/main/java/ru/ulstu/project/service/ProjectService.java
index bdf5f33..99d8919 100644
--- a/src/main/java/ru/ulstu/project/service/ProjectService.java
+++ b/src/main/java/ru/ulstu/project/service/ProjectService.java
@@ -41,6 +41,10 @@ public class ProjectService {
return new ProjectDto(projectRepository.findOne(id));
}
+ public List getProjectStatuses() {
+ return Arrays.asList(Project.ProjectStatus.values());
+ }
+
@Transactional
public Project create(ProjectDto projectDto) {
Project newProject = copyFromDto(new Project(), projectDto);
diff --git a/src/main/resources/templates/projects/project.html b/src/main/resources/templates/projects/project.html
index b46c328..cce6df8 100644
--- a/src/main/resources/templates/projects/project.html
+++ b/src/main/resources/templates/projects/project.html
@@ -33,6 +33,15 @@
class="alert alert-danger">Incorrect title
+
+
+
+
+