diff --git a/build.gradle b/build.gradle
index a858707..d09505e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,11 +16,14 @@ buildscript {
group 'ru.ulstu'
version '0.1.0-SNAPSHOT'
+apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'checkstyle'
+mainClassName = 'ru.ulstu.NgTrackerApplication'
+
build.dependsOn checkstyleMain
bootRun.dependsOn checkstyleMain
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/java/ru/ulstu/configuration/MvcConfiguration.java b/src/main/java/ru/ulstu/configuration/MvcConfiguration.java
index 14e6337..8543847 100644
--- a/src/main/java/ru/ulstu/configuration/MvcConfiguration.java
+++ b/src/main/java/ru/ulstu/configuration/MvcConfiguration.java
@@ -12,6 +12,7 @@ public class MvcConfiguration extends WebMvcConfigurerAdapter {
registry.addViewController("/{articlename:\\w+}");
//registry.addViewController("/admin/{articlename:\\w+}");
registry.addViewController("/papers/{articlename:\\w+}");
+ registry.addViewController("/grants/{articlename:\\w+}");
registry.addRedirectViewController("/", "/index");
registry.addRedirectViewController("/default", "/index");
}
diff --git a/src/main/java/ru/ulstu/core/controller/AdviceController.java b/src/main/java/ru/ulstu/core/controller/AdviceController.java
index 916359a..2fe853e 100644
--- a/src/main/java/ru/ulstu/core/controller/AdviceController.java
+++ b/src/main/java/ru/ulstu/core/controller/AdviceController.java
@@ -11,8 +11,15 @@ import ru.ulstu.core.error.EntityIdIsNullException;
import ru.ulstu.core.model.ErrorConstants;
import ru.ulstu.core.model.response.Response;
import ru.ulstu.core.model.response.ResponseExtended;
-import ru.ulstu.user.error.*;
-import ru.ulstu.user.error.*;
+import ru.ulstu.user.error.UserActivationError;
+import ru.ulstu.user.error.UserEmailExistsException;
+import ru.ulstu.user.error.UserIdExistsException;
+import ru.ulstu.user.error.UserIsUndeadException;
+import ru.ulstu.user.error.UserLoginExistsException;
+import ru.ulstu.user.error.UserNotActivatedException;
+import ru.ulstu.user.error.UserNotFoundException;
+import ru.ulstu.user.error.UserPasswordsNotValidOrNotMatchException;
+import ru.ulstu.user.error.UserResetKeyError;
import java.util.Set;
import java.util.stream.Collectors;
diff --git a/src/main/java/ru/ulstu/odin/service/OdinService.java b/src/main/java/ru/ulstu/odin/service/OdinService.java
index 9de2426..d1c9081 100644
--- a/src/main/java/ru/ulstu/odin/service/OdinService.java
+++ b/src/main/java/ru/ulstu/odin/service/OdinService.java
@@ -5,12 +5,25 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import ru.ulstu.core.error.OdinException;
-import ru.ulstu.odin.model.*;
-import ru.ulstu.odin.model.*;
+import ru.ulstu.odin.model.OdinBooleanField;
+import ru.ulstu.odin.model.OdinCollectionField;
+import ru.ulstu.odin.model.OdinDateField;
+import ru.ulstu.odin.model.OdinDto;
+import ru.ulstu.odin.model.OdinField;
+import ru.ulstu.odin.model.OdinMetadata;
+import ru.ulstu.odin.model.OdinNumericField;
+import ru.ulstu.odin.model.OdinObjectField;
+import ru.ulstu.odin.model.OdinStringField;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import java.util.stream.Collectors;
@Service
diff --git a/src/main/java/ru/ulstu/paper/controller/PaperController.java b/src/main/java/ru/ulstu/paper/controller/PaperController.java
index e5acd23..c5cbf4f 100644
--- a/src/main/java/ru/ulstu/paper/controller/PaperController.java
+++ b/src/main/java/ru/ulstu/paper/controller/PaperController.java
@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
import ru.ulstu.configuration.Constants;
import ru.ulstu.core.model.response.Response;
import ru.ulstu.paper.model.PaperDto;
+import ru.ulstu.paper.model.PaperFilterDto;
import ru.ulstu.paper.model.PaperStatusDto;
import ru.ulstu.paper.service.PaperService;
@@ -37,23 +38,28 @@ public class PaperController {
}
@PostMapping
- public Response createPaper(@RequestBody @Valid PaperDto paperDto) throws IOException {
- return new Response(paperService.create(paperDto));
+ public Response createPaper(@RequestBody @Valid PaperDto paperDto) throws IOException {
+ return new Response<>(paperService.create(paperDto));
}
@PutMapping
- public Response updatePaper(@RequestBody @Valid PaperDto paperDto) throws IOException {
- return new Response(paperService.update(paperDto));
+ public Response updatePaper(@RequestBody @Valid PaperDto paperDto) throws IOException {
+ return new Response<>(paperService.update(paperDto));
}
@DeleteMapping("/{paper-id}")
- public Response delete(@PathVariable("paper-id") Integer paperId) throws IOException {
+ public Response delete(@PathVariable("paper-id") Integer paperId) throws IOException {
paperService.delete(paperId);
- return new Response(true);
+ return new Response<>(true);
}
@GetMapping("/statuses")
public Response> getPaperStatuses() {
return new Response<>(paperService.getPaperStatuses());
}
+
+ @PostMapping("/filter")
+ public Response> filter(@RequestBody @Valid PaperFilterDto paperFilterDto) throws IOException {
+ return new Response<>(paperService.filter(paperFilterDto));
+ }
}
diff --git a/src/main/java/ru/ulstu/paper/model/Paper.java b/src/main/java/ru/ulstu/paper/model/Paper.java
index e9cc92c..c2a7f31 100644
--- a/src/main/java/ru/ulstu/paper/model/Paper.java
+++ b/src/main/java/ru/ulstu/paper/model/Paper.java
@@ -23,7 +23,12 @@ import java.util.Set;
@Entity
public class Paper extends BaseEntity implements UserContainer {
public enum PaperStatus {
- ATTENTION("Обратить внимание"), ON_PREPARATION("На подготовке"), DRAFT("Черновик"), COMPLETED("Завершена");
+ ATTENTION("Обратить внимание"),
+ ON_PREPARATION("На подготовке"),
+ ON_REVIEW("На проверке"),
+ DRAFT("Черновик"),
+ COMPLETED("Завершена"),
+ FAILED("Провалены сроки");
private String name;
diff --git a/src/main/java/ru/ulstu/paper/model/PaperDto.java b/src/main/java/ru/ulstu/paper/model/PaperDto.java
index dc48fcd..d9a1229 100644
--- a/src/main/java/ru/ulstu/paper/model/PaperDto.java
+++ b/src/main/java/ru/ulstu/paper/model/PaperDto.java
@@ -8,6 +8,7 @@ import ru.ulstu.user.model.UserDto;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.Set;
+import java.util.stream.Collectors;
import static ru.ulstu.core.util.StreamApiUtils.convert;
@@ -121,4 +122,11 @@ public class PaperDto {
public Set getAuthors() {
return authors;
}
+
+ public String getAuthorsString() {
+ return authors
+ .stream()
+ .map(author -> author.getLastName() + author.getFirstName())
+ .collect(Collectors.joining(", "));
+ }
}
diff --git a/src/main/java/ru/ulstu/paper/model/PaperFilterDto.java b/src/main/java/ru/ulstu/paper/model/PaperFilterDto.java
new file mode 100644
index 0000000..c832bed
--- /dev/null
+++ b/src/main/java/ru/ulstu/paper/model/PaperFilterDto.java
@@ -0,0 +1,24 @@
+package ru.ulstu.paper.model;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class PaperFilterDto {
+ private final Integer authorId;
+ private final Integer year;
+
+ @JsonCreator
+ public PaperFilterDto(@JsonProperty("authorId") Integer authorId,
+ @JsonProperty("year") Integer year) {
+ this.authorId = authorId;
+ this.year = year;
+ }
+
+ public Integer getAuthorId() {
+ return authorId;
+ }
+
+ public Integer getYear() {
+ return year;
+ }
+}
diff --git a/src/main/java/ru/ulstu/paper/repository/PaperRepository.java b/src/main/java/ru/ulstu/paper/repository/PaperRepository.java
index 613bb6a..5d0cd9a 100644
--- a/src/main/java/ru/ulstu/paper/repository/PaperRepository.java
+++ b/src/main/java/ru/ulstu/paper/repository/PaperRepository.java
@@ -1,9 +1,15 @@
package ru.ulstu.paper.repository;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
import ru.ulstu.paper.model.Paper;
+import ru.ulstu.user.model.User;
import java.util.List;
public interface PaperRepository extends JpaRepository {
+
+ @Query("SELECT p FROM Paper p WHERE (:author IS NULL OR :author MEMBER OF p.authors) AND YEAR(p.createDate) = :year OR :year IS NULL")
+ List filter(@Param("author") User author, @Param("year") Integer year);
}
diff --git a/src/main/java/ru/ulstu/strategy/api/PaperCreateStrategy.java b/src/main/java/ru/ulstu/paper/service/PaperCreateStrategy.java
similarity index 68%
rename from src/main/java/ru/ulstu/strategy/api/PaperCreateStrategy.java
rename to src/main/java/ru/ulstu/paper/service/PaperCreateStrategy.java
index da457a1..d819d80 100644
--- a/src/main/java/ru/ulstu/strategy/api/PaperCreateStrategy.java
+++ b/src/main/java/ru/ulstu/paper/service/PaperCreateStrategy.java
@@ -1,26 +1,22 @@
-package ru.ulstu.strategy.api;
+package ru.ulstu.paper.service;
import org.springframework.stereotype.Service;
import ru.ulstu.core.util.DateUtils;
import ru.ulstu.paper.model.Paper;
-import ru.ulstu.paper.service.PaperService;
+import ru.ulstu.strategy.api.EntityCreateStrategy;
import ru.ulstu.user.model.User;
-import ru.ulstu.user.service.UserService;
import java.util.Date;
import java.util.List;
@Service
public class PaperCreateStrategy extends EntityCreateStrategy {
- private static final String DEFAULT_NAME = "Статья создана автоматически";
+ private static final String DEFAULT_NAME = "Статья создана автоматически, т.к. у вас не найдено статей";
private static final int DEFAULT_DEADLINE_DAYS = 14;
private final PaperService paperService;
- private final UserService userService;
- public PaperCreateStrategy(PaperService paperService,
- UserService userService) {
+ public PaperCreateStrategy(PaperService paperService) {
this.paperService = paperService;
- this.userService = userService;
}
@Override
diff --git a/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java b/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java
index 736ae87..99e0c86 100644
--- a/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java
+++ b/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java
@@ -31,7 +31,8 @@ public class PaperNotificationService {
private boolean needToSendDeadlineNotification(Paper paper, Date compareDate, boolean isDeadlineBeforeWeek) {
return (paper.getDeadlineDate() != null)
&& (compareDate.after(paper.getDeadlineDate()) && isDeadlineBeforeWeek
- || compareDate.before(paper.getDeadlineDate()) && !isDeadlineBeforeWeek);
+ || compareDate.before(paper.getDeadlineDate()) && !isDeadlineBeforeWeek)
+ && paper.getDeadlineDate().after(new Date());
}
private void sendMessageDeadline(Paper paper) {
@@ -54,4 +55,11 @@ public class PaperNotificationService {
mailService.sendEmailFromTemplate(variables, author, "paperStatusChangeNotification", "Изменился статус статьи");
});
}
+
+ public void sendFailedNotification(Paper paper, Paper.PaperStatus oldStatus) {
+ Map variables = ImmutableMap.of("paper", paper, "oldStatus", oldStatus);
+ paper.getAuthors().forEach(author -> {
+ mailService.sendEmailFromTemplate(variables, author, "paperFailedNotification", "Статья провалена");
+ });
+ }
}
diff --git a/src/main/java/ru/ulstu/paper/service/DeadlineScheduler.java b/src/main/java/ru/ulstu/paper/service/PaperScheduler.java
similarity index 55%
rename from src/main/java/ru/ulstu/paper/service/DeadlineScheduler.java
rename to src/main/java/ru/ulstu/paper/service/PaperScheduler.java
index d6d9852..ed035d9 100644
--- a/src/main/java/ru/ulstu/paper/service/DeadlineScheduler.java
+++ b/src/main/java/ru/ulstu/paper/service/PaperScheduler.java
@@ -6,16 +6,16 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@Service
-public class DeadlineScheduler {
+public class PaperScheduler {
private final static boolean IS_DEADLINE_NOTIFICATION_BEFORE_WEEK = true;
- private final Logger log = LoggerFactory.getLogger(DeadlineScheduler.class);
+ private final Logger log = LoggerFactory.getLogger(PaperScheduler.class);
private final PaperNotificationService paperNotificationService;
private final PaperService paperService;
- public DeadlineScheduler(PaperNotificationService paperNotificationService,
- PaperService paperService) {
+ public PaperScheduler(PaperNotificationService paperNotificationService,
+ PaperService paperService) {
this.paperNotificationService = paperNotificationService;
this.paperService = paperService;
}
@@ -23,15 +23,22 @@ public class DeadlineScheduler {
@Scheduled(cron = "0 0 8 * 1 ?")
public void checkDeadlineBeforeWeek() {
- log.debug("DeadlineScheduler.checkDeadlineBeforeWeek started");
+ log.debug("PaperScheduler.checkDeadlineBeforeWeek started");
paperNotificationService.sendDeadlineNotifications(paperService.findAll(), !IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
- log.debug("DeadlineScheduler.checkDeadlineBeforeWeek finished");
+ log.debug("PaperScheduler.checkDeadlineBeforeWeek finished");
}
@Scheduled(cron = "0 0 8 * * ?")
public void checkDeadlineAfterWeek() {
- log.debug("DeadlineScheduler.checkDeadlineAfterWeek started");
+ log.debug("PaperScheduler.checkDeadlineAfterWeek started");
paperNotificationService.sendDeadlineNotifications(paperService.findAll(), IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
- log.debug("DeadlineScheduler.checkDeadlineAfterWeek finished");
+ log.debug("PaperScheduler.checkDeadlineAfterWeek finished");
+ }
+
+ @Scheduled(cron = "0 0 6 * * ?")
+ public void closeFailedPapers() {
+ log.debug("PaperScheduler.closeFailedPapers started");
+ paperService.closeFailedPapers();
+ log.debug("PaperScheduler.closeFailedPapers finished");
}
}
diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java
index a5b5237..0e1abbc 100644
--- a/src/main/java/ru/ulstu/paper/service/PaperService.java
+++ b/src/main/java/ru/ulstu/paper/service/PaperService.java
@@ -5,6 +5,7 @@ import org.springframework.transaction.annotation.Transactional;
import ru.ulstu.file.service.FileService;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.paper.model.PaperDto;
+import ru.ulstu.paper.model.PaperFilterDto;
import ru.ulstu.paper.model.PaperStatusDto;
import ru.ulstu.paper.repository.PaperRepository;
import ru.ulstu.user.model.User;
@@ -17,6 +18,9 @@ import java.util.List;
import java.util.stream.Collectors;
import static ru.ulstu.core.util.StreamApiUtils.convert;
+import static ru.ulstu.paper.model.Paper.PaperStatus.ATTENTION;
+import static ru.ulstu.paper.model.Paper.PaperStatus.DRAFT;
+import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION;
@Service
public class PaperService {
@@ -40,7 +44,7 @@ public class PaperService {
return paperRepository.findAll().stream().sorted((paper1, paper2) -> {
int statusCompareResult =
Integer.valueOf(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper1.getStatus()))
- .compareTo(Integer.valueOf(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper2.getStatus())));
+ .compareTo(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper2.getStatus()));
if (statusCompareResult != 0) {
return statusCompareResult;
}
@@ -53,7 +57,7 @@ public class PaperService {
}
@Transactional
- public int create(PaperDto paperDto) throws IOException {
+ public Integer create(PaperDto paperDto) throws IOException {
Paper newPaper = copyFromDto(new Paper(), paperDto);
newPaper = paperRepository.save(newPaper);
paperNotificationService.sendCreateNotification(newPaper);
@@ -64,7 +68,7 @@ public class PaperService {
paper.setComment(paperDto.getComment());
paper.setCreateDate(paper.getCreateDate() == null ? new Date() : paper.getCreateDate());
paper.setLocked(paperDto.getLocked());
- paper.setStatus(paperDto.getStatus() == null ? Paper.PaperStatus.DRAFT : paperDto.getStatus());
+ paper.setStatus(paperDto.getStatus() == null ? DRAFT : paperDto.getStatus());
paper.setTitle(paperDto.getTitle());
paper.setUpdateDate(new Date());
paper.setDeadlineDate(paperDto.getDeadlineDate());
@@ -72,9 +76,7 @@ public class PaperService {
paper.setFileData(fileService.createFileFromTmp(paperDto.getTmpFileName()));
}
if (paperDto.getAuthors() != null && !paperDto.getAuthors().isEmpty()) {
- paperDto.getAuthors().forEach(authorIds -> {
- paper.getAuthors().add(userService.findById(authorIds.getId()));
- });
+ paperDto.getAuthors().forEach(authorIds -> paper.getAuthors().add(userService.findById(authorIds.getId())));
}
return paper;
}
@@ -105,7 +107,7 @@ public class PaperService {
}
public List getPaperStatuses() {
- return convert(Arrays.asList(Paper.PaperStatus.values()), status -> new PaperStatusDto(status));
+ return convert(Arrays.asList(Paper.PaperStatus.values()), PaperStatusDto::new);
}
@Transactional
@@ -116,11 +118,32 @@ public class PaperService {
paper.setDeadlineDate(deadlineDate);
paper.setCreateDate(new Date());
paper.setUpdateDate(new Date());
- paper.setStatus(Paper.PaperStatus.DRAFT);
+ paper.setStatus(DRAFT);
paper = paperRepository.save(paper);
paperNotificationService.sendCreateNotification(paper);
return paper;
}
+
+ public List filter(PaperFilterDto filterDto) {
+ return convert(paperRepository.filter(userService.findById(filterDto.getAuthorId()), filterDto.getYear()), PaperDto::new);
+ }
+
+ public void closeFailedPapers() {
+ List papers = paperRepository.findAll()
+ .stream()
+ .filter(paper -> paper.getDeadlineDate() != null
+ && (paper.getStatus() == ON_PREPARATION
+ || paper.getStatus() == DRAFT
+ || paper.getStatus() == ATTENTION)
+ && paper.getDeadlineDate().before(new Date()))
+ .collect(Collectors.toList());
+ papers.forEach(paper -> {
+ Paper.PaperStatus oldStatus = paper.getStatus();
+ paper.setStatus(Paper.PaperStatus.FAILED);
+ paperRepository.save(paper);
+ paperNotificationService.sendFailedNotification(paper, oldStatus);
+ });
+ }
}
diff --git a/src/main/java/ru/ulstu/timeline/controller/EventController.java b/src/main/java/ru/ulstu/timeline/controller/EventController.java
index 6f79b31..77cb118 100644
--- a/src/main/java/ru/ulstu/timeline/controller/EventController.java
+++ b/src/main/java/ru/ulstu/timeline/controller/EventController.java
@@ -13,6 +13,7 @@ import ru.ulstu.core.model.response.Response;
import ru.ulstu.timeline.model.EventDto;
import ru.ulstu.timeline.service.EventService;
+import javax.validation.Valid;
import java.util.List;
import static ru.ulstu.timeline.controller.EventController.URL;
@@ -30,16 +31,21 @@ public class EventController {
@GetMapping
public Response> getEvents() {
- return new Response<>(eventService.findAll());
+ return new Response<>(eventService.findAllDto());
+ }
+
+ @GetMapping("/future")
+ public Response> getFutureEvents() {
+ return new Response<>(eventService.findAllFutureDto());
}
@PostMapping
- public Response createEvent(@RequestBody EventDto timelineDto) {
+ public Response createEvent(@RequestBody @Valid EventDto timelineDto) {
return new Response(eventService.create(timelineDto));
}
@PutMapping
- public Response updateEvent(@RequestBody EventDto eventDto) {
+ public Response updateEvent(@RequestBody @Valid EventDto eventDto) {
return new Response(eventService.update(eventDto));
}
diff --git a/src/main/java/ru/ulstu/timeline/model/Event.java b/src/main/java/ru/ulstu/timeline/model/Event.java
index 404025a..290f136 100644
--- a/src/main/java/ru/ulstu/timeline/model/Event.java
+++ b/src/main/java/ru/ulstu/timeline/model/Event.java
@@ -4,22 +4,50 @@ import org.hibernate.validator.constraints.NotBlank;
import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.user.model.User;
+import javax.persistence.CascadeType;
import javax.persistence.Column;
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.persistence.Temporal;
import javax.persistence.TemporalType;
+import javax.validation.constraints.NotNull;
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 PeriodEvent period;
+
+ @Enumerated(value = EnumType.STRING)
+ private EventStatus status;
+
@Column(name = "execute_date")
@Temporal(TemporalType.TIMESTAMP)
+ @NotNull
private Date executeDate;
@Column(name = "create_date")
@@ -35,6 +63,14 @@ public class Event extends BaseEntity {
@ManyToMany(fetch = FetchType.EAGER)
private List recipients;
+ @ManyToOne
+ @JoinColumn(name = "child_id")
+ private Event child;
+
+ @OneToMany(cascade = CascadeType.ALL)
+ @JoinColumn(name = "child_id")
+ private List parents;
+
public String getTitle() {
return title;
}
@@ -43,6 +79,22 @@ public class Event extends BaseEntity {
this.title = title;
}
+ public Event.EventStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(EventStatus status) {
+ this.status = status;
+ }
+
+ public PeriodEvent getPeriod() {
+ return period;
+ }
+
+ public void setPeriod(PeriodEvent period) {
+ this.period = period;
+ }
+
public Date getCreateDate() {
return createDate;
}
@@ -82,4 +134,20 @@ public class Event extends BaseEntity {
public void setExecuteDate(Date executeDate) {
this.executeDate = executeDate;
}
+
+ public Event getChild() {
+ return child;
+ }
+
+ public void setChild(Event child) {
+ this.child = child;
+ }
+
+ public List getParents() {
+ return parents;
+ }
+
+ public void setParents(List parents) {
+ this.parents = parents;
+ }
}
diff --git a/src/main/java/ru/ulstu/timeline/model/EventDto.java b/src/main/java/ru/ulstu/timeline/model/EventDto.java
index 59cef34..9e70a9d 100644
--- a/src/main/java/ru/ulstu/timeline/model/EventDto.java
+++ b/src/main/java/ru/ulstu/timeline/model/EventDto.java
@@ -2,8 +2,10 @@ package ru.ulstu.timeline.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import org.hibernate.validator.constraints.NotBlank;
import ru.ulstu.user.model.UserDto;
+import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
@@ -11,7 +13,11 @@ import static ru.ulstu.core.util.StreamApiUtils.convert;
public class EventDto {
private final Integer id;
+ @NotBlank
private final String title;
+ private final PeriodEvent period;
+ private final Event.EventStatus status;
+ @NotNull
private final Date executeDate;
private final Date createDate;
private final Date updateDate;
@@ -21,6 +27,8 @@ public class EventDto {
@JsonCreator
public EventDto(@JsonProperty("id") Integer id,
@JsonProperty("title") String title,
+ @JsonProperty("status") Event.EventStatus status,
+ @JsonProperty("period") PeriodEvent period,
@JsonProperty("executeDate") Date executeDate,
@JsonProperty("createDate") Date createDate,
@JsonProperty("updateDate") Date updateDate,
@@ -28,6 +36,8 @@ public class EventDto {
@JsonProperty("recipients") List recipients) {
this.id = id;
this.title = title;
+ this.period = period;
+ this.status = status;
this.executeDate = executeDate;
this.createDate = createDate;
this.updateDate = updateDate;
@@ -38,6 +48,8 @@ public class EventDto {
public EventDto(Event event) {
this.id = event.getId();
this.title = event.getTitle();
+ this.status = event.getStatus();
+ this.period = event.getPeriod();
this.executeDate = event.getExecuteDate();
this.createDate = event.getCreateDate();
this.updateDate = event.getUpdateDate();
@@ -53,6 +65,14 @@ public class EventDto {
return title;
}
+ public PeriodEvent getPeriod() {
+ return period;
+ }
+
+ 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/model/PeriodEvent.java b/src/main/java/ru/ulstu/timeline/model/PeriodEvent.java
new file mode 100644
index 0000000..c25528e
--- /dev/null
+++ b/src/main/java/ru/ulstu/timeline/model/PeriodEvent.java
@@ -0,0 +1,26 @@
+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/repository/EventRepository.java b/src/main/java/ru/ulstu/timeline/repository/EventRepository.java
index 6267d51..4848e12 100644
--- a/src/main/java/ru/ulstu/timeline/repository/EventRepository.java
+++ b/src/main/java/ru/ulstu/timeline/repository/EventRepository.java
@@ -9,4 +9,7 @@ import java.util.List;
public interface EventRepository extends JpaRepository {
@Query("SELECT e FROM Event e WHERE e.executeDate = CURRENT_DATE")
List findByCurrentDate();
+
+ @Query("SELECT e FROM Event e WHERE e.executeDate > CURRENT_DATE ORDER BY e.executeDate")
+ List findAllFuture();
}
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..6df7fcb
--- /dev/null
+++ b/src/main/java/ru/ulstu/timeline/service/EventScheduler.java
@@ -0,0 +1,73 @@
+package ru.ulstu.timeline.service;
+
+import com.google.common.collect.ImmutableMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+import ru.ulstu.core.util.DateUtils;
+import ru.ulstu.timeline.model.Event;
+import ru.ulstu.timeline.model.PeriodEvent;
+import ru.ulstu.user.service.MailService;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class EventScheduler {
+
+ private final Logger log = LoggerFactory.getLogger(EventScheduler.class);
+ private final EventService eventService;
+ private final MailService mailService;
+
+ public EventScheduler(EventService eventService,
+ MailService mailService) {
+ this.eventService = eventService;
+ this.mailService = mailService;
+ }
+
+ @Scheduled(cron = "0 0 8 * * ?")
+ public void sendNotifications() {
+ List events = eventService.findByCurrentDate();
+ events.forEach(event -> {
+ Map variables = ImmutableMap.of("description", event.getDescription());
+ event.getRecipients()
+ .forEach(recipient -> mailService.sendEmailFromTemplate(variables, recipient, "eventNotification", event.getTitle()));
+ });
+ }
+
+ @Scheduled(cron = "0 0 * * * ?")
+ public void checkPeriodEvents() {
+ log.debug("EventScheduler.checkPeriodEvents started");
+ //TODO: filter
+ for (Event event : eventService.findAll()) {
+ if (halfOfThePeriodHasPassed(event)) {
+ eventService.createBasedOn(event, DateUtils.addDays(event.getExecuteDate(), getShiftInDays(event.getPeriod())));
+ }
+ }
+
+ log.debug("EventScheduler.checkPeriodEvents finished");
+ }
+
+ private int getShiftInDays(PeriodEvent periodEvent) {
+ switch (periodEvent) {
+ case EVERY_DAY:
+ return periodEvent.getPeriod().getDays();
+ case EVERY_WEEK:
+ return periodEvent.getPeriod().getDays();
+ case EVERY_MONTH:
+ return periodEvent.getPeriod().getMonths() * 30;
+ case EVERY_YEAR:
+ return periodEvent.getPeriod().getYears() * 365;
+ default:
+ throw new RuntimeException("period event not exists");
+ }
+ }
+
+ private boolean halfOfThePeriodHasPassed(Event event) {
+ return event.getPeriod() != null && event.getChild() == null
+ && new Date().after(
+ DateUtils.addDays(event.getExecuteDate(), (int) Math.round((double) getShiftInDays(event.getPeriod()) / 2)));
+ }
+}
diff --git a/src/main/java/ru/ulstu/timeline/service/EventService.java b/src/main/java/ru/ulstu/timeline/service/EventService.java
index 0c1cf6c..ca95b9a 100644
--- a/src/main/java/ru/ulstu/timeline/service/EventService.java
+++ b/src/main/java/ru/ulstu/timeline/service/EventService.java
@@ -1,18 +1,15 @@
package ru.ulstu.timeline.service;
-import com.google.common.collect.ImmutableMap;
-import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ru.ulstu.timeline.model.Event;
import ru.ulstu.timeline.model.EventDto;
import ru.ulstu.timeline.repository.EventRepository;
import ru.ulstu.user.model.UserDto;
-import ru.ulstu.user.service.MailService;
import ru.ulstu.user.service.UserService;
+import java.util.Date;
import java.util.List;
-import java.util.Map;
import static ru.ulstu.core.util.StreamApiUtils.convert;
@@ -21,18 +18,19 @@ public class EventService {
private final EventRepository eventRepository;
private final UserService userService;
- private final MailService mailService;
public EventService(EventRepository eventRepository,
- UserService userService,
- MailService mailService) {
+ UserService userService) {
this.eventRepository = eventRepository;
this.userService = userService;
- this.mailService = mailService;
}
- public List findAll() {
- return convert(eventRepository.findAll(), EventDto::new);
+ public List findAllDto() {
+ return convert(findAll(), EventDto::new);
+ }
+
+ public List findAll() {
+ return eventRepository.findAll();
}
@Transactional
@@ -42,11 +40,13 @@ public class EventService {
private Event copyFromDto(Event event, EventDto eventDto) {
event.setExecuteDate(eventDto.getExecuteDate());
- event.setCreateDate(eventDto.getCreateDate());
+ event.setCreateDate(eventDto.getId() == null ? new Date() : eventDto.getCreateDate());
event.setDescription(eventDto.getDescription());
event.setRecipients(userService.findByIds(convert(eventDto.getRecipients(), UserDto::getId)));
event.setTitle(eventDto.getTitle());
- event.setUpdateDate(eventDto.getUpdateDate());
+ event.setPeriod(eventDto.getPeriod());
+ event.setStatus(eventDto.getStatus());
+ event.setUpdateDate(new Date());
return event;
}
@@ -57,8 +57,9 @@ public class EventService {
}
@Transactional
- public void delete(Integer timelineId) {
- Event event = eventRepository.findOne(timelineId);
+ public void delete(Integer eventId) {
+ Event event = eventRepository.findOne(eventId);
+ event.setParents(null);
eventRepository.delete(event);
}
@@ -66,13 +67,32 @@ public class EventService {
return eventRepository.findAll(ids);
}
- @Scheduled(cron = "0 0 8 * * ?")
- public void sendNotifications() {
- List events = eventRepository.findByCurrentDate();
- events.forEach(event -> {
- Map variables = ImmutableMap.of("description", event.getDescription());
- event.getRecipients()
- .forEach(recipient -> mailService.sendEmailFromTemplate(variables, recipient, "eventNotification", event.getTitle()));
- });
+ public void createBasedOn(Event event, Date executeDate) {
+ //backup event id
+ Integer parentEventId = event.getId();
+
+ event.setId(null);
+ event.setStatus(Event.EventStatus.POSSIBLE);
+ event.setExecuteDate(executeDate);
+ event.setCreateDate(new Date());
+ event.setUpdateDate(new Date());
+ event = eventRepository.save(event);
+
+ //set child to parent
+ Event parentEvent = eventRepository.findOne(parentEventId);
+ parentEvent.setChild(event);
+ eventRepository.save(parentEvent);
+ }
+
+ public List findByCurrentDate() {
+ return eventRepository.findByCurrentDate();
+ }
+
+ public List findAllFuture() {
+ return eventRepository.findAllFuture();
+ }
+
+ public List findAllFutureDto() {
+ return convert(findAllFuture(), EventDto::new);
}
}
diff --git a/src/main/java/ru/ulstu/user/controller/UserController.java b/src/main/java/ru/ulstu/user/controller/UserController.java
index f9f49e3..d7db909 100644
--- a/src/main/java/ru/ulstu/user/controller/UserController.java
+++ b/src/main/java/ru/ulstu/user/controller/UserController.java
@@ -3,7 +3,15 @@ package ru.ulstu.user.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.annotation.Secured;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
import ru.ulstu.configuration.Constants;
import ru.ulstu.core.model.response.PageableItems;
import ru.ulstu.core.model.response.Response;
@@ -11,10 +19,14 @@ import ru.ulstu.odin.controller.OdinController;
import ru.ulstu.odin.model.OdinMetadata;
import ru.ulstu.odin.model.OdinVoid;
import ru.ulstu.odin.service.OdinService;
-import ru.ulstu.user.model.*;
+import ru.ulstu.user.model.UserDto;
+import ru.ulstu.user.model.UserListDto;
+import ru.ulstu.user.model.UserResetPasswordDto;
+import ru.ulstu.user.model.UserRoleConstants;
+import ru.ulstu.user.model.UserRoleDto;
+import ru.ulstu.user.model.UserSessionListDto;
import ru.ulstu.user.service.UserService;
import ru.ulstu.user.service.UserSessionService;
-import ru.ulstu.user.model.*;
import javax.validation.Valid;
diff --git a/src/main/java/ru/ulstu/user/model/User.java b/src/main/java/ru/ulstu/user/model/User.java
index 8d5bce8..16a873b 100644
--- a/src/main/java/ru/ulstu/user/model/User.java
+++ b/src/main/java/ru/ulstu/user/model/User.java
@@ -5,7 +5,14 @@ import org.hibernate.validator.constraints.Email;
import ru.ulstu.configuration.Constants;
import ru.ulstu.core.model.BaseEntity;
-import javax.persistence.*;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
diff --git a/src/main/java/ru/ulstu/user/service/UserMapper.java b/src/main/java/ru/ulstu/user/service/UserMapper.java
index 5607a26..7359bba 100644
--- a/src/main/java/ru/ulstu/user/service/UserMapper.java
+++ b/src/main/java/ru/ulstu/user/service/UserMapper.java
@@ -1,11 +1,18 @@
package ru.ulstu.user.service;
import org.springframework.stereotype.Service;
-import ru.ulstu.user.model.*;
-import ru.ulstu.user.model.*;
+import ru.ulstu.user.model.User;
+import ru.ulstu.user.model.UserDto;
+import ru.ulstu.user.model.UserListDto;
+import ru.ulstu.user.model.UserRole;
+import ru.ulstu.user.model.UserRoleDto;
import ru.ulstu.user.repository.UserRoleRepository;
-import java.util.*;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
import java.util.stream.Collectors;
@Service
diff --git a/src/main/java/ru/ulstu/user/service/UserService.java b/src/main/java/ru/ulstu/user/service/UserService.java
index e6fca9f..d8d29a5 100644
--- a/src/main/java/ru/ulstu/user/service/UserService.java
+++ b/src/main/java/ru/ulstu/user/service/UserService.java
@@ -16,13 +16,33 @@ import ru.ulstu.core.error.EntityIdIsNullException;
import ru.ulstu.core.jpa.OffsetablePageRequest;
import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.core.model.response.PageableItems;
-import ru.ulstu.user.error.*;
-import ru.ulstu.user.model.*;
+import ru.ulstu.user.error.UserActivationError;
+import ru.ulstu.user.error.UserEmailExistsException;
+import ru.ulstu.user.error.UserIdExistsException;
+import ru.ulstu.user.error.UserIsUndeadException;
+import ru.ulstu.user.error.UserLoginExistsException;
+import ru.ulstu.user.error.UserNotActivatedException;
+import ru.ulstu.user.error.UserNotFoundException;
+import ru.ulstu.user.error.UserPasswordsNotValidOrNotMatchException;
+import ru.ulstu.user.error.UserResetKeyError;
+import ru.ulstu.user.model.User;
+import ru.ulstu.user.model.UserDto;
+import ru.ulstu.user.model.UserListDto;
+import ru.ulstu.user.model.UserResetPasswordDto;
+import ru.ulstu.user.model.UserRole;
+import ru.ulstu.user.model.UserRoleConstants;
+import ru.ulstu.user.model.UserRoleDto;
import ru.ulstu.user.repository.UserRepository;
import ru.ulstu.user.repository.UserRoleRepository;
import ru.ulstu.user.util.UserUtils;
-import java.util.*;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
import java.util.stream.Collectors;
@Service
diff --git a/src/main/java/ru/ulstu/user/service/UserSessionService.java b/src/main/java/ru/ulstu/user/service/UserSessionService.java
index 36479a9..0d985cd 100644
--- a/src/main/java/ru/ulstu/user/service/UserSessionService.java
+++ b/src/main/java/ru/ulstu/user/service/UserSessionService.java
@@ -6,8 +6,8 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import ru.ulstu.core.model.response.PageableItems;
import ru.ulstu.core.jpa.OffsetablePageRequest;
+import ru.ulstu.core.model.response.PageableItems;
import ru.ulstu.user.error.UserNotFoundException;
import ru.ulstu.user.model.User;
import ru.ulstu.user.model.UserSession;
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/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-20181111_000000-schema.xml b/src/main/resources/db/changelog-20181111_000000-schema.xml
new file mode 100644
index 0000000..1aa0c64
--- /dev/null
+++ b/src/main/resources/db/changelog-20181111_000000-schema.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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 fe8d7d6..d0199a1 100644
--- a/src/main/resources/db/changelog-master.xml
+++ b/src/main/resources/db/changelog-master.xml
@@ -13,5 +13,7 @@
+
+
\ 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..afbbe20 100644
--- a/src/main/resources/mail_templates/paperCreateNotification.html
+++ b/src/main/resources/mail_templates/paperCreateNotification.html
@@ -10,7 +10,7 @@
Уважаемый(ая) Ivan Ivanov
- Вам нужно поработать над статьей "Title".
+ Вам нужно поработать над статьей "Title".
Срок исполнения: .
diff --git a/src/main/resources/mail_templates/paperFailedNotification.html b/src/main/resources/mail_templates/paperFailedNotification.html
new file mode 100644
index 0000000..cacc7e9
--- /dev/null
+++ b/src/main/resources/mail_templates/paperFailedNotification.html
@@ -0,0 +1,22 @@
+
+
+
+ Уведомление о провале статьи
+
+
+
+
+
+ Уважаемый(ая) Ivan Ivanov
+
+
+ Статья "Title" провалена.
+ Предыдущий статус - "oldStatus".
+
+
+ Regards,
+
+ NG-tracker.
+
+
+
diff --git a/src/main/resources/public/css/agency.css b/src/main/resources/public/css/agency.css
index a754bc3..80102ba 100644
--- a/src/main/resources/public/css/agency.css
+++ b/src/main/resources/public/css/agency.css
@@ -20,17 +20,21 @@ a:hover {
}
.text-primary {
- color: #fed136 !important;
+ color: #29c0ff !important;
}
.text-warning {
- color: #fe4819 !important;
+ color: red !important;
}
.text-success {
color: #00fe8e !important;
}
+.text-failed {
+ color: #A38831 !important;
+}
+
h1,
h2,
h3,
diff --git a/src/main/resources/public/js/papers.js b/src/main/resources/public/js/papers.js
index d114fd9..e45ea55 100644
--- a/src/main/resources/public/js/papers.js
+++ b/src/main/resources/public/js/papers.js
@@ -1,19 +1,51 @@
var urlPapers = "/api/1.0/papers";
var urlPaperStatuses = "/api/1.0/papers/statuses";
+var urlDeletePaper = "/api/1.0/papers/";
-function showPapers(papersElement) {
+function showPapers(papersElement, paperRowClass) {
getFromRest(urlPapers, function (paperList) {
paperList.forEach(function (paper, index) {
- $(papersElement).parent().append("" +
- "
" +
+ $(papersElement).parent().append("
");
+ "'>
" + (index + 1) + ". " + paper.title + "" +
+ "
" +
+ "" +
+ "
");
});
+
+ $(paperRowClass).mouseenter(function (event) {
+ var paperRow = $(event.target).closest(paperRowClass);
+ $(paperRow).css("background-color", "#f8f9fa");
+ $(paperRow).find(".remove-paper").removeClass("d-none");
+
+ });
+ $(paperRowClass).mouseleave(function (event) {
+ var paperRow = $(event.target).closest(paperRowClass);
+ $(paperRow).css("background-color", "white");
+ $(paperRow).closest(paperRowClass).find(".remove-paper").addClass("d-none");
+ });
+ });
+}
+
+function deletePaper(id, papersElement, paperRowClass) {
+ $("#remove-paper-modal").modal('show');
+
+ $("#modal-btn-yes").on("click", function () {
+ deleteFromRest(urlDeletePaper + id, function () {
+ showFeedbackMessage("Статья удалена");
+ $(paperRowClass).remove();
+ showPapers(papersElement, paperRowClass);
+ });
+ $("#remove-paper-modal").modal('hide');
+ });
+
+ $("#modal-btn-no").on("click", function () {
+ $("#remove-paper-modal").modal('hide');
});
}
@@ -40,11 +72,36 @@ function getPaperStatusClass(status) {
return "text-draft"
case 'ON_PREPARATION':
return "text-primary";
+ case 'ON_REVIEW':
+ return "text-primary";
case 'COMPLETED':
return "text-success";
case 'ATTENTION':
return "text-warning";
+ case 'FAILED':
+ return "text-failed";
default:
return "";
}
+}
+
+function showPaperDashboard(dashboardElement) {
+ getFromRest(urlPapers, function (paperList) {
+ paperList.forEach(function (paper, index) {
+ $(dashboardElement).append("" +
+ "
" +
+ "
" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "
" +
+ "
" +
+ "
" + paper.title + "" +
+ "
" + paper.authorsString + "
" +
+ "
" +
+ "
" +
+ "
");
+ });
+ });
}
\ No newline at end of file
diff --git a/src/main/resources/public/js/timeline.js b/src/main/resources/public/js/timeline.js
new file mode 100644
index 0000000..6f2b52f
--- /dev/null
+++ b/src/main/resources/public/js/timeline.js
@@ -0,0 +1,27 @@
+var urlTimeline = "/api/1.0/events/future";
+
+function showTimeline(timelineElement) {
+ $(timelineElement).empty();
+ getFromRest(urlTimeline, function (eventList) {
+ eventList.forEach(function (event, index) {
+ var date = new Date(event.executeDate);
+ var formated_date = date.toLocaleDateString();
+
+ $(timelineElement).append("" +
+ "
" + formated_date + "
" +
+ "" +
+ "
" +
+ "
" + event.title + "
" +
+ "" +
+ "
" +
+ "
" + event.description + "
" +
+ "
" +
+ "
" +
+ "");
+ });
+ });
+}
+
+function eventInverted(index) {
+ return index % 2 == 1 ? "timeline-inverted" : "";
+}
\ No newline at end of file
diff --git a/src/main/resources/templates/default.html b/src/main/resources/templates/default.html
index 33884bf..b261b2f 100644
--- a/src/main/resources/templates/default.html
+++ b/src/main/resources/templates/default.html
@@ -91,6 +91,34 @@
+
+
+
+