From c21e8afc1fc77677d97ddbfee0946751fffcf705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D0=BC=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=20=D0=9C?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D1=8F?= Date: Sat, 23 Mar 2019 22:04:56 +0400 Subject: [PATCH] latex text in paper --- src/main/java/ru/ulstu/file/model/FileData.java | 11 +++++++++++ src/main/java/ru/ulstu/paper/model/Paper.java | 12 +++++++++++- src/main/java/ru/ulstu/paper/model/PaperDto.java | 14 +++++++++++++- .../java/ru/ulstu/paper/service/PaperService.java | 1 + .../db/changelog-20190323_000001-schema.xml | 14 ++++++++++++++ src/main/resources/db/changelog-master.xml | 1 + 6 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/db/changelog-20190323_000001-schema.xml diff --git a/src/main/java/ru/ulstu/file/model/FileData.java b/src/main/java/ru/ulstu/file/model/FileData.java index e5b3277..08445a3 100644 --- a/src/main/java/ru/ulstu/file/model/FileData.java +++ b/src/main/java/ru/ulstu/file/model/FileData.java @@ -19,6 +19,9 @@ public class FileData extends BaseEntity { private byte[] data; + @Column(name = "is_latex_attach") + private boolean isLatexAttach; + public String getName() { return name; } @@ -50,4 +53,12 @@ public class FileData extends BaseEntity { public void setData(byte[] data) { this.data = data; } + + public boolean isLatexAttach() { + return isLatexAttach; + } + + public void setLatexAttach(boolean latexAttach) { + isLatexAttach = latexAttach; + } } diff --git a/src/main/java/ru/ulstu/paper/model/Paper.java b/src/main/java/ru/ulstu/paper/model/Paper.java index b2f8327..31d106c 100644 --- a/src/main/java/ru/ulstu/paper/model/Paper.java +++ b/src/main/java/ru/ulstu/paper/model/Paper.java @@ -77,7 +77,6 @@ public class Paper extends BaseEntity implements UserContainer { private Boolean locked = false; - @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "paper_id", unique = true) @Fetch(FetchMode.SUBSELECT) @@ -86,6 +85,9 @@ public class Paper extends BaseEntity implements UserContainer { @ManyToMany(fetch = FetchType.EAGER) private Set authors = new HashSet<>(); + @Column(name = "latex_text") + private String latexText; + public PaperStatus getStatus() { return status; } @@ -158,6 +160,14 @@ public class Paper extends BaseEntity implements UserContainer { this.authors = authors; } + public String getLatexText() { + return latexText; + } + + public void setLatexText(String latexText) { + this.latexText = latexText; + } + @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 18284f4..f33d207 100644 --- a/src/main/java/ru/ulstu/paper/model/PaperDto.java +++ b/src/main/java/ru/ulstu/paper/model/PaperDto.java @@ -4,8 +4,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils; import org.hibernate.validator.constraints.NotEmpty; -import ru.ulstu.file.model.FileDataDto; import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.file.model.FileDataDto; import ru.ulstu.user.model.UserDto; import javax.validation.constraints.Size; @@ -35,6 +35,7 @@ public class PaperDto { private Set authorIds; private Set authors; private Integer filterAuthorId; + private String latexText; public PaperDto() { deadlines.add(new Deadline()); @@ -48,6 +49,7 @@ public class PaperDto { @JsonProperty("updateDate") Date updateDate, @JsonProperty("deadlines") List deadlines, @JsonProperty("comment") String comment, + @JsonProperty("latex_text") String latexText, @JsonProperty("locked") Boolean locked, @JsonProperty("files") List files, @JsonProperty("authorIds") Set authorIds, @@ -59,6 +61,7 @@ public class PaperDto { this.updateDate = updateDate; this.deadlines = deadlines; this.comment = comment; + this.latexText = latexText; this.locked = locked; this.files = files; this.authors = authors; @@ -72,6 +75,7 @@ public class PaperDto { this.updateDate = paper.getUpdateDate(); this.deadlines = paper.getDeadlines(); this.comment = paper.getComment(); + this.latexText = paper.getLatexText(); this.locked = paper.getLocked(); this.files = convert(paper.getFiles(), FileDataDto::new); this.authorIds = convert(paper.getAuthors(), user -> user.getId()); @@ -166,6 +170,14 @@ public class PaperDto { this.authorIds = authorIds; } + public String getLatexText() { + return latexText; + } + + public void setLatexText(String latexText) { + this.latexText = latexText; + } + 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 a664d00..926a7d7 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -83,6 +83,7 @@ public class PaperService { private Paper copyFromDto(Paper paper, PaperDto paperDto) throws IOException { paper.setComment(paperDto.getComment()); + paper.setLatexText(paperDto.getLatexText()); 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-20190323_000001-schema.xml b/src/main/resources/db/changelog-20190323_000001-schema.xml new file mode 100644 index 0000000..1ab3efb --- /dev/null +++ b/src/main/resources/db/changelog-20190323_000001-schema.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/src/main/resources/db/changelog-master.xml b/src/main/resources/db/changelog-master.xml index dcba122..23440cf 100644 --- a/src/main/resources/db/changelog-master.xml +++ b/src/main/resources/db/changelog-master.xml @@ -19,5 +19,6 @@ + \ No newline at end of file