From be2dd291f69111144da7a1a32ffcc6f4db1e60ec Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Thu, 4 Apr 2019 12:48:05 +0400 Subject: [PATCH 01/29] #55 added conference model without user's participation and deposit. May be needed new user model. --- .../ru/ulstu/conference/model/Conference.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/main/java/ru/ulstu/conference/model/Conference.java b/src/main/java/ru/ulstu/conference/model/Conference.java index b2851ed..12e1869 100644 --- a/src/main/java/ru/ulstu/conference/model/Conference.java +++ b/src/main/java/ru/ulstu/conference/model/Conference.java @@ -1,11 +1,60 @@ package ru.ulstu.conference.model; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; +import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; +import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.paper.model.Paper; +import ru.ulstu.user.model.User; +import javax.persistence.CascadeType; +import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.JoinColumn; +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 java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; @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) + private Date beginDate = new Date(); + + @Column(name = "end_date") + @Temporal(TemporalType.TIMESTAMP) + private Date endDate = new Date(); + + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) + @JoinColumn(name = "conference_id", unique = true) + @Fetch(FetchMode.SUBSELECT) + @OrderBy("date") + private List deadlines = new ArrayList<>(); + + @ManyToMany(fetch = FetchType.EAGER) + private Set papers = new HashSet<>(); + + @ManyToMany(fetch = FetchType.EAGER) + private Set users = new HashSet<>(); } From dc12a671d247e0a9f820f21f7410624368534eaa Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Thu, 4 Apr 2019 12:50:12 +0400 Subject: [PATCH 02/29] #55 added setters/getters --- .../ru/ulstu/conference/model/Conference.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/main/java/ru/ulstu/conference/model/Conference.java b/src/main/java/ru/ulstu/conference/model/Conference.java index 12e1869..10cc709 100644 --- a/src/main/java/ru/ulstu/conference/model/Conference.java +++ b/src/main/java/ru/ulstu/conference/model/Conference.java @@ -57,4 +57,76 @@ public class Conference extends BaseEntity { @ManyToMany(fetch = FetchType.EAGER) private Set users = new HashSet<>(); + + 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 getDeadlines() { + return deadlines; + } + + public void setDeadlines(List deadlines) { + this.deadlines = deadlines; + } + + public Set getPapers() { + return papers; + } + + public void setPapers(Set papers) { + this.papers = papers; + } + + public Set getUsers() { + return users; + } + + public void setUsers(Set users) { + this.users = users; + } } From e3bbade40bb1552277e19130a526df5c9ad68cdc Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Thu, 4 Apr 2019 17:39:28 +0400 Subject: [PATCH 03/29] #55 added ConferenceDto --- .../ru/ulstu/conference/model/Conference.java | 10 +- .../ulstu/conference/model/ConferenceDto.java | 185 ++++++++++++++++++ 2 files changed, 194 insertions(+), 1 deletion(-) diff --git a/src/main/java/ru/ulstu/conference/model/Conference.java b/src/main/java/ru/ulstu/conference/model/Conference.java index 10cc709..8cb1c64 100644 --- a/src/main/java/ru/ulstu/conference/model/Conference.java +++ b/src/main/java/ru/ulstu/conference/model/Conference.java @@ -13,6 +13,7 @@ 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; @@ -42,7 +43,7 @@ public class Conference extends BaseEntity { @Temporal(TemporalType.TIMESTAMP) private Date beginDate = new Date(); - @Column(name = "end_date") + @Temporal(TemporalType.TIMESTAMP) private Date endDate = new Date(); @@ -52,10 +53,17 @@ public class Conference extends BaseEntity { @OrderBy("date") private List deadlines = new ArrayList<>(); + @ManyToMany(fetch = FetchType.EAGER) + @JoinTable(name = "paper_conference", + joinColumns = {@JoinColumn(name = "conference_id")}, + inverseJoinColumns = {@JoinColumn(name = "paper_id")}) private Set papers = new HashSet<>(); @ManyToMany(fetch = FetchType.EAGER) + @JoinTable(name = "users_conference", + joinColumns = {@JoinColumn(name = "conference_id")}, + inverseJoinColumns = {@JoinColumn(name = "users_id")}) private Set users = new HashSet<>(); public String getTitle() { diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java index e3f757e..d5c586f 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java @@ -1,4 +1,189 @@ package ru.ulstu.conference.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.hibernate.validator.constraints.NotEmpty; +import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.paper.model.PaperDto; +import ru.ulstu.user.model.UserDto; + +import javax.validation.constraints.Size; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import static ru.ulstu.core.util.StreamApiUtils.convert; + public class ConferenceDto { + + 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; + private Date beginDate; + private Date endDate; + @NotEmpty + private List deadlines = new ArrayList<>(); + private Set userIds; + private Set paperIds; + private Set papers; + private Set users; + private Integer filterUserId; + + public ConferenceDto() { + deadlines.add(new Deadline()); + } + + @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 deadlines, + @JsonProperty("userIds") Set userIds, + @JsonProperty("paperIds") Set paperIds, + @JsonProperty("users") Set users, + @JsonProperty("papers") Set papers) { + 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; + } + + 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 = convert(conference.getUsers(), UserDto::new); + this.papers = convert(conference.getPapers(), PaperDto::new); + + } + + 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 getDeadlines() { + return deadlines; + } + + public void setDeadlines(List deadlines) { + this.deadlines = deadlines; + } + + public Set getUserIds() { + return userIds; + } + + public void setUserIds(Set userIds) { + this.userIds = userIds; + } + + public Set getPaperIds() { + return paperIds; + } + + public void setPaperIds(Set paperIds) { + this.paperIds = paperIds; + } + + public Set getPapers() { + return papers; + } + + public void setPapers(Set papers) { + this.papers = papers; + } + + public Set getUsers() { + return users; + } + + public void setUsers(Set users) { + this.users = users; + } + + public Integer getFilterUserId() { + return filterUserId; + } + + public void setFilterUserId(Integer filterUserId) { + this.filterUserId = filterUserId; + } } From d189891e8c01622bae211331918575a92819e799 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Thu, 4 Apr 2019 17:47:18 +0400 Subject: [PATCH 04/29] #55 added ConferenceFilterDto --- .../controller/ConferenceController.java | 5 +++ .../conference/model/ConferenceFilterDto.java | 39 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index aa871ba..3e4c17e 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -16,4 +16,9 @@ public class ConferenceController { public ConferenceController(ConferenceService paperService) { this.conferenceService = paperService; } +// +// @GetMapping("/papers") +// public void getPapers(ModelMap modelMap) { +// modelMap.put("filteredPapers", new PaperFilterDto(paperService.findAllDto(), null, null)); +// } } diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java index 379c8b6..c2447e9 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java @@ -1,4 +1,43 @@ package ru.ulstu.conference.model; +import java.util.List; + public class ConferenceFilterDto { + + private List papers; + private Integer filterAuthorId; + private Integer year; + + public ConferenceFilterDto() { + } + + public ConferenceFilterDto(List conferenceDtos, Integer filterAuthorId, Integer year) { + this.papers = conferenceDtos; + this.filterAuthorId = filterAuthorId; + this.year = year; + } + + public List getPapers() { + return papers; + } + + public void setPapers(List papers) { + this.papers = papers; + } + + public Integer getFilterAuthorId() { + return filterAuthorId; + } + + public void setFilterAuthorId(Integer filterAuthorId) { + this.filterAuthorId = filterAuthorId; + } + + public Integer getYear() { + return year; + } + + public void setYear(Integer year) { + this.year = year; + } } From 2d04b1b43ac89fdd22f41744b78e617c02b8f18f Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Thu, 4 Apr 2019 17:58:22 +0400 Subject: [PATCH 05/29] #55 added findAll method in ConferenceService --- .../controller/ConferenceController.java | 13 +++++--- .../conference/service/ConferenceService.java | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 3e4c17e..167be2a 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -2,7 +2,10 @@ package ru.ulstu.conference.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.conference.model.ConferenceFilterDto; import ru.ulstu.conference.service.ConferenceService; import springfox.documentation.annotations.ApiIgnore; @@ -16,9 +19,9 @@ public class ConferenceController { public ConferenceController(ConferenceService paperService) { this.conferenceService = paperService; } -// -// @GetMapping("/papers") -// public void getPapers(ModelMap modelMap) { -// modelMap.put("filteredPapers", new PaperFilterDto(paperService.findAllDto(), null, null)); -// } + + @GetMapping("/papers") + public void getPapers(ModelMap modelMap) { + modelMap.put("filteredPapers", new ConferenceFilterDto(conferenceService.findAllDto(), null, null)); + } } diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index a8147c9..fd9cc5b 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -1,11 +1,20 @@ package ru.ulstu.conference.service; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import ru.ulstu.conference.model.Conference; +import ru.ulstu.conference.model.ConferenceDto; import ru.ulstu.conference.repository.ConferenceRepository; import ru.ulstu.deadline.service.DeadlineService; +import java.util.List; + +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 DeadlineService deadlineService; @@ -14,4 +23,28 @@ public class ConferenceService { this.conferenceRepository = conferenceRepository; this.deadlineService = deadlineService; } + + public List findAll() { + return conferenceRepository.findAll(); + } + + public List findAllDto() { + List conferences = convert(findAll(), ConferenceDto::new); + conferences.forEach(conferenceDto -> conferenceDto.setTitle(StringUtils.abbreviate(conferenceDto.getTitle(), MAX_DISPLAY_SIZE))); + return conferences; + } + +// private List sortPapers(List conferences) { +// return conferences.stream().sorted((paper1, paper2) -> { +// int statusCompareResult = +// Integer.valueOf(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper1.getStatus())) +// .compareTo(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper2.getStatus())); +// if (statusCompareResult != 0) { +// return statusCompareResult; +// } +// return paper1.getTitle().compareTo(paper2.getTitle()); +// }).collect(toList()); +// } + + } From 9d69f75530618750de2db7a38aa8c91c00e783ec Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Thu, 4 Apr 2019 20:26:38 +0400 Subject: [PATCH 06/29] #55 fixes --- .../conference/controller/ConferenceController.java | 6 +++--- .../ulstu/conference/model/ConferenceFilterDto.java | 12 ++++++------ .../resources/templates/conferences/conferences.html | 6 ++++-- .../conferences/fragments/confLineFragment.html | 5 ++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 167be2a..153bd28 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -20,8 +20,8 @@ public class ConferenceController { this.conferenceService = paperService; } - @GetMapping("/papers") - public void getPapers(ModelMap modelMap) { - modelMap.put("filteredPapers", new ConferenceFilterDto(conferenceService.findAllDto(), null, null)); + @GetMapping("/conferences") + public void getConferences(ModelMap modelMap) { + modelMap.put("filteredConferences", new ConferenceFilterDto(conferenceService.findAllDto(), null, null)); } } diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java index c2447e9..5b85839 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java @@ -4,7 +4,7 @@ import java.util.List; public class ConferenceFilterDto { - private List papers; + private List conferences; private Integer filterAuthorId; private Integer year; @@ -12,17 +12,17 @@ public class ConferenceFilterDto { } public ConferenceFilterDto(List conferenceDtos, Integer filterAuthorId, Integer year) { - this.papers = conferenceDtos; + this.conferences = conferenceDtos; this.filterAuthorId = filterAuthorId; this.year = year; } - public List getPapers() { - return papers; + public List getConferences() { + return conferences; } - public void setPapers(List papers) { - this.papers = papers; + public void setConferences(List conferences) { + this.conferences = conferences; } public Integer getFilterAuthorId() { diff --git a/src/main/resources/templates/conferences/conferences.html b/src/main/resources/templates/conferences/conferences.html index c725f2b..fa88aaf 100644 --- a/src/main/resources/templates/conferences/conferences.html +++ b/src/main/resources/templates/conferences/conferences.html @@ -7,7 +7,7 @@
-
+
@@ -19,7 +19,9 @@
- + +
+
diff --git a/src/main/resources/templates/conferences/fragments/confLineFragment.html b/src/main/resources/templates/conferences/fragments/confLineFragment.html index f54a777..c97dfbd 100644 --- a/src/main/resources/templates/conferences/fragments/confLineFragment.html +++ b/src/main/resources/templates/conferences/fragments/confLineFragment.html @@ -6,9 +6,8 @@
- - - + + Date: Fri, 5 Apr 2019 13:21:15 +0400 Subject: [PATCH 07/29] #55 added transition to the page new conference --- .../controller/ConferenceController.java | 14 +++++++++++++- .../conference/service/ConferenceService.java | 14 +++----------- .../templates/conferences/conference.html | 6 ++++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 153bd28..291b5fc 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -5,8 +5,10 @@ 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 org.springframework.web.bind.annotation.RequestParam; import ru.ulstu.conference.model.ConferenceFilterDto; import ru.ulstu.conference.service.ConferenceService; +import ru.ulstu.paper.model.PaperDto; import springfox.documentation.annotations.ApiIgnore; @Controller() @@ -22,6 +24,16 @@ public class ConferenceController { @GetMapping("/conferences") public void getConferences(ModelMap modelMap) { - modelMap.put("filteredConferences", new ConferenceFilterDto(conferenceService.findAllDto(), null, null)); + modelMap.put("filteredConferences", new ConferenceFilterDto(conferenceService.findAllDto(), + null, null)); + } + + @GetMapping("/conference") + public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) { + if (id != null && id > 0) { + modelMap.put("conferenceDto", conferenceService.findOneDto(id)); + } else { + modelMap.put("conferenceDto", new PaperDto()); + } } } diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index fd9cc5b..8fcccb0 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -34,17 +34,9 @@ public class ConferenceService { return conferences; } -// private List sortPapers(List conferences) { -// return conferences.stream().sorted((paper1, paper2) -> { -// int statusCompareResult = -// Integer.valueOf(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper1.getStatus())) -// .compareTo(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper2.getStatus())); -// if (statusCompareResult != 0) { -// return statusCompareResult; -// } -// return paper1.getTitle().compareTo(paper2.getTitle()); -// }).collect(toList()); -// } + public ConferenceDto findOneDto(Integer id) { + return new ConferenceDto(conferenceRepository.findOne(id)); + } } diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index 59545b5..7e8d0b7 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -18,11 +18,13 @@
- +
- +
From 91d216801243eca967042c17ccd7b0c224dbc4b2 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 13:34:38 +0400 Subject: [PATCH 08/29] #82 show paper formatted lines --- .../core/controller/AdviceController.java | 8 +---- .../paper/controller/PaperController.java | 2 +- .../paper/controller/PaperRestController.java | 5 +++ .../ru/ulstu/paper/service/PaperService.java | 31 +++++++++++++++++-- src/main/java/ru/ulstu/user/model/User.java | 9 ++++++ 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/main/java/ru/ulstu/core/controller/AdviceController.java b/src/main/java/ru/ulstu/core/controller/AdviceController.java index 1c71df1..8238797 100644 --- a/src/main/java/ru/ulstu/core/controller/AdviceController.java +++ b/src/main/java/ru/ulstu/core/controller/AdviceController.java @@ -20,7 +20,6 @@ import ru.ulstu.user.error.UserNotActivatedException; import ru.ulstu.user.error.UserNotFoundException; import ru.ulstu.user.error.UserPasswordsNotValidOrNotMatchException; import ru.ulstu.user.error.UserResetKeyError; -import ru.ulstu.user.model.User; import ru.ulstu.user.service.UserService; import java.util.Set; @@ -28,7 +27,6 @@ import java.util.stream.Collectors; @ControllerAdvice public class AdviceController { - private final static String USER_NAME_TEMPLATE = "%s %s %s"; private final Logger log = LoggerFactory.getLogger(AdviceController.class); private final UserService userService; @@ -38,11 +36,7 @@ public class AdviceController { @ModelAttribute("currentUser") public String getCurrentUser() { - User user = userService.getCurrentUser(); - return String.format(USER_NAME_TEMPLATE, - user.getLastName(), - user.getFirstName().substring(0, 1), - user.getPatronymic().substring(0, 1)); + return userService.getCurrentUser().getUserAbbreviate(); } private Response handleException(ErrorConstants error) { diff --git a/src/main/java/ru/ulstu/paper/controller/PaperController.java b/src/main/java/ru/ulstu/paper/controller/PaperController.java index 9169bd9..27fec4e 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperController.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperController.java @@ -51,7 +51,7 @@ public class PaperController { @GetMapping("/dashboard") public void getDashboard(ModelMap modelMap) { - modelMap.put("papers", paperService.findAllActive()); + modelMap.put("papers", paperService.findAllActiveDto()); } @GetMapping("/paper") diff --git a/src/main/java/ru/ulstu/paper/controller/PaperRestController.java b/src/main/java/ru/ulstu/paper/controller/PaperRestController.java index 5dd6b9f..2bd8384 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperRestController.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperRestController.java @@ -61,4 +61,9 @@ public class PaperRestController { public Response> filter(@RequestBody @Valid PaperFilterDto paperFilterDto) throws IOException { return new Response<>(paperService.filter(paperFilterDto)); } + + @GetMapping("formatted-list") + public Response> getFormattedPaperList() { + return new Response<>(paperService.getFormattedPaperList()); + } } diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index aab62d1..a93c9c6 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -21,6 +21,7 @@ import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import static java.util.stream.Collectors.toList; import static org.springframework.util.ObjectUtils.isEmpty; @@ -34,6 +35,7 @@ import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION; @Service public class PaperService { private final static int MAX_DISPLAY_SIZE = 40; + private final static String PAPER_FORMATTED_TEMPLATE = "%s %s"; private final PaperNotificationService paperNotificationService; private final PaperRepository paperRepository; @@ -66,13 +68,17 @@ public class PaperService { return papers; } - public List findAllActive() { - return findAllDto() + public List findAllActive() { + return findAll() .stream() .filter(paper -> paper.getStatus() != COMPLETED && paper.getStatus() != FAILED) .collect(toList()); } + public List findAllActiveDto() { + return convert(findAllActive(), PaperDto::new); + } + public PaperDto findOneDto(Integer id) { return new PaperDto(paperRepository.findOne(id)); } @@ -212,4 +218,25 @@ public class PaperService { public List getPaperAuthors() { return userService.findAll(); } + + public List getFormattedPaperList() { + return findAllCompleted() + .stream() + .map(paper -> String.format(PAPER_FORMATTED_TEMPLATE, paper.getTitle(), getAuthors(paper))) + .collect(toList()); + } + + private List findAllCompleted() { + return findAll() + .stream() + .filter(paper -> paper.getStatus() == COMPLETED) + .collect(toList()); + } + + private String getAuthors(Paper paper) { + return paper.getAuthors() + .stream() + .map(User::getUserAbbreviate) + .collect(Collectors.joining(", ")); + } } diff --git a/src/main/java/ru/ulstu/user/model/User.java b/src/main/java/ru/ulstu/user/model/User.java index de9f028..089d1c9 100644 --- a/src/main/java/ru/ulstu/user/model/User.java +++ b/src/main/java/ru/ulstu/user/model/User.java @@ -24,6 +24,8 @@ import java.util.Set; @Entity @Table(name = "users") public class User extends BaseEntity { + private final static String USER_ABBREVIATE_TEMPLATE = "%s %s %s"; + @NotNull @Pattern(regexp = Constants.LOGIN_REGEX) @Size(min = 1, max = 50) @@ -186,4 +188,11 @@ public class User extends BaseEntity { public void setPatronymic(String patronymic) { this.patronymic = patronymic; } + + public String getUserAbbreviate() { + return String.format(USER_ABBREVIATE_TEMPLATE, + lastName == null ? "" : lastName, + firstName == null ? "" : firstName.substring(0, 1), + patronymic == null ? "" : patronymic.substring(0, 1)); + } } From 54edeb0559bbfc159a3e61f0ca79a35093f61e67 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 13:39:53 +0400 Subject: [PATCH 09/29] #82 fix user abbreviate --- src/main/java/ru/ulstu/user/model/User.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/ru/ulstu/user/model/User.java b/src/main/java/ru/ulstu/user/model/User.java index 089d1c9..06f407b 100644 --- a/src/main/java/ru/ulstu/user/model/User.java +++ b/src/main/java/ru/ulstu/user/model/User.java @@ -24,7 +24,7 @@ import java.util.Set; @Entity @Table(name = "users") public class User extends BaseEntity { - private final static String USER_ABBREVIATE_TEMPLATE = "%s %s %s"; + private final static String USER_ABBREVIATE_TEMPLATE = "%s %s%s"; @NotNull @Pattern(regexp = Constants.LOGIN_REGEX) @@ -192,7 +192,7 @@ public class User extends BaseEntity { public String getUserAbbreviate() { return String.format(USER_ABBREVIATE_TEMPLATE, lastName == null ? "" : lastName, - firstName == null ? "" : firstName.substring(0, 1), - patronymic == null ? "" : patronymic.substring(0, 1)); + firstName == null ? "" : firstName.substring(0, 1) + ".", + patronymic == null ? "" : patronymic.substring(0, 1) + "."); } } From bbc398251fe62555a3dce1d96e1ed8d1b3194f34 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 16:16:40 +0400 Subject: [PATCH 10/29] #83 try to change container --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2b2fe64..36814a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: ubuntu:18.04 +image: ng-tracker-container cache: key: "$CI_PROJECT_ID" From 4a05d52e4c270f801342acd6c46093df8339b97e Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 16:25:10 +0400 Subject: [PATCH 11/29] #83 try to change container --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36814a3..f60ac81 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: ng-tracker-container +image: romanov73/is:ng-tracker-container cache: key: "$CI_PROJECT_ID" From 67bfad22f9c8183f8873f95fa88197042ee581eb Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 5 Apr 2019 16:30:45 +0400 Subject: [PATCH 12/29] #55 added create and update methods --- .../controller/ConferenceController.java | 28 +++++++++++++ .../conference/service/ConferenceService.java | 42 +++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 291b5fc..0da8d8d 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -3,14 +3,23 @@ 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.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.service.ConferenceService; import ru.ulstu.paper.model.PaperDto; import springfox.documentation.annotations.ApiIgnore; +import javax.validation.Valid; +import java.io.IOException; +import java.util.stream.Collectors; + +import static org.springframework.util.StringUtils.isEmpty; + @Controller() @RequestMapping(value = "/conferences") @ApiIgnore @@ -36,4 +45,23 @@ public class ConferenceController { modelMap.put("conferenceDto", new PaperDto()); } } + + @PostMapping(value = "/conference", params = "save") + public String save(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException { + filterEmptyDeadlines(conferenceDto); + if (conferenceDto.getDeadlines().isEmpty()) { + errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); + } + if (errors.hasErrors()) { + return "/conferences/conference"; + } + conferenceService.save(conferenceDto); + return "redirect:/conferences/conferences"; + } + + private void filterEmptyDeadlines(ConferenceDto conferenceDto) { + conferenceDto.setDeadlines(conferenceDto.getDeadlines().stream() + .filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription())) + .collect(Collectors.toList())); + } } diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index 8fcccb0..e5afd0f 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -2,13 +2,16 @@ package ru.ulstu.conference.service; import org.apache.commons.lang3.StringUtils; 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.repository.ConferenceRepository; import ru.ulstu.deadline.service.DeadlineService; +import java.io.IOException; import java.util.List; +import static org.springframework.util.ObjectUtils.isEmpty; import static ru.ulstu.core.util.StreamApiUtils.convert; @Service @@ -38,5 +41,44 @@ public class ConferenceService { return new ConferenceDto(conferenceRepository.findOne(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.findOne(conferenceDto.getId()); + + conferenceRepository.save(copyFromDto(conference, conferenceDto)); + + return conference.getId(); + } + + 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(conference.getBeginDate()); + conference.setEndDate(conference.getEndDate()); + + conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines())); + + return conference; + } + } From fe1820d540f69764337d4203e8090b4a47e6dccd Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 16:37:03 +0400 Subject: [PATCH 13/29] #83 try to change container --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f60ac81..ad0d58e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,8 +9,8 @@ variables: GRADLE_OPTS: "-Dorg.gradle.daemon=false" before_script: - - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' - - apt-get install openjdk-8-jdk git -y +# - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' +# - apt-get install openjdk-8-jdk git -y - eval $(ssh-agent -s) - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - mkdir -p ~/.ssh From c7cdbe9044439f42e2371ba7d57822c467f6cdfb Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 17:35:17 +0400 Subject: [PATCH 14/29] #83 add tasks, modify build script for passing application properties --- .gitlab-ci.yml | 20 +++++++++++++++++++ build.gradle | 4 ++++ .../java/ru/ulstu/NgTrackerApplication.java | 17 ++++++++++++++++ .../configuration/ApplicationProperties.java | 12 +++++++++++ src/main/resources/application.properties | 3 ++- 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad0d58e..1d2c728 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,26 @@ build: - build - .gradle +checkRun: + stage: test + script: ./gradlew bootRun -Dng-tracker.check-run=true + cache: + key: "$CI_PROJECT_ID" + policy: push + paths: + - build + - .gradle + +checkStyle: + stage: test + script: ./gradlew check + cache: + key: "$CI_PROJECT_ID" + policy: push + paths: + - build + - .gradle + deploy: stage: deploy script: diff --git a/build.gradle b/build.gradle index 4e0e9cb..ffc7d0a 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,10 @@ bootRun.dependsOn checkstyleMain sourceCompatibility = 1.8 targetCompatibility = 1.8 +bootRun { + systemProperties = System.properties +} + checkstyle { project.ext.checkstyleVersion = '8.8' diff --git a/src/main/java/ru/ulstu/NgTrackerApplication.java b/src/main/java/ru/ulstu/NgTrackerApplication.java index 5e6ee4f..fbe3a2f 100644 --- a/src/main/java/ru/ulstu/NgTrackerApplication.java +++ b/src/main/java/ru/ulstu/NgTrackerApplication.java @@ -2,13 +2,30 @@ package ru.ulstu; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.event.EventListener; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import ru.ulstu.configuration.ApplicationProperties; import ru.ulstu.core.repository.JpaDetachableRepositoryImpl; @SpringBootApplication @EnableJpaRepositories(repositoryBaseClass = JpaDetachableRepositoryImpl.class) public class NgTrackerApplication { + private final ApplicationProperties applicationProperties; + + public NgTrackerApplication(ApplicationProperties applicationProperties) { + this.applicationProperties = applicationProperties; + } + public static void main(String[] args) { SpringApplication.run(NgTrackerApplication.class, args); } + + @EventListener(ApplicationReadyEvent.class) + public void doSomethingAfterStartup() { + System.out.println("hello world, I have just started up"); + if (applicationProperties.isCheckRun()) { + System.exit(0); + } + } } diff --git a/src/main/java/ru/ulstu/configuration/ApplicationProperties.java b/src/main/java/ru/ulstu/configuration/ApplicationProperties.java index 8615cb2..f75f53f 100644 --- a/src/main/java/ru/ulstu/configuration/ApplicationProperties.java +++ b/src/main/java/ru/ulstu/configuration/ApplicationProperties.java @@ -11,12 +11,16 @@ import org.springframework.validation.annotation.Validated; public class ApplicationProperties { @NotBlank private String baseUrl; + @NotBlank private String undeadUserLogin; + private boolean devMode; private boolean useHttps; + private boolean checkRun; + public boolean isUseHttps() { return useHttps; } @@ -48,4 +52,12 @@ public class ApplicationProperties { public void setDevMode(boolean devMode) { this.devMode = devMode; } + + public boolean isCheckRun() { + return checkRun; + } + + public void setCheckRun(boolean checkRun) { + this.checkRun = checkRun; + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fb1b116..038ddcf 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -35,4 +35,5 @@ liquibase.change-log=classpath:db/changelog-master.xml ng-tracker.base-url=http://127.0.0.1:8080 ng-tracker.undead-user-login=admin ng-tracker.dev-mode=true -ng-tracker.use-https=false \ No newline at end of file +ng-tracker.use-https=false +ng-tracker.check-run=false \ No newline at end of file From 7a7dfb337f51c4fdefe54d8b004a85e426d00e74 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 17:41:31 +0400 Subject: [PATCH 15/29] #83 fix postgres service --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1d2c728..1436e0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,6 +11,8 @@ variables: before_script: # - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' # - apt-get install openjdk-8-jdk git -y + - service postgresql stop + - service postgresql start - eval $(ssh-agent -s) - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - mkdir -p ~/.ssh From 94dabd07fbd0241b7bbf26c386739ab42498bac1 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 17:47:10 +0400 Subject: [PATCH 16/29] #83 fix code --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1436e0f..404edd9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,8 +9,6 @@ variables: GRADLE_OPTS: "-Dorg.gradle.daemon=false" before_script: -# - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' -# - apt-get install openjdk-8-jdk git -y - service postgresql stop - service postgresql start - eval $(ssh-agent -s) From 0feef9016a2dea23be407e425e924ade86ed3bfb Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 17:48:23 +0400 Subject: [PATCH 17/29] #83 disable cache --- .gitlab-ci.yml | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 404edd9..6709891 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,5 @@ image: romanov73/is:ng-tracker-container -cache: - key: "$CI_PROJECT_ID" - paths: - - .gradle/ - variables: GRADLE_OPTS: "-Dorg.gradle.daemon=false" @@ -20,32 +15,14 @@ before_script: build: stage: build script: ./gradlew assemble - cache: - key: "$CI_PROJECT_ID" - policy: push - paths: - - build - - .gradle checkRun: stage: test script: ./gradlew bootRun -Dng-tracker.check-run=true - cache: - key: "$CI_PROJECT_ID" - policy: push - paths: - - build - - .gradle checkStyle: stage: test script: ./gradlew check - cache: - key: "$CI_PROJECT_ID" - policy: push - paths: - - build - - .gradle deploy: stage: deploy @@ -53,12 +30,6 @@ deploy: - sh deploy/gdccloud/deploy.sh only: - dev - cache: - key: "$CI_PROJECT_ID" - policy: pull - paths: - - build - - .gradle environment: name: staging url: http://193.110.3.124:8080 From 72add3638b01f111d65e8b645a08936b56c6ee63 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 18:01:12 +0400 Subject: [PATCH 18/29] #83 check CI --- src/main/java/ru/ulstu/paper/model/WrongEntity.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/ru/ulstu/paper/model/WrongEntity.java diff --git a/src/main/java/ru/ulstu/paper/model/WrongEntity.java b/src/main/java/ru/ulstu/paper/model/WrongEntity.java new file mode 100644 index 0000000..85deec8 --- /dev/null +++ b/src/main/java/ru/ulstu/paper/model/WrongEntity.java @@ -0,0 +1,7 @@ +package ru.ulstu.paper.model; + +import javax.persistence.Entity; + +@Entity +public class WrongEntity { +} From eb524d49d055dc436f47803f6dcacf6a7975ba96 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 5 Apr 2019 18:01:43 +0400 Subject: [PATCH 19/29] #55 added html side, don't work, because can't parse date, like in deadlines --- .../controller/ConferenceController.java | 9 +++--- .../ru/ulstu/conference/model/Conference.java | 9 ++++-- .../templates/conferences/conference.html | 30 ++++++++++++------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 0da8d8d..f3c4864 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -11,7 +11,6 @@ import org.springframework.web.bind.annotation.RequestParam; import ru.ulstu.conference.model.ConferenceDto; import ru.ulstu.conference.model.ConferenceFilterDto; import ru.ulstu.conference.service.ConferenceService; -import ru.ulstu.paper.model.PaperDto; import springfox.documentation.annotations.ApiIgnore; import javax.validation.Valid; @@ -27,8 +26,8 @@ public class ConferenceController { private final ConferenceService conferenceService; - public ConferenceController(ConferenceService paperService) { - this.conferenceService = paperService; + public ConferenceController(ConferenceService conferenceService) { + this.conferenceService = conferenceService; } @GetMapping("/conferences") @@ -42,7 +41,7 @@ public class ConferenceController { if (id != null && id > 0) { modelMap.put("conferenceDto", conferenceService.findOneDto(id)); } else { - modelMap.put("conferenceDto", new PaperDto()); + modelMap.put("conferenceDto", new ConferenceDto()); } } @@ -53,10 +52,12 @@ public class ConferenceController { errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); } if (errors.hasErrors()) { + System.out.println("я здесь 2"); return "/conferences/conference"; } conferenceService.save(conferenceDto); return "redirect:/conferences/conferences"; + } private void filterEmptyDeadlines(ConferenceDto conferenceDto) { diff --git a/src/main/java/ru/ulstu/conference/model/Conference.java b/src/main/java/ru/ulstu/conference/model/Conference.java index 8cb1c64..1c824b3 100644 --- a/src/main/java/ru/ulstu/conference/model/Conference.java +++ b/src/main/java/ru/ulstu/conference/model/Conference.java @@ -3,6 +3,7 @@ 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.deadline.model.Deadline; import ru.ulstu.paper.model.Paper; @@ -41,11 +42,13 @@ public class Conference extends BaseEntity { @Column(name = "begin_date") @Temporal(TemporalType.TIMESTAMP) - private Date beginDate = new Date(); - + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date beginDate; + @Column(name = "end_date") @Temporal(TemporalType.TIMESTAMP) - private Date endDate = new Date(); + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date endDate; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "conference_id", unique = true) diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index 7e8d0b7..3330bed 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -28,36 +28,44 @@
-
-
-
- -
+
+ - + placeholder="Описание" + th:field="*{deadlines[__${rowStat.index}__].description}"/> + Удалить + alt="Удалить" + th:onclick="|$('#deadlines${rowStat.index}\\.description').val(''); + $('#deadlines${rowStat.index}\\.date').val(''); + $('#addDeadline').click();|"/>
+

Incorrect title

- +
- +
From e0ca29fbab8ab6d1b6ce5d74ee5de27397584c8b Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 21:47:42 +0400 Subject: [PATCH 20/29] #83 fix wrong entity --- src/main/java/ru/ulstu/paper/model/WrongEntity.java | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/main/java/ru/ulstu/paper/model/WrongEntity.java diff --git a/src/main/java/ru/ulstu/paper/model/WrongEntity.java b/src/main/java/ru/ulstu/paper/model/WrongEntity.java deleted file mode 100644 index 85deec8..0000000 --- a/src/main/java/ru/ulstu/paper/model/WrongEntity.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.ulstu.paper.model; - -import javax.persistence.Entity; - -@Entity -public class WrongEntity { -} From b9af7c20c78b058b7ecd3efd1adb7a64b763e116 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Sat, 6 Apr 2019 00:11:49 +0400 Subject: [PATCH 21/29] fix grids --- src/main/resources/public/css/agency.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/resources/public/css/agency.css b/src/main/resources/public/css/agency.css index 24680aa..e1cc226 100644 --- a/src/main/resources/public/css/agency.css +++ b/src/main/resources/public/css/agency.css @@ -777,11 +777,25 @@ ul.social-buttons li a:active, ul.social-buttons li a:focus, ul.social-buttons l box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05); } +@media (min-width: 1500px) { + .col-xl-3 { + max-width: 20%; + } + + .container { + max-width: 1340px; + } +} + .toolbar-button { width: 100%; margin: 5px; } +.img-fluid { + width: 100% !important; +} + /* --------------------------------------------------- FEEDBACK STYLE ----------------------------------------------------- */ From 926cd02096ebb358765be277e677189b057f3abf Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sat, 6 Apr 2019 11:05:30 +0400 Subject: [PATCH 22/29] #55 fixed adding to DB --- src/main/java/ru/ulstu/conference/model/ConferenceDto.java | 7 +++++++ .../ru/ulstu/conference/service/ConferenceService.java | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java index d5c586f..a9414c1 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java @@ -3,10 +3,13 @@ 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.PaperDto; import ru.ulstu.user.model.UserDto; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; import javax.validation.constraints.Size; import java.util.ArrayList; import java.util.Date; @@ -26,7 +29,11 @@ public class ConferenceDto { @Size(max = 255) private String url; private int ping; + @Temporal(TemporalType.TIMESTAMP) + @DateTimeFormat(pattern = "yyyy-MM-dd") private Date beginDate; + @Temporal(TemporalType.TIMESTAMP) + @DateTimeFormat(pattern = "yyyy-MM-dd") private Date endDate; @NotEmpty private List deadlines = new ArrayList<>(); diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index e5afd0f..c28c637 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -72,8 +72,8 @@ public class ConferenceService { conference.setDescription(conferenceDto.getDescription()); conference.setUrl(conferenceDto.getUrl()); conference.setPing(0); - conference.setBeginDate(conference.getBeginDate()); - conference.setEndDate(conference.getEndDate()); + conference.setBeginDate(conferenceDto.getBeginDate()); + conference.setEndDate(conferenceDto.getEndDate()); conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines())); From 3e5aeaf29062aadc44b68aba3b8d477e09c8673a Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sat, 6 Apr 2019 14:41:10 +0400 Subject: [PATCH 23/29] #55 fast fixes --- .../ru/ulstu/conference/controller/ConferenceController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index f3c4864..d957e76 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -52,7 +52,6 @@ public class ConferenceController { errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); } if (errors.hasErrors()) { - System.out.println("я здесь 2"); return "/conferences/conference"; } conferenceService.save(conferenceDto); From db43da9ec0e4b5806f65052cbaf2e6221f62b39a Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sun, 7 Apr 2019 10:01:44 +0400 Subject: [PATCH 24/29] #55 added nav controller --- .../controller/ConferenceController.java | 11 +++++++---- .../controller/NavigationController.java | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/main/java/ru/ulstu/conference/controller/NavigationController.java diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index d957e76..c3b4917 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -18,6 +18,11 @@ import java.io.IOException; import java.util.stream.Collectors; import static org.springframework.util.StringUtils.isEmpty; +import static ru.ulstu.conference.controller.NavigationController.CONFERENCES_PAGE; +import static ru.ulstu.conference.controller.NavigationController.CONFERENCE_PAGE; +import static ru.ulstu.conference.controller.NavigationController.REDIRECT_TO; +import static ru.ulstu.grant.controller.Navigation.hasErrors; + @Controller() @RequestMapping(value = "/conferences") @@ -51,11 +56,9 @@ public class ConferenceController { if (conferenceDto.getDeadlines().isEmpty()) { errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); } - if (errors.hasErrors()) { - return "/conferences/conference"; - } + hasErrors(errors, CONFERENCE_PAGE); conferenceService.save(conferenceDto); - return "redirect:/conferences/conferences"; + return String.format(REDIRECT_TO, CONFERENCES_PAGE); } diff --git a/src/main/java/ru/ulstu/conference/controller/NavigationController.java b/src/main/java/ru/ulstu/conference/controller/NavigationController.java new file mode 100644 index 0000000..84f88ad --- /dev/null +++ b/src/main/java/ru/ulstu/conference/controller/NavigationController.java @@ -0,0 +1,18 @@ +package ru.ulstu.conference.controller; + +import org.springframework.validation.Errors; + +public class NavigationController { + + public static final String REDIRECT_TO = "redirect:%s"; + 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; + } + +} From c49b56916c14ac493440522767d49d04e49fb677 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Sun, 7 Apr 2019 10:08:13 +0400 Subject: [PATCH 25/29] #55 added initialization of fields in ConferenceDto --- .../ulstu/conference/model/ConferenceDto.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java index a9414c1..277e783 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java @@ -13,6 +13,7 @@ import javax.persistence.TemporalType; import javax.validation.constraints.Size; import java.util.ArrayList; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -25,22 +26,22 @@ public class ConferenceDto { @Size(min = 2, max = 400) private String title; @Size(max = 500) - private String description; + private String description = ""; @Size(max = 255) - private String url; - private int ping; + private String url = ""; + private int ping = 0; @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(pattern = "yyyy-MM-dd") - private Date beginDate; + private Date beginDate = new Date(); @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(pattern = "yyyy-MM-dd") - private Date endDate; + private Date endDate = new Date(); @NotEmpty private List deadlines = new ArrayList<>(); - private Set userIds; - private Set paperIds; - private Set papers; - private Set users; + private Set userIds = new HashSet<>(); + private Set paperIds = new HashSet<>(); + private Set papers = new HashSet<>(); + private Set users = new HashSet<>(); private Integer filterUserId; public ConferenceDto() { From e350f8b3c161ca4f23445100b6b2a333e726d808 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Mon, 8 Apr 2019 07:40:26 +0400 Subject: [PATCH 26/29] #55 refactor controller navigation, fix conference edit url --- .../controller/ConferenceController.java | 11 +++++------ .../conference/model/ConferenceFilterDto.java | 4 ++++ .../controller/Navigation.java} | 9 +++++---- .../ulstu/grant/controller/GrantController.java | 8 ++++---- .../ru/ulstu/grant/controller/Navigation.java | 16 ---------------- .../conferences/fragments/confLineFragment.html | 2 +- 6 files changed, 19 insertions(+), 31 deletions(-) rename src/main/java/ru/ulstu/{conference/controller/NavigationController.java => core/controller/Navigation.java} (69%) delete mode 100644 src/main/java/ru/ulstu/grant/controller/Navigation.java diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index c3b4917..528975c 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -18,10 +18,10 @@ import java.io.IOException; import java.util.stream.Collectors; import static org.springframework.util.StringUtils.isEmpty; -import static ru.ulstu.conference.controller.NavigationController.CONFERENCES_PAGE; -import static ru.ulstu.conference.controller.NavigationController.CONFERENCE_PAGE; -import static ru.ulstu.conference.controller.NavigationController.REDIRECT_TO; -import static ru.ulstu.grant.controller.Navigation.hasErrors; +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; +import static ru.ulstu.core.controller.Navigation.hasErrors; @Controller() @@ -37,8 +37,7 @@ public class ConferenceController { @GetMapping("/conferences") public void getConferences(ModelMap modelMap) { - modelMap.put("filteredConferences", new ConferenceFilterDto(conferenceService.findAllDto(), - null, null)); + modelMap.put("filteredConferences", new ConferenceFilterDto(conferenceService.findAllDto())); } @GetMapping("/conference") diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java index 5b85839..37878b2 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java @@ -17,6 +17,10 @@ public class ConferenceFilterDto { this.year = year; } + public ConferenceFilterDto(List conferenceDtos) { + this(conferenceDtos, null, null); + } + public List getConferences() { return conferences; } diff --git a/src/main/java/ru/ulstu/conference/controller/NavigationController.java b/src/main/java/ru/ulstu/core/controller/Navigation.java similarity index 69% rename from src/main/java/ru/ulstu/conference/controller/NavigationController.java rename to src/main/java/ru/ulstu/core/controller/Navigation.java index 84f88ad..caea429 100644 --- a/src/main/java/ru/ulstu/conference/controller/NavigationController.java +++ b/src/main/java/ru/ulstu/core/controller/Navigation.java @@ -1,10 +1,12 @@ -package ru.ulstu.conference.controller; +package ru.ulstu.core.controller; import org.springframework.validation.Errors; -public class NavigationController { - +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"; @@ -14,5 +16,4 @@ public class NavigationController { } return null; } - } diff --git a/src/main/java/ru/ulstu/grant/controller/GrantController.java b/src/main/java/ru/ulstu/grant/controller/GrantController.java index 65b11dc..a7dc948 100644 --- a/src/main/java/ru/ulstu/grant/controller/GrantController.java +++ b/src/main/java/ru/ulstu/grant/controller/GrantController.java @@ -21,10 +21,10 @@ import java.util.List; import java.util.stream.Collectors; import static org.springframework.util.StringUtils.isEmpty; -import static ru.ulstu.grant.controller.Navigation.GRANTS_PAGE; -import static ru.ulstu.grant.controller.Navigation.GRANT_PAGE; -import static ru.ulstu.grant.controller.Navigation.REDIRECT_TO; -import static ru.ulstu.grant.controller.Navigation.hasErrors; +import static ru.ulstu.core.controller.Navigation.GRANTS_PAGE; +import static ru.ulstu.core.controller.Navigation.GRANT_PAGE; +import static ru.ulstu.core.controller.Navigation.REDIRECT_TO; +import static ru.ulstu.core.controller.Navigation.hasErrors; @Controller() diff --git a/src/main/java/ru/ulstu/grant/controller/Navigation.java b/src/main/java/ru/ulstu/grant/controller/Navigation.java deleted file mode 100644 index bf1626f..0000000 --- a/src/main/java/ru/ulstu/grant/controller/Navigation.java +++ /dev/null @@ -1,16 +0,0 @@ -package ru.ulstu.grant.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 String hasErrors(Errors errors, String page) { - if (errors.hasErrors()) { - return page; - } - return null; - } -} diff --git a/src/main/resources/templates/conferences/fragments/confLineFragment.html b/src/main/resources/templates/conferences/fragments/confLineFragment.html index c97dfbd..317da03 100644 --- a/src/main/resources/templates/conferences/fragments/confLineFragment.html +++ b/src/main/resources/templates/conferences/fragments/confLineFragment.html @@ -6,7 +6,7 @@
- + From 3017366c9162f5d5438e5fc447390bff2f107939 Mon Sep 17 00:00:00 2001 From: user Date: Mon, 8 Apr 2019 11:27:15 +0300 Subject: [PATCH 27/29] =?UTF-8?q?=E2=84=9685=20try=20to=20add=20issue=20te?= =?UTF-8?q?mplate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab/issue_templates/feature.md | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .gitlab/issue_templates/feature.md diff --git a/.gitlab/issue_templates/feature.md b/.gitlab/issue_templates/feature.md new file mode 100644 index 0000000..932d386 --- /dev/null +++ b/.gitlab/issue_templates/feature.md @@ -0,0 +1,50 @@ +## Краткое описание задачи +``` +Что требуется сделать +``` + +## `Опционально` Список верстаемых страниц +``` +Будут затронуты страницы: +* 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` +* Сценарий просмотра проверяется при ручном внечении записей в БД +``` \ No newline at end of file From 689a7799e3803f5bc4f21a3584c39beaee4de2b2 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Mon, 8 Apr 2019 22:04:30 +0400 Subject: [PATCH 28/29] #55 added method in controller --- .../conference/controller/ConferenceController.java | 9 +++++++++ src/main/resources/templates/conferences/conference.html | 2 +- .../conferences/fragments/confNavigationFragment.html | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 528975c..1de420b 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam; import ru.ulstu.conference.model.ConferenceDto; import ru.ulstu.conference.model.ConferenceFilterDto; import ru.ulstu.conference.service.ConferenceService; +import ru.ulstu.deadline.model.Deadline; import springfox.documentation.annotations.ApiIgnore; import javax.validation.Valid; @@ -61,6 +62,14 @@ public class ConferenceController { } + @PostMapping(value = "/conference", params = "addDeadline") + public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) { + filterEmptyDeadlines(conferenceDto); + hasErrors(errors, CONFERENCE_PAGE); + conferenceDto.getDeadlines().add(new Deadline()); + return CONFERENCE_PAGE; + } + private void filterEmptyDeadlines(ConferenceDto conferenceDto) { conferenceDto.setDeadlines(conferenceDto.getDeadlines().stream() .filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription())) diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index 3330bed..3917128 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -68,7 +68,7 @@ class="alert alert-danger">Incorrect title

-
diff --git a/src/main/resources/templates/conferences/fragments/confNavigationFragment.html b/src/main/resources/templates/conferences/fragments/confNavigationFragment.html index 31cc00f..45a945e 100644 --- a/src/main/resources/templates/conferences/fragments/confNavigationFragment.html +++ b/src/main/resources/templates/conferences/fragments/confNavigationFragment.html @@ -21,7 +21,7 @@
- Добавить конференцию + Новая конференцию
From c308a5e5aff71b75e0cd6d93609c5da035dbeb9e Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Tue, 9 Apr 2019 14:47:14 +0400 Subject: [PATCH 29/29] #55 Navigation's method "hasErrors" don't work. it returns String, not redirection. --- .../ulstu/conference/controller/ConferenceController.java | 7 ++++--- src/main/resources/templates/conferences/conference.html | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 1de420b..006a1de 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -22,7 +22,6 @@ 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; -import static ru.ulstu.core.controller.Navigation.hasErrors; @Controller() @@ -56,7 +55,8 @@ public class ConferenceController { if (conferenceDto.getDeadlines().isEmpty()) { errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); } - hasErrors(errors, CONFERENCE_PAGE); + if (errors.hasErrors()) + return CONFERENCE_PAGE; conferenceService.save(conferenceDto); return String.format(REDIRECT_TO, CONFERENCES_PAGE); @@ -65,7 +65,8 @@ public class ConferenceController { @PostMapping(value = "/conference", params = "addDeadline") public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) { filterEmptyDeadlines(conferenceDto); - hasErrors(errors, CONFERENCE_PAGE); + if (errors.hasErrors()) + return CONFERENCE_PAGE; conferenceDto.getDeadlines().add(new Deadline()); return CONFERENCE_PAGE; } diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index 3917128..cbc0019 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -30,6 +30,9 @@ +

Incorrect title

+

@@ -61,11 +64,12 @@ $('#deadlines${rowStat.index}\\.date').val(''); $('#addDeadline').click();|"/>
-

Incorrect title

+

+