#101 project model edited
commit
eceb8ec528
@ -0,0 +1,50 @@
|
|||||||
|
package ru.ulstu.grant.page;
|
||||||
|
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class KiasPage {
|
||||||
|
private final static String KIAS_GRANT_DATE_FORMAT = "dd.MM.yyyy HH:mm";
|
||||||
|
private WebDriver driver;
|
||||||
|
|
||||||
|
public KiasPage(WebDriver webDriver) {
|
||||||
|
this.driver = webDriver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean goToNextPage() {
|
||||||
|
try {
|
||||||
|
if (driver.findElements(By.id("js-ctrlNext")).size() > 0) {
|
||||||
|
driver.findElement(By.id("js-ctrlNext")).click();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WebElement> getPageOfGrants() {
|
||||||
|
WebElement listContest = driver.findElement(By.tagName("tBody"));
|
||||||
|
List<WebElement> grants = listContest.findElements(By.cssSelector("tr.tr"));
|
||||||
|
return grants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGrantTitle(WebElement grant) {
|
||||||
|
return grant.findElement(By.cssSelector("td.tertiary")).findElement(By.tagName("a")).getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date parseDeadLineDate(WebElement grantElement) throws ParseException {
|
||||||
|
String deadlineDate = getFirstDeadline(grantElement); //10.06.2019 23:59
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat(KIAS_GRANT_DATE_FORMAT);
|
||||||
|
return formatter.parse(deadlineDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getFirstDeadline(WebElement grantElement) {
|
||||||
|
return grantElement.findElement(By.xpath("./td[5]")).getText();
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,23 @@
|
|||||||
package ru.ulstu.grant.repository;
|
package ru.ulstu.grant.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import ru.ulstu.grant.model.Grant;
|
import ru.ulstu.grant.model.Grant;
|
||||||
|
import ru.ulstu.name.BaseRepository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface GrantRepository extends JpaRepository<Grant, Integer> {
|
public interface GrantRepository extends JpaRepository<Grant, Integer>, BaseRepository {
|
||||||
|
|
||||||
List<Grant> findByStatus(Grant.GrantStatus status);
|
List<Grant> findByStatus(Grant.GrantStatus status);
|
||||||
|
|
||||||
|
Grant findByTitle(String title);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Query("SELECT title FROM Grant g WHERE (g.title = :name) AND (:id IS NULL OR g.id != :id) ")
|
||||||
|
String findByNameAndNotId(@Param("name") String name, @Param("id") Integer id);
|
||||||
|
|
||||||
|
@Query("SELECT g FROM Grant g WHERE (g.status <> 'SKIPPED') AND (g.status <> 'COMPLETED')")
|
||||||
|
List<Grant> findAllActive();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
package ru.ulstu.grant.service;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.core.util.DateUtils;
|
||||||
|
import ru.ulstu.grant.model.Grant;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
import ru.ulstu.user.service.MailService;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GrantNotificationService {
|
||||||
|
private final static int DAYS_TO_DEADLINE_NOTIFICATION = 7;
|
||||||
|
private final static String TEMPLATE_DEADLINE = "grantDeadlineNotification";
|
||||||
|
private final static String TEMPLATE_CREATE = "grantCreateNotification";
|
||||||
|
private final static String TEMPLATE_AUTHORS_CHANGED = "grantAuthorsChangeNotification";
|
||||||
|
private final static String TEMPLATE_LEADER_CHANGED = "grantLeaderChangeNotification";
|
||||||
|
|
||||||
|
private final static String TITLE_DEADLINE = "Приближается дедлайн гранта: %s";
|
||||||
|
private final static String TITLE_CREATE = "Создан грант: %s";
|
||||||
|
private final static String TITLE_AUTHORS_CHANGED = "Изменился состав рабочей группы гранта: %s";
|
||||||
|
private final static String TITLE_LEADER_CHANGED = "Изменился руководитель гранта: %s";
|
||||||
|
|
||||||
|
private final MailService mailService;
|
||||||
|
|
||||||
|
public GrantNotificationService(MailService mailService) {
|
||||||
|
this.mailService = mailService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendDeadlineNotifications(List<Grant> grants, boolean isDeadlineBeforeWeek) {
|
||||||
|
Date now = DateUtils.addDays(new Date(), DAYS_TO_DEADLINE_NOTIFICATION);
|
||||||
|
grants.stream()
|
||||||
|
.filter(grant -> needToSendDeadlineNotification(grant, now, isDeadlineBeforeWeek))
|
||||||
|
.forEach(grant -> sendMessageDeadline(grant));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean needToSendDeadlineNotification(Grant grant, Date compareDate, boolean isDeadlineBeforeWeek) {
|
||||||
|
return (grant.getNextDeadline().isPresent())
|
||||||
|
&& (compareDate.before(grant.getNextDeadline().get().getDate()) && isDeadlineBeforeWeek
|
||||||
|
|| compareDate.after(grant.getNextDeadline().get().getDate()) && !isDeadlineBeforeWeek)
|
||||||
|
&& grant.getNextDeadline().get().getDate().after(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMessageDeadline(Grant grant) {
|
||||||
|
Map<String, Object> variables = ImmutableMap.of("grant", grant);
|
||||||
|
sendForAllAuthors(variables, grant, TEMPLATE_DEADLINE, String.format(TITLE_DEADLINE, grant.getTitle()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendCreateNotification(Grant grant) {
|
||||||
|
Map<String, Object> variables = ImmutableMap.of("grant", grant);
|
||||||
|
sendForAllAuthors(variables, grant, TEMPLATE_CREATE, String.format(TITLE_CREATE, grant.getTitle()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendAuthorsChangeNotification(Grant grant, Set<User> oldAuthors) {
|
||||||
|
Map<String, Object> variables = ImmutableMap.of("grant", grant, "oldAuthors", oldAuthors);
|
||||||
|
sendForAllAuthors(variables, grant, TEMPLATE_AUTHORS_CHANGED, String.format(TITLE_AUTHORS_CHANGED, grant.getTitle()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendLeaderChangeNotification(Grant grant, User oldLeader) {
|
||||||
|
Map<String, Object> variables = ImmutableMap.of("grant", grant, "oldLeader", oldLeader);
|
||||||
|
sendForAllAuthors(variables, grant, TEMPLATE_LEADER_CHANGED, String.format(TITLE_LEADER_CHANGED, grant.getTitle()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendForAllAuthors(Map<String, Object> variables, Grant grant, String template, String title) {
|
||||||
|
Set<User> allAuthors = grant.getAuthors();
|
||||||
|
allAuthors.forEach(author -> mailService.sendEmailFromTemplate(variables, author, template, title));
|
||||||
|
mailService.sendEmailFromTemplate(variables, grant.getLeader(), template, title);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package ru.ulstu.grant.service;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GrantScheduler {
|
||||||
|
private final static boolean IS_DEADLINE_NOTIFICATION_BEFORE_WEEK = true;
|
||||||
|
|
||||||
|
private final Logger log = LoggerFactory.getLogger(GrantScheduler.class);
|
||||||
|
|
||||||
|
private final GrantNotificationService grantNotificationService;
|
||||||
|
private final GrantService grantService;
|
||||||
|
|
||||||
|
public GrantScheduler(GrantNotificationService grantNotificationService,
|
||||||
|
GrantService grantService) {
|
||||||
|
this.grantNotificationService = grantNotificationService;
|
||||||
|
this.grantService = grantService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0 8 * * MON", zone = "Europe/Samara")
|
||||||
|
public void checkDeadlineBeforeWeek() {
|
||||||
|
log.debug("GrantScheduler.checkDeadlineBeforeWeek started");
|
||||||
|
grantNotificationService.sendDeadlineNotifications(grantService.findAll(), IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
||||||
|
log.debug("GrantScheduler.checkDeadlineBeforeWeek finished");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0 8 * * ?", zone = "Europe/Samara")
|
||||||
|
public void loadGrantsFromKias() {
|
||||||
|
log.debug("GrantScheduler.loadGrantsFromKias started");
|
||||||
|
try {
|
||||||
|
grantService.createFromKias();
|
||||||
|
} catch (ParseException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
log.debug("GrantScheduler.loadGrantsFromKias finished");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.name;
|
||||||
|
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
public interface BaseRepository {
|
||||||
|
String findByNameAndNotId(@Param("name") String name, @Param("id") Integer id);
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package ru.ulstu.name;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public abstract class BaseService {
|
||||||
|
|
||||||
|
public BaseRepository baseRepository;
|
||||||
|
|
||||||
|
public void checkUniqueName(NameContainer nameContainer, Errors errors, Integer id, String checkField, String errorMessage) {
|
||||||
|
if (nameContainer.getName().equals(baseRepository.findByNameAndNotId(nameContainer.getName(), id))) {
|
||||||
|
errors.rejectValue(checkField, "errorCode", errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String checkUniqueName(NameContainer nameContainer, Integer id) {
|
||||||
|
if (nameContainer.getName().equals(baseRepository.findByNameAndNotId(nameContainer.getName(), id))) {
|
||||||
|
return baseRepository.findByNameAndNotId(nameContainer.getName(), id);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package ru.ulstu.name;
|
||||||
|
|
||||||
|
public abstract class NameContainer {
|
||||||
|
|
||||||
|
private String name = "";
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package ru.ulstu.paper.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AutoCompleteData {
|
||||||
|
private List<String> authors = new ArrayList<>();
|
||||||
|
private List<String> publicationTitles = new ArrayList<>();
|
||||||
|
private List<String> publishers = new ArrayList<>();
|
||||||
|
private List<String> journalOrCollectionTitles = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<String> getAuthors() {
|
||||||
|
return authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthors(List<String> authors) {
|
||||||
|
this.authors = authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getPublicationTitles() {
|
||||||
|
return publicationTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicationTitles(List<String> publicationTitles) {
|
||||||
|
this.publicationTitles = publicationTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getPublishers() {
|
||||||
|
return publishers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublishers(List<String> publishers) {
|
||||||
|
this.publishers = publishers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getJournalOrCollectionTitles() {
|
||||||
|
return journalOrCollectionTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJournalOrCollectionTitles(List<String> journalOrCollectionTitles) {
|
||||||
|
this.journalOrCollectionTitles = journalOrCollectionTitles;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
package ru.ulstu.paper.model;
|
||||||
|
|
||||||
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Reference extends BaseEntity {
|
||||||
|
|
||||||
|
private String authors;
|
||||||
|
|
||||||
|
@Column(name = "publication_title")
|
||||||
|
private String publicationTitle;
|
||||||
|
|
||||||
|
@Column(name = "publication_year")
|
||||||
|
private Integer publicationYear;
|
||||||
|
|
||||||
|
private String publisher;
|
||||||
|
|
||||||
|
private String pages;
|
||||||
|
|
||||||
|
@Column(name = "journal_or_collection_title")
|
||||||
|
private String journalOrCollectionTitle;
|
||||||
|
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
@Column(name = "reference_type")
|
||||||
|
private ReferenceDto.ReferenceType referenceType = ReferenceDto.ReferenceType.ARTICLE;
|
||||||
|
|
||||||
|
public String getAuthors() {
|
||||||
|
return authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthors(String authors) {
|
||||||
|
this.authors = authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublicationTitle() {
|
||||||
|
return publicationTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicationTitle(String publicationTitle) {
|
||||||
|
this.publicationTitle = publicationTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPublicationYear() {
|
||||||
|
return publicationYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicationYear(Integer publicationYear) {
|
||||||
|
this.publicationYear = publicationYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublisher() {
|
||||||
|
return publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublisher(String publisher) {
|
||||||
|
this.publisher = publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPages() {
|
||||||
|
return pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPages(String pages) {
|
||||||
|
this.pages = pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJournalOrCollectionTitle() {
|
||||||
|
return journalOrCollectionTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJournalOrCollectionTitle(String journalOrCollectionTitle) {
|
||||||
|
this.journalOrCollectionTitle = journalOrCollectionTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceDto.ReferenceType getReferenceType() {
|
||||||
|
return referenceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferenceType(ReferenceDto.ReferenceType referenceType) {
|
||||||
|
this.referenceType = referenceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package ru.ulstu.paper.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import ru.ulstu.paper.model.Reference;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ReferenceRepository extends JpaRepository<Reference, Integer> {
|
||||||
|
void deleteById(Integer id);
|
||||||
|
|
||||||
|
@Query("SELECT DISTINCT r.authors FROM Reference r")
|
||||||
|
List<String> findDistinctAuthors();
|
||||||
|
|
||||||
|
@Query("SELECT DISTINCT r.publicationTitle FROM Reference r")
|
||||||
|
List<String> findDistinctPublicationTitles();
|
||||||
|
|
||||||
|
@Query("SELECT DISTINCT r.publisher FROM Reference r")
|
||||||
|
List<String> findDistinctPublishers();
|
||||||
|
|
||||||
|
@Query("SELECT DISTINCT r.journalOrCollectionTitle FROM Reference r where r.journalOrCollectionTitle <> ''")
|
||||||
|
List<String> findDistinctJournalOrCollectionTitles();
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package ru.ulstu.students.model;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "scheduler")
|
||||||
|
public class Scheduler extends BaseEntity {
|
||||||
|
|
||||||
|
@OneToOne(optional = false)
|
||||||
|
@JoinColumn(name = "task_id")
|
||||||
|
private Task task;
|
||||||
|
|
||||||
|
@Temporal(value = TemporalType.TIMESTAMP)
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date date;
|
||||||
|
|
||||||
|
public Scheduler() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Scheduler(Task task, Date date) {
|
||||||
|
this.task = task;
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task getTask() {
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTask(Task task) {
|
||||||
|
this.task = task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(Date date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package ru.ulstu.students.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import ru.ulstu.students.model.Scheduler;
|
||||||
|
import ru.ulstu.students.model.Task;
|
||||||
|
|
||||||
|
public interface SchedulerRepository extends JpaRepository<Scheduler, Integer> {
|
||||||
|
|
||||||
|
Scheduler findOneByTask(Task task);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,116 @@
|
|||||||
|
package ru.ulstu.students.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ru.ulstu.students.model.Scheduler;
|
||||||
|
import ru.ulstu.students.model.Task;
|
||||||
|
import ru.ulstu.students.repository.SchedulerRepository;
|
||||||
|
import ru.ulstu.tags.model.Tag;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SchedulerService {
|
||||||
|
|
||||||
|
private final TaskService taskService;
|
||||||
|
private final SchedulerRepository schedulerRepository;
|
||||||
|
|
||||||
|
public SchedulerService(TaskService taskService, SchedulerRepository schedulerRepository) {
|
||||||
|
this.taskService = taskService;
|
||||||
|
this.schedulerRepository = schedulerRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void save(Tag tag) {
|
||||||
|
List<Task> taskList = taskService.findTasksByTag(tag);
|
||||||
|
create(taskList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
private Scheduler create(Task task) {
|
||||||
|
Scheduler scheduler = new Scheduler(task, task.getDeadlines().get(task.getDeadlines().size() - 1).getDate());
|
||||||
|
return schedulerRepository.save(scheduler);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
private void delete(Integer schedulerId) {
|
||||||
|
if (schedulerRepository.exists(schedulerId)) {
|
||||||
|
schedulerRepository.delete(schedulerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkPlanToday() {
|
||||||
|
List<Scheduler> schedulerList = schedulerRepository.findAll();
|
||||||
|
if (!schedulerList.isEmpty()) {
|
||||||
|
doTodayPlanIfNeed(schedulerList);
|
||||||
|
schedulerList = schedulerRepository.findAll();
|
||||||
|
}
|
||||||
|
checkNewPlan(schedulerList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkNewPlan(List<Scheduler> schedulerList) {
|
||||||
|
Set<Tag> tags = taskService.checkRepeatingTags(true);
|
||||||
|
Set<Tag> newTags = null;
|
||||||
|
if (!schedulerList.isEmpty()) {
|
||||||
|
newTags = checkNewTags(tags, schedulerList);
|
||||||
|
} else {
|
||||||
|
if (!tags.isEmpty()) {
|
||||||
|
newTags = tags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newTags != null) {
|
||||||
|
newTags.forEach(tag -> {
|
||||||
|
if (!hasNewTag(tag, schedulerList)) {
|
||||||
|
save(tag);
|
||||||
|
Task task = taskService.findTasksByTag(tag).get(0);
|
||||||
|
schedulerList.add(new Scheduler(task, task.getDeadlines().get(task.getDeadlines().size() - 1).getDate()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasNewTag(Tag tag, List<Scheduler> schedulerList) {
|
||||||
|
|
||||||
|
return schedulerList
|
||||||
|
.stream()
|
||||||
|
.anyMatch(scheduler -> scheduler.getTask().getTags().contains(tag));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Set<Tag> checkNewTags(Set<Tag> tags, List<Scheduler> schedulerList) {
|
||||||
|
Set<Tag> newTags = tags
|
||||||
|
.stream()
|
||||||
|
.filter(tag -> schedulerList
|
||||||
|
.stream()
|
||||||
|
.anyMatch(scheduler ->
|
||||||
|
!scheduler.getTask().getTags().contains(tag)))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
if (!newTags.isEmpty()) {
|
||||||
|
return newTags;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doTodayPlanIfNeed(List<Scheduler> schedulerList) {
|
||||||
|
List<Scheduler> plan = schedulerList
|
||||||
|
.stream()
|
||||||
|
.filter(scheduler -> scheduler.getDate().before(new Date()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
doToday(plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doToday(List<Scheduler> plan) {
|
||||||
|
plan.forEach(scheduler -> {
|
||||||
|
taskService.createPeriodTask(scheduler);
|
||||||
|
delete(scheduler.getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package ru.ulstu.students.service;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TaskGenerationService {
|
||||||
|
|
||||||
|
private final Logger log = LoggerFactory.getLogger(TaskGenerationService.class);
|
||||||
|
private final TaskService taskService;
|
||||||
|
private final SchedulerService schedulerService;
|
||||||
|
|
||||||
|
public TaskGenerationService(TaskService taskService, SchedulerService schedulerService) {
|
||||||
|
|
||||||
|
this.taskService = taskService;
|
||||||
|
this.schedulerService = schedulerService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0 0 * * ?", zone = "Europe/Samara")
|
||||||
|
public void generateTasks() {
|
||||||
|
log.debug("SchedulerService.checkPlanToday started");
|
||||||
|
schedulerService.checkPlanToday();
|
||||||
|
log.debug("SchedulerService.checkPlanToday finished");
|
||||||
|
|
||||||
|
log.debug("TaskService.generateYearTasks started");
|
||||||
|
taskService.generateYearTasks();
|
||||||
|
log.debug("TaskService.generateYearTasks finished");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package ru.ulstu.user.controller;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import ru.ulstu.configuration.Constants;
|
||||||
|
import ru.ulstu.odin.controller.OdinController;
|
||||||
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
import ru.ulstu.user.model.UserListDto;
|
||||||
|
import ru.ulstu.user.service.UserService;
|
||||||
|
import ru.ulstu.user.service.UserSessionService;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "/users")
|
||||||
|
public class UserMvcController extends OdinController<UserListDto, UserDto> {
|
||||||
|
|
||||||
|
private final Logger log = LoggerFactory.getLogger(UserMvcController.class);
|
||||||
|
|
||||||
|
private final UserService userService;
|
||||||
|
private final UserSessionService userSessionService;
|
||||||
|
|
||||||
|
public UserMvcController(UserService userService,
|
||||||
|
UserSessionService userSessionService) {
|
||||||
|
super(UserListDto.class, UserDto.class);
|
||||||
|
this.userService = userService;
|
||||||
|
this.userSessionService = userSessionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/profile")
|
||||||
|
public void getUserProfile(ModelMap modelMap, HttpServletRequest request) {
|
||||||
|
HttpSession session = request.getSession(false);
|
||||||
|
final String sessionId = session.getAttribute(Constants.SESSION_ID_ATTR).toString();
|
||||||
|
modelMap.addAttribute("userDto", new UserDto(userSessionService.getUserBySessionId(sessionId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/profile")
|
||||||
|
public void updateUserProfile(ModelMap modelMap, HttpServletRequest request, UserDto userDto) {
|
||||||
|
HttpSession session = request.getSession(false);
|
||||||
|
final String sessionId = session.getAttribute(Constants.SESSION_ID_ATTR).toString();
|
||||||
|
User user = userSessionService.getUserBySessionId(sessionId);
|
||||||
|
modelMap.addAttribute("userDto", userService.updateUserInformation(user, userDto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/dashboard")
|
||||||
|
public void getUsersDashboard(ModelMap modelMap) {
|
||||||
|
modelMap.addAllAttributes(userService.getUsersInfo());
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package ru.ulstu.user.error;
|
package ru.ulstu.user.error;
|
||||||
|
|
||||||
public class UserPasswordsNotValidOrNotMatchException extends RuntimeException {
|
public class UserPasswordsNotValidOrNotMatchException extends RuntimeException {
|
||||||
public UserPasswordsNotValidOrNotMatchException() {
|
public UserPasswordsNotValidOrNotMatchException(String message) {
|
||||||
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.user.error;
|
||||||
|
|
||||||
|
public class UserSendingMailException extends RuntimeException {
|
||||||
|
public UserSendingMailException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package ru.ulstu.user.model;
|
||||||
|
|
||||||
|
import ru.ulstu.conference.model.Conference;
|
||||||
|
import ru.ulstu.utils.timetable.model.Lesson;
|
||||||
|
|
||||||
|
public class UserInfoNow {
|
||||||
|
private Lesson lesson;
|
||||||
|
private Conference conference;
|
||||||
|
private User user;
|
||||||
|
private boolean isOnline;
|
||||||
|
|
||||||
|
public UserInfoNow(Lesson lesson, Conference conference, User user, boolean isOnline) {
|
||||||
|
this.lesson = lesson;
|
||||||
|
this.conference = conference;
|
||||||
|
this.user = user;
|
||||||
|
this.isOnline = isOnline;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Lesson getLesson() {
|
||||||
|
return lesson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLesson(Lesson lesson) {
|
||||||
|
this.lesson = lesson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Conference getConference() {
|
||||||
|
return conference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConference(Conference conference) {
|
||||||
|
this.conference = conference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOnline() {
|
||||||
|
return isOnline;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnline(boolean online) {
|
||||||
|
isOnline = online;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
package ru.ulstu.utils.timetable;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.springframework.web.client.RestClientException;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import ru.ulstu.core.util.DateUtils;
|
||||||
|
import ru.ulstu.utils.timetable.errors.TimetableClientException;
|
||||||
|
import ru.ulstu.utils.timetable.model.Lesson;
|
||||||
|
import ru.ulstu.utils.timetable.model.TimetableResponse;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TimetableService {
|
||||||
|
private static final String TIMETABLE_URL = "http://timetable.athene.tech/api/1.0/timetable?filter=%s";
|
||||||
|
private SimpleDateFormat lessonTimeFormat = new SimpleDateFormat("hh:mm");
|
||||||
|
|
||||||
|
private long[] lessonsStarts = new long[] {
|
||||||
|
lessonTimeFormat.parse("8:00:00").getTime(),
|
||||||
|
lessonTimeFormat.parse("9:40:00").getTime(),
|
||||||
|
lessonTimeFormat.parse("11:30:00").getTime(),
|
||||||
|
lessonTimeFormat.parse("13:10:00").getTime(),
|
||||||
|
lessonTimeFormat.parse("14:50:00").getTime(),
|
||||||
|
lessonTimeFormat.parse("16:30:00").getTime(),
|
||||||
|
lessonTimeFormat.parse("18:10:00").getTime(),
|
||||||
|
};
|
||||||
|
|
||||||
|
public TimetableService() throws ParseException {
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getCurrentDay() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
int day = calendar.get(Calendar.DAY_OF_WEEK);
|
||||||
|
return (day + 5) % 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getCurrentLessonNumber() {
|
||||||
|
long lessonDuration = 90 * 60000;
|
||||||
|
Date now = new Date();
|
||||||
|
long timeNow = now.getTime() % (24 * 60 * 60 * 1000L);
|
||||||
|
|
||||||
|
for (int i = 0; i < lessonsStarts.length; i++) {
|
||||||
|
if (timeNow > lessonsStarts[i] && timeNow < lessonsStarts[i] + lessonDuration) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getCurrentWeek() {
|
||||||
|
Date currentDate = Calendar.getInstance().getTime();
|
||||||
|
currentDate = DateUtils.clearTime(currentDate);
|
||||||
|
|
||||||
|
Calendar firstJan = Calendar.getInstance();
|
||||||
|
firstJan.set(Calendar.MONTH, 0);
|
||||||
|
firstJan.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
|
||||||
|
return (int) Math.round(Math.ceil((((currentDate.getTime() - firstJan.getTime().getTime()) / 86400000)
|
||||||
|
+ DateUtils.addDays(firstJan.getTime(), 1).getTime() / 7) % 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
private TimetableResponse getTimetableForUser(String userFIO) throws RestClientException {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
return restTemplate.getForObject(String.format(TIMETABLE_URL, userFIO), TimetableResponse.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Lesson getCurrentLesson(String userFio) {
|
||||||
|
TimetableResponse response;
|
||||||
|
try {
|
||||||
|
response = getTimetableForUser(userFio);
|
||||||
|
} catch (RestClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new TimetableClientException(userFio);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lessonNumber = getCurrentLessonNumber();
|
||||||
|
if (lessonNumber < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Lesson> lessons = response
|
||||||
|
.getResponse()
|
||||||
|
.getWeeks()
|
||||||
|
.get(getCurrentWeek())
|
||||||
|
.getDays()
|
||||||
|
.get(getCurrentDay())
|
||||||
|
.getLessons()
|
||||||
|
.get(lessonNumber);
|
||||||
|
|
||||||
|
if (lessons.size() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new ObjectMapper().convertValue(lessons.get(0), Lesson.class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.utils.timetable.errors;
|
||||||
|
|
||||||
|
public class TimetableClientException extends RuntimeException {
|
||||||
|
public TimetableClientException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package ru.ulstu.utils.timetable.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class Day {
|
||||||
|
|
||||||
|
private Integer day;
|
||||||
|
private List<List<Lesson>> lessons = new ArrayList<>();
|
||||||
|
|
||||||
|
public Integer getDay() {
|
||||||
|
return day;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDay(Integer day) {
|
||||||
|
this.day = day;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<List<Lesson>> getLessons() {
|
||||||
|
return lessons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLessons(List<List<Lesson>> lessons) {
|
||||||
|
this.lessons = lessons;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
|||||||
|
package ru.ulstu.utils.timetable.model;
|
||||||
|
|
||||||
|
public class Lesson {
|
||||||
|
private String group;
|
||||||
|
private String nameOfLesson;
|
||||||
|
private String teacher;
|
||||||
|
private String room;
|
||||||
|
|
||||||
|
public String getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNameOfLesson() {
|
||||||
|
return nameOfLesson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTeacher() {
|
||||||
|
return teacher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoom() {
|
||||||
|
return room;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package ru.ulstu.utils.timetable.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Response {
|
||||||
|
|
||||||
|
private List<Week> weeks = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<Week> getWeeks() {
|
||||||
|
return weeks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWeeks(List<Week> weeks) {
|
||||||
|
this.weeks = weeks;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package ru.ulstu.utils.timetable.model;
|
||||||
|
|
||||||
|
public class TimetableResponse {
|
||||||
|
private Response response;
|
||||||
|
private String error;
|
||||||
|
|
||||||
|
public Response getResponse() {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResponse(Response response) {
|
||||||
|
this.response = response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getError() {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setError(String error) {
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package ru.ulstu.utils.timetable.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Week implements Serializable {
|
||||||
|
|
||||||
|
private List<Day> days = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<Day> getDays() {
|
||||||
|
return days;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDays(List<Day> days) {
|
||||||
|
this.days = days;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
|
||||||
|
<changeSet author="nastya" id="20190505_000001-1">
|
||||||
|
<createTable tableName="scheduler">
|
||||||
|
<column name="id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="task_id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="date" type="timestamp">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_scheduler" tableName="scheduler"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="scheduler" baseColumnNames="task_id"
|
||||||
|
constraintName="fk_scheduler_task_id" referencedTableName="task"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="anton" id="20190506_000000-1">
|
||||||
|
<addColumn tableName="deadline">
|
||||||
|
<column name="executor" type="varchar(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="deadline">
|
||||||
|
<column name="done" type="boolean"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="anton" id="20190506_000000-2">
|
||||||
|
<createTable tableName="project_executors">
|
||||||
|
<column name="project_id" type="integer"/>
|
||||||
|
<column name="executors_id" type="integer"/>
|
||||||
|
</createTable>
|
||||||
|
<addForeignKeyConstraint baseTableName="project_executors" baseColumnNames="project_id"
|
||||||
|
constraintName="fk_project_project_executors" referencedTableName="project"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="project_executors" baseColumnNames="executors_id"
|
||||||
|
constraintName="fk_user_project_executors" referencedTableName="users"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="tanya" id="20190507_000001-1">
|
||||||
|
<sql>
|
||||||
|
update grants
|
||||||
|
set leader_id =
|
||||||
|
(select u.id
|
||||||
|
from users u
|
||||||
|
where u.last_name = 'Романов' AND u.first_name = 'Антон');
|
||||||
|
</sql>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="anton" id="20190507_000002-1">
|
||||||
|
<addColumn tableName="event">
|
||||||
|
<column name="project_id" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addForeignKeyConstraint baseTableName="event" baseColumnNames="project_id"
|
||||||
|
constraintName="fk_event_project_id" referencedTableName="project"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="nastya" id="20190511_000000-1">
|
||||||
|
<addColumn tableName="event">
|
||||||
|
<column name="task_id" type="integer"></column>
|
||||||
|
</addColumn>
|
||||||
|
<addForeignKeyConstraint baseTableName="event" baseColumnNames="task_id"
|
||||||
|
constraintName="fk_event_task_id" referencedTableName="task"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="anton" id="20190517_000001-1">
|
||||||
|
<modifyDataType tableName="deadline"
|
||||||
|
columnName="executor"
|
||||||
|
newDataType="integer"
|
||||||
|
schemaName="public"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="deadline" baseColumnNames="executor"
|
||||||
|
constraintName="fk_deadline_executor" referencedTableName="users"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="tanya" id="20190520_000000-1">
|
||||||
|
<dropColumn columnName="applicationFileName" tableName="grants"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="masha" id="20190523_000000-1">
|
||||||
|
<createTable tableName="reference">
|
||||||
|
<column name="id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="authors" type="varchar(255)"/>
|
||||||
|
<column name="publication_title" type="varchar(255)"/>
|
||||||
|
<column name="publication_year" type="integer"/>
|
||||||
|
<column name="paper_id" type="integer"/>
|
||||||
|
<column name="publisher" type="varchar(255)"/>
|
||||||
|
<column name="pages" type="varchar(255)"/>
|
||||||
|
<column name="journal_or_collection_title" type="varchar(255)"/>
|
||||||
|
<column name="reference_type" type="varchar(255)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_reference" tableName="reference"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="reference" baseColumnNames="paper_id"
|
||||||
|
constraintName="fk_reference_paper_id" referencedTableName="paper"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="anton" id="20190528_000000-1">
|
||||||
|
<renameColumn tableName="deadline"
|
||||||
|
columnDataType="integer"
|
||||||
|
newColumnName="executors"
|
||||||
|
oldColumnName="executor"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="anton" id="20190528_000000-3">
|
||||||
|
<createTable tableName="deadline_executors">
|
||||||
|
<column name="deadline_id" type="integer"/>
|
||||||
|
<column name="executors_id" type="integer"/>
|
||||||
|
</createTable>
|
||||||
|
<addForeignKeyConstraint baseTableName="deadline_executors" baseColumnNames="deadline_id"
|
||||||
|
constraintName="fk_deadline_deadline_executors" referencedTableName="deadline"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="deadline_executors" baseColumnNames="executors_id"
|
||||||
|
constraintName="fk_user_deadline_executors" referencedTableName="users"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<title>Password reset</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
|
<link rel="shortcut icon" th:href="@{|${baseUrl}/favicon.ico|}"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>
|
||||||
|
Dear <span th:text="${user.firstName + ' ' + user.lastName}">Ivan Ivanov</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Your password has been changed.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Regards,
|
||||||
|
<br/>
|
||||||
|
<em>Balance Team.</em>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue