diff --git a/src/main/java/ru/ulstu/paper/model/Paper.java b/src/main/java/ru/ulstu/paper/model/Paper.java index c09fd28..fce6817 100644 --- a/src/main/java/ru/ulstu/paper/model/Paper.java +++ b/src/main/java/ru/ulstu/paper/model/Paper.java @@ -9,26 +9,8 @@ import ru.ulstu.deadline.model.Deadline; import ru.ulstu.file.model.FileData; import ru.ulstu.user.model.User; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; +import javax.persistence.*; +import java.util.*; @Entity public class Paper extends BaseEntity implements UserContainer { @@ -75,6 +57,8 @@ public class Paper extends BaseEntity implements UserContainer { private String comment; + private String url; + private Boolean locked = false; @ManyToOne @@ -156,6 +140,14 @@ public class Paper extends BaseEntity implements UserContainer { this.authors = authors; } + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + @Override public Set getUsers() { return getAuthors(); diff --git a/src/main/java/ru/ulstu/paper/model/PaperDto.java b/src/main/java/ru/ulstu/paper/model/PaperDto.java index 3405768..7c6eeb7 100644 --- a/src/main/java/ru/ulstu/paper/model/PaperDto.java +++ b/src/main/java/ru/ulstu/paper/model/PaperDto.java @@ -29,6 +29,7 @@ public class PaperDto { @NotEmpty private List deadlines = new ArrayList<>(); private String comment; + private String url; private Boolean locked; private String tmpFileName; private Integer fileId; @@ -50,6 +51,7 @@ public class PaperDto { @JsonProperty("updateDate") Date updateDate, @JsonProperty("deadlines") List deadlines, @JsonProperty("comment") String comment, + @JsonProperty("url") String url, @JsonProperty("locked") Boolean locked, @JsonProperty("tmpFileName") String tmpFileName, @JsonProperty("authorIds") Set authorIds, @@ -61,6 +63,7 @@ public class PaperDto { this.updateDate = updateDate; this.deadlines = deadlines; this.comment = comment; + this.url = url; this.locked = locked; this.tmpFileName = tmpFileName; this.fileId = null; @@ -77,6 +80,7 @@ public class PaperDto { this.updateDate = paper.getUpdateDate(); this.deadlines = paper.getDeadlines(); this.comment = paper.getComment(); + this.url = paper.getUrl(); this.locked = paper.getLocked(); this.tmpFileName = null; this.fileId = paper.getFileData() == null ? null : paper.getFileData().getId(); @@ -198,6 +202,14 @@ public class PaperDto { this.authorIds = authorIds; } + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + public String getAuthorsString() { return StringUtils.abbreviate(authors .stream() diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index 9df8be2..49102d6 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -14,20 +14,12 @@ import ru.ulstu.user.model.User; import ru.ulstu.user.service.UserService; import java.io.IOException; -import java.util.Arrays; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; import static org.springframework.util.ObjectUtils.isEmpty; import static ru.ulstu.core.util.StreamApiUtils.convert; -import static ru.ulstu.paper.model.Paper.PaperStatus.ATTENTION; -import static ru.ulstu.paper.model.Paper.PaperStatus.COMPLETED; -import static ru.ulstu.paper.model.Paper.PaperStatus.DRAFT; -import static ru.ulstu.paper.model.Paper.PaperStatus.FAILED; -import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION; +import static ru.ulstu.paper.model.Paper.PaperStatus.*; @Service public class PaperService { @@ -82,6 +74,7 @@ public class PaperService { private Paper copyFromDto(Paper paper, PaperDto paperDto) throws IOException { paper.setComment(paperDto.getComment()); + paper.setUrl(paperDto.getUrl()); paper.setCreateDate(paper.getCreateDate() == null ? new Date() : paper.getCreateDate()); paper.setLocked(paperDto.getLocked()); paper.setStatus(paperDto.getStatus() == null ? DRAFT : paperDto.getStatus()); diff --git a/src/main/resources/db/changelog-20190318_000001-schema.xml b/src/main/resources/db/changelog-20190318_000001-schema.xml new file mode 100644 index 0000000..98ec657 --- /dev/null +++ b/src/main/resources/db/changelog-20190318_000001-schema.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/src/main/resources/db/changelog-master.xml b/src/main/resources/db/changelog-master.xml index b8654ae..1276108 100644 --- a/src/main/resources/db/changelog-master.xml +++ b/src/main/resources/db/changelog-master.xml @@ -18,5 +18,6 @@ + \ No newline at end of file diff --git a/src/main/resources/templates/papers/fragments/paperDashboardFragment.html b/src/main/resources/templates/papers/fragments/paperDashboardFragment.html index 122696e..f55d724 100644 --- a/src/main/resources/templates/papers/fragments/paperDashboardFragment.html +++ b/src/main/resources/templates/papers/fragments/paperDashboardFragment.html @@ -10,7 +10,13 @@
- title +

+

+ + title +

authors

diff --git a/src/main/resources/templates/papers/paper.html b/src/main/resources/templates/papers/paper.html index a5ff6b5..a01e858 100644 --- a/src/main/resources/templates/papers/paper.html +++ b/src/main/resources/templates/papers/paper.html @@ -50,6 +50,13 @@ th:field="*{comment}"> +
+ + +
+