From 92d3067dd3e24cf41af0475d82eaa0c067b6aea0 Mon Sep 17 00:00:00 2001 From: Alyona Date: Tue, 30 Oct 2018 23:59:42 +0400 Subject: [PATCH 1/4] added event status --- .../java/ru/ulstu/timeline/model/Event.java | 32 +++++++++++++++---- .../ru/ulstu/timeline/model/EventDto.java | 6 ++++ .../ulstu/timeline/model/EventStatusDto.java | 19 +++++++++++ .../ulstu/timeline/service/EventService.java | 1 + 4 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 src/main/java/ru/ulstu/timeline/model/EventStatusDto.java diff --git a/src/main/java/ru/ulstu/timeline/model/Event.java b/src/main/java/ru/ulstu/timeline/model/Event.java index 404025a..7a0117c 100644 --- a/src/main/java/ru/ulstu/timeline/model/Event.java +++ b/src/main/java/ru/ulstu/timeline/model/Event.java @@ -4,20 +4,32 @@ import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.user.model.User; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.ManyToMany; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import javax.persistence.*; import java.util.Date; import java.util.List; @Entity public class Event extends BaseEntity { + public enum EventStatus { + POSSIBLE("Возможное"), NEW("Новое"), IN_PROGRESS("В процессе"), COMPLETED("Завершено"); + + private String name; + + EventStatus(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } + @NotBlank private String title; + @Enumerated(value = EnumType.STRING) + private EventStatus status; + @Column(name = "execute_date") @Temporal(TemporalType.TIMESTAMP) private Date executeDate; @@ -43,6 +55,14 @@ public class Event extends BaseEntity { this.title = title; } + public EventStatus getStatus() { + return status; + } + + public void setStatus(EventStatus status) { + this.status = status; + } + public Date getCreateDate() { return createDate; } diff --git a/src/main/java/ru/ulstu/timeline/model/EventDto.java b/src/main/java/ru/ulstu/timeline/model/EventDto.java index 59cef34..b409ce8 100644 --- a/src/main/java/ru/ulstu/timeline/model/EventDto.java +++ b/src/main/java/ru/ulstu/timeline/model/EventDto.java @@ -12,6 +12,7 @@ import static ru.ulstu.core.util.StreamApiUtils.convert; public class EventDto { private final Integer id; private final String title; + private final Event.EventStatus status; private final Date executeDate; private final Date createDate; private final Date updateDate; @@ -21,6 +22,7 @@ public class EventDto { @JsonCreator public EventDto(@JsonProperty("id") Integer id, @JsonProperty("title") String title, + @JsonProperty("status") Event.EventStatus status, @JsonProperty("executeDate") Date executeDate, @JsonProperty("createDate") Date createDate, @JsonProperty("updateDate") Date updateDate, @@ -28,6 +30,7 @@ public class EventDto { @JsonProperty("recipients") List recipients) { this.id = id; this.title = title; + this.status = status; this.executeDate = executeDate; this.createDate = createDate; this.updateDate = updateDate; @@ -38,6 +41,7 @@ public class EventDto { public EventDto(Event event) { this.id = event.getId(); this.title = event.getTitle(); + this.status = event.getStatus(); this.executeDate = event.getExecuteDate(); this.createDate = event.getCreateDate(); this.updateDate = event.getUpdateDate(); @@ -53,6 +57,8 @@ public class EventDto { return title; } + public Event.EventStatus getStatus() { return status; } + public Date getCreateDate() { return createDate; } diff --git a/src/main/java/ru/ulstu/timeline/model/EventStatusDto.java b/src/main/java/ru/ulstu/timeline/model/EventStatusDto.java new file mode 100644 index 0000000..6bb4bbc --- /dev/null +++ b/src/main/java/ru/ulstu/timeline/model/EventStatusDto.java @@ -0,0 +1,19 @@ +package ru.ulstu.timeline.model; + +public class EventStatusDto { + private final String id; + private final String name; + + public EventStatusDto(Event.EventStatus status) { + this.id = status.name(); + this.name = status.getName(); + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/ru/ulstu/timeline/service/EventService.java b/src/main/java/ru/ulstu/timeline/service/EventService.java index 0c1cf6c..8d8189d 100644 --- a/src/main/java/ru/ulstu/timeline/service/EventService.java +++ b/src/main/java/ru/ulstu/timeline/service/EventService.java @@ -46,6 +46,7 @@ public class EventService { event.setDescription(eventDto.getDescription()); event.setRecipients(userService.findByIds(convert(eventDto.getRecipients(), UserDto::getId))); event.setTitle(eventDto.getTitle()); + event.setStatus(eventDto.getStatus()); event.setUpdateDate(eventDto.getUpdateDate()); return event; } From 0341a823d27c7a519efad4843429fc212952d0f7 Mon Sep 17 00:00:00 2001 From: Alyona Date: Wed, 31 Oct 2018 19:33:21 +0400 Subject: [PATCH 2/4] =?UTF-8?q?Merge=20branch=20'master'=20of=20C:\Users\?= =?UTF-8?q?=D0=BA=D0=B0=D1=82=D1=8F\IdeaProjects\ng-tracker=20with=20confl?= =?UTF-8?q?icts.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ulstu/timeline/model/EventStatusDto.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/ru/ulstu/timeline/model/EventStatusDto.java diff --git a/src/main/java/ru/ulstu/timeline/model/EventStatusDto.java b/src/main/java/ru/ulstu/timeline/model/EventStatusDto.java new file mode 100644 index 0000000..6bb4bbc --- /dev/null +++ b/src/main/java/ru/ulstu/timeline/model/EventStatusDto.java @@ -0,0 +1,19 @@ +package ru.ulstu.timeline.model; + +public class EventStatusDto { + private final String id; + private final String name; + + public EventStatusDto(Event.EventStatus status) { + this.id = status.name(); + this.name = status.getName(); + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } +} From 8fe9f6625ca2fe4f98b895f0521665055b1b4e13 Mon Sep 17 00:00:00 2001 From: Alyona Date: Wed, 31 Oct 2018 20:06:27 +0400 Subject: [PATCH 3/4] changelog --- .../db/changelog-20181031_000000-schema.xml | 13 +++++++++++++ src/main/resources/db/changelog-master.xml | 1 + 2 files changed, 14 insertions(+) create mode 100644 src/main/resources/db/changelog-20181031_000000-schema.xml diff --git a/src/main/resources/db/changelog-20181031_000000-schema.xml b/src/main/resources/db/changelog-20181031_000000-schema.xml new file mode 100644 index 0000000..7a727fc --- /dev/null +++ b/src/main/resources/db/changelog-20181031_000000-schema.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/db/changelog-master.xml b/src/main/resources/db/changelog-master.xml index bd52f71..d2de71d 100644 --- a/src/main/resources/db/changelog-master.xml +++ b/src/main/resources/db/changelog-master.xml @@ -13,4 +13,5 @@ + \ No newline at end of file From 42fb1a15374a27d1a8ab14d3d87244a3bccf74d8 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Thu, 1 Nov 2018 12:53:19 +0400 Subject: [PATCH 4/4] fix imports --- src/main/java/ru/ulstu/timeline/model/Event.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/ru/ulstu/timeline/model/Event.java b/src/main/java/ru/ulstu/timeline/model/Event.java index 7a0117c..89ff4cd 100644 --- a/src/main/java/ru/ulstu/timeline/model/Event.java +++ b/src/main/java/ru/ulstu/timeline/model/Event.java @@ -4,7 +4,14 @@ import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.user.model.User; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.ManyToMany; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; import java.util.Date; import java.util.List;