#33 url in paper

This commit is contained in:
Семенова Мария 2019-03-18 23:31:33 +04:00
parent 9418a47a1d
commit e6bf603edc
7 changed files with 52 additions and 31 deletions

View File

@ -9,26 +9,8 @@ import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.file.model.FileData; import ru.ulstu.file.model.FileData;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
import javax.persistence.CascadeType; import javax.persistence.*;
import javax.persistence.Column; import java.util.*;
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;
@Entity @Entity
public class Paper extends BaseEntity implements UserContainer { public class Paper extends BaseEntity implements UserContainer {
@ -75,6 +57,8 @@ public class Paper extends BaseEntity implements UserContainer {
private String comment; private String comment;
private String url;
private Boolean locked = false; private Boolean locked = false;
@ManyToOne @ManyToOne
@ -156,6 +140,14 @@ public class Paper extends BaseEntity implements UserContainer {
this.authors = authors; this.authors = authors;
} }
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override @Override
public Set<User> getUsers() { public Set<User> getUsers() {
return getAuthors(); return getAuthors();

View File

@ -29,6 +29,7 @@ public class PaperDto {
@NotEmpty @NotEmpty
private List<Deadline> deadlines = new ArrayList<>(); private List<Deadline> deadlines = new ArrayList<>();
private String comment; private String comment;
private String url;
private Boolean locked; private Boolean locked;
private String tmpFileName; private String tmpFileName;
private Integer fileId; private Integer fileId;
@ -50,6 +51,7 @@ public class PaperDto {
@JsonProperty("updateDate") Date updateDate, @JsonProperty("updateDate") Date updateDate,
@JsonProperty("deadlines") List<Deadline> deadlines, @JsonProperty("deadlines") List<Deadline> deadlines,
@JsonProperty("comment") String comment, @JsonProperty("comment") String comment,
@JsonProperty("url") String url,
@JsonProperty("locked") Boolean locked, @JsonProperty("locked") Boolean locked,
@JsonProperty("tmpFileName") String tmpFileName, @JsonProperty("tmpFileName") String tmpFileName,
@JsonProperty("authorIds") Set<Integer> authorIds, @JsonProperty("authorIds") Set<Integer> authorIds,
@ -61,6 +63,7 @@ public class PaperDto {
this.updateDate = updateDate; this.updateDate = updateDate;
this.deadlines = deadlines; this.deadlines = deadlines;
this.comment = comment; this.comment = comment;
this.url = url;
this.locked = locked; this.locked = locked;
this.tmpFileName = tmpFileName; this.tmpFileName = tmpFileName;
this.fileId = null; this.fileId = null;
@ -77,6 +80,7 @@ public class PaperDto {
this.updateDate = paper.getUpdateDate(); this.updateDate = paper.getUpdateDate();
this.deadlines = paper.getDeadlines(); this.deadlines = paper.getDeadlines();
this.comment = paper.getComment(); this.comment = paper.getComment();
this.url = paper.getUrl();
this.locked = paper.getLocked(); this.locked = paper.getLocked();
this.tmpFileName = null; this.tmpFileName = null;
this.fileId = paper.getFileData() == null ? null : paper.getFileData().getId(); this.fileId = paper.getFileData() == null ? null : paper.getFileData().getId();
@ -198,6 +202,14 @@ public class PaperDto {
this.authorIds = authorIds; this.authorIds = authorIds;
} }
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getAuthorsString() { public String getAuthorsString() {
return StringUtils.abbreviate(authors return StringUtils.abbreviate(authors
.stream() .stream()

View File

@ -14,20 +14,12 @@ import ru.ulstu.user.model.User;
import ru.ulstu.user.service.UserService; import ru.ulstu.user.service.UserService;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.*;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.springframework.util.ObjectUtils.isEmpty; import static org.springframework.util.ObjectUtils.isEmpty;
import static ru.ulstu.core.util.StreamApiUtils.convert; 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.*;
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;
@Service @Service
public class PaperService { public class PaperService {
@ -82,6 +74,7 @@ public class PaperService {
private Paper copyFromDto(Paper paper, PaperDto paperDto) throws IOException { private Paper copyFromDto(Paper paper, PaperDto paperDto) throws IOException {
paper.setComment(paperDto.getComment()); paper.setComment(paperDto.getComment());
paper.setUrl(paperDto.getUrl());
paper.setCreateDate(paper.getCreateDate() == null ? new Date() : paper.getCreateDate()); paper.setCreateDate(paper.getCreateDate() == null ? new Date() : paper.getCreateDate());
paper.setLocked(paperDto.getLocked()); paper.setLocked(paperDto.getLocked());
paper.setStatus(paperDto.getStatus() == null ? DRAFT : paperDto.getStatus()); paper.setStatus(paperDto.getStatus() == null ? DRAFT : paperDto.getStatus());

View File

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

View File

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

View File

@ -10,7 +10,13 @@
<span th:replace="papers/fragments/paperStatusFragment :: paperStatus(paperStatus=${paper.status})"/> <span th:replace="papers/fragments/paperStatusFragment :: paperStatus(paperStatus=${paper.status})"/>
</div> </div>
<div class="col col-10 text-right"> <div class="col col-10 text-right">
<p th:if="${paper.url!=null and paper.url!=''}"><a th:href="${paper.url}"><i
class="fa fa-external-link fa-2x"
aria-hidden="true"></i></a></p>
<p th:unless="${paper.url!=null and paper.url!=''}"><i class="fa fa-fw fa-2x" aria-hidden="true"></i></p>
<a th:href="'paper?id='+${paper.id}">
<h7 class="service-heading" th:text="${paper.title}"> title</h7> <h7 class="service-heading" th:text="${paper.title}"> title</h7>
</a>
<p class="text-muted" th:text="${paper.authorsString}">authors</p> <p class="text-muted" th:text="${paper.authorsString}">authors</p>
</div> </div>
</div> </div>

View File

@ -50,6 +50,13 @@
th:field="*{comment}"></textarea> th:field="*{comment}"></textarea>
</div> </div>
<div class="form-group">
<label for="title">Ссылка на сайт конференции:</label>
<input class="form-control" id="url" type="text"
placeholder="Url"
th:field="*{url}"/>
</div>
<div class="form-group"> <div class="form-group">
<label>Дедлайны:</label> <label>Дедлайны:</label>
<div class="row" th:each="deadline, rowStat : *{deadlines}"> <div class="row" th:each="deadline, rowStat : *{deadlines}">