From a3d1834ab8968dd9689a295addb7720579841e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D0=BC=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=20=D0=9C?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D1=8F?= Date: Sun, 21 Apr 2019 12:17:31 +0400 Subject: [PATCH] #110 add paper type --- .../paper/controller/PaperController.java | 5 ++++ src/main/java/ru/ulstu/paper/model/Paper.java | 28 +++++++++++++++++++ .../java/ru/ulstu/paper/model/PaperDto.java | 12 ++++++++ .../ru/ulstu/paper/service/PaperService.java | 7 +++++ .../db/changelog-20190421_000000-schema.xml | 15 ++++++++++ src/main/resources/db/changelog-master.xml | 1 + .../resources/templates/papers/paper.html | 9 ++++++ 7 files changed, 77 insertions(+) create mode 100644 src/main/resources/db/changelog-20190421_000000-schema.xml diff --git a/src/main/java/ru/ulstu/paper/controller/PaperController.java b/src/main/java/ru/ulstu/paper/controller/PaperController.java index ad30822..e11e4d9 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperController.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperController.java @@ -105,6 +105,11 @@ public class PaperController { return paperService.getPaperStatuses(); } + @ModelAttribute("allTypes") + public List getPaperTypes() { + return paperService.getPaperTypes(); + } + @ModelAttribute("allAuthors") public List getAllAuthors() { return paperService.getPaperAuthors(); diff --git a/src/main/java/ru/ulstu/paper/model/Paper.java b/src/main/java/ru/ulstu/paper/model/Paper.java index c7f7fcf..65bd32c 100644 --- a/src/main/java/ru/ulstu/paper/model/Paper.java +++ b/src/main/java/ru/ulstu/paper/model/Paper.java @@ -53,12 +53,32 @@ public class Paper extends BaseEntity implements UserContainer { } } + public enum PaperType { + OTHER("Прочая публикация"), + VAK("ВАК"), + SCOPUS("Scopus"), + WEB_OF_SCIENCE("Web Of Science"); + + private String typeName; + + PaperType(String name) { + this.typeName = name; + } + + public String getTypeName() { + return typeName; + } + } + @NotBlank private String title; @Enumerated(value = EnumType.STRING) private PaperStatus status = PaperStatus.DRAFT; + @Enumerated(value = EnumType.STRING) + private PaperType type = PaperType.OTHER; + @Column(name = "create_date") @Temporal(TemporalType.TIMESTAMP) private Date createDate = new Date(); @@ -102,6 +122,14 @@ public class Paper extends BaseEntity implements UserContainer { this.status = status; } + public PaperType getType() { + return type; + } + + public void setType(PaperType type) { + this.type = type; + } + public Date getCreateDate() { return createDate; } diff --git a/src/main/java/ru/ulstu/paper/model/PaperDto.java b/src/main/java/ru/ulstu/paper/model/PaperDto.java index 7ddc0e0..11d6dfc 100644 --- a/src/main/java/ru/ulstu/paper/model/PaperDto.java +++ b/src/main/java/ru/ulstu/paper/model/PaperDto.java @@ -25,6 +25,7 @@ public class PaperDto { @Size(min = 3, max = 254) private String title; private Paper.PaperStatus status; + private Paper.PaperType type; private Date createDate; private Date updateDate; @NotEmpty @@ -46,6 +47,7 @@ public class PaperDto { public PaperDto(@JsonProperty("id") Integer id, @JsonProperty("title") String title, @JsonProperty("status") Paper.PaperStatus status, + @JsonProperty("type") Paper.PaperType type, @JsonProperty("createDate") Date createDate, @JsonProperty("updateDate") Date updateDate, @JsonProperty("deadlines") List deadlines, @@ -59,6 +61,7 @@ public class PaperDto { this.id = id; this.title = title; this.status = status; + this.type = type; this.createDate = createDate; this.updateDate = updateDate; this.deadlines = deadlines; @@ -74,6 +77,7 @@ public class PaperDto { this.id = paper.getId(); this.title = paper.getTitle(); this.status = paper.getStatus(); + this.type = paper.getType(); this.createDate = paper.getCreateDate(); this.updateDate = paper.getUpdateDate(); this.deadlines = paper.getDeadlines(); @@ -110,6 +114,14 @@ public class PaperDto { this.status = status; } + public Paper.PaperType getType() { + return type; + } + + public void setType(Paper.PaperType type) { + this.type = type; + } + public Date getCreateDate() { return createDate; } diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index a10d941..1633c07 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -31,6 +31,7 @@ import static ru.ulstu.paper.model.Paper.PaperStatus.COMPLETED; import static ru.ulstu.paper.model.Paper.PaperStatus.DRAFT; import static ru.ulstu.paper.model.Paper.PaperStatus.FAILED; import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION; +import static ru.ulstu.paper.model.Paper.PaperType.OTHER; @Service public class PaperService { @@ -99,6 +100,7 @@ public class PaperService { paper.setCreateDate(paper.getCreateDate() == null ? new Date() : paper.getCreateDate()); paper.setLocked(paperDto.getLocked()); paper.setStatus(paperDto.getStatus() == null ? DRAFT : paperDto.getStatus()); + paper.setType(paperDto.getType() == null ? OTHER : paperDto.getType()); paper.setTitle(paperDto.getTitle()); paper.setUpdateDate(new Date()); paper.setDeadlines(deadlineService.saveOrCreate(paperDto.getDeadlines())); @@ -149,6 +151,10 @@ public class PaperService { return Arrays.asList(Paper.PaperStatus.values()); } + public List getPaperTypes() { + return Arrays.asList(Paper.PaperType.values()); + } + @Transactional public Paper create(String title, User user, Date deadlineDate) { Paper paper = new Paper(); @@ -158,6 +164,7 @@ public class PaperService { paper.setCreateDate(new Date()); paper.setUpdateDate(new Date()); paper.setStatus(DRAFT); + paper.setType(OTHER); paper = paperRepository.save(paper); paperNotificationService.sendCreateNotification(paper); diff --git a/src/main/resources/db/changelog-20190421_000000-schema.xml b/src/main/resources/db/changelog-20190421_000000-schema.xml new file mode 100644 index 0000000..b7fc374 --- /dev/null +++ b/src/main/resources/db/changelog-20190421_000000-schema.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/src/main/resources/db/changelog-master.xml b/src/main/resources/db/changelog-master.xml index 32651bc..d0f1837 100644 --- a/src/main/resources/db/changelog-master.xml +++ b/src/main/resources/db/changelog-master.xml @@ -30,4 +30,5 @@ + \ No newline at end of file diff --git a/src/main/resources/templates/papers/paper.html b/src/main/resources/templates/papers/paper.html index fe355f6..d408913 100644 --- a/src/main/resources/templates/papers/paper.html +++ b/src/main/resources/templates/papers/paper.html @@ -47,6 +47,15 @@

+
+ + +
+