latex text in paper

This commit is contained in:
Семенова Мария 2019-03-23 22:04:56 +04:00
parent f5ce1aa269
commit c21e8afc1f
6 changed files with 51 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -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<User> 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<User> getUsers() {
return getAuthors();

View File

@ -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<Integer> authorIds;
private Set<UserDto> 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<Deadline> deadlines,
@JsonProperty("comment") String comment,
@JsonProperty("latex_text") String latexText,
@JsonProperty("locked") Boolean locked,
@JsonProperty("files") List<FileDataDto> files,
@JsonProperty("authorIds") Set<Integer> 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()

View File

@ -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());

View File

@ -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>

View File

@ -19,5 +19,6 @@
<include file="db/changelog-20181208_000000-schema.xml"/>
<include file="db/changelog-20181224_000000-schema.xml"/>
<include file="db/changelog-20190318_000000-schema.xml"/>
<include file="db/changelog-20190323_000001-schema.xml"/>
<include file="db/common/changelog-20190312_130000-schema.xml"/>
</databaseChangeLog>