#97 dashboard added
commit
ba565746f5
@ -0,0 +1,110 @@
|
||||
package ru.ulstu.conference.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import ru.ulstu.core.model.BaseEntity;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Entity
|
||||
@Table(name = "users_conference")
|
||||
public class ConferenceUser extends BaseEntity {
|
||||
|
||||
public enum Participation {
|
||||
INTRAMURAL("Очная"),
|
||||
EXTRAMURAL("Заочная");
|
||||
|
||||
private String participationName;
|
||||
|
||||
Participation(String name) {
|
||||
this.participationName = name;
|
||||
}
|
||||
|
||||
public String getParticipation() {
|
||||
return participationName;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Deposit {
|
||||
ARTICLE("Статья"),
|
||||
REPORT("Доклад"),
|
||||
PRESENTATION("Презентация");
|
||||
|
||||
private String depositName;
|
||||
|
||||
Deposit(String name) {
|
||||
this.depositName = name;
|
||||
}
|
||||
|
||||
public String getDeposit() {
|
||||
return depositName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Column(name = "participation", nullable = false)
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private Participation participation = Participation.INTRAMURAL;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "deposit", nullable = false)
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private Deposit deposit = Deposit.ARTICLE;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "users_id")
|
||||
private User user;
|
||||
|
||||
public ConferenceUser() {
|
||||
}
|
||||
|
||||
public ConferenceUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public ConferenceUser(@JsonProperty("id") Integer id,
|
||||
@JsonProperty("deposit") Participation participation,
|
||||
@JsonProperty("deposit") Deposit deposit,
|
||||
@JsonProperty("user") User user) {
|
||||
this.setId(id);
|
||||
this.participation = participation;
|
||||
this.deposit = deposit;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
||||
public Participation getParticipation() {
|
||||
return participation;
|
||||
}
|
||||
|
||||
public void setParticipation(Participation participation) {
|
||||
this.participation = participation;
|
||||
}
|
||||
|
||||
public Deposit getDeposit() {
|
||||
return deposit;
|
||||
}
|
||||
|
||||
public void setDeposit(Deposit deposit) {
|
||||
this.deposit = deposit;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,19 @@
|
||||
package ru.ulstu.conference.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.conference.model.Conference;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ConferenceRepository extends JpaRepository<Conference, Integer> {
|
||||
@Query("SELECT c FROM Conference c LEFT JOIN c.users u WHERE (:user IS NULL OR u.user = :user) " +
|
||||
"AND (YEAR(c.beginDate) = :year OR :year IS NULL) ORDER BY begin_date DESC")
|
||||
List<Conference> findByUserAndYear(@Param("user") User user, @Param("year") Integer year);
|
||||
|
||||
@Query("SELECT c FROM Conference c WHERE c.beginDate > :date")
|
||||
List<Conference> findAllActive(@Param("date") Date date);
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.conference.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import ru.ulstu.conference.model.ConferenceUser;
|
||||
|
||||
public interface ConferenceUserRepository extends JpaRepository<ConferenceUser, Integer> {
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package ru.ulstu.conference.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.ulstu.conference.model.ConferenceUser;
|
||||
import ru.ulstu.conference.repository.ConferenceUserRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class ConferenceUserService {
|
||||
|
||||
private final ConferenceUserRepository conferenceUserRepository;
|
||||
|
||||
public ConferenceUserService(ConferenceUserRepository conferenceUserRepository) {
|
||||
this.conferenceUserRepository = conferenceUserRepository;
|
||||
}
|
||||
|
||||
public List<ConferenceUser> saveOrCreate(List<ConferenceUser> users) {
|
||||
return users
|
||||
.stream()
|
||||
.map(user -> {
|
||||
return user.getId() != null ? update(user) : create(user);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ConferenceUser update(ConferenceUser user) {
|
||||
ConferenceUser updateUser = conferenceUserRepository.findOne(user.getId());
|
||||
updateUser.setDeposit(user.getDeposit());
|
||||
updateUser.setParticipation(user.getParticipation());
|
||||
conferenceUserRepository.save(updateUser);
|
||||
return updateUser;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ConferenceUser create(ConferenceUser user) {
|
||||
ConferenceUser newUser = new ConferenceUser();
|
||||
newUser.setDeposit(user.getDeposit());
|
||||
newUser.setParticipation(user.getParticipation());
|
||||
newUser.setUser(user.getUser());
|
||||
newUser = conferenceUserRepository.save(newUser);
|
||||
return newUser;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package ru.ulstu.grant.model;
|
||||
|
||||
public class GrantStatusDto {
|
||||
private final String id;
|
||||
private final String name;
|
||||
|
||||
public GrantStatusDto(Grant.GrantStatus status) {
|
||||
this.id = status.name();
|
||||
this.name = status.getStatusName();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package ru.ulstu.paper.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.file.service.FileService;
|
||||
import ru.ulstu.paper.model.PaperDto;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
|
||||
@Service
|
||||
public class LatexService {
|
||||
private final String pdfLatexError = "Errors occurred while executing pdfLaTeX.";
|
||||
private final String bibtexError = "Errors occurred while executing bibtex.";
|
||||
private String errorMessage;
|
||||
private File pdfFile;
|
||||
private FileService fileService;
|
||||
|
||||
public LatexService(FileService fileService) {
|
||||
this.fileService = fileService;
|
||||
}
|
||||
|
||||
public byte[] generatePdfFromLatexFile(PaperDto paper) throws IOException, InterruptedException {
|
||||
fileService.createLatexAttachs(paper);
|
||||
File tex = fileService.createLatexFile(paper);
|
||||
|
||||
if (!generate(paper.getTitle(), tex.getParentFile())) {
|
||||
throw new IOException(errorMessage);
|
||||
}
|
||||
|
||||
return Files.readAllBytes(pdfFile.toPath());
|
||||
}
|
||||
|
||||
private int startProcess(String[] args, File dir, String message) throws IOException, InterruptedException {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(args);
|
||||
processBuilder.redirectErrorStream(true);
|
||||
processBuilder.directory(dir);
|
||||
|
||||
Process process = processBuilder.start();
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream());
|
||||
|
||||
try (BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
|
||||
while ((bufferedReader.readLine()) != null) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
int exitCode = process.waitFor();
|
||||
if (exitCode != 0) {
|
||||
errorMessage = message + " Exit value of the process: " + exitCode;
|
||||
}
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
private boolean generate(String filename, File dir) throws IOException, InterruptedException {
|
||||
startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError);
|
||||
startProcess(new String[]{"bibtex", filename}, dir, bibtexError);
|
||||
if (startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError) != 0) {
|
||||
return false;
|
||||
}
|
||||
return checkPdf(filename, dir);
|
||||
}
|
||||
|
||||
private boolean checkPdf(String filename, File dir) {
|
||||
pdfFile = new File(dir.getAbsolutePath() + File.separator + filename + ".pdf");
|
||||
|
||||
if (pdfFile.isFile()) {
|
||||
return true;
|
||||
} else {
|
||||
errorMessage = "The pdf file could not be created.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
@ -0,0 +1,26 @@
|
||||
<?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="tanya" id="20190402_000000-1">
|
||||
<addColumn tableName="grants">
|
||||
<column name="leader_id" type="integer"></column>
|
||||
</addColumn>
|
||||
<addForeignKeyConstraint baseTableName="grants" baseColumnNames="leader_id"
|
||||
constraintName="fk_grants_leader_id" referencedTableName="users"
|
||||
referencedColumnNames="id"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="tanya" id="20190402_000000-2">
|
||||
<createTable tableName="grants_authors">
|
||||
<column name="grant_id" type="integer"/>
|
||||
<column name="authors_id" type="integer"/>
|
||||
</createTable>
|
||||
<addForeignKeyConstraint baseTableName="grants_authors" baseColumnNames="grant_id"
|
||||
constraintName="fk_grants_grants_authors" referencedTableName="grants"
|
||||
referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="grants_authors" baseColumnNames="authors_id"
|
||||
constraintName="fk_user_grants_authors" referencedTableName="users"
|
||||
referencedColumnNames="id"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -0,0 +1,13 @@
|
||||
<?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="tanya" id="20190404_000000-1">
|
||||
<addColumn tableName="users">
|
||||
<column name="birth_date" type="timestamp"></column>
|
||||
</addColumn>
|
||||
<addColumn tableName="users">
|
||||
<column name="degree" type="varchar(255)"></column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -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="vova" id="20190417_000000-1">
|
||||
<addColumn tableName="users_conference">
|
||||
<column name="id" type="integer"></column>
|
||||
<column name="version" type="integer"></column>
|
||||
</addColumn>
|
||||
<addPrimaryKey columnNames="id" constraintName="pk_users_conference" tableName="users_conference"/>
|
||||
<modifyDataType tableName="users_conference" columnName="participation" newDataType="varchar(255)"/>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
@ -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>
|
@ -0,0 +1,12 @@
|
||||
.div-deadline-date {
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
.form-deadline-date{
|
||||
padding-right: 3px;
|
||||
}
|
||||
|
||||
.div-deadline-description{
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
@ -1,5 +1,9 @@
|
||||
#files-list .row > div:nth-child(6) {
|
||||
#files-list .row > div:nth-child(7) {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.nav-tabs {
|
||||
margin-bottom: 20px;
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<body>
|
||||
<div th:fragment="filesList (isLatexAttach)" th:remove="tag">
|
||||
<th:block th:each="file, rowStat : *{files}">
|
||||
|
||||
<span th:if="${(!isLatexAttach and file.isLatexAttach == null) or file.isLatexAttach == isLatexAttach}" th:remove="tag">
|
||||
|
||||
<div class="row" th:id="|files${rowStat.index}|"
|
||||
th:style="${file.deleted} ? 'display: none;' :''">
|
||||
<input type="hidden" th:field="*{files[__${rowStat.index}__].id}"/>
|
||||
<input type="hidden"
|
||||
th:field="*{files[__${rowStat.index}__].deleted}"/>
|
||||
<input type="hidden"
|
||||
th:field="*{files[__${rowStat.index}__].name}"/>
|
||||
<input type="hidden"
|
||||
th:field="*{files[__${rowStat.index}__].tmpFileName}"/>
|
||||
<input type="hidden"
|
||||
th:field="*{files[__${rowStat.index}__].isLatexAttach}"/>
|
||||
<div class="col-2">
|
||||
<a class="btn btn-danger float-right"
|
||||
th:onclick="|$('#files${rowStat.index}\\.deleted').val('true'); $('#files${rowStat.index}').hide(); |">
|
||||
<span aria-hidden="true"><i class="fa fa-times"/></span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-10">
|
||||
<a th:onclick="${file.id==null} ? 'downloadFile('+${file.tmpFileName}+',null,\''+${file.name}+'\')':
|
||||
'downloadFile(null,'+${file.id}+',\''+${file.name}+'\')' "
|
||||
href="javascript:void(0)"
|
||||
th:text="*{files[__${rowStat.index}__].name}">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</th:block>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue