Merge remote-tracking branch 'origin/move-to-jdk11' into gl_87
commit
a53a12fa55
@ -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`
|
||||||
|
* Сценарий просмотра проверяется при ручном внечении записей в БД
|
@ -0,0 +1,156 @@
|
|||||||
|
package ru.ulstu.conference.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import ru.ulstu.conference.model.ConferenceDto;
|
||||||
|
import ru.ulstu.conference.model.ConferenceFilterDto;
|
||||||
|
import ru.ulstu.conference.model.ConferenceUser;
|
||||||
|
import ru.ulstu.conference.service.ConferenceService;
|
||||||
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.springframework.util.StringUtils.isEmpty;
|
||||||
|
import static ru.ulstu.core.controller.Navigation.CONFERENCES_PAGE;
|
||||||
|
import static ru.ulstu.core.controller.Navigation.CONFERENCE_PAGE;
|
||||||
|
import static ru.ulstu.core.controller.Navigation.REDIRECT_TO;
|
||||||
|
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
@RequestMapping(value = "/conferences")
|
||||||
|
@ApiIgnore
|
||||||
|
public class ConferenceController {
|
||||||
|
|
||||||
|
private final ConferenceService conferenceService;
|
||||||
|
|
||||||
|
public ConferenceController(ConferenceService conferenceService) {
|
||||||
|
this.conferenceService = conferenceService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/conferences")
|
||||||
|
public void getConferences(ModelMap modelMap) {
|
||||||
|
modelMap.put("filteredConferences", new ConferenceFilterDto(conferenceService.findAllDto()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/conferences")
|
||||||
|
public void filterConferences(@Valid ConferenceFilterDto conferenceFilterDto, ModelMap modelMap) {
|
||||||
|
modelMap.put("filteredConferences", new ConferenceFilterDto(conferenceService.filter(conferenceFilterDto),
|
||||||
|
conferenceFilterDto.getFilterUserId(),
|
||||||
|
conferenceFilterDto.getYear()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/dashboard")
|
||||||
|
public void getDashboard(ModelMap modelMap) {
|
||||||
|
modelMap.put("conferences", conferenceService.findAllActiveDto());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/conference")
|
||||||
|
public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
|
||||||
|
if (id != null && id > 0) {
|
||||||
|
modelMap.put("conferenceDto", conferenceService.getExistConferenceById(id));
|
||||||
|
} else {
|
||||||
|
modelMap.put("conferenceDto", conferenceService.getNewConference());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/conference", params = "save")
|
||||||
|
public String save(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException {
|
||||||
|
filterEmptyDeadlines(conferenceDto);
|
||||||
|
if (errors.hasErrors()) {
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
conferenceService.save(conferenceDto);
|
||||||
|
return String.format(REDIRECT_TO, CONFERENCES_PAGE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/delete/{conference-id}")
|
||||||
|
public String delete(@PathVariable("conference-id") Integer conferenceId) throws IOException {
|
||||||
|
conferenceService.delete(conferenceId);
|
||||||
|
return String.format(REDIRECT_TO, CONFERENCES_PAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/conference", params = "addDeadline")
|
||||||
|
public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) {
|
||||||
|
filterEmptyDeadlines(conferenceDto);
|
||||||
|
if (errors.hasErrors()) {
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
conferenceDto.getDeadlines().add(new Deadline());
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/conference", params = "removeDeadline")
|
||||||
|
public String removeDeadline(@Valid ConferenceDto conferenceDto, Errors errors,
|
||||||
|
@RequestParam(value = "removeDeadline") Integer deadlineIndex) throws IOException {
|
||||||
|
if (errors.hasErrors()) {
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
conferenceService.removeDeadline(conferenceDto, deadlineIndex);
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/conference", params = "removePaper")
|
||||||
|
public String removePaper(@Valid ConferenceDto conferenceDto, Errors errors,
|
||||||
|
@RequestParam(value = "removePaper") Integer paperIndex) throws IOException {
|
||||||
|
if (errors.hasErrors()) {
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
conferenceService.removePaper(conferenceDto, paperIndex);
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/conference", params = "takePart")
|
||||||
|
public String takePart(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException {
|
||||||
|
if (errors.hasErrors()) {
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
conferenceService.takePart(conferenceDto);
|
||||||
|
return CONFERENCE_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("allParticipation")
|
||||||
|
public List<ConferenceUser.Participation> getAllParticipation() {
|
||||||
|
return conferenceService.getAllParticipations();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("allDeposit")
|
||||||
|
public List<ConferenceUser.Deposit> getAllDeposit() {
|
||||||
|
return conferenceService.getAllDeposit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("allUsers")
|
||||||
|
public List<User> getAllUsers() {
|
||||||
|
return conferenceService.getAllUsers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("allYears")
|
||||||
|
public List<Integer> getAllYears() {
|
||||||
|
List<Integer> years = new ArrayList<>();
|
||||||
|
for (int i = Calendar.getInstance().get(Calendar.YEAR); i > 2010; i--) {
|
||||||
|
years.add(i);
|
||||||
|
}
|
||||||
|
return years;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void filterEmptyDeadlines(ConferenceDto conferenceDto) {
|
||||||
|
conferenceDto.setDeadlines(conferenceDto.getDeadlines().stream()
|
||||||
|
.filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription()))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,138 @@
|
|||||||
|
package ru.ulstu.conference.model;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Fetch;
|
||||||
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
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.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.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "conference")
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,222 @@
|
|||||||
|
package ru.ulstu.conference.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.paper.model.Paper;
|
||||||
|
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
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 {
|
||||||
|
|
||||||
|
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(), BaseEntity::getId);
|
||||||
|
this.paperIds = convert(conference.getPapers(), BaseEntity::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];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package ru.ulstu.conference.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package ru.ulstu.conference.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.conference.model.Conference;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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> {
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.conference.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ConferenceNotificationService {
|
||||||
|
}
|
@ -0,0 +1,176 @@
|
|||||||
|
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.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.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
|
||||||
|
public class ConferenceService {
|
||||||
|
private final static int MAX_DISPLAY_SIZE = 40;
|
||||||
|
|
||||||
|
private final ConferenceRepository conferenceRepository;
|
||||||
|
private final ConferenceUserService conferenceUserService;
|
||||||
|
private final DeadlineService deadlineService;
|
||||||
|
private final PaperService paperService;
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
public ConferenceService(ConferenceRepository conferenceRepository,
|
||||||
|
ConferenceUserService conferenceUserService,
|
||||||
|
DeadlineService deadlineService,
|
||||||
|
PaperService paperService,
|
||||||
|
UserService userService) {
|
||||||
|
this.conferenceRepository = conferenceRepository;
|
||||||
|
this.conferenceUserService = conferenceUserService;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package ru.ulstu.core.controller;
|
||||||
|
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
|
||||||
|
public class Navigation {
|
||||||
|
public static final String REDIRECT_TO = "redirect:%s";
|
||||||
|
public static final String GRANTS_PAGE = "/grants/grants";
|
||||||
|
public static final String GRANT_PAGE = "/grants/grant";
|
||||||
|
|
||||||
|
public static final String CONFERENCES_PAGE = "/conferences/conferences";
|
||||||
|
public static final String CONFERENCE_PAGE = "/conferences/conference";
|
||||||
|
|
||||||
|
public static String hasErrors(Errors errors, String page) {
|
||||||
|
if (errors.hasErrors()) {
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -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,207 +0,0 @@
|
|||||||
package ru.ulstu.core.service;
|
|
||||||
|
|
||||||
import org.apache.poi.POIXMLDocument;
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
||||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
|
||||||
import org.apache.poi.ss.usermodel.*;
|
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
|
||||||
import org.apache.poi.ss.util.RegionUtil;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
||||||
import ru.ulstu.core.error.XlsParseException;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
public class XlsDocumentBuilder {
|
|
||||||
private static final int DEFAULT_SHEET_NUM = 0;
|
|
||||||
private File documentFile;
|
|
||||||
private Workbook workBook;
|
|
||||||
private Sheet currentSheet;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for reading and writing data from/to *.[xls|xlsx] document
|
|
||||||
*
|
|
||||||
* @param file contains existing document for reading or new document to save
|
|
||||||
*/
|
|
||||||
public XlsDocumentBuilder(File file) throws IOException, XlsParseException {
|
|
||||||
this.documentFile = file;
|
|
||||||
if (file.exists()) {
|
|
||||||
workBook = getWorkBook(file);
|
|
||||||
currentSheet = workBook.getSheetAt(DEFAULT_SHEET_NUM);
|
|
||||||
} else {
|
|
||||||
workBook = new XSSFWorkbook();
|
|
||||||
currentSheet = workBook.createSheet();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Workbook getWorkBook(File file) throws XlsParseException, IOException {
|
|
||||||
InputStream inputStream = new PushbackInputStream(new FileInputStream(file), 4096);
|
|
||||||
if (isXlsx(inputStream)) {
|
|
||||||
return new XSSFWorkbook(inputStream);
|
|
||||||
} else if (isExcel(inputStream)) {
|
|
||||||
return new HSSFWorkbook(inputStream);
|
|
||||||
}
|
|
||||||
throw new XlsParseException("Wrong document format");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change active sheet to write or read data
|
|
||||||
*
|
|
||||||
* @param index index of sheet to activate
|
|
||||||
*/
|
|
||||||
public XlsDocumentBuilder setActiveSheet(int index) {
|
|
||||||
workBook.setActiveSheet(index);
|
|
||||||
currentSheet = workBook.getSheetAt(index);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new sheet in document and set it active
|
|
||||||
*
|
|
||||||
* @param sheetName
|
|
||||||
*/
|
|
||||||
public XlsDocumentBuilder insertNewSheet(String sheetName) {
|
|
||||||
currentSheet = workBook.createSheet(sheetName);
|
|
||||||
workBook.setActiveSheet(getSheetCount() - 1);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public XlsDocumentBuilder insertNewSheet(String sheetName, int order) {
|
|
||||||
insertNewSheet(sheetName);
|
|
||||||
workBook.setSheetOrder(sheetName, order);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns number of sheet in document
|
|
||||||
*
|
|
||||||
* @return sheets count
|
|
||||||
*/
|
|
||||||
public int getSheetCount() {
|
|
||||||
return workBook.getNumberOfSheets();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns number of rows in sheet
|
|
||||||
*
|
|
||||||
* @return rows count
|
|
||||||
*/
|
|
||||||
public int getRowCount() {
|
|
||||||
return currentSheet.getLastRowNum();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns number of columns in sheet
|
|
||||||
*
|
|
||||||
* @return columns count
|
|
||||||
*/
|
|
||||||
public int getColumnCount() {
|
|
||||||
Row row = currentSheet.getRow(getRowCount());
|
|
||||||
if (row == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return row.getLastCellNum() - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns converted to string representation of cell value
|
|
||||||
*
|
|
||||||
* @param rowIndex row index of current sheet
|
|
||||||
* @param colIndex column index of current sheet
|
|
||||||
* @return string value of cell
|
|
||||||
*/
|
|
||||||
public String getCellAsString(int rowIndex, int colIndex) {
|
|
||||||
Cell cell = currentSheet.getRow(rowIndex).getCell(colIndex);
|
|
||||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
|
||||||
return cell.getStringCellValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets string cell value
|
|
||||||
*
|
|
||||||
* @param rowIndex row index of current sheet
|
|
||||||
* @param colIndex column index of current sheet
|
|
||||||
*/
|
|
||||||
public XlsDocumentBuilder setCellValue(int rowIndex, int colIndex, String value) {
|
|
||||||
if (currentSheet.getRow(rowIndex) == null) {
|
|
||||||
currentSheet.createRow(rowIndex);
|
|
||||||
}
|
|
||||||
if (currentSheet.getRow(rowIndex).getCell(colIndex) == null) {
|
|
||||||
currentSheet.getRow(rowIndex).createCell(colIndex);
|
|
||||||
}
|
|
||||||
Cell cell = currentSheet.getRow(rowIndex).getCell(colIndex);
|
|
||||||
cell.setCellValue(value);
|
|
||||||
setColumnAutosize(colIndex, colIndex);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public XlsDocumentBuilder setCellValue(int rowIndex, int colIndex, int value) {
|
|
||||||
return setCellValue(rowIndex, colIndex, String.valueOf(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public XlsDocumentBuilder setCellValue(int rowIndex, int colIndex, long value) {
|
|
||||||
return setCellValue(rowIndex, colIndex, String.valueOf(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save current file
|
|
||||||
*/
|
|
||||||
public XlsDocumentBuilder save() throws IOException {
|
|
||||||
OutputStream out = new FileOutputStream(documentFile);
|
|
||||||
workBook.write(out);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isExcel(InputStream i) throws IOException {
|
|
||||||
return (POIFSFileSystem.hasPOIFSHeader(i) || POIXMLDocument.hasOOXMLHeader(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isXlsx(InputStream i) throws IOException {
|
|
||||||
return POIXMLDocument.hasOOXMLHeader(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getActiveSheetIndex() {
|
|
||||||
return workBook.getActiveSheetIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
public XlsDocumentBuilder mergeCells(int rowFrom, int rowTo, int colFrom, int colTo) {
|
|
||||||
currentSheet.addMergedRegion(new CellRangeAddress(rowFrom, rowTo, colFrom, colTo));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRegionBorderWithMedium(int rowFrom, int rowTo, int colFrom, int colTo) {
|
|
||||||
for (int row = rowFrom; row < rowTo; row++) {
|
|
||||||
for (int col = colFrom; col <= colTo; col++) {
|
|
||||||
CellRangeAddress cellRangeAddress = new CellRangeAddress(row, row, col, col);
|
|
||||||
RegionUtil.setBorderBottom(CellStyle.BORDER_THIN, cellRangeAddress, currentSheet, workBook);
|
|
||||||
RegionUtil.setBorderLeft(CellStyle.BORDER_THIN, cellRangeAddress, currentSheet, workBook);
|
|
||||||
RegionUtil.setBorderRight(CellStyle.BORDER_THIN, cellRangeAddress, currentSheet, workBook);
|
|
||||||
RegionUtil.setBorderTop(CellStyle.BORDER_THIN, cellRangeAddress, currentSheet, workBook);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public XlsDocumentBuilder setColumnAutosize(int from, int to) {
|
|
||||||
for (int col = from; col <= to; col++) {
|
|
||||||
currentSheet.autoSizeColumn(col, true);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public XlsDocumentBuilder setRowAutosize(int from, int to) {
|
|
||||||
CellStyle style = workBook.createCellStyle();
|
|
||||||
style.setWrapText(true);
|
|
||||||
for (int row = from; row <= to; row++) {
|
|
||||||
for (int col = 0; col <= currentSheet.getRow(row).getLastCellNum(); col++) {
|
|
||||||
if (currentSheet.getRow(row).getCell(col) != null) {
|
|
||||||
currentSheet.getRow(row).getCell(col).setCellStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public XlsDocumentBuilder deleteSheet(int index) {
|
|
||||||
workBook.removeSheetAt(index);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
package ru.ulstu.deadline.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class DeadlineDto {
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
|
||||||
private Date date;
|
|
||||||
|
|
||||||
public DeadlineDto() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonCreator
|
|
||||||
public DeadlineDto(@JsonProperty("id") Integer id,
|
|
||||||
@JsonProperty("description") String description,
|
|
||||||
@JsonProperty("date") Date date) {
|
|
||||||
this.id = id;
|
|
||||||
this.description = description;
|
|
||||||
this.date = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeadlineDto(Deadline deadline) {
|
|
||||||
this.id = deadline.getId();
|
|
||||||
this.description = deadline.getDescription();
|
|
||||||
this.date = deadline.getDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDate(Date date) {
|
|
||||||
this.date = date;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,95 @@
|
|||||||
|
package ru.ulstu.file.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
public class FileDataDto {
|
||||||
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
private String fileName;
|
||||||
|
private String tmpFileName;
|
||||||
|
private boolean deleted;
|
||||||
|
private Boolean isLatexAttach;
|
||||||
|
|
||||||
|
public FileDataDto() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public FileDataDto(@JsonProperty("id") Integer id,
|
||||||
|
@JsonProperty("name") String name,
|
||||||
|
@JsonProperty("isLatexAttach") Boolean isLatexAttach,
|
||||||
|
@JsonProperty("fileName") String fileName,
|
||||||
|
@JsonProperty("tmpFileName") String tmpFileName) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.tmpFileName = tmpFileName;
|
||||||
|
this.isLatexAttach = isLatexAttach;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileDataDto(FileData fileData) {
|
||||||
|
this.id = fileData.getId();
|
||||||
|
this.name = fileData.getName();
|
||||||
|
this.isLatexAttach = fileData.isLatexAttach();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileDataDto(String fileName, String tmpFileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.tmpFileName = tmpFileName;
|
||||||
|
}
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileName(String fileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTmpFileName() {
|
||||||
|
return tmpFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTmpFileName(String tmpFileName) {
|
||||||
|
this.tmpFileName = tmpFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDeleted() {
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeleted(boolean deleted) {
|
||||||
|
this.deleted = deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean isLatexAttach() {
|
||||||
|
return isLatexAttach;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIsLatexAttach() {
|
||||||
|
return isLatexAttach;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatexAttach(Boolean latexAttach) {
|
||||||
|
isLatexAttach = latexAttach;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsLatexAttach(Boolean latexAttach) {
|
||||||
|
isLatexAttach = latexAttach;
|
||||||
|
}
|
||||||
|
}
|
@ -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,23 @@
|
|||||||
|
package ru.ulstu.index.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import ru.ulstu.core.controller.AdviceController;
|
||||||
|
import ru.ulstu.user.service.UserService;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
@RequestMapping(value = "/index")
|
||||||
|
@ApiIgnore
|
||||||
|
public class IndexController extends AdviceController {
|
||||||
|
public IndexController(UserService userService) {
|
||||||
|
super(userService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public void currentUser(ModelMap modelMap) {
|
||||||
|
//нужен здесь для добавления параметров на стартовой странице
|
||||||
|
}
|
||||||
|
}
|
@ -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,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 ru.ulstu.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.tags.model.Tag;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
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 ru.ulstu.core.model.BaseEntity;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
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,12 @@
|
|||||||
|
<?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="20190318_000000-1">
|
||||||
|
<dropColumn columnName="file_id" tableName="paper"/>
|
||||||
|
<addColumn tableName="file">
|
||||||
|
<column name="paper_id" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
|
||||||
|
</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="masha" id="20190319_000001-1">
|
||||||
|
<addColumn tableName="paper">
|
||||||
|
<column name="url" type="varchar(255)"></column>
|
||||||
|
</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="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,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="masha" id="20190327_000000-1">
|
||||||
|
<addColumn tableName="event">
|
||||||
|
<column name="paper_id" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addForeignKeyConstraint baseTableName="event" baseColumnNames="paper_id"
|
||||||
|
constraintName="fk_event_paper_id" referencedTableName="paper"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,55 @@
|
|||||||
|
<?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="20190331_000000-1">
|
||||||
|
<createTable tableName="tag">
|
||||||
|
<column name="id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="tagname" type="varchar(255)"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_tag" tableName="tag"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet author="nastya" id="20190331_000000-2">
|
||||||
|
<createTable tableName="task">
|
||||||
|
<column name="id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="user_id" type="integer"/>
|
||||||
|
<column name="title" type="varchar(255)"/>
|
||||||
|
<column name="description" type="varchar(255)"/>
|
||||||
|
<column name="status" type="varchar(255)"/>
|
||||||
|
<column name="deadline_date" type="timestamp"/>
|
||||||
|
<column name="create_date" type="timestamp"/>
|
||||||
|
<column name="update_date" type="timestamp"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_task" tableName="task"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="task" baseColumnNames="user_id"
|
||||||
|
constraintName="fk_user_task_id" referencedTableName="users"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet author="nastya" id="20190331_000000-3">
|
||||||
|
<createTable tableName="task_tags">
|
||||||
|
<column name="task_id" type="integer"/>
|
||||||
|
<column name="tag_id" type="integer"/>
|
||||||
|
</createTable>
|
||||||
|
<addForeignKeyConstraint baseTableName="task_tags" baseColumnNames="task_id"
|
||||||
|
constraintName="fk_task_id" referencedTableName="task"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="task_tags" baseColumnNames="tag_id"
|
||||||
|
constraintName="fk_tag_id" referencedTableName="tag"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet author="nastya" id="20190331_000000-4">
|
||||||
|
<addColumn tableName="deadline">
|
||||||
|
<column name="task_id" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addForeignKeyConstraint baseTableName="deadline" baseColumnNames="task_id"
|
||||||
|
constraintName="fk_deadlines_task" referencedTableName="task"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,63 @@
|
|||||||
|
<?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="20190331_000010-1">
|
||||||
|
<createTable tableName="conference">
|
||||||
|
<column name="id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="title" type="varchar(300)"/>
|
||||||
|
<column name="description" type="varchar(500)"/>
|
||||||
|
<column name="url" type="varchar(255)"/>
|
||||||
|
<column name="ping" type="integer"/>
|
||||||
|
<column name="begin_date" type="timestamp"/>
|
||||||
|
<column name="end_date" type="timestamp"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_conference" tableName="conference"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
|
||||||
|
<changeSet author="vova" id="20190331_000010-2">
|
||||||
|
<createTable tableName="paper_conference">
|
||||||
|
<column name="conference_id" type="integer"/>
|
||||||
|
<column name="paper_id" type="integer"/>
|
||||||
|
</createTable>
|
||||||
|
<addForeignKeyConstraint baseTableName="paper_conference" baseColumnNames="conference_id"
|
||||||
|
constraintName=" fk_paper_conference_conference" referencedTableName="conference"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="paper_conference" baseColumnNames="paper_id"
|
||||||
|
constraintName="fk_paper_conference_paper" referencedTableName="paper"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet author="vova" id="20190331_000010-3">
|
||||||
|
<createTable tableName="users_conference">
|
||||||
|
<column name="conference_id" type="integer"/>
|
||||||
|
<column name="users_id" type="integer"/>
|
||||||
|
<column name="participation" type="boolean"/>
|
||||||
|
<column name="deposit" type="varchar(255)"/>
|
||||||
|
</createTable>
|
||||||
|
<addForeignKeyConstraint baseTableName="users_conference" baseColumnNames="conference_id"
|
||||||
|
constraintName=" fk_users_conference_conference" referencedTableName="conference"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="users_conference" baseColumnNames="users_id"
|
||||||
|
constraintName="fk_users_conference_users" referencedTableName="users"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet author="vova" id="20190331_000010-4">
|
||||||
|
<addColumn tableName="deadline">
|
||||||
|
<column name="conference_id" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addForeignKeyConstraint baseTableName="deadline" baseColumnNames="conference_id"
|
||||||
|
constraintName=" fk_deadlines_conference" referencedTableName="conference"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet author="orion" id="20190331_000010-5">
|
||||||
|
<addColumn tableName="conference">
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</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,16 @@
|
|||||||
|
<?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="file_id" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addForeignKeyConstraint baseTableName="project" baseColumnNames="file_id"
|
||||||
|
constraintName="fk_project_file_id" referencedTableName="file"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
<addColumn tableName="project">
|
||||||
|
<column name="applicationFileName" type="varchar(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,16 @@
|
|||||||
|
<?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="20190312_130000-1">
|
||||||
|
<addColumn tableName="users">
|
||||||
|
<column name="patronymic" type="varchar(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="orion" id="20190312_130000-2">
|
||||||
|
<sql>
|
||||||
|
update users
|
||||||
|
set first_name = 'Антон', patronymic = 'Алексеевич', last_name = 'Романов' where id = 1;
|
||||||
|
</sql>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue