#110 add paper type
This commit is contained in:
parent
bc98785be9
commit
a3d1834ab8
@ -105,6 +105,11 @@ public class PaperController {
|
|||||||
return paperService.getPaperStatuses();
|
return paperService.getPaperStatuses();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("allTypes")
|
||||||
|
public List<Paper.PaperType> getPaperTypes() {
|
||||||
|
return paperService.getPaperTypes();
|
||||||
|
}
|
||||||
|
|
||||||
@ModelAttribute("allAuthors")
|
@ModelAttribute("allAuthors")
|
||||||
public List<User> getAllAuthors() {
|
public List<User> getAllAuthors() {
|
||||||
return paperService.getPaperAuthors();
|
return paperService.getPaperAuthors();
|
||||||
|
@ -53,12 +53,32 @@ public class Paper extends BaseEntity implements UserContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PaperType {
|
||||||
|
OTHER("Прочая публикация"),
|
||||||
|
VAK("ВАК"),
|
||||||
|
SCOPUS("Scopus"),
|
||||||
|
WEB_OF_SCIENCE("Web Of Science");
|
||||||
|
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
PaperType(String name) {
|
||||||
|
this.typeName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypeName() {
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
@Enumerated(value = EnumType.STRING)
|
@Enumerated(value = EnumType.STRING)
|
||||||
private PaperStatus status = PaperStatus.DRAFT;
|
private PaperStatus status = PaperStatus.DRAFT;
|
||||||
|
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
private PaperType type = PaperType.OTHER;
|
||||||
|
|
||||||
@Column(name = "create_date")
|
@Column(name = "create_date")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date createDate = new Date();
|
private Date createDate = new Date();
|
||||||
@ -102,6 +122,14 @@ public class Paper extends BaseEntity implements UserContainer {
|
|||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PaperType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(PaperType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
public Date getCreateDate() {
|
public Date getCreateDate() {
|
||||||
return createDate;
|
return createDate;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ public class PaperDto {
|
|||||||
@Size(min = 3, max = 254)
|
@Size(min = 3, max = 254)
|
||||||
private String title;
|
private String title;
|
||||||
private Paper.PaperStatus status;
|
private Paper.PaperStatus status;
|
||||||
|
private Paper.PaperType type;
|
||||||
private Date createDate;
|
private Date createDate;
|
||||||
private Date updateDate;
|
private Date updateDate;
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
@ -46,6 +47,7 @@ public class PaperDto {
|
|||||||
public PaperDto(@JsonProperty("id") Integer id,
|
public PaperDto(@JsonProperty("id") Integer id,
|
||||||
@JsonProperty("title") String title,
|
@JsonProperty("title") String title,
|
||||||
@JsonProperty("status") Paper.PaperStatus status,
|
@JsonProperty("status") Paper.PaperStatus status,
|
||||||
|
@JsonProperty("type") Paper.PaperType type,
|
||||||
@JsonProperty("createDate") Date createDate,
|
@JsonProperty("createDate") Date createDate,
|
||||||
@JsonProperty("updateDate") Date updateDate,
|
@JsonProperty("updateDate") Date updateDate,
|
||||||
@JsonProperty("deadlines") List<Deadline> deadlines,
|
@JsonProperty("deadlines") List<Deadline> deadlines,
|
||||||
@ -59,6 +61,7 @@ public class PaperDto {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
this.type = type;
|
||||||
this.createDate = createDate;
|
this.createDate = createDate;
|
||||||
this.updateDate = updateDate;
|
this.updateDate = updateDate;
|
||||||
this.deadlines = deadlines;
|
this.deadlines = deadlines;
|
||||||
@ -74,6 +77,7 @@ public class PaperDto {
|
|||||||
this.id = paper.getId();
|
this.id = paper.getId();
|
||||||
this.title = paper.getTitle();
|
this.title = paper.getTitle();
|
||||||
this.status = paper.getStatus();
|
this.status = paper.getStatus();
|
||||||
|
this.type = paper.getType();
|
||||||
this.createDate = paper.getCreateDate();
|
this.createDate = paper.getCreateDate();
|
||||||
this.updateDate = paper.getUpdateDate();
|
this.updateDate = paper.getUpdateDate();
|
||||||
this.deadlines = paper.getDeadlines();
|
this.deadlines = paper.getDeadlines();
|
||||||
@ -110,6 +114,14 @@ public class PaperDto {
|
|||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Paper.PaperType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Paper.PaperType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
public Date getCreateDate() {
|
public Date getCreateDate() {
|
||||||
return createDate;
|
return createDate;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ 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.DRAFT;
|
||||||
import static ru.ulstu.paper.model.Paper.PaperStatus.FAILED;
|
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.ON_PREPARATION;
|
||||||
|
import static ru.ulstu.paper.model.Paper.PaperType.OTHER;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PaperService {
|
public class PaperService {
|
||||||
@ -99,6 +100,7 @@ public class PaperService {
|
|||||||
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());
|
||||||
|
paper.setType(paperDto.getType() == null ? OTHER : paperDto.getType());
|
||||||
paper.setTitle(paperDto.getTitle());
|
paper.setTitle(paperDto.getTitle());
|
||||||
paper.setUpdateDate(new Date());
|
paper.setUpdateDate(new Date());
|
||||||
paper.setDeadlines(deadlineService.saveOrCreate(paperDto.getDeadlines()));
|
paper.setDeadlines(deadlineService.saveOrCreate(paperDto.getDeadlines()));
|
||||||
@ -149,6 +151,10 @@ public class PaperService {
|
|||||||
return Arrays.asList(Paper.PaperStatus.values());
|
return Arrays.asList(Paper.PaperStatus.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Paper.PaperType> getPaperTypes() {
|
||||||
|
return Arrays.asList(Paper.PaperType.values());
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Paper create(String title, User user, Date deadlineDate) {
|
public Paper create(String title, User user, Date deadlineDate) {
|
||||||
Paper paper = new Paper();
|
Paper paper = new Paper();
|
||||||
@ -158,6 +164,7 @@ public class PaperService {
|
|||||||
paper.setCreateDate(new Date());
|
paper.setCreateDate(new Date());
|
||||||
paper.setUpdateDate(new Date());
|
paper.setUpdateDate(new Date());
|
||||||
paper.setStatus(DRAFT);
|
paper.setStatus(DRAFT);
|
||||||
|
paper.setType(OTHER);
|
||||||
paper = paperRepository.save(paper);
|
paper = paperRepository.save(paper);
|
||||||
|
|
||||||
paperNotificationService.sendCreateNotification(paper);
|
paperNotificationService.sendCreateNotification(paper);
|
||||||
|
15
src/main/resources/db/changelog-20190421_000000-schema.xml
Normal file
15
src/main/resources/db/changelog-20190421_000000-schema.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?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="20190421_000000-1">
|
||||||
|
<addColumn tableName="paper">
|
||||||
|
<column name="type" type="varchar(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="masha" id="20190421_000000-2">
|
||||||
|
<update tableName="paper">
|
||||||
|
<column name="type" value="OTHER"/>
|
||||||
|
</update>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -30,4 +30,5 @@
|
|||||||
<include file="db/common/changelog-20190312_130000-schema.xml"/>
|
<include file="db/common/changelog-20190312_130000-schema.xml"/>
|
||||||
<include file="db/changelog-20190402_000000-schema.xml"/>
|
<include file="db/changelog-20190402_000000-schema.xml"/>
|
||||||
<include file="db/changelog-20190404_000000-schema.xml"/>
|
<include file="db/changelog-20190404_000000-schema.xml"/>
|
||||||
|
<include file="db/changelog-20190421_000000-schema.xml"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
@ -47,6 +47,15 @@
|
|||||||
<p class="help-block text-danger"></p>
|
<p class="help-block text-danger"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="type">Тип статьи:</label>
|
||||||
|
<select class="form-control" th:field="*{type}" id="type">
|
||||||
|
<option th:each="type : ${allTypes}" th:value="${type}"
|
||||||
|
th:text="${type.typeName}">Type
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="status">Статус:</label>
|
<label for="status">Статус:</label>
|
||||||
<select class="form-control" th:field="*{status}" id="status">
|
<select class="form-control" th:field="*{status}" id="status">
|
||||||
|
Loading…
Reference in New Issue
Block a user