Merge branch 'dev' into move-to-jdk11
# Conflicts: # build.gradle # src/main/java/ru/ulstu/grant/model/GrantDto.java # src/main/java/ru/ulstu/grant/service/GrantService.java # src/main/java/ru/ulstu/paper/model/PaperDto.java # src/main/java/ru/ulstu/project/model/Project.javapull/161/head
commit
7684bac74d
@ -0,0 +1,46 @@
|
|||||||
|
## Краткое описание задачи
|
||||||
|
|
||||||
|
Что требуется сделать
|
||||||
|
|
||||||
|
|
||||||
|
## `Опционально` Список верстаемых страниц
|
||||||
|
|
||||||
|
Будут затронуты страницы:
|
||||||
|
* page1.html
|
||||||
|
* page2.html
|
||||||
|
* page3.html
|
||||||
|
|
||||||
|
## `Опционально` Список затрагиваемых модулей
|
||||||
|
|
||||||
|
При реализации задачи потребуется также реализовать методы контроллера
|
||||||
|
|
||||||
|
|
||||||
|
## `Опционально` Список реализуемых функций
|
||||||
|
|
||||||
|
После выполнения задачи станет доступным:
|
||||||
|
* просмотр `entity_name`
|
||||||
|
* редактирование `entity_name`
|
||||||
|
* валидация `entity_name`
|
||||||
|
|
||||||
|
## `Опционально` Сценарии работы
|
||||||
|
|
||||||
|
Сценарий просмотра:
|
||||||
|
1. Зайти на главную страницу приложения
|
||||||
|
2. Перейти в раздел `section_name`
|
||||||
|
3. Перейти к списку `entity_name`
|
||||||
|
4. Выбрать нужную `entity_name` и нажать на нее
|
||||||
|
|
||||||
|
Сценарий редактирования:
|
||||||
|
1. Зайти на главную страницу приложения
|
||||||
|
2. Перейти в раздел `section_name`
|
||||||
|
3. Перейти к списку `entity_name`
|
||||||
|
4. Выбрать нужную `entity_name` и нажать на нее
|
||||||
|
5. Внести нужные правки в поля и сохранить
|
||||||
|
|
||||||
|
## Описание конечного результата, дающего возможность проверки выполнения задачи: компоненты проекта, сценарии работы
|
||||||
|
|
||||||
|
* Сверстаны страницы page1.hml, page2.hml, page3.hml
|
||||||
|
* Реализован контроллер для обслуживания страниц
|
||||||
|
* Сохранение в БД еще не реализовано
|
||||||
|
* Валидация происходит по полям `field1, field2`
|
||||||
|
* Сценарий просмотра проверяется при ручном внечении записей в БД
|
@ -1,11 +1,138 @@
|
|||||||
package ru.ulstu.conference.model;
|
package ru.ulstu.conference.model;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Fetch;
|
||||||
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
import org.hibernate.validator.constraints.NotBlank;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.paper.model.Paper;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.JoinTable;
|
||||||
|
import javax.persistence.ManyToMany;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.OrderBy;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "conference")
|
@Table(name = "conference")
|
||||||
public class Conference extends BaseEntity {
|
public class Conference extends BaseEntity {
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private int ping;
|
||||||
|
|
||||||
|
@Column(name = "begin_date")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date beginDate;
|
||||||
|
|
||||||
|
@Column(name = "end_date")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date endDate;
|
||||||
|
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "conference_id", unique = true)
|
||||||
|
@Fetch(FetchMode.SUBSELECT)
|
||||||
|
@OrderBy("date")
|
||||||
|
private List<Deadline> deadlines = new ArrayList<>();
|
||||||
|
|
||||||
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
|
@JoinTable(name = "paper_conference",
|
||||||
|
joinColumns = {@JoinColumn(name = "conference_id")},
|
||||||
|
inverseJoinColumns = {@JoinColumn(name = "paper_id")})
|
||||||
|
private List<Paper> papers = new ArrayList<>();
|
||||||
|
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "conference_id", unique = true)
|
||||||
|
@Fetch(FetchMode.SUBSELECT)
|
||||||
|
private List<ConferenceUser> users = new ArrayList<>();
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPing() {
|
||||||
|
return ping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPing(int ping) {
|
||||||
|
this.ping = ping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getBeginDate() {
|
||||||
|
return beginDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeginDate(Date beginDate) {
|
||||||
|
this.beginDate = beginDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getEndDate() {
|
||||||
|
return endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(Date endDate) {
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Deadline> getDeadlines() {
|
||||||
|
return deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeadlines(List<Deadline> deadlines) {
|
||||||
|
this.deadlines = deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Paper> getPapers() {
|
||||||
|
return papers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPapers(List<Paper> papers) {
|
||||||
|
this.papers = papers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceUser> getUsers() {
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsers(List<ConferenceUser> users) {
|
||||||
|
this.users = users;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,221 @@
|
|||||||
package ru.ulstu.conference.model;
|
package ru.ulstu.conference.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.paper.model.Paper;
|
||||||
|
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
public class ConferenceDto {
|
public class ConferenceDto {
|
||||||
|
|
||||||
|
private final static String BEGIN_DATE = "Начало: ";
|
||||||
|
private final static String END_DATE = "Конец: ";
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
@NotEmpty
|
||||||
|
@Size(min = 2, max = 400)
|
||||||
|
private String title;
|
||||||
|
@Size(max = 500)
|
||||||
|
private String description = "";
|
||||||
|
@Size(max = 255)
|
||||||
|
private String url = "";
|
||||||
|
private int ping = 0;
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date beginDate = new Date();
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date endDate = new Date();
|
||||||
|
private List<Deadline> deadlines = new ArrayList<>();
|
||||||
|
private List<Integer> removedDeadlineIds = new ArrayList<>();
|
||||||
|
private List<Integer> userIds = new ArrayList<>();
|
||||||
|
private List<Integer> paperIds = new ArrayList<>();
|
||||||
|
private List<Paper> papers = new ArrayList<>();
|
||||||
|
private List<Paper> notSelectedPapers = new ArrayList<>();
|
||||||
|
private List<ConferenceUser> users = new ArrayList<>();
|
||||||
|
private boolean disabledTakePart = false;
|
||||||
|
|
||||||
|
public ConferenceDto() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public ConferenceDto(@JsonProperty("id") Integer id,
|
||||||
|
@JsonProperty("title") String title,
|
||||||
|
@JsonProperty("description") String description,
|
||||||
|
@JsonProperty("url") String url,
|
||||||
|
@JsonProperty("ping") Integer ping,
|
||||||
|
@JsonProperty("beginDate") Date beginDate,
|
||||||
|
@JsonProperty("endDate") Date endDate,
|
||||||
|
@JsonProperty("deadlines") List<Deadline> deadlines,
|
||||||
|
@JsonProperty("userIds") List<Integer> userIds,
|
||||||
|
@JsonProperty("paperIds") List<Integer> paperIds,
|
||||||
|
@JsonProperty("users") List<ConferenceUser> users,
|
||||||
|
@JsonProperty("papers") List<Paper> papers,
|
||||||
|
@JsonProperty("notSelectedPapers") List<Paper> notSelectedPapers,
|
||||||
|
@JsonProperty("notSelectedPapers") Boolean disabledTakePart) {
|
||||||
|
this.id = id;
|
||||||
|
this.title = title;
|
||||||
|
this.description = description;
|
||||||
|
this.url = url;
|
||||||
|
this.ping = ping;
|
||||||
|
this.beginDate = beginDate;
|
||||||
|
this.endDate = endDate;
|
||||||
|
this.deadlines = deadlines;
|
||||||
|
this.userIds = userIds;
|
||||||
|
this.paperIds = paperIds;
|
||||||
|
this.users = users;
|
||||||
|
this.papers = papers;
|
||||||
|
this.notSelectedPapers = notSelectedPapers;
|
||||||
|
this.disabledTakePart = disabledTakePart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceDto(Conference conference) {
|
||||||
|
this.id = conference.getId();
|
||||||
|
this.title = conference.getTitle();
|
||||||
|
this.description = conference.getDescription();
|
||||||
|
this.url = conference.getUrl();
|
||||||
|
this.ping = conference.getPing();
|
||||||
|
this.beginDate = conference.getBeginDate();
|
||||||
|
this.endDate = conference.getEndDate();
|
||||||
|
this.deadlines = conference.getDeadlines();
|
||||||
|
this.userIds = convert(conference.getUsers(), user -> user.getId());
|
||||||
|
this.paperIds = convert(conference.getPapers(), paper -> paper.getId());
|
||||||
|
this.users = conference.getUsers();
|
||||||
|
this.papers = conference.getPapers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPing() {
|
||||||
|
return ping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPing(int ping) {
|
||||||
|
this.ping = ping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getBeginDate() {
|
||||||
|
return beginDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeginDate(Date beginDate) {
|
||||||
|
this.beginDate = beginDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getEndDate() {
|
||||||
|
return endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(Date endDate) {
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Deadline> getDeadlines() {
|
||||||
|
return deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeadlines(List<Deadline> deadlines) {
|
||||||
|
this.deadlines = deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getUserIds() {
|
||||||
|
return userIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserIds(List<Integer> userIds) {
|
||||||
|
this.userIds = userIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getPaperIds() {
|
||||||
|
return paperIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaperIds(List<Integer> paperIds) {
|
||||||
|
this.paperIds = paperIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Paper> getPapers() {
|
||||||
|
return papers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPapers(List<Paper> papers) {
|
||||||
|
this.papers = papers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceUser> getUsers() {
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsers(List<ConferenceUser> users) {
|
||||||
|
this.users = users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisabledTakePart() {
|
||||||
|
return disabledTakePart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisabledTakePart(boolean disabledTakePart) {
|
||||||
|
this.disabledTakePart = disabledTakePart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getRemovedDeadlineIds() {
|
||||||
|
return removedDeadlineIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemovedDeadlineIds(List<Integer> removedDeadlineIds) {
|
||||||
|
this.removedDeadlineIds = removedDeadlineIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Paper> getNotSelectedPapers() {
|
||||||
|
return notSelectedPapers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotSelectedPapers(List<Paper> notSelectedPapers) {
|
||||||
|
this.notSelectedPapers = notSelectedPapers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDatesString() {
|
||||||
|
return BEGIN_DATE + beginDate.toString().split(" ")[0] + " " + END_DATE + endDate.toString().split(" ")[0];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,47 @@
|
|||||||
package ru.ulstu.conference.model;
|
package ru.ulstu.conference.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ConferenceFilterDto {
|
public class ConferenceFilterDto {
|
||||||
|
|
||||||
|
private List<ConferenceDto> conferences;
|
||||||
|
private Integer filterUserId;
|
||||||
|
private Integer year;
|
||||||
|
|
||||||
|
public ConferenceFilterDto() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceFilterDto(List<ConferenceDto> conferenceDtos, Integer filterUserId, Integer year) {
|
||||||
|
this.conferences = conferenceDtos;
|
||||||
|
this.filterUserId = filterUserId;
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceFilterDto(List<ConferenceDto> conferenceDtos) {
|
||||||
|
this(conferenceDtos, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceDto> getConferences() {
|
||||||
|
return conferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConferences(List<ConferenceDto> conferences) {
|
||||||
|
this.conferences = conferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getFilterUserId() {
|
||||||
|
return filterUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilterUserId(Integer filterUserId) {
|
||||||
|
this.filterUserId = filterUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getYear() {
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYear(Integer year) {
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,110 @@
|
|||||||
|
package ru.ulstu.conference.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "users_conference")
|
||||||
|
public class ConferenceUser extends BaseEntity {
|
||||||
|
|
||||||
|
public enum Participation {
|
||||||
|
INTRAMURAL("Очная"),
|
||||||
|
EXTRAMURAL("Заочная");
|
||||||
|
|
||||||
|
private String participationName;
|
||||||
|
|
||||||
|
Participation(String name) {
|
||||||
|
this.participationName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParticipation() {
|
||||||
|
return participationName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Deposit {
|
||||||
|
ARTICLE("Статья"),
|
||||||
|
REPORT("Доклад"),
|
||||||
|
PRESENTATION("Презентация");
|
||||||
|
|
||||||
|
private String depositName;
|
||||||
|
|
||||||
|
Deposit(String name) {
|
||||||
|
this.depositName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeposit() {
|
||||||
|
return depositName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Column(name = "participation", nullable = false)
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
private Participation participation = Participation.INTRAMURAL;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Column(name = "deposit", nullable = false)
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
private Deposit deposit = Deposit.ARTICLE;
|
||||||
|
|
||||||
|
@ManyToOne(optional = false)
|
||||||
|
@JoinColumn(name = "users_id")
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
public ConferenceUser() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public ConferenceUser(@JsonProperty("id") Integer id,
|
||||||
|
@JsonProperty("deposit") Participation participation,
|
||||||
|
@JsonProperty("deposit") Deposit deposit,
|
||||||
|
@JsonProperty("user") User user) {
|
||||||
|
this.setId(id);
|
||||||
|
this.participation = participation;
|
||||||
|
this.deposit = deposit;
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Participation getParticipation() {
|
||||||
|
return participation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParticipation(Participation participation) {
|
||||||
|
this.participation = participation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Deposit getDeposit() {
|
||||||
|
return deposit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeposit(Deposit deposit) {
|
||||||
|
this.deposit = deposit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,19 @@
|
|||||||
package ru.ulstu.conference.repository;
|
package ru.ulstu.conference.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.conference.model.Conference;
|
import ru.ulstu.conference.model.Conference;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface ConferenceRepository extends JpaRepository<Conference, Integer> {
|
public interface ConferenceRepository extends JpaRepository<Conference, Integer> {
|
||||||
|
@Query("SELECT c FROM Conference c LEFT JOIN c.users u WHERE (:user IS NULL OR u.user = :user) " +
|
||||||
|
"AND (YEAR(c.beginDate) = :year OR :year IS NULL) ORDER BY begin_date DESC")
|
||||||
|
List<Conference> findByUserAndYear(@Param("user") User user, @Param("year") Integer year);
|
||||||
|
|
||||||
|
@Query("SELECT c FROM Conference c WHERE c.beginDate > :date")
|
||||||
|
List<Conference> findAllActive(@Param("date") Date date);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.conference.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import ru.ulstu.conference.model.ConferenceUser;
|
||||||
|
|
||||||
|
public interface ConferenceUserRepository extends JpaRepository<ConferenceUser, Integer> {
|
||||||
|
}
|
@ -1,17 +1,176 @@
|
|||||||
package ru.ulstu.conference.service;
|
package ru.ulstu.conference.service;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ru.ulstu.conference.model.Conference;
|
||||||
|
import ru.ulstu.conference.model.ConferenceDto;
|
||||||
|
import ru.ulstu.conference.model.ConferenceFilterDto;
|
||||||
|
import ru.ulstu.conference.model.ConferenceUser;
|
||||||
import ru.ulstu.conference.repository.ConferenceRepository;
|
import ru.ulstu.conference.repository.ConferenceRepository;
|
||||||
import ru.ulstu.deadline.service.DeadlineService;
|
import ru.ulstu.deadline.service.DeadlineService;
|
||||||
|
import ru.ulstu.paper.model.Paper;
|
||||||
|
import ru.ulstu.paper.service.PaperService;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||||
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ConferenceService {
|
public class ConferenceService {
|
||||||
|
private final static int MAX_DISPLAY_SIZE = 40;
|
||||||
|
|
||||||
private final ConferenceRepository conferenceRepository;
|
private final ConferenceRepository conferenceRepository;
|
||||||
|
private final ConferenceUserService conferenceUserService;
|
||||||
private final DeadlineService deadlineService;
|
private final DeadlineService deadlineService;
|
||||||
|
private final PaperService paperService;
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
public ConferenceService(ConferenceRepository conferenceRepository,
|
public ConferenceService(ConferenceRepository conferenceRepository,
|
||||||
DeadlineService deadlineService) {
|
ConferenceUserService conferenceUserService,
|
||||||
|
DeadlineService deadlineService,
|
||||||
|
PaperService paperService,
|
||||||
|
UserService userService) {
|
||||||
this.conferenceRepository = conferenceRepository;
|
this.conferenceRepository = conferenceRepository;
|
||||||
|
this.conferenceUserService = conferenceUserService;
|
||||||
this.deadlineService = deadlineService;
|
this.deadlineService = deadlineService;
|
||||||
|
this.paperService = paperService;
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceDto getExistConferenceById(Integer id) {
|
||||||
|
ConferenceDto conferenceDto = findOneDto(id);
|
||||||
|
conferenceDto.setNotSelectedPapers(getNotSelectPapers(conferenceDto.getPaperIds()));
|
||||||
|
conferenceDto.setDisabledTakePart(isCurrentUserParticipant(conferenceDto.getUsers()));
|
||||||
|
return conferenceDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceDto getNewConference() {
|
||||||
|
ConferenceDto conferenceDto = new ConferenceDto();
|
||||||
|
conferenceDto.setNotSelectedPapers(getNotSelectPapers(new ArrayList<Integer>()));
|
||||||
|
return conferenceDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Conference> findAll() {
|
||||||
|
return conferenceRepository.findAll(new Sort(Sort.Direction.DESC, "beginDate"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceDto> findAllDto() {
|
||||||
|
List<ConferenceDto> conferences = convert(findAll(), ConferenceDto::new);
|
||||||
|
conferences.forEach(conferenceDto -> conferenceDto.setTitle(StringUtils.abbreviate(conferenceDto.getTitle(), MAX_DISPLAY_SIZE)));
|
||||||
|
return conferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceDto findOneDto(Integer id) {
|
||||||
|
return new ConferenceDto(conferenceRepository.getOne(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save(ConferenceDto conferenceDto) throws IOException {
|
||||||
|
if (isEmpty(conferenceDto.getId())) {
|
||||||
|
create(conferenceDto);
|
||||||
|
} else {
|
||||||
|
update(conferenceDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Integer create(ConferenceDto conferenceDto) throws IOException {
|
||||||
|
Conference newConference = copyFromDto(new Conference(), conferenceDto);
|
||||||
|
newConference = conferenceRepository.save(newConference);
|
||||||
|
return newConference.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Integer update(ConferenceDto conferenceDto) throws IOException {
|
||||||
|
Conference conference = conferenceRepository.getOne(conferenceDto.getId());
|
||||||
|
conferenceRepository.save(copyFromDto(conference, conferenceDto));
|
||||||
|
conferenceDto.getRemovedDeadlineIds().forEach(deadlineService::remove);
|
||||||
|
return conference.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void delete(Integer conferenceId) {
|
||||||
|
if (conferenceRepository.existsById(conferenceId)) {
|
||||||
|
conferenceRepository.deleteById(conferenceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeDeadline(ConferenceDto conferenceDto, Integer deadlineIndex) throws IOException {
|
||||||
|
if (conferenceDto.getDeadlines().get(deadlineIndex).getId() != null) {
|
||||||
|
conferenceDto.getRemovedDeadlineIds().add(conferenceDto.getDeadlines().get(deadlineIndex).getId());
|
||||||
|
}
|
||||||
|
conferenceDto.getDeadlines().remove((int) deadlineIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePaper(ConferenceDto conferenceDto, Integer paperIndex) throws IOException {
|
||||||
|
Paper removedPaper = conferenceDto.getPapers().remove((int) paperIndex);
|
||||||
|
conferenceDto.getNotSelectedPapers().add(removedPaper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void takePart(ConferenceDto conferenceDto) throws IOException {
|
||||||
|
conferenceDto.getUsers().add(new ConferenceUser(userService.getCurrentUser()));
|
||||||
|
conferenceDto.setDisabledTakePart(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Paper> getNotSelectPapers(List<Integer> paperIds) {
|
||||||
|
return paperService.findAllNotSelect(paperIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<User> getAllUsers() {
|
||||||
|
return userService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceUser.Participation> getAllParticipations() {
|
||||||
|
return Arrays.asList(ConferenceUser.Participation.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceUser.Deposit> getAllDeposit() {
|
||||||
|
return Arrays.asList(ConferenceUser.Deposit.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Conference copyFromDto(Conference conference, ConferenceDto conferenceDto) throws IOException {
|
||||||
|
conference.setTitle(conferenceDto.getTitle());
|
||||||
|
conference.setDescription(conferenceDto.getDescription());
|
||||||
|
conference.setUrl(conferenceDto.getUrl());
|
||||||
|
conference.setPing(0);
|
||||||
|
conference.setBeginDate(conferenceDto.getBeginDate());
|
||||||
|
conference.setEndDate(conferenceDto.getEndDate());
|
||||||
|
conference.setPapers(conferenceDto.getPapers());
|
||||||
|
conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines()));
|
||||||
|
conference.setUsers(conferenceUserService.saveOrCreate(conferenceDto.getUsers()));
|
||||||
|
if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) {
|
||||||
|
conferenceDto.getPaperIds().forEach(paperId ->
|
||||||
|
conference.getPapers().add(paperService.findEntityById(paperId)));
|
||||||
|
}
|
||||||
|
return conference;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isCurrentUserParticipant(List<ConferenceUser> conferenceUsers) {
|
||||||
|
return conferenceUsers.stream().anyMatch(participant -> participant.getUser().equals(userService.getCurrentUser()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceDto> filter(ConferenceFilterDto conferenceFilterDto) {
|
||||||
|
return convert(conferenceRepository.findByUserAndYear(
|
||||||
|
conferenceFilterDto.getFilterUserId() == null ? null : userService.findById(conferenceFilterDto.getFilterUserId()),
|
||||||
|
conferenceFilterDto.getYear()), ConferenceDto::new);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceDto> findAllActiveDto() {
|
||||||
|
return convert(findAllActive(), ConferenceDto::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Conference> findAllActive() {
|
||||||
|
return conferenceRepository.findAllActive(new Date());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package ru.ulstu.conference.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ru.ulstu.conference.model.ConferenceUser;
|
||||||
|
import ru.ulstu.conference.repository.ConferenceUserRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ConferenceUserService {
|
||||||
|
|
||||||
|
private final ConferenceUserRepository conferenceUserRepository;
|
||||||
|
|
||||||
|
public ConferenceUserService(ConferenceUserRepository conferenceUserRepository) {
|
||||||
|
this.conferenceUserRepository = conferenceUserRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceUser> saveOrCreate(List<ConferenceUser> users) {
|
||||||
|
return users
|
||||||
|
.stream()
|
||||||
|
.map(user -> {
|
||||||
|
return user.getId() != null ? update(user) : create(user);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public ConferenceUser update(ConferenceUser user) {
|
||||||
|
ConferenceUser updateUser = conferenceUserRepository.getOne(user.getId());
|
||||||
|
updateUser.setDeposit(user.getDeposit());
|
||||||
|
updateUser.setParticipation(user.getParticipation());
|
||||||
|
conferenceUserRepository.save(updateUser);
|
||||||
|
return updateUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public ConferenceUser create(ConferenceUser user) {
|
||||||
|
ConferenceUser newUser = new ConferenceUser();
|
||||||
|
newUser.setDeposit(user.getDeposit());
|
||||||
|
newUser.setParticipation(user.getParticipation());
|
||||||
|
newUser.setUser(user.getUser());
|
||||||
|
newUser = conferenceUserRepository.save(newUser);
|
||||||
|
return newUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
package ru.ulstu.core.error;
|
|
||||||
|
|
||||||
public class XlsLoadException extends Exception {
|
|
||||||
public XlsLoadException(String s) {
|
|
||||||
super(s);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package ru.ulstu.core.error;
|
|
||||||
|
|
||||||
public class XlsParseException extends Exception {
|
|
||||||
public XlsParseException(String s) {
|
|
||||||
super(s);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package ru.ulstu.core.service;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import ru.ulstu.core.model.TreeDto;
|
|
||||||
import ru.ulstu.core.model.TreeEntity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class TreeService<T extends TreeEntity> {
|
|
||||||
public TreeDto getTree(String rootName, List<T> rootItems) {
|
|
||||||
return addChildNode(new TreeDto(rootName), rootItems, element -> true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TreeDto getTree(String rootName, List<T> rootItems, Predicate<T> filterPredicate) {
|
|
||||||
return addChildNode(new TreeDto(rootName), rootItems, filterPredicate);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TreeDto addChildNode(TreeDto currentRoot, List<T> children, Predicate<T> filterPredicate) {
|
|
||||||
if (children != null) {
|
|
||||||
children.stream()
|
|
||||||
.filter(filterPredicate)
|
|
||||||
.forEach(item -> {
|
|
||||||
TreeDto newNode = new TreeDto(item);
|
|
||||||
currentRoot.getChildren().add(addChildNode(newNode, item.getChildren(), filterPredicate));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return currentRoot;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package ru.ulstu.grant.model;
|
|
||||||
|
|
||||||
public class GrantStatusDto {
|
|
||||||
private final String id;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public GrantStatusDto(Grant.GrantStatus status) {
|
|
||||||
this.id = status.name();
|
|
||||||
this.name = status.getStatusName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,76 @@
|
|||||||
|
package ru.ulstu.paper.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.file.service.FileService;
|
||||||
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class LatexService {
|
||||||
|
private final String pdfLatexError = "Errors occurred while executing pdfLaTeX.";
|
||||||
|
private final String bibtexError = "Errors occurred while executing bibtex.";
|
||||||
|
private String errorMessage;
|
||||||
|
private File pdfFile;
|
||||||
|
private FileService fileService;
|
||||||
|
|
||||||
|
public LatexService(FileService fileService) {
|
||||||
|
this.fileService = fileService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] generatePdfFromLatexFile(PaperDto paper) throws IOException, InterruptedException {
|
||||||
|
fileService.createLatexAttachs(paper);
|
||||||
|
File tex = fileService.createLatexFile(paper);
|
||||||
|
|
||||||
|
if (!generate(paper.getTitle(), tex.getParentFile())) {
|
||||||
|
throw new IOException(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Files.readAllBytes(pdfFile.toPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
private int startProcess(String[] args, File dir, String message) throws IOException, InterruptedException {
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder(args);
|
||||||
|
processBuilder.redirectErrorStream(true);
|
||||||
|
processBuilder.directory(dir);
|
||||||
|
|
||||||
|
Process process = processBuilder.start();
|
||||||
|
InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream());
|
||||||
|
|
||||||
|
try (BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
|
||||||
|
while ((bufferedReader.readLine()) != null) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int exitCode = process.waitFor();
|
||||||
|
if (exitCode != 0) {
|
||||||
|
errorMessage = message + " Exit value of the process: " + exitCode;
|
||||||
|
}
|
||||||
|
return exitCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean generate(String filename, File dir) throws IOException, InterruptedException {
|
||||||
|
startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError);
|
||||||
|
startProcess(new String[]{"bibtex", filename}, dir, bibtexError);
|
||||||
|
if (startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return checkPdf(filename, dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkPdf(String filename, File dir) {
|
||||||
|
pdfFile = new File(dir.getAbsolutePath() + File.separator + filename + ".pdf");
|
||||||
|
|
||||||
|
if (pdfFile.isFile()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
errorMessage = "The pdf file could not be created.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package ru.ulstu.project.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import ru.ulstu.project.model.Project;
|
||||||
|
import ru.ulstu.project.model.ProjectDto;
|
||||||
|
import ru.ulstu.project.service.ProjectService;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
@RequestMapping(value = "/projects")
|
||||||
|
@ApiIgnore
|
||||||
|
public class ProjectController {
|
||||||
|
private final ProjectService projectService;
|
||||||
|
|
||||||
|
public ProjectController(ProjectService projectService) {
|
||||||
|
this.projectService = projectService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/dashboard")
|
||||||
|
public void getDashboard(ModelMap modelMap) {
|
||||||
|
modelMap.put("projects", projectService.findAllDto());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/projects")
|
||||||
|
public void getProjects(ModelMap modelMap) {
|
||||||
|
modelMap.put("projects", projectService.findAllDto());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/project")
|
||||||
|
public void getProject(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
|
||||||
|
if (id != null && id > 0) {
|
||||||
|
modelMap.put("projectDto", projectService.findOneDto(id));
|
||||||
|
} else {
|
||||||
|
modelMap.put("projectDto", new ProjectDto());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("allStatuses")
|
||||||
|
public List<Project.ProjectStatus> getProjectStatuses() {
|
||||||
|
return projectService.getProjectStatuses();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package ru.ulstu.students.controller;
|
||||||
|
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
|
||||||
|
public class Navigation {
|
||||||
|
public static final String REDIRECT_TO = "redirect:%s";
|
||||||
|
public static final String TASKS_PAGE = "/students/tasks";
|
||||||
|
public static final String TASK_PAGE = "/students/task";
|
||||||
|
|
||||||
|
public static String hasErrors(Errors errors, String page) {
|
||||||
|
if (errors.hasErrors()) {
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,144 @@
|
|||||||
|
package ru.ulstu.students.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.tags.model.Tag;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class TaskDto {
|
||||||
|
|
||||||
|
private final static int MAX_TAGS_LENGTH = 50;
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
@NotEmpty
|
||||||
|
private String title;
|
||||||
|
private String description;
|
||||||
|
private Task.TaskStatus status;
|
||||||
|
private List<Deadline> deadlines = new ArrayList<>();
|
||||||
|
private Date createDate;
|
||||||
|
private Date updateDate;
|
||||||
|
private Set<Integer> tagIds;
|
||||||
|
private List<Tag> tags;
|
||||||
|
|
||||||
|
public TaskDto() {
|
||||||
|
deadlines.add(new Deadline());
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public TaskDto(@JsonProperty("id") Integer id,
|
||||||
|
@JsonProperty("title") String title,
|
||||||
|
@JsonProperty("description") String description,
|
||||||
|
@JsonProperty("createDate") Date createDate,
|
||||||
|
@JsonProperty("updateDate") Date updateDate,
|
||||||
|
@JsonProperty("status") Task.TaskStatus status,
|
||||||
|
@JsonProperty("deadlines") List<Deadline> deadlines,
|
||||||
|
@JsonProperty("tagIds") Set<Integer> tagIds,
|
||||||
|
@JsonProperty("tags") List<Tag> tags) {
|
||||||
|
this.id = id;
|
||||||
|
this.title = title;
|
||||||
|
this.status = status;
|
||||||
|
this.deadlines = deadlines;
|
||||||
|
this.createDate = createDate;
|
||||||
|
this.updateDate = updateDate;
|
||||||
|
this.description = description;
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskDto(Task task) {
|
||||||
|
this.id = task.getId();
|
||||||
|
this.title = task.getTitle();
|
||||||
|
this.status = task.getStatus();
|
||||||
|
this.deadlines = task.getDeadlines();
|
||||||
|
this.createDate = task.getCreateDate();
|
||||||
|
this.updateDate = task.getUpdateDate();
|
||||||
|
this.description = task.getDescription();
|
||||||
|
this.tags = task.getTags();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task.TaskStatus getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Task.TaskStatus status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Deadline> getDeadlines() {
|
||||||
|
return deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeadlines(List<Deadline> deadlines) {
|
||||||
|
this.deadlines = deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateDate() {
|
||||||
|
return createDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateDate(Date createDate) {
|
||||||
|
this.createDate = createDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateDate() {
|
||||||
|
return updateDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateDate(Date updateDate) {
|
||||||
|
this.updateDate = updateDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Integer> getTagIds() {
|
||||||
|
return tagIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTagIds(Set<Integer> tagIds) {
|
||||||
|
this.tagIds = tagIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Tag> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTags(List<Tag> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTagsString() {
|
||||||
|
return StringUtils.abbreviate(tags
|
||||||
|
.stream()
|
||||||
|
.map(tag -> tag.getTagName())
|
||||||
|
.collect(Collectors.joining(", ")), MAX_TAGS_LENGTH);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.students.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import ru.ulstu.students.model.Task;
|
||||||
|
|
||||||
|
public interface TaskRepository extends JpaRepository<Task, Integer> {
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
package ru.ulstu.students.service;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ru.ulstu.deadline.service.DeadlineService;
|
||||||
|
import ru.ulstu.students.model.Task;
|
||||||
|
import ru.ulstu.students.model.TaskDto;
|
||||||
|
import ru.ulstu.students.repository.TaskRepository;
|
||||||
|
import ru.ulstu.tags.service.TagService;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||||
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
import static ru.ulstu.students.model.Task.TaskStatus.IN_WORK;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TaskService {
|
||||||
|
|
||||||
|
private final static int MAX_DISPLAY_SIZE = 40;
|
||||||
|
|
||||||
|
private final TaskRepository taskRepository;
|
||||||
|
private final DeadlineService deadlineService;
|
||||||
|
private final TagService tagService;
|
||||||
|
|
||||||
|
public TaskService(TaskRepository grantRepository,
|
||||||
|
DeadlineService deadlineService, TagService tagService) {
|
||||||
|
this.taskRepository = grantRepository;
|
||||||
|
this.deadlineService = deadlineService;
|
||||||
|
this.tagService = tagService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Task> findAll() {
|
||||||
|
return taskRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TaskDto> findAllDto() {
|
||||||
|
List<TaskDto> tasks = convert(findAll(), TaskDto::new);
|
||||||
|
tasks.forEach(taskDto -> taskDto.setTitle(StringUtils.abbreviate(taskDto.getTitle(), MAX_DISPLAY_SIZE)));
|
||||||
|
return tasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskDto findOneDto(Integer id) {
|
||||||
|
return new TaskDto(taskRepository.getOne(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Integer create(TaskDto taskDto) throws IOException {
|
||||||
|
Task newTask = copyFromDto(new Task(), taskDto);
|
||||||
|
newTask = taskRepository.save(newTask);
|
||||||
|
return newTask.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task copyFromDto(Task task, TaskDto taskDto) throws IOException {
|
||||||
|
task.setTitle(taskDto.getTitle());
|
||||||
|
task.setDescription(taskDto.getDescription());
|
||||||
|
task.setStatus(taskDto.getStatus() == null ? IN_WORK : taskDto.getStatus());
|
||||||
|
task.setDeadlines(deadlineService.saveOrCreate(taskDto.getDeadlines()));
|
||||||
|
task.setCreateDate(task.getCreateDate() == null ? new Date() : task.getCreateDate());
|
||||||
|
task.setUpdateDate(new Date());
|
||||||
|
task.getTags().clear();
|
||||||
|
task.setTags(tagService.saveOrCreate(taskDto.getTags()));
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Integer update(TaskDto taskDto) throws IOException {
|
||||||
|
Task task = taskRepository.getOne(taskDto.getId());
|
||||||
|
taskRepository.save(copyFromDto(task, taskDto));
|
||||||
|
return task.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void delete(Integer taskId) throws IOException {
|
||||||
|
Task task = taskRepository.getOne(taskId);
|
||||||
|
taskRepository.delete(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save(TaskDto taskDto) throws IOException {
|
||||||
|
if (isEmpty(taskDto.getId())) {
|
||||||
|
create(taskDto);
|
||||||
|
} else {
|
||||||
|
update(taskDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Task.TaskStatus> getTaskStatuses() {
|
||||||
|
return Arrays.asList(Task.TaskStatus.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package ru.ulstu.tags.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "tag")
|
||||||
|
public class Tag extends BaseEntity {
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
@Size(max = 50)
|
||||||
|
@Column(name = "tag_name")
|
||||||
|
private String tagName;
|
||||||
|
|
||||||
|
public Tag() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public Tag(@JsonProperty("id") Integer id,
|
||||||
|
@JsonProperty("tag_name") String tagName) {
|
||||||
|
this.setId(id);
|
||||||
|
this.tagName = tagName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tag(String name) {
|
||||||
|
this.tagName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTagName() {
|
||||||
|
return tagName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTagName(String tagName) {
|
||||||
|
this.tagName = tagName;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package ru.ulstu.tags.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.tags.model.Tag;
|
||||||
|
|
||||||
|
public interface TagRepository extends JpaRepository<Tag, Integer> {
|
||||||
|
|
||||||
|
@Query("SELECT t FROM Tag t WHERE (t.tagName = :tagName)")
|
||||||
|
Tag findByName(@Param("tagName") String tagName);
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package ru.ulstu.tags.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.tags.model.Tag;
|
||||||
|
import ru.ulstu.tags.repository.TagRepository;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TagService {
|
||||||
|
|
||||||
|
private final TagRepository tagRepository;
|
||||||
|
|
||||||
|
|
||||||
|
public TagService(TagRepository tagRepository) {
|
||||||
|
|
||||||
|
this.tagRepository = tagRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Tag> saveOrCreate(List<Tag> tags) {
|
||||||
|
return tags
|
||||||
|
.stream()
|
||||||
|
.map(tag -> {
|
||||||
|
if (tag.getId() != null) {
|
||||||
|
return getExistById(tag);
|
||||||
|
} else {
|
||||||
|
Tag existTag = isExistByName(tag.getTagName());
|
||||||
|
return existTag != null ? existTag : create(tag);
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Tag getExistById(Tag tag) {
|
||||||
|
return tagRepository.getOne(tag.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Tag isExistByName(String tagName) {
|
||||||
|
return tagRepository.findByName(tagName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Tag create(Tag tag) {
|
||||||
|
Tag newTag = new Tag();
|
||||||
|
newTag.setTagName(tag.getTagName());
|
||||||
|
newTag = tagRepository.save(newTag);
|
||||||
|
return newTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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="masha" id="20190323_000000-1">
|
||||||
|
<addColumn tableName="paper">
|
||||||
|
<column name="latex_text" type="varchar"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="file">
|
||||||
|
<column name="is_latex_attach" type="boolean"/>
|
||||||
|
</addColumn>
|
||||||
|
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,26 @@
|
|||||||
|
<?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="20190402_000000-1">
|
||||||
|
<addColumn tableName="grants">
|
||||||
|
<column name="leader_id" type="integer"></column>
|
||||||
|
</addColumn>
|
||||||
|
<addForeignKeyConstraint baseTableName="grants" baseColumnNames="leader_id"
|
||||||
|
constraintName="fk_grants_leader_id" referencedTableName="users"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet author="tanya" id="20190402_000000-2">
|
||||||
|
<createTable tableName="grants_authors">
|
||||||
|
<column name="grant_id" type="integer"/>
|
||||||
|
<column name="authors_id" type="integer"/>
|
||||||
|
</createTable>
|
||||||
|
<addForeignKeyConstraint baseTableName="grants_authors" baseColumnNames="grant_id"
|
||||||
|
constraintName="fk_grants_grants_authors" referencedTableName="grants"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="grants_authors" baseColumnNames="authors_id"
|
||||||
|
constraintName="fk_user_grants_authors" referencedTableName="users"
|
||||||
|
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="tanya" id="20190404_000000-1">
|
||||||
|
<addColumn tableName="users">
|
||||||
|
<column name="birth_date" type="timestamp"></column>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="users">
|
||||||
|
<column name="degree" type="varchar(255)"></column>
|
||||||
|
</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="nastya" id="20190410_000000-1">
|
||||||
|
<addColumn tableName="tag">
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<renameColumn tableName="tag" oldColumnName="tagname" newColumnName="tag_name"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet author="nastya" id="20190410_000000-2">
|
||||||
|
<addColumn tableName="task">
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
</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="vova" id="20190417_000000-1">
|
||||||
|
<addColumn tableName="users_conference">
|
||||||
|
<column name="id" type="integer"></column>
|
||||||
|
<column name="version" type="integer"></column>
|
||||||
|
</addColumn>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_users_conference" tableName="users_conference"/>
|
||||||
|
<modifyDataType tableName="users_conference" columnName="participation" newDataType="varchar(255)"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,22 @@
|
|||||||
|
<?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="20190418_000000-1">
|
||||||
|
<addColumn tableName="project">
|
||||||
|
<column name="status" type="varchar(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="project">
|
||||||
|
<column name="description" type="varchar(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="project">
|
||||||
|
<column name="grant_id" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addForeignKeyConstraint baseTableName="project" baseColumnNames="grant_id"
|
||||||
|
constraintName="fk_project_grant_id" referencedTableName="grants"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
<addColumn tableName="project">
|
||||||
|
<column name="repository" type="varchar(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,15 @@
|
|||||||
|
<?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="20190421_000000-1">
|
||||||
|
<addColumn tableName="paper">
|
||||||
|
<column name="type" type="varchar(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="masha" id="20190421_000000-2">
|
||||||
|
<update tableName="paper">
|
||||||
|
<column name="type" value="OTHER"/>
|
||||||
|
</update>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,10 @@
|
|||||||
|
<?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="orion" id="20190423_100000-1">
|
||||||
|
<addColumn tableName="hibernate_sequences">
|
||||||
|
<column name="next_val" type="bigint"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,12 @@
|
|||||||
|
.div-deadline-date {
|
||||||
|
padding-right: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-deadline-date {
|
||||||
|
padding-right: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.div-deadline-description {
|
||||||
|
padding-left: 5px;
|
||||||
|
padding-right: 5px;
|
||||||
|
}
|
@ -1,5 +1,9 @@
|
|||||||
#files-list .row > div:nth-child(6) {
|
#files-list .row > div:nth-child(7) {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nav-tabs {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
@ -1,24 +1,65 @@
|
|||||||
.bootstrap-tagsinput{
|
.tags-container {
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: .375rem .75rem;
|
padding: .375rem .75rem;
|
||||||
|
background-color: #fff;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||||
|
display: inline-block;
|
||||||
|
color: #555;
|
||||||
|
vertical-align: middle;
|
||||||
|
border-radius: 4px;
|
||||||
|
max-width: 100%;
|
||||||
|
line-height: 22px;
|
||||||
|
cursor: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-tag-name {
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
outline: none;
|
||||||
|
background-color: transparent;
|
||||||
|
padding: 0 6px;
|
||||||
|
margin: 0;
|
||||||
|
width: auto;
|
||||||
|
max-width: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bootstrap-tagsinput .label{
|
.tag {
|
||||||
|
display: inline-block;
|
||||||
|
padding: .2em .6em .3em;
|
||||||
|
background-color: orange;
|
||||||
|
border-radius: .25em;
|
||||||
|
margin-right: 4px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
|
||||||
|
font-size: 75%;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-name span[data-role="remove"] {
|
||||||
|
margin-left: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
display: inline;
|
.tag-name span[data-role="remove"]:after {
|
||||||
padding: .2em .6em .3em;
|
content: "x";
|
||||||
font-size: 75%;
|
padding: 0px 2px;
|
||||||
font-weight: 700;
|
|
||||||
line-height: 2.5;
|
|
||||||
color: #fff;
|
|
||||||
text-align: center;
|
|
||||||
white-space: nowrap;
|
|
||||||
vertical-align: baseline;
|
|
||||||
border-radius: .25em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bootstrap-tagsinput .label-info{
|
.tag-name input[type="text"] {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
display: inline-flex;
|
||||||
|
font-size: 100%;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
vertical-align: baseline;
|
||||||
|
outline: none;
|
||||||
|
cursor: default;
|
||||||
|
|
||||||
background-color: orange;
|
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,29 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
$('.data-href-js').click( function() {
|
$('a[data-confirm]').click(function (ev) {
|
||||||
window.location = $(this).attr('data-href');
|
var href = $(this).attr('href');
|
||||||
});
|
if (!$('#dataConfirmModal').length) {
|
||||||
|
$('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' +
|
||||||
$('.circle').parent().click( function() {
|
' >\n' +
|
||||||
$(this).children('.circle').toggleClass('circle-active');
|
' <div class="modal-dialog modal-sm">\n' +
|
||||||
});
|
' <div class="modal-content">\n' +
|
||||||
|
' <div class="modal-header">\n' +
|
||||||
$('.checkbox-js').parent().click( function() {
|
' <h8 class="modal-title" id="myModalLabel">Удалить конференцию?</h8>\n' +
|
||||||
$(this).children('.checkbox').toggleClass('selected');
|
' <button type="button" class="close" data-dismiss="modal" aria-label="Закрыть"><span\n' +
|
||||||
});
|
' aria-hidden="true">×</span></button>\n' +
|
||||||
|
' </div>\n' +
|
||||||
$('#select-all-js').click( function() {
|
|
||||||
$(this).toggleClass('selected');
|
|
||||||
|
|
||||||
var childNodes = $('.conference-item .form-check .checkbox')
|
' <div class="modal-footer">\n' +
|
||||||
.each(function(i, elem) {
|
' <a class="btn btn-primary" id="dataConfirmOK">Да</a>' +
|
||||||
if ($(this).hasClass('selected') && !$('#select-all-js').hasClass('selected')) {
|
' <button class="btn primary" data-dismiss="modal" aria-hidden="true">Нет</button>' +
|
||||||
$(this).toggleClass('selected');
|
' </div>\n' +
|
||||||
} else if (!$(this).hasClass('selected') && $('#select-all-js').hasClass('selected')){
|
' </div>\n' +
|
||||||
$(this).toggleClass('selected');
|
' </div>\n' +
|
||||||
}
|
' </div>');
|
||||||
});
|
}
|
||||||
|
$('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm'));
|
||||||
|
$('#dataConfirmOK').attr('href', href);
|
||||||
|
$('#dataConfirmModal').modal({show: true});
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<body>
|
||||||
|
<div th:fragment="filesList (isLatexAttach)" th:remove="tag">
|
||||||
|
<th:block th:each="file, rowStat : *{files}">
|
||||||
|
|
||||||
|
<span th:if="${(!isLatexAttach and file.isLatexAttach == null) or file.isLatexAttach == isLatexAttach}"
|
||||||
|
th:remove="tag">
|
||||||
|
|
||||||
|
<div class="row" th:id="|files${rowStat.index}|"
|
||||||
|
th:style="${file.deleted} ? 'display: none;' :''">
|
||||||
|
<input type="hidden" th:field="*{files[__${rowStat.index}__].id}"/>
|
||||||
|
<input type="hidden"
|
||||||
|
th:field="*{files[__${rowStat.index}__].deleted}"/>
|
||||||
|
<input type="hidden"
|
||||||
|
th:field="*{files[__${rowStat.index}__].name}"/>
|
||||||
|
<input type="hidden"
|
||||||
|
th:field="*{files[__${rowStat.index}__].tmpFileName}"/>
|
||||||
|
<input type="hidden"
|
||||||
|
th:field="*{files[__${rowStat.index}__].isLatexAttach}"/>
|
||||||
|
<div class="col-2">
|
||||||
|
<a class="btn btn-danger float-right"
|
||||||
|
th:onclick="|$('#files${rowStat.index}\\.deleted').val('true'); $('#files${rowStat.index}').hide(); |">
|
||||||
|
<span aria-hidden="true"><i class="fa fa-times"/></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-10">
|
||||||
|
<a th:onclick="${file.id==null} ? 'downloadFile('+${file.tmpFileName}+',null,\''+${file.name}+'\')':
|
||||||
|
'downloadFile(null,'+${file.id}+',\''+${file.name}+'\')' "
|
||||||
|
href="javascript:void(0)"
|
||||||
|
th:text="*{files[__${rowStat.index}__].name}">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</th:block>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container" layout:fragment="content">
|
||||||
|
<section id="services">
|
||||||
|
<div class="container">
|
||||||
|
<div class="col-lg-12 text-center">
|
||||||
|
<h2 class="section-heading text-uppercase">Проекты</h2>
|
||||||
|
<div th:replace="projects/fragments/projectNavigationFragment"/>
|
||||||
|
</div>
|
||||||
|
<div class="row justify-content-center" id="dashboard">
|
||||||
|
<th:block>
|
||||||
|
<div/>
|
||||||
|
</th:block>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head th:fragment="headerfiles">
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:fragment="projectLine (project)" class="row text-left project-row" style="background-color: white;">
|
||||||
|
<div class="col">
|
||||||
|
<span th:replace="projects/fragments/projectStatusFragment :: projectStatus(projectStatus=${project.status})"/>
|
||||||
|
<a th:href="@{'project?id='+${project.id}}">
|
||||||
|
<span class="h6" th:text="${project.title}"/>
|
||||||
|
<span class="text-muted" th:text="${project.description}"/>
|
||||||
|
</a>
|
||||||
|
<input class="id-class" type="hidden" th:value="${project.id}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,26 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head th:fragment="headerfiles">
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||||
|
<a href="./projects" class="btn btn-light toolbar-button"><i class="fa fa-list-alt"></i>
|
||||||
|
Список</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||||
|
<a href="./dashboard" class="btn btn-light toolbar-button"><i class="fa fa-newspaper-o"
|
||||||
|
aria-hidden="true"></i> Панель
|
||||||
|
управления</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||||
|
<a href="./project?id=0" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle"
|
||||||
|
aria-hidden="true"></i>
|
||||||
|
Добавить проект</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head th:fragment="headerfiles">
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span th:fragment="paperStatus (paperStatus)" class="fa-stack fa-1x">
|
||||||
|
<th:block th:switch="${projectStatus.name()}">
|
||||||
|
<div th:case="'APPLICATION'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-draft"></i>
|
||||||
|
</div>
|
||||||
|
<div th:case="'ON_COMPETITION'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-review"></i>
|
||||||
|
</div>
|
||||||
|
<div th:case="'SUCCESSFUL_PASSAGE'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-accepted"></i>
|
||||||
|
</div>
|
||||||
|
<div th:case="'IN_WORK'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-primary"></i>
|
||||||
|
</div>
|
||||||
|
<div th:case="'COMPLETED'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-success"></i>
|
||||||
|
</div>
|
||||||
|
<div th:case="'FAILED'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-failed"></i>
|
||||||
|
</div>
|
||||||
|
</th:block>
|
||||||
|
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
|
||||||
|
</span>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,146 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container" layout:fragment="content">
|
||||||
|
|
||||||
|
<section id="paper">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 text-center">
|
||||||
|
<h2 class="section-heading text-uppercase">Редактирование проекта</h2>
|
||||||
|
<div th:replace="projects/fragments/projectNavigationFragment"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<form id="project-form" method="post"
|
||||||
|
th:action="@{'/projects/project?id='+ *{id == null ? '' : id} + ''}"
|
||||||
|
th:object="${projectDto}">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 col-sm-12">
|
||||||
|
<input type="hidden" name="id" th:field="*{id}"/>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="title">Название:</label>
|
||||||
|
<input class="form-control" id="title" type="text"
|
||||||
|
placeholder="Название проекта"
|
||||||
|
th:field="*{title}"/>
|
||||||
|
<p th:if="${#fields.hasErrors('title')}" th:errors="*{title}"
|
||||||
|
class="alert alert-danger">Incorrect title</p>
|
||||||
|
<p class="help-block text-danger"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="status">Статус:</label>
|
||||||
|
<select class="form-control" th:field="*{status}" id="status">
|
||||||
|
<option th:each="status : ${allStatuses}" th:value="${status}"
|
||||||
|
th:text="${status.statusName}">Status
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="description">Описание:</label>
|
||||||
|
<textarea class="form-control" rows="3" id="description"
|
||||||
|
th:field="*{description}"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="createGrant">Добавить грант:</label>
|
||||||
|
<div th:if="*{grant} == null">
|
||||||
|
<input type="submit" id="createGrant" name="createGrant" class="btn btn-primary"
|
||||||
|
value="Добавить грант"/>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" th:field="*{grant.id}"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="repository">Ссылка на репозиторий:</label>
|
||||||
|
<input class="form-control" id="repository" type="text"
|
||||||
|
placeholder="http://"
|
||||||
|
th:field="*{repository}"/>
|
||||||
|
<p th:if="${#fields.hasErrors('repository')}" th:errors="*{repository}"
|
||||||
|
class="alert alert-danger">Incorrect repository link</p>
|
||||||
|
<p class="help-block text-danger"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Дедлайны показателей:</label>
|
||||||
|
<div class="row">
|
||||||
|
<input type="hidden"/>
|
||||||
|
<div class="col-6">
|
||||||
|
<input type="date" class="form-control" name="deadline"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input class="form-control" type="text" placeholder="Описание"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-2">
|
||||||
|
<a class="btn btn-danger float-right"><span
|
||||||
|
aria-hidden="true"><i class="fa fa-times"/></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p th:if="${#fields.hasErrors('deadlines')}" th:errors="*{deadlines}"
|
||||||
|
class="alert alert-danger">Incorrect title</p>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="submit" id="addDeadline" name="addDeadline" class="btn btn-primary"
|
||||||
|
value="Добавить
|
||||||
|
дедлайн"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="loader">Загрузить файл:</label>
|
||||||
|
<div id="loader">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<button id="sendMessageButton" name="save" class="btn btn-success text-uppercase"
|
||||||
|
type="submit">
|
||||||
|
Сохранить
|
||||||
|
</button>
|
||||||
|
<button id="cancelButton" class="btn btn-default text-uppercase"
|
||||||
|
href="/projects/projects">
|
||||||
|
Отмена
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<script type="text/javascript" src="/js/file-loader.js"></script>
|
||||||
|
<script>
|
||||||
|
/*<![CDATA[*/
|
||||||
|
$(document).ready(function () {
|
||||||
|
new FileLoader({
|
||||||
|
div: "loader",
|
||||||
|
url: urlFileUpload,
|
||||||
|
maxSize: 2,
|
||||||
|
extensions: ["doc", "docx", "xls", "jpg", "png", "pdf", "txt"],
|
||||||
|
callback: function (response) {
|
||||||
|
showFeedbackMessage("Файл успешно загружен");
|
||||||
|
console.debug(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.selectpicker').selectpicker();
|
||||||
|
});
|
||||||
|
/*]]>*/
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,33 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorator="default" xmlns:th="">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container" layout:fragment="content">
|
||||||
|
<form id="projects-form" method="post" th:action="@{'/projects/projects'}">
|
||||||
|
<input th:type="hidden" name="projectDeleteId" id="projectDeleteId"/>
|
||||||
|
<section id="projects">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row" id="project-list">
|
||||||
|
<div class="col-lg-12 text-center">
|
||||||
|
<h2 class="section-heading text-uppercase">Проекты</h2>
|
||||||
|
<div th:replace="projects/fragments/projectNavigationFragment"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-9 col-sm-12">
|
||||||
|
<th:block th:each="project : ${projects}">
|
||||||
|
<div th:replace="projects/fragments/projectLineFragment :: projectLine(project=${project})"/>
|
||||||
|
</th:block>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 col-sm-12">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue