Resolve "Тип статьи" #194

Merged
SemenovaMasha merged 1 commits from 110-paper-type into dev 5 years ago

@ -105,6 +105,11 @@ public class PaperController {
return paperService.getPaperStatuses();
}
@ModelAttribute("allTypes")
public List<Paper.PaperType> getPaperTypes() {
return paperService.getPaperTypes();
}
@ModelAttribute("allAuthors")
public List<User> getAllAuthors() {
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
private String title;
@Enumerated(value = EnumType.STRING)
private PaperStatus status = PaperStatus.DRAFT;
@Enumerated(value = EnumType.STRING)
private PaperType type = PaperType.OTHER;
@Column(name = "create_date")
@Temporal(TemporalType.TIMESTAMP)
private Date createDate = new Date();
@ -102,6 +122,14 @@ public class Paper extends BaseEntity implements UserContainer {
this.status = status;
}
public PaperType getType() {
return type;
}
public void setType(PaperType type) {
this.type = type;
}
public Date getCreateDate() {
return createDate;
}

@ -25,6 +25,7 @@ public class PaperDto {
@Size(min = 3, max = 254)
private String title;
private Paper.PaperStatus status;
private Paper.PaperType type;
private Date createDate;
private Date updateDate;
@NotEmpty
@ -46,6 +47,7 @@ public class PaperDto {
public PaperDto(@JsonProperty("id") Integer id,
@JsonProperty("title") String title,
@JsonProperty("status") Paper.PaperStatus status,
@JsonProperty("type") Paper.PaperType type,
@JsonProperty("createDate") Date createDate,
@JsonProperty("updateDate") Date updateDate,
@JsonProperty("deadlines") List<Deadline> deadlines,
@ -59,6 +61,7 @@ public class PaperDto {
this.id = id;
this.title = title;
this.status = status;
this.type = type;
this.createDate = createDate;
this.updateDate = updateDate;
this.deadlines = deadlines;
@ -74,6 +77,7 @@ public class PaperDto {
this.id = paper.getId();
this.title = paper.getTitle();
this.status = paper.getStatus();
this.type = paper.getType();
this.createDate = paper.getCreateDate();
this.updateDate = paper.getUpdateDate();
this.deadlines = paper.getDeadlines();
@ -110,6 +114,14 @@ public class PaperDto {
this.status = status;
}
public Paper.PaperType getType() {
return type;
}
public void setType(Paper.PaperType type) {
this.type = type;
}
public Date getCreateDate() {
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.FAILED;
import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION;
import static ru.ulstu.paper.model.Paper.PaperType.OTHER;
@Service
public class PaperService {
@ -99,6 +100,7 @@ public class PaperService {
paper.setCreateDate(paper.getCreateDate() == null ? new Date() : paper.getCreateDate());
paper.setLocked(paperDto.getLocked());
paper.setStatus(paperDto.getStatus() == null ? DRAFT : paperDto.getStatus());
paper.setType(paperDto.getType() == null ? OTHER : paperDto.getType());
paper.setTitle(paperDto.getTitle());
paper.setUpdateDate(new Date());
paper.setDeadlines(deadlineService.saveOrCreate(paperDto.getDeadlines()));
@ -149,6 +151,10 @@ public class PaperService {
return Arrays.asList(Paper.PaperStatus.values());
}
public List<Paper.PaperType> getPaperTypes() {
return Arrays.asList(Paper.PaperType.values());
}
@Transactional
public Paper create(String title, User user, Date deadlineDate) {
Paper paper = new Paper();
@ -158,6 +164,7 @@ public class PaperService {
paper.setCreateDate(new Date());
paper.setUpdateDate(new Date());
paper.setStatus(DRAFT);
paper.setType(OTHER);
paper = paperRepository.save(paper);
paperNotificationService.sendCreateNotification(paper);

@ -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/changelog-20190402_000000-schema.xml"/>
<include file="db/changelog-20190404_000000-schema.xml"/>
<include file="db/changelog-20190421_000000-schema.xml"/>
</databaseChangeLog>

@ -47,6 +47,15 @@
<p class="help-block text-danger"></p>
</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">
<label for="status">Статус:</label>
<select class="form-control" th:field="*{status}" id="status">

Loading…
Cancel
Save