From 92d3067dd3e24cf41af0475d82eaa0c067b6aea0 Mon Sep 17 00:00:00 2001 From: Alyona Date: Tue, 30 Oct 2018 23:59:42 +0400 Subject: [PATCH 01/40] 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 02/40] =?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=20conf?= =?UTF-8?q?licts.?= 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 03/40] 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 04/40] 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; From 25707db6cd59430a0942f9ac99deae18204b0937 Mon Sep 17 00:00:00 2001 From: Alyona Date: Fri, 9 Nov 2018 14:48:21 +0400 Subject: [PATCH 05/40] added period event --- .../java/ru/ulstu/timeline/model/Event.java | 22 +++++-- .../ru/ulstu/timeline/model/EventDto.java | 12 ++++ .../ru/ulstu/timeline/model/PeriodEvent.java | 24 +++++++ .../timeline/service/EventScheduler.java | 63 +++++++++++++++++++ .../ulstu/timeline/service/EventService.java | 2 + 5 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 src/main/java/ru/ulstu/timeline/model/PeriodEvent.java create mode 100644 src/main/java/ru/ulstu/timeline/service/EventScheduler.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..cec7614 100644 --- a/src/main/java/ru/ulstu/timeline/model/Event.java +++ b/src/main/java/ru/ulstu/timeline/model/Event.java @@ -4,12 +4,7 @@ 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; @@ -18,6 +13,13 @@ public class Event extends BaseEntity { @NotBlank private String title; + @Enumerated(value = EnumType.STRING) + private PeriodEvent period; + + @Column(name = "begin_date") + @Temporal(TemporalType.TIMESTAMP) + private Date beginDate; + @Column(name = "execute_date") @Temporal(TemporalType.TIMESTAMP) private Date executeDate; @@ -43,6 +45,14 @@ public class Event extends BaseEntity { this.title = title; } + public PeriodEvent getPeriod() {return period; } + + public void setPeriod(PeriodEvent period) { this.period = period; } + + public Date getBeginDate() {return beginDate; } + + public void setBeginDate(Date beginDate){this.beginDate = beginDate; } + 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..65ca13e 100644 --- a/src/main/java/ru/ulstu/timeline/model/EventDto.java +++ b/src/main/java/ru/ulstu/timeline/model/EventDto.java @@ -12,6 +12,8 @@ import static ru.ulstu.core.util.StreamApiUtils.convert; public class EventDto { private final Integer id; private final String title; + private final PeriodEvent period; + private final Date beginDate; private final Date executeDate; private final Date createDate; private final Date updateDate; @@ -21,6 +23,8 @@ public class EventDto { @JsonCreator public EventDto(@JsonProperty("id") Integer id, @JsonProperty("title") String title, + @JsonProperty("period") PeriodEvent period, + @JsonProperty("beginDate") Date beginDate, @JsonProperty("executeDate") Date executeDate, @JsonProperty("createDate") Date createDate, @JsonProperty("updateDate") Date updateDate, @@ -28,6 +32,8 @@ public class EventDto { @JsonProperty("recipients") List recipients) { this.id = id; this.title = title; + this.period = period; + this.beginDate = beginDate; this.executeDate = executeDate; this.createDate = createDate; this.updateDate = updateDate; @@ -38,6 +44,8 @@ public class EventDto { public EventDto(Event event) { this.id = event.getId(); this.title = event.getTitle(); + this.period = event.getPeriod(); + this.beginDate = event.getBeginDate(); this.executeDate = event.getExecuteDate(); this.createDate = event.getCreateDate(); this.updateDate = event.getUpdateDate(); @@ -53,6 +61,10 @@ public class EventDto { return title; } + public PeriodEvent getPeriod() { return period; } + + public Date getBeginDate() { return beginDate; } + public Date getCreateDate() { return createDate; } diff --git a/src/main/java/ru/ulstu/timeline/model/PeriodEvent.java b/src/main/java/ru/ulstu/timeline/model/PeriodEvent.java new file mode 100644 index 0000000..b5e73b8 --- /dev/null +++ b/src/main/java/ru/ulstu/timeline/model/PeriodEvent.java @@ -0,0 +1,24 @@ +package ru.ulstu.timeline.model; + +import java.time.Period; + +public enum PeriodEvent { + EVERY_YEAR(Period.ofYears(1), "Каждый год"), + EVERY_MONTH(Period.ofMonths(1), "Каждый месяц"), + EVERY_WEEK(Period.ofWeeks(1), "Каждую неделю"), + EVERY_DAY(Period.ofDays(1), "Каждый день"); + + private Period period; + private String message; + + PeriodEvent(Period period, String message) { + this.period = period; + this.message = message; + } + + public Period getPeriod() { return period; } + + public String getMessage() { + return message; + } +} diff --git a/src/main/java/ru/ulstu/timeline/service/EventScheduler.java b/src/main/java/ru/ulstu/timeline/service/EventScheduler.java new file mode 100644 index 0000000..482e201 --- /dev/null +++ b/src/main/java/ru/ulstu/timeline/service/EventScheduler.java @@ -0,0 +1,63 @@ +package ru.ulstu.timeline.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Scheduled; +import ru.ulstu.core.util.DateUtils; +import ru.ulstu.timeline.model.Event; +import ru.ulstu.timeline.model.EventDto; +import ru.ulstu.timeline.repository.EventRepository; + +import java.sql.Date; +import java.time.LocalDate; +import java.time.Period; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Calendar; + + +public class EventScheduler { + + private final Logger log = LoggerFactory.getLogger(EventScheduler.class); + private final EventService eventService; + private final EventRepository eventRepository; + + public EventScheduler(EventRepository eventRepository, EventService eventService) { + this.eventRepository = eventRepository; + this.eventService = eventService; + } + + @Scheduled(cron = "0 0 8/12 * 1 ?") + public void checkPeriodEvents() { + log.debug("EventScheduler.checkPeriodEvents started"); + for (Event event : eventRepository.findAll()) { + if(halfOfThePariodHasPassed(event)){ + event.setCreateDate(Date.from((LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant()))); + event.setBeginDate(DateUtils.addDays(event.getBeginDate(), event.getPeriod().getPeriod().getDays())); + event.setUpdateDate(null); + + eventService.create(new EventDto( + event.getId(), + event.getTitle(), + event.getPeriod(), + event.getBeginDate(), + event.getExecuteDate(), + event.getCreateDate(), + event.getUpdateDate(), + event.getDescription(), + new ArrayList<>() + )); + } + } + + log.debug("EventScheduler.checkPeriodEvents finished"); + } + + private boolean halfOfThePariodHasPassed(Event event){ + if (Period.between(event.getBeginDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), + LocalDate.now()).getDays() <= event.getPeriod().getPeriod().getDays() / 2) { + return true; + } + return false; + } +} diff --git a/src/main/java/ru/ulstu/timeline/service/EventService.java b/src/main/java/ru/ulstu/timeline/service/EventService.java index 0c1cf6c..4ead8ab 100644 --- a/src/main/java/ru/ulstu/timeline/service/EventService.java +++ b/src/main/java/ru/ulstu/timeline/service/EventService.java @@ -46,6 +46,8 @@ public class EventService { event.setDescription(eventDto.getDescription()); event.setRecipients(userService.findByIds(convert(eventDto.getRecipients(), UserDto::getId))); event.setTitle(eventDto.getTitle()); + event.setPeriod(eventDto.getPeriod()); + event.setBeginDate(eventDto.getBeginDate()); event.setUpdateDate(eventDto.getUpdateDate()); return event; } From 392b2a965753bd4d532e020244a273913a1efdaf Mon Sep 17 00:00:00 2001 From: Alyona Date: Fri, 9 Nov 2018 14:51:19 +0400 Subject: [PATCH 06/40] added period event --- src/main/java/ru/ulstu/timeline/service/EventScheduler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/ulstu/timeline/service/EventScheduler.java b/src/main/java/ru/ulstu/timeline/service/EventScheduler.java index 482e201..14c1177 100644 --- a/src/main/java/ru/ulstu/timeline/service/EventScheduler.java +++ b/src/main/java/ru/ulstu/timeline/service/EventScheduler.java @@ -31,7 +31,7 @@ public class EventScheduler { public void checkPeriodEvents() { log.debug("EventScheduler.checkPeriodEvents started"); for (Event event : eventRepository.findAll()) { - if(halfOfThePariodHasPassed(event)){ + if(halfOfThePeriodHasPassed(event)){ event.setCreateDate(Date.from((LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant()))); event.setBeginDate(DateUtils.addDays(event.getBeginDate(), event.getPeriod().getPeriod().getDays())); event.setUpdateDate(null); @@ -53,7 +53,7 @@ public class EventScheduler { log.debug("EventScheduler.checkPeriodEvents finished"); } - private boolean halfOfThePariodHasPassed(Event event){ + private boolean halfOfThePeriodHasPassed(Event event){ if (Period.between(event.getBeginDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now()).getDays() <= event.getPeriod().getPeriod().getDays() / 2) { return true; From 1211b0db2975992911cd3b9788a46a9e714bb098 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 9 Nov 2018 14:53:24 +0400 Subject: [PATCH 07/40] add styles in email templates --- deploy/gdccloud/deploy.sh | 2 +- src/main/resources/application.properties | 2 +- .../paperCreateNotification.html | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/deploy/gdccloud/deploy.sh b/deploy/gdccloud/deploy.sh index 5429a76..26604b7 100644 --- a/deploy/gdccloud/deploy.sh +++ b/deploy/gdccloud/deploy.sh @@ -18,6 +18,6 @@ fi ssh $USERSERVER "cd /tmp && rm -rf $ARTIFACT_NAME*.jar && echo `date` 'killed' >> log_$ARTIFACT_NAME" scp build/libs/$ARTIFACT_NAME-0.1.0-SNAPSHOT.jar $USERSERVER:/tmp/$ARTIFACT_NAME-0.1.0-SNAPSHOT.jar -ssh $USERSERVER -f "cd /tmp/ && /opt/jdk1.8.0_192/bin/java -jar $ARTIFACT_NAME-0.1.0-SNAPSHOT.jar -Xms 512m -Xmx 1024m --server.port=8443 --server.http.port=8080 >> /home/user/logfile_$ARTIFACT_NAME" & +ssh $USERSERVER -f "cd /tmp/ && /opt/jdk1.8.0_192/bin/java -jar $ARTIFACT_NAME-0.1.0-SNAPSHOT.jar -Xms 512m -Xmx 1024m --server.port=8443 --server.http.port=8080 --ng-tracker.base-url=http://193.110.3.124:8080 >> /home/user/logfile_$ARTIFACT_NAME" & sleep 10 echo "is deployed" \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e696ccd..fb1b116 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -32,7 +32,7 @@ liquibase.drop-first=false liquibase.enabled=true liquibase.change-log=classpath:db/changelog-master.xml # Application Settings -ng-tracker.base-url=https://127.0.0.1:8443 +ng-tracker.base-url=http://127.0.0.1:8080 ng-tracker.undead-user-login=admin ng-tracker.dev-mode=true ng-tracker.use-https=false \ No newline at end of file diff --git a/src/main/resources/mail_templates/paperCreateNotification.html b/src/main/resources/mail_templates/paperCreateNotification.html index 3e71ce9..0d80bf9 100644 --- a/src/main/resources/mail_templates/paperCreateNotification.html +++ b/src/main/resources/mail_templates/paperCreateNotification.html @@ -4,8 +4,33 @@ Уведомление о создании статьи + + + + + + + + + + + + + + +

Уважаемый(ая) Ivan Ivanov

From 5c54817fc62a2358a2dbd9d2564d95eeda3cc2cb Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 9 Nov 2018 15:05:39 +0400 Subject: [PATCH 08/40] fix styles --- .../mail_templates/paperCreateNotification.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/resources/mail_templates/paperCreateNotification.html b/src/main/resources/mail_templates/paperCreateNotification.html index 0d80bf9..a0aa43f 100644 --- a/src/main/resources/mail_templates/paperCreateNotification.html +++ b/src/main/resources/mail_templates/paperCreateNotification.html @@ -5,17 +5,17 @@ - - + + - - - - + + + + - + From 6aa5f807b705793e650d5b1ce3f883f78a30b807 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 9 Nov 2018 15:21:03 +0400 Subject: [PATCH 09/40] move styles to body --- .../paperCreateNotification.html | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/resources/mail_templates/paperCreateNotification.html b/src/main/resources/mail_templates/paperCreateNotification.html index a0aa43f..8b4ded9 100644 --- a/src/main/resources/mail_templates/paperCreateNotification.html +++ b/src/main/resources/mail_templates/paperCreateNotification.html @@ -4,22 +4,20 @@ Уведомление о создании статьи - - - - - - - - - - - - - + + + + + + + + + + +