Merge branch 'move-to-jdk11' into 'dev'
update versions Closes #73 See merge request romanov73/ng-tracker!34
This commit is contained in:
commit
9e6993f136
@ -1,4 +1,4 @@
|
|||||||
image: romanov73/is:ng-tracker-container
|
image: romanov73/is:ng-tracker-container-11
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||||
|
13
build.gradle
13
build.gradle
@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
versionSpringBoot = '1.5.10.RELEASE'
|
versionSpringBoot = '2.1.6.RELEASE'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@ -105,13 +105,14 @@ dependencies {
|
|||||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jetty'
|
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jetty'
|
||||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
|
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
|
||||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
|
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
|
||||||
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4'
|
compile group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect'
|
||||||
|
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity5'
|
||||||
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-afterburner'
|
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-afterburner'
|
||||||
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5'
|
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5'
|
||||||
|
|
||||||
compile group: 'postgresql', name: 'postgresql', version: '9.1-901.jdbc4'
|
compile group: 'org.postgresql', name: 'postgresql', version: '42.2.5'
|
||||||
|
|
||||||
compile group: 'org.liquibase', name: 'liquibase-core', version: '3.5.3'
|
compile group: 'org.liquibase', name: 'liquibase-core', version: '3.6.3'
|
||||||
compile group: 'com.mattbertolini', name: 'liquibase-slf4j', version: '2.0.0'
|
compile group: 'com.mattbertolini', name: 'liquibase-slf4j', version: '2.0.0'
|
||||||
|
|
||||||
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
|
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
|
||||||
@ -129,6 +130,6 @@ dependencies {
|
|||||||
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
|
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
|
||||||
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.3.1'
|
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.3.1'
|
||||||
testCompile group: 'org.seleniumhq.selenium', name: 'selenium-support', version: '3.3.1'
|
testCompile group: 'org.seleniumhq.selenium', name: 'selenium-support', version: '3.3.1'
|
||||||
testCompile group: 'com.google.guava', name: 'guava', version: '21.0'
|
//testCompile group: 'com.google.guava', name: 'guava', version: '21.0'
|
||||||
|
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
|
||||||
}
|
}
|
@ -18,6 +18,6 @@ fi
|
|||||||
|
|
||||||
ssh $USERSERVER "cd /tmp && rm -rf $ARTIFACT_NAME*.jar && echo `date` 'killed' >> log_$ARTIFACT_NAME"
|
ssh $USERSERVER "cd /tmp && rm -rf $ARTIFACT_NAME*.jar && echo `date` 'killed' >> log_$ARTIFACT_NAME"
|
||||||
scp build/libs/$ARTIFACT_NAME-0.1.0-SNAPSHOT.jar $USERSERVER:/tmp/$ARTIFACT_NAME-0.1.0-SNAPSHOT.jar
|
scp build/libs/$ARTIFACT_NAME-0.1.0-SNAPSHOT.jar $USERSERVER:/tmp/$ARTIFACT_NAME-0.1.0-SNAPSHOT.jar
|
||||||
ssh $USERSERVER -f "cd /tmp/ && /opt/jdk1.8.0_192/bin/java -jar $ARTIFACT_NAME-0.1.0-SNAPSHOT.jar -Xms 512m -Xmx 1024m --server.port=8443 --server.http.port=8080 --ng-tracker.base-url=http://193.110.3.124:8080 --ng-tracker.dev-mode=false --ng-tracker.driver-path=/home/user >> /home/user/logfile_$ARTIFACT_NAME" &
|
ssh $USERSERVER -f "cd /tmp/ && /opt/jdk11/bin/java -jar $ARTIFACT_NAME-0.1.0-SNAPSHOT.jar -Xms 512m -Xmx 1024m --server.port=8443 --server.http.port=8080 --ng-tracker.base-url=http://193.110.3.124:8080 --ng-tracker.dev-mode=false --ng-tracker.driver-path=/home/user >> /home/user/logfile_$ARTIFACT_NAME" &
|
||||||
sleep 10
|
sleep 10
|
||||||
echo "is deployed"
|
echo "is deployed"
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
|
||||||
|
@ -4,20 +4,17 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import ru.ulstu.configuration.Constants;
|
|
||||||
import ru.ulstu.core.model.response.PageableItems;
|
|
||||||
import ru.ulstu.commit.model.CommitListDto;
|
import ru.ulstu.commit.model.CommitListDto;
|
||||||
import ru.ulstu.commit.service.CommitService;
|
import ru.ulstu.commit.service.CommitService;
|
||||||
|
import ru.ulstu.configuration.Constants;
|
||||||
|
import ru.ulstu.core.model.response.PageableItems;
|
||||||
import ru.ulstu.core.model.response.Response;
|
import ru.ulstu.core.model.response.Response;
|
||||||
import ru.ulstu.odin.controller.OdinController;
|
import ru.ulstu.odin.controller.OdinController;
|
||||||
import ru.ulstu.odin.model.OdinVoid;
|
import ru.ulstu.odin.model.OdinVoid;
|
||||||
|
|
||||||
import static ru.ulstu.commit.controller.CommitController.URL;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(URL)
|
@RequestMapping(Constants.API_1_0 + "commits")
|
||||||
public class CommitController extends OdinController<CommitListDto, OdinVoid> {
|
public class CommitController extends OdinController<CommitListDto, OdinVoid> {
|
||||||
public static final String URL = Constants.API_1_0 + "commits";
|
|
||||||
private final CommitService commitService;
|
private final CommitService commitService;
|
||||||
|
|
||||||
public CommitController(CommitService commitService) {
|
public CommitController(CommitService commitService) {
|
||||||
|
@ -2,7 +2,6 @@ package ru.ulstu.conference.model;
|
|||||||
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.core.model.EventSource;
|
import ru.ulstu.core.model.EventSource;
|
||||||
@ -25,6 +24,7 @@ import javax.persistence.OrderBy;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -2,14 +2,15 @@ package ru.ulstu.conference.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.name.NameContainer;
|
import ru.ulstu.name.NameContainer;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.paper.model.Paper;
|
||||||
|
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -90,8 +91,8 @@ public class ConferenceDto extends NameContainer {
|
|||||||
this.beginDate = conference.getBeginDate();
|
this.beginDate = conference.getBeginDate();
|
||||||
this.endDate = conference.getEndDate();
|
this.endDate = conference.getEndDate();
|
||||||
this.deadlines = conference.getDeadlines();
|
this.deadlines = conference.getDeadlines();
|
||||||
this.userIds = convert(conference.getUsers(), user -> user.getId());
|
this.userIds = convert(conference.getUsers(), BaseEntity::getId);
|
||||||
this.paperIds = convert(conference.getPapers(), paper -> paper.getId());
|
this.paperIds = convert(conference.getPapers(), BaseEntity::getId);
|
||||||
this.users = conference.getUsers();
|
this.users = conference.getUsers();
|
||||||
this.papers = conference.getPapers();
|
this.papers = conference.getPapers();
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class ConferenceUser extends BaseEntity {
|
|||||||
INTRAMURAL("Очная"),
|
INTRAMURAL("Очная"),
|
||||||
EXTRAMURAL("Заочная");
|
EXTRAMURAL("Заочная");
|
||||||
|
|
||||||
private String participationName;
|
private final String participationName;
|
||||||
|
|
||||||
Participation(String name) {
|
Participation(String name) {
|
||||||
this.participationName = name;
|
this.participationName = name;
|
||||||
@ -38,7 +38,7 @@ public class ConferenceUser extends BaseEntity {
|
|||||||
REPORT("Доклад"),
|
REPORT("Доклад"),
|
||||||
PRESENTATION("Презентация");
|
PRESENTATION("Презентация");
|
||||||
|
|
||||||
private String depositName;
|
private final String depositName;
|
||||||
|
|
||||||
Deposit(String name) {
|
Deposit(String name) {
|
||||||
this.depositName = name;
|
this.depositName = name;
|
||||||
|
@ -63,7 +63,7 @@ public class ConferenceNotificationService {
|
|||||||
|
|
||||||
public void sendCreateNotification(Conference conference) {
|
public void sendCreateNotification(Conference conference) {
|
||||||
Map<String, Object> variables = ImmutableMap.of("conference", conference);
|
Map<String, Object> variables = ImmutableMap.of("conference", conference);
|
||||||
sendForAllUsers(variables, TEMPLATE_CREATE, String.format(TITLE_CREATE, conference.getTitle()));
|
sendForAllUsers(variables, String.format(TITLE_CREATE, conference.getTitle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDeadlineNotification(Conference conference) {
|
public void updateDeadlineNotification(Conference conference) {
|
||||||
@ -76,8 +76,8 @@ public class ConferenceNotificationService {
|
|||||||
sendForAllParticipants(variables, conference, TEMPLATE_UPDATE_DATES, String.format(TITLE_UPDATE_DATES, conference.getTitle()));
|
sendForAllParticipants(variables, conference, TEMPLATE_UPDATE_DATES, String.format(TITLE_UPDATE_DATES, conference.getTitle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendForAllUsers(Map<String, Object> variables, String template, String title) {
|
private void sendForAllUsers(Map<String, Object> variables, String title) {
|
||||||
userService.findAll().forEach(user -> mailService.sendEmailFromTemplate(variables, user, template, title));
|
userService.findAll().forEach(user -> mailService.sendEmailFromTemplate(variables, user, ConferenceNotificationService.TEMPLATE_CREATE, title));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendForAllParticipants(Map<String, Object> variables, Conference conference, String template, String title) {
|
private void sendForAllParticipants(Map<String, Object> variables, Conference conference, String template, String title) {
|
||||||
|
@ -16,7 +16,6 @@ import ru.ulstu.deadline.service.DeadlineService;
|
|||||||
import ru.ulstu.name.BaseService;
|
import ru.ulstu.name.BaseService;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.paper.model.Paper;
|
||||||
import ru.ulstu.paper.service.PaperService;
|
import ru.ulstu.paper.service.PaperService;
|
||||||
import ru.ulstu.ping.model.Ping;
|
|
||||||
import ru.ulstu.ping.service.PingService;
|
import ru.ulstu.ping.service.PingService;
|
||||||
import ru.ulstu.timeline.service.EventService;
|
import ru.ulstu.timeline.service.EventService;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
@ -66,7 +65,7 @@ public class ConferenceService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ConferenceDto getExistConferenceById(Integer id) {
|
public ConferenceDto getExistConferenceById(Integer id) {
|
||||||
ConferenceDto conferenceDto = new ConferenceDto(conferenceRepository.findOne(id));
|
ConferenceDto conferenceDto = new ConferenceDto(conferenceRepository.getOne(id));
|
||||||
conferenceDto.setNotSelectedPapers(getNotSelectPapers(conferenceDto.getPaperIds()));
|
conferenceDto.setNotSelectedPapers(getNotSelectPapers(conferenceDto.getPaperIds()));
|
||||||
conferenceDto.setDisabledTakePart(isCurrentUserParticipant(conferenceDto.getUsers()));
|
conferenceDto.setDisabledTakePart(isCurrentUserParticipant(conferenceDto.getUsers()));
|
||||||
return conferenceDto;
|
return conferenceDto;
|
||||||
@ -97,7 +96,6 @@ public class ConferenceService extends BaseService {
|
|||||||
checkUniqueName(conferenceDto,
|
checkUniqueName(conferenceDto,
|
||||||
errors,
|
errors,
|
||||||
conferenceDto.getId(),
|
conferenceDto.getId(),
|
||||||
"title",
|
|
||||||
"Конференция с таким именем уже существует");
|
"Конференция с таким именем уже существует");
|
||||||
if (errors.hasErrors()) {
|
if (errors.hasErrors()) {
|
||||||
return false;
|
return false;
|
||||||
@ -122,8 +120,8 @@ public class ConferenceService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Conference update(ConferenceDto conferenceDto) throws IOException {
|
private Conference update(ConferenceDto conferenceDto) throws IOException {
|
||||||
Conference conference = conferenceRepository.findOne(conferenceDto.getId());
|
Conference conference = conferenceRepository.getOne(conferenceDto.getId());
|
||||||
List<Deadline> oldDeadlines = conference.getDeadlines().stream()
|
List<Deadline> oldDeadlines = conference.getDeadlines().stream()
|
||||||
.map(this::copyDeadline)
|
.map(this::copyDeadline)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@ -141,9 +139,9 @@ public class ConferenceService extends BaseService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean delete(Integer conferenceId) {
|
public boolean delete(Integer conferenceId) {
|
||||||
if (conferenceRepository.exists(conferenceId)) {
|
if (conferenceRepository.existsById(conferenceId)) {
|
||||||
eventService.removeConferencesEvent(conferenceRepository.findOne(conferenceId));
|
eventService.removeConferencesEvent(conferenceRepository.getOne(conferenceId));
|
||||||
conferenceRepository.delete(conferenceId);
|
conferenceRepository.deleteById(conferenceId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -249,7 +247,7 @@ public class ConferenceService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Conference findOne(Integer conferenceId) {
|
private Conference findOne(Integer conferenceId) {
|
||||||
return conferenceRepository.findOne(conferenceId);
|
return conferenceRepository.getOne(conferenceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChartData(ModelMap modelMap) {
|
public void setChartData(ModelMap modelMap) {
|
||||||
@ -294,7 +292,7 @@ public class ConferenceService extends BaseService {
|
|||||||
return newDeadline;
|
return newDeadline;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkEmptyFieldsOfDeadline(ConferenceDto conferenceDto, Errors errors) {
|
private void checkEmptyFieldsOfDeadline(ConferenceDto conferenceDto, Errors errors) {
|
||||||
for (Deadline deadline : conferenceDto.getDeadlines()) {
|
for (Deadline deadline : conferenceDto.getDeadlines()) {
|
||||||
if (deadline.getDate() == null || deadline.getDescription().isEmpty()) {
|
if (deadline.getDate() == null || deadline.getDescription().isEmpty()) {
|
||||||
errors.rejectValue("deadlines", "errorCode", "Все поля дедлайна должны быть заполнены");
|
errors.rejectValue("deadlines", "errorCode", "Все поля дедлайна должны быть заполнены");
|
||||||
|
@ -26,8 +26,8 @@ public class ConferenceUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public ConferenceUser update(ConferenceUser user) {
|
private ConferenceUser update(ConferenceUser user) {
|
||||||
ConferenceUser updateUser = conferenceUserRepository.findOne(user.getId());
|
ConferenceUser updateUser = conferenceUserRepository.getOne(user.getId());
|
||||||
updateUser.setDeposit(user.getDeposit());
|
updateUser.setDeposit(user.getDeposit());
|
||||||
updateUser.setParticipation(user.getParticipation());
|
updateUser.setParticipation(user.getParticipation());
|
||||||
conferenceUserRepository.save(updateUser);
|
conferenceUserRepository.save(updateUser);
|
||||||
@ -35,7 +35,7 @@ public class ConferenceUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public ConferenceUser create(ConferenceUser user) {
|
private ConferenceUser create(ConferenceUser user) {
|
||||||
ConferenceUser newUser = new ConferenceUser();
|
ConferenceUser newUser = new ConferenceUser();
|
||||||
newUser.setDeposit(user.getDeposit());
|
newUser.setDeposit(user.getDeposit());
|
||||||
newUser.setParticipation(user.getParticipation());
|
newUser.setParticipation(user.getParticipation());
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package ru.ulstu.configuration;
|
package ru.ulstu.configuration;
|
||||||
|
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "ng-tracker")
|
@ConfigurationProperties(prefix = "ng-tracker")
|
||||||
@Validated
|
@Validated
|
||||||
|
@ -2,18 +2,18 @@ package ru.ulstu.configuration;
|
|||||||
|
|
||||||
import org.eclipse.jetty.server.ServerConnector;
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyServerCustomizer;
|
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class HttpListenerConfiguration implements EmbeddedServletContainerCustomizer {
|
public class HttpListenerConfiguration implements WebServerFactoryCustomizer<ConfigurableWebServerFactory> {
|
||||||
@Value("${server.http.port}")
|
@Value("${server.http.port}")
|
||||||
private int httpPort;
|
private int httpPort;
|
||||||
|
|
||||||
private void configureJetty(JettyEmbeddedServletContainerFactory jettyFactory) {
|
private void configureJetty(JettyServletWebServerFactory jettyFactory) {
|
||||||
jettyFactory.addServerCustomizers((JettyServerCustomizer) server -> {
|
jettyFactory.addServerCustomizers((JettyServerCustomizer) server -> {
|
||||||
ServerConnector serverConnector = new ServerConnector(server);
|
ServerConnector serverConnector = new ServerConnector(server);
|
||||||
serverConnector.setPort(httpPort);
|
serverConnector.setPort(httpPort);
|
||||||
@ -22,9 +22,9 @@ public class HttpListenerConfiguration implements EmbeddedServletContainerCustom
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
public void customize(ConfigurableWebServerFactory factory) {
|
||||||
if (container instanceof JettyEmbeddedServletContainerFactory) {
|
if (factory instanceof JettyServletWebServerFactory) {
|
||||||
configureJetty((JettyEmbeddedServletContainerFactory) container);
|
configureJetty((JettyServletWebServerFactory) factory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package ru.ulstu.configuration;
|
|||||||
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
|
import org.thymeleaf.extras.springsecurity5.dialect.SpringSecurityDialect;
|
||||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
import org.thymeleaf.spring5.SpringTemplateEngine;
|
||||||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
|
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
|
||||||
import org.thymeleaf.templateresolver.ITemplateResolver;
|
import org.thymeleaf.templateresolver.ITemplateResolver;
|
||||||
|
|
||||||
@ -17,30 +17,17 @@ public class MailTemplateConfiguration {
|
|||||||
final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
|
final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
|
||||||
templateEngine.addTemplateResolver(templateResolver);
|
templateEngine.addTemplateResolver(templateResolver);
|
||||||
templateEngine.addTemplateResolver(emailTemplateResolver());
|
templateEngine.addTemplateResolver(emailTemplateResolver());
|
||||||
templateEngine.addTemplateResolver(mvcTemplateResolver());
|
|
||||||
templateEngine.addDialect(new LayoutDialect());
|
templateEngine.addDialect(new LayoutDialect());
|
||||||
templateEngine.addDialect(sec);
|
templateEngine.addDialect(sec);
|
||||||
return templateEngine;
|
return templateEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassLoaderTemplateResolver emailTemplateResolver() {
|
private ClassLoaderTemplateResolver emailTemplateResolver() {
|
||||||
ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver();
|
ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver();
|
||||||
emailTemplateResolver.setPrefix("mail_templates/");
|
emailTemplateResolver.setPrefix("/mail_templates/");
|
||||||
emailTemplateResolver.setTemplateMode("HTML5");
|
emailTemplateResolver.setTemplateMode("HTML");
|
||||||
emailTemplateResolver.setSuffix(".html");
|
emailTemplateResolver.setSuffix(".html");
|
||||||
emailTemplateResolver.setOrder(1);
|
|
||||||
emailTemplateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
emailTemplateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||||
return emailTemplateResolver;
|
return emailTemplateResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassLoaderTemplateResolver mvcTemplateResolver() {
|
|
||||||
ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver();
|
|
||||||
emailTemplateResolver.setPrefix("templates");
|
|
||||||
emailTemplateResolver.setTemplateMode("HTML5");
|
|
||||||
emailTemplateResolver.setSuffix(".html");
|
|
||||||
emailTemplateResolver.setOrder(2);
|
|
||||||
emailTemplateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
|
||||||
return emailTemplateResolver;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package ru.ulstu.configuration;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class MvcConfiguration extends WebMvcConfigurerAdapter {
|
public class MvcConfiguration implements WebMvcConfigurer {
|
||||||
@Override
|
@Override
|
||||||
public void addViewControllers(ViewControllerRegistry registry) {
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
registry.addViewController("/{articlename:\\w+}");
|
registry.addViewController("/{articlename:\\w+}");
|
||||||
|
@ -35,6 +35,11 @@ public class AdviceController {
|
|||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("currentUser")
|
||||||
|
public String getCurrentUser() {
|
||||||
|
return userService.getCurrentUser().getUserAbbreviate();
|
||||||
|
}
|
||||||
|
|
||||||
@ModelAttribute("flashMessage")
|
@ModelAttribute("flashMessage")
|
||||||
public String getFlashMessage() {
|
public String getFlashMessage() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -6,19 +6,19 @@ import org.springframework.data.domain.Sort;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class OffsetablePageRequest implements Pageable, Serializable {
|
public class OffsetablePageRequest implements Pageable, Serializable {
|
||||||
private final int offset;
|
private final long offset;
|
||||||
private final int count;
|
private final int count;
|
||||||
private final Sort sort;
|
private final Sort sort;
|
||||||
|
|
||||||
public OffsetablePageRequest(int offset, int count) {
|
public OffsetablePageRequest(long offset, int count) {
|
||||||
this(offset, count, null);
|
this(offset, count, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OffsetablePageRequest(int offset, int count, Sort.Direction direction, String... properties) {
|
public OffsetablePageRequest(long offset, int count, Sort.Direction direction, String... properties) {
|
||||||
this(offset, count, new Sort(direction, properties));
|
this(offset, count, new Sort(direction, properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
public OffsetablePageRequest(int offset, int count, Sort sort) {
|
public OffsetablePageRequest(long offset, int count, Sort sort) {
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
throw new IllegalArgumentException("Offset value must not be less than zero!");
|
throw new IllegalArgumentException("Offset value must not be less than zero!");
|
||||||
}
|
}
|
||||||
@ -42,11 +42,11 @@ public class OffsetablePageRequest implements Pageable, Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPageNumber() {
|
public int getPageNumber() {
|
||||||
return offset / count;
|
return (int) (offset / count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOffset() {
|
public long getOffset() {
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public class OffsetablePageRequest implements Pageable, Serializable {
|
|||||||
return hasPrevious() ? previous() : first();
|
return hasPrevious() ? previous() : first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pageable previous() {
|
private Pageable previous() {
|
||||||
return getOffset() == 0 ? this : new OffsetablePageRequest(getOffset() - getPageSize(), getPageSize(), getSort());
|
return getOffset() == 0 ? this : new OffsetablePageRequest(getOffset() - getPageSize(), getPageSize(), getSort());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,9 +89,9 @@ public class OffsetablePageRequest implements Pageable, Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
long result = 1;
|
||||||
result = prime * result + offset;
|
result = prime * result + offset;
|
||||||
result = prime * result + count;
|
result = prime * result + count;
|
||||||
return result;
|
return (int) result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,11 @@ import javax.persistence.GenerationType;
|
|||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class BaseEntity implements Serializable, Comparable {
|
public abstract class BaseEntity implements Serializable, Comparable<BaseEntity> {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.TABLE)
|
@GeneratedValue(strategy = GenerationType.TABLE)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
@ -16,14 +17,6 @@ public abstract class BaseEntity implements Serializable, Comparable {
|
|||||||
@Version
|
@Version
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
|
||||||
public BaseEntity() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseEntity(Integer id, Integer version) {
|
|
||||||
this.id = id;
|
|
||||||
this.version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -75,8 +68,8 @@ public abstract class BaseEntity implements Serializable, Comparable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Object o) {
|
public int compareTo(@NotNull BaseEntity o) {
|
||||||
return id != null ? id.compareTo(((BaseEntity) o).getId()) : -1;
|
return id != null ? id.compareTo(o.getId()) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
@ -16,8 +16,8 @@ public enum ErrorConstants {
|
|||||||
FILE_UPLOAD_ERROR(110, "File upload error"),
|
FILE_UPLOAD_ERROR(110, "File upload error"),
|
||||||
USER_SENDING_MAIL_EXCEPTION(111, "Во время отправки приглашения пользователю произошла ошибка");
|
USER_SENDING_MAIL_EXCEPTION(111, "Во время отправки приглашения пользователю произошла ошибка");
|
||||||
|
|
||||||
private int code;
|
private final int code;
|
||||||
private String message;
|
private final String message;
|
||||||
|
|
||||||
ErrorConstants(int code, String message) {
|
ErrorConstants(int code, String message) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
package ru.ulstu.core.model;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TreeDto {
|
|
||||||
private Integer id;
|
|
||||||
private String text;
|
|
||||||
private List<TreeDto> children = new ArrayList<>();
|
|
||||||
|
|
||||||
public TreeDto() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends TreeEntity> TreeDto(TreeEntity item) {
|
|
||||||
this.text = item.toString();
|
|
||||||
this.id = item.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TreeDto(String rootName) {
|
|
||||||
this.text = rootName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getText() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TreeDto> getChildren() {
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package ru.ulstu.core.model;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface TreeEntity<T> {
|
|
||||||
|
|
||||||
Integer getId();
|
|
||||||
|
|
||||||
List<T> getChildren();
|
|
||||||
|
|
||||||
void setChildren(List<T> children);
|
|
||||||
|
|
||||||
T getParent();
|
|
||||||
|
|
||||||
void setParent(T parent);
|
|
||||||
}
|
|
@ -6,5 +6,6 @@ import java.util.Set;
|
|||||||
|
|
||||||
public interface UserActivity {
|
public interface UserActivity {
|
||||||
String getTitle();
|
String getTitle();
|
||||||
|
|
||||||
Set<User> getActivityUsers();
|
Set<User> getActivityUsers();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package ru.ulstu.core.model.response;
|
package ru.ulstu.core.model.response;
|
||||||
|
|
||||||
class ControllerResponse<D, E> {
|
class ControllerResponse<D, E> {
|
||||||
private D data;
|
private final D data;
|
||||||
private ControllerResponseError<E> error;
|
private final ControllerResponseError<E> error;
|
||||||
|
|
||||||
ControllerResponse(D data) {
|
ControllerResponse(D data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
@ -3,8 +3,8 @@ package ru.ulstu.core.model.response;
|
|||||||
import ru.ulstu.core.model.ErrorConstants;
|
import ru.ulstu.core.model.ErrorConstants;
|
||||||
|
|
||||||
class ControllerResponseError<D> {
|
class ControllerResponseError<D> {
|
||||||
private ErrorConstants description;
|
private final ErrorConstants description;
|
||||||
private D data;
|
private final D data;
|
||||||
|
|
||||||
ControllerResponseError(ErrorConstants description, D data) {
|
ControllerResponseError(ErrorConstants description, D data) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
@ -8,7 +8,7 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
public class JpaDetachableRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRepository<T, ID>
|
public class JpaDetachableRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRepository<T, ID>
|
||||||
implements JpaDetachableRepository<T, ID> {
|
implements JpaDetachableRepository<T, ID> {
|
||||||
private EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
public JpaDetachableRepositoryImpl(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager) {
|
public JpaDetachableRepositoryImpl(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager) {
|
||||||
super(entityInformation, entityManager);
|
super(entityInformation, entityManager);
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package ru.ulstu.core.util;
|
|
||||||
|
|
||||||
public class NumberUtils {
|
|
||||||
public static Double ceil(Double number) {
|
|
||||||
if (number == null) {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
return Double.valueOf(Math.ceil(number));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Double round(Double number) {
|
|
||||||
if (number == null) {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
return Double.valueOf(Math.ceil(number * 100)) / 100;
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,12 +11,12 @@ public class StreamApiUtils {
|
|||||||
public static <T, R> List<T> convert(List<R> entities, Function<R, T> converter) {
|
public static <T, R> List<T> convert(List<R> entities, Function<R, T> converter) {
|
||||||
return entities == null
|
return entities == null
|
||||||
? Collections.emptyList()
|
? Collections.emptyList()
|
||||||
: entities.stream().map(e -> converter.apply(e)).collect(Collectors.toList());
|
: entities.stream().map(converter).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, R> Set<T> convert(Set<R> entities, Function<R, T> converter) {
|
public static <T, R> Set<T> convert(Set<R> entities, Function<R, T> converter) {
|
||||||
return entities == null
|
return entities == null
|
||||||
? Collections.emptySet()
|
? Collections.emptySet()
|
||||||
: entities.stream().map(e -> converter.apply(e)).collect(Collectors.toSet());
|
: entities.stream().map(converter).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ public class DeadlineService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Deadline update(Deadline deadline) {
|
private Deadline update(Deadline deadline) {
|
||||||
Deadline updateDeadline = deadlineRepository.findOne(deadline.getId());
|
Deadline updateDeadline = deadlineRepository.getOne(deadline.getId());
|
||||||
updateDeadline.setDate(deadline.getDate());
|
updateDeadline.setDate(deadline.getDate());
|
||||||
updateDeadline.setDescription(deadline.getDescription());
|
updateDeadline.setDescription(deadline.getDescription());
|
||||||
updateDeadline.setExecutors(deadline.getExecutors());
|
updateDeadline.setExecutors(deadline.getExecutors());
|
||||||
@ -49,7 +49,7 @@ public class DeadlineService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void remove(Integer deadlineId) {
|
public void remove(Integer deadlineId) {
|
||||||
deadlineRepository.delete(deadlineId);
|
deadlineRepository.deleteById(deadlineId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date findByGrantIdAndDate(Integer id, Date date) {
|
public Date findByGrantIdAndDate(Integer id, Date date) {
|
||||||
|
@ -21,13 +21,10 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static ru.ulstu.file.FileController.URL;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(URL)
|
@RequestMapping(Constants.API_1_0 + "files")
|
||||||
public class FileController {
|
public class FileController {
|
||||||
public static final String URL = Constants.API_1_0 + "files";
|
|
||||||
|
|
||||||
private final FileService fileService;
|
private final FileService fileService;
|
||||||
|
|
||||||
public FileController(FileService fileService) {
|
public FileController(FileService fileService) {
|
||||||
@ -53,6 +50,6 @@ public class FileController {
|
|||||||
|
|
||||||
@PostMapping("/uploadTmpFile")
|
@PostMapping("/uploadTmpFile")
|
||||||
public Response<FileDataDto> upload(@RequestParam("file") MultipartFile multipartFile) throws IOException {
|
public Response<FileDataDto> upload(@RequestParam("file") MultipartFile multipartFile) throws IOException {
|
||||||
return new Response(fileService.createFromMultipartFile(multipartFile));
|
return new Response<>(fileService.createFromMultipartFile(multipartFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,15 +27,15 @@ public class FileService {
|
|||||||
private final static int META_FILE_NAME_INDEX = 0;
|
private final static int META_FILE_NAME_INDEX = 0;
|
||||||
private final static int META_FILE_SIZE_INDEX = 1;
|
private final static int META_FILE_SIZE_INDEX = 1;
|
||||||
|
|
||||||
private String tmpDir;
|
private final String tmpDir;
|
||||||
private FileRepository fileRepository;
|
private final FileRepository fileRepository;
|
||||||
|
|
||||||
public FileService(FileRepository fileRepository) {
|
public FileService(FileRepository fileRepository) {
|
||||||
tmpDir = System.getProperty("java.io.tmpdir");
|
tmpDir = System.getProperty("java.io.tmpdir");
|
||||||
this.fileRepository = fileRepository;
|
this.fileRepository = fileRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileData createFileFromTmp(String tmpFileName) throws IOException {
|
private FileData createFileFromTmp(String tmpFileName) throws IOException {
|
||||||
FileData fileData = new FileData();
|
FileData fileData = new FileData();
|
||||||
fileData.setData(getTmpFile(tmpFileName));
|
fileData.setData(getTmpFile(tmpFileName));
|
||||||
fileData.setSize(getTmpFileSize(tmpFileName));
|
fileData.setSize(getTmpFileSize(tmpFileName));
|
||||||
@ -43,7 +43,7 @@ public class FileService {
|
|||||||
return fileRepository.save(fileData);
|
return fileRepository.save(fileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String uploadToTmpDir(MultipartFile multipartFile) throws IOException {
|
private String uploadToTmpDir(MultipartFile multipartFile) throws IOException {
|
||||||
String tmpFileName = String.valueOf(System.currentTimeMillis()) + UUID.randomUUID();
|
String tmpFileName = String.valueOf(System.currentTimeMillis()) + UUID.randomUUID();
|
||||||
Files.write(getTmpFilePath(tmpFileName), multipartFile.getBytes());
|
Files.write(getTmpFilePath(tmpFileName), multipartFile.getBytes());
|
||||||
String meta = multipartFile.getOriginalFilename() + "\n" + multipartFile.getSize();
|
String meta = multipartFile.getOriginalFilename() + "\n" + multipartFile.getSize();
|
||||||
@ -56,7 +56,7 @@ public class FileService {
|
|||||||
.split("\n");
|
.split("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTmpFileSize(String tmpFileName) throws IOException {
|
private long getTmpFileSize(String tmpFileName) throws IOException {
|
||||||
return Long.valueOf(getMeta(tmpFileName)[META_FILE_SIZE_INDEX]).longValue();
|
return Long.valueOf(getMeta(tmpFileName)[META_FILE_SIZE_INDEX]).longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public class FileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FileData getFile(Integer fileId) {
|
public FileData getFile(Integer fileId) {
|
||||||
return fileRepository.findOne(fileId);
|
return fileRepository.getOne(fileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteTmpFile(String tmpFileName) throws IOException {
|
public void deleteTmpFile(String tmpFileName) throws IOException {
|
||||||
@ -97,13 +97,13 @@ public class FileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public FileData update(FileDataDto fileDataDto) {
|
private FileData update(FileDataDto fileDataDto) {
|
||||||
FileData file = fileRepository.findOne(fileDataDto.getId());
|
FileData file = fileRepository.getOne(fileDataDto.getId());
|
||||||
return fileRepository.save(copyFromDto(file, fileDataDto));
|
return fileRepository.save(copyFromDto(file, fileDataDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public FileData create(FileDataDto fileDataDto) throws IOException {
|
private FileData create(FileDataDto fileDataDto) throws IOException {
|
||||||
FileData newFile = createFileFromTmp(fileDataDto.getTmpFileName());
|
FileData newFile = createFileFromTmp(fileDataDto.getTmpFileName());
|
||||||
copyFromDto(newFile, fileDataDto);
|
copyFromDto(newFile, fileDataDto);
|
||||||
return fileRepository.save(newFile);
|
return fileRepository.save(newFile);
|
||||||
@ -117,7 +117,7 @@ public class FileService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delete(Integer fileId) {
|
public void delete(Integer fileId) {
|
||||||
fileRepository.delete(fileRepository.findOne(fileId));
|
fileRepository.delete(fileRepository.getOne(fileId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileDataDto createFromMultipartFile(MultipartFile multipartFile) throws IOException {
|
public FileDataDto createFromMultipartFile(MultipartFile multipartFile) throws IOException {
|
||||||
@ -134,7 +134,7 @@ public class FileService {
|
|||||||
File renamed = getTmpFilePath(fileDataDto.getName()).toFile();
|
File renamed = getTmpFilePath(fileDataDto.getName()).toFile();
|
||||||
oldFile.renameTo(renamed);
|
oldFile.renameTo(renamed);
|
||||||
} else {
|
} else {
|
||||||
Files.write(getTmpFilePath(fileDataDto.getName()), fileRepository.findOne(fileDataDto.getId()).getData());
|
Files.write(getTmpFilePath(fileDataDto.getName()), fileRepository.getOne(fileDataDto.getId()).getData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package ru.ulstu.grant.model;
|
|||||||
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.core.model.EventSource;
|
import ru.ulstu.core.model.EventSource;
|
||||||
import ru.ulstu.core.model.UserActivity;
|
import ru.ulstu.core.model.UserActivity;
|
||||||
@ -26,6 +25,7 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.OrderBy;
|
import javax.persistence.OrderBy;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -50,7 +50,7 @@ public class Grant extends BaseEntity implements UserActivity, EventSource {
|
|||||||
LOADED_FROM_KIAS("Загружен автоматически"),
|
LOADED_FROM_KIAS("Загружен автоматически"),
|
||||||
SKIPPED("Не интересует");
|
SKIPPED("Не интересует");
|
||||||
|
|
||||||
private String statusName;
|
private final String statusName;
|
||||||
|
|
||||||
GrantStatus(String statusName) {
|
GrantStatus(String statusName) {
|
||||||
this.statusName = statusName;
|
this.statusName = statusName;
|
||||||
|
@ -3,7 +3,6 @@ package ru.ulstu.grant.model;
|
|||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.file.model.FileDataDto;
|
import ru.ulstu.file.model.FileDataDto;
|
||||||
import ru.ulstu.name.NameContainer;
|
import ru.ulstu.name.NameContainer;
|
||||||
@ -11,6 +10,7 @@ import ru.ulstu.paper.model.PaperDto;
|
|||||||
import ru.ulstu.project.model.ProjectDto;
|
import ru.ulstu.project.model.ProjectDto;
|
||||||
import ru.ulstu.user.model.UserDto;
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -79,8 +79,7 @@ public class GrantService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GrantDto getExistGrantById(Integer id) {
|
public GrantDto getExistGrantById(Integer id) {
|
||||||
GrantDto grantDto = new GrantDto(findById(id));
|
return new GrantDto(findById(id));
|
||||||
return grantDto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Grant> findAll() {
|
public List<Grant> findAll() {
|
||||||
@ -134,7 +133,7 @@ public class GrantService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Integer update(GrantDto grantDto) throws IOException {
|
private Integer update(GrantDto grantDto) throws IOException {
|
||||||
Grant grant = findById(grantDto.getId());
|
Grant grant = findById(grantDto.getId());
|
||||||
Set<User> oldAuthors = new HashSet<>(grant.getAuthors());
|
Set<User> oldAuthors = new HashSet<>(grant.getAuthors());
|
||||||
User oldLeader = grant.getLeader();
|
User oldLeader = grant.getLeader();
|
||||||
@ -182,7 +181,7 @@ public class GrantService extends BaseService {
|
|||||||
filterEmptyDeadlines(grantDto);
|
filterEmptyDeadlines(grantDto);
|
||||||
checkEmptyDeadlines(grantDto, errors);
|
checkEmptyDeadlines(grantDto, errors);
|
||||||
checkEmptyLeader(grantDto, errors);
|
checkEmptyLeader(grantDto, errors);
|
||||||
checkUniqueName(grantDto, errors, grantDto.getId(), "title", "Грант с таким именем уже существует");
|
checkUniqueName(grantDto, errors, grantDto.getId(), "Грант с таким именем уже существует");
|
||||||
if (errors.hasErrors()) {
|
if (errors.hasErrors()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -194,7 +193,7 @@ public class GrantService extends BaseService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean saveFromKias(GrantDto grantDto) throws IOException {
|
private boolean saveFromKias(GrantDto grantDto) throws IOException {
|
||||||
grantDto.setName(grantDto.getTitle());
|
grantDto.setName(grantDto.getTitle());
|
||||||
String title = checkUniqueName(grantDto, grantDto.getId()); //проверка уникальности имени
|
String title = checkUniqueName(grantDto, grantDto.getId()); //проверка уникальности имени
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
@ -332,7 +331,7 @@ public class GrantService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Grant findById(Integer id) {
|
public Grant findById(Integer id) {
|
||||||
return grantRepository.findOne(id);
|
return grantRepository.getOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -23,12 +23,10 @@ public class KiasService {
|
|||||||
private final static String CONTEST_TYPE = "-1";
|
private final static String CONTEST_TYPE = "-1";
|
||||||
|
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final ApplicationProperties applicationProperties;
|
|
||||||
|
|
||||||
public KiasService(UserService userService,
|
public KiasService(UserService userService,
|
||||||
ApplicationProperties applicationProperties) {
|
ApplicationProperties applicationProperties) {
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.applicationProperties = applicationProperties;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GrantDto> getNewGrantsDto() throws ParseException, IOException {
|
public List<GrantDto> getNewGrantsDto() throws ParseException, IOException {
|
||||||
@ -46,7 +44,7 @@ public class KiasService {
|
|||||||
return grants;
|
return grants;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GrantDto> getKiasGrants(HtmlPage page) throws ParseException {
|
private List<GrantDto> getKiasGrants(HtmlPage page) throws ParseException {
|
||||||
List<GrantDto> newGrants = new ArrayList<>();
|
List<GrantDto> newGrants = new ArrayList<>();
|
||||||
KiasPage kiasPage = new KiasPage(page);
|
KiasPage kiasPage = new KiasPage(page);
|
||||||
do {
|
do {
|
||||||
|
@ -8,13 +8,13 @@ public abstract class BaseService {
|
|||||||
|
|
||||||
public BaseRepository baseRepository;
|
public BaseRepository baseRepository;
|
||||||
|
|
||||||
public void checkUniqueName(NameContainer nameContainer, Errors errors, Integer id, String checkField, String errorMessage) {
|
protected void checkUniqueName(NameContainer nameContainer, Errors errors, Integer id, String errorMessage) {
|
||||||
if (nameContainer.getName().equals(baseRepository.findByNameAndNotId(nameContainer.getName(), id))) {
|
if (nameContainer.getName().equals(baseRepository.findByNameAndNotId(nameContainer.getName(), id))) {
|
||||||
errors.rejectValue(checkField, "errorCode", errorMessage);
|
errors.rejectValue("title", "errorCode", errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String checkUniqueName(NameContainer nameContainer, Integer id) {
|
protected String checkUniqueName(NameContainer nameContainer, Integer id) {
|
||||||
if (nameContainer.getName().equals(baseRepository.findByNameAndNotId(nameContainer.getName(), id))) {
|
if (nameContainer.getName().equals(baseRepository.findByNameAndNotId(nameContainer.getName(), id))) {
|
||||||
return baseRepository.findByNameAndNotId(nameContainer.getName(), id);
|
return baseRepository.findByNameAndNotId(nameContainer.getName(), id);
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,10 @@ import ru.ulstu.odin.service.OdinService;
|
|||||||
|
|
||||||
public abstract class OdinController<L, E extends OdinDto> {
|
public abstract class OdinController<L, E extends OdinDto> {
|
||||||
public static final String META_LIST_URL = "/meta/list";
|
public static final String META_LIST_URL = "/meta/list";
|
||||||
public static final String META_ELEMENT_URL = "/meta/element";
|
private static final String META_ELEMENT_URL = "/meta/element";
|
||||||
|
|
||||||
private Class<L> listDtoClass;
|
private final Class<L> listDtoClass;
|
||||||
private Class<E> elementDtoClass;
|
private final Class<E> elementDtoClass;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OdinService<L, E> odinService;
|
private OdinService<L, E> odinService;
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package ru.ulstu.odin.model;
|
|||||||
import ru.ulstu.core.error.OdinException;
|
import ru.ulstu.core.error.OdinException;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
@ -14,9 +15,9 @@ public class OdinCollectionField extends OdinField {
|
|||||||
ParameterizedType genericType = (ParameterizedType) field.getGenericType();
|
ParameterizedType genericType = (ParameterizedType) field.getGenericType();
|
||||||
Type fieldElementClass = genericType.getActualTypeArguments()[0];
|
Type fieldElementClass = genericType.getActualTypeArguments()[0];
|
||||||
try {
|
try {
|
||||||
OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).newInstance();
|
OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).getDeclaredConstructor().newInstance();
|
||||||
this.path = someInstance.getControllerPath();
|
this.path = someInstance.getControllerPath();
|
||||||
} catch (IllegalAccessException | InstantiationException e) {
|
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
throw new OdinException(String.format("Can't create new instance, check default constructor of %s",
|
throw new OdinException(String.format("Can't create new instance, check default constructor of %s",
|
||||||
fieldElementClass.getTypeName()));
|
fieldElementClass.getTypeName()));
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package ru.ulstu.odin.model;
|
package ru.ulstu.odin.model;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
|
||||||
import ru.ulstu.core.error.OdinException;
|
import ru.ulstu.core.error.OdinException;
|
||||||
import ru.ulstu.odin.model.annotation.OdinCaption;
|
import ru.ulstu.odin.model.annotation.OdinCaption;
|
||||||
import ru.ulstu.odin.model.annotation.OdinReadOnly;
|
import ru.ulstu.odin.model.annotation.OdinReadOnly;
|
||||||
import ru.ulstu.odin.model.annotation.OdinVisible;
|
import ru.ulstu.odin.model.annotation.OdinVisible;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -31,15 +31,16 @@ public abstract class OdinField implements Comparable {
|
|||||||
return this.name().toLowerCase();
|
return this.name().toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected final OdinFieldType fieldType;
|
|
||||||
protected final String fieldName;
|
|
||||||
protected final String caption;
|
|
||||||
protected final OdinVisible.OdinVisibleType visible;
|
|
||||||
protected final boolean readOnly;
|
|
||||||
protected final boolean notEmpty;
|
|
||||||
private Field field;
|
|
||||||
|
|
||||||
public OdinField(Field field, OdinFieldType fieldType) {
|
private final OdinFieldType fieldType;
|
||||||
|
private final String fieldName;
|
||||||
|
private final String caption;
|
||||||
|
private final OdinVisible.OdinVisibleType visible;
|
||||||
|
private final boolean readOnly;
|
||||||
|
private final boolean notEmpty;
|
||||||
|
private final Field field;
|
||||||
|
|
||||||
|
OdinField(Field field, OdinFieldType fieldType) {
|
||||||
this.field = field;
|
this.field = field;
|
||||||
this.fieldName = getFieldName(field);
|
this.fieldName = getFieldName(field);
|
||||||
this.caption = Optional.ofNullable(getValueFromAnnotation(OdinCaption.class, "value"))
|
this.caption = Optional.ofNullable(getValueFromAnnotation(OdinCaption.class, "value"))
|
||||||
@ -92,7 +93,7 @@ public abstract class OdinField implements Comparable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T> T getValue(Class<? extends Annotation> annotationClass, String valueName, Class<T> clazz) {
|
<T> T getValue(Class<? extends Annotation> annotationClass, String valueName, Class<T> clazz) {
|
||||||
if (field.isAnnotationPresent(annotationClass)) {
|
if (field.isAnnotationPresent(annotationClass)) {
|
||||||
return cast(getValueFromAnnotation(annotationClass, valueName), clazz);
|
return cast(getValueFromAnnotation(annotationClass, valueName), clazz);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package ru.ulstu.odin.model;
|
|||||||
import ru.ulstu.core.error.OdinException;
|
import ru.ulstu.core.error.OdinException;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
public class OdinObjectField extends OdinField {
|
public class OdinObjectField extends OdinField {
|
||||||
@ -12,9 +13,9 @@ public class OdinObjectField extends OdinField {
|
|||||||
super(field, OdinFieldType.OBJECT);
|
super(field, OdinFieldType.OBJECT);
|
||||||
Type fieldElementClass = field.getType();
|
Type fieldElementClass = field.getType();
|
||||||
try {
|
try {
|
||||||
OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).newInstance();
|
OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).getDeclaredConstructor().newInstance();
|
||||||
this.path = someInstance.getControllerPath();
|
this.path = someInstance.getControllerPath();
|
||||||
} catch (IllegalAccessException | InstantiationException e) {
|
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
throw new OdinException(String.format("Can't create new instance, check default constructor of %s",
|
throw new OdinException(String.format("Can't create new instance, check default constructor of %s",
|
||||||
fieldElementClass.getTypeName()));
|
fieldElementClass.getTypeName()));
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package ru.ulstu.odin.model;
|
package ru.ulstu.odin.model;
|
||||||
|
|
||||||
import org.hibernate.validator.constraints.Email;
|
|
||||||
import ru.ulstu.odin.model.annotation.OdinString;
|
import ru.ulstu.odin.model.annotation.OdinString;
|
||||||
import ru.ulstu.odin.model.annotation.OdinString.OdinStringType;
|
import ru.ulstu.odin.model.annotation.OdinString.OdinStringType;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Email;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
package ru.ulstu.odinexample.controller;
|
|
||||||
|
|
||||||
public class OdinExampleController {
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
package ru.ulstu.odinexample.model;
|
|
||||||
|
|
||||||
public class OdinExampleDto {
|
|
||||||
}
|
|
@ -1,103 +0,0 @@
|
|||||||
package ru.ulstu.odinexample.model;
|
|
||||||
|
|
||||||
import ru.ulstu.core.util.DateUtils;
|
|
||||||
import ru.ulstu.odin.model.annotation.OdinCaption;
|
|
||||||
import ru.ulstu.odin.model.annotation.OdinDate;
|
|
||||||
import ru.ulstu.odin.model.annotation.OdinNumeric;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class OdinExampleListDto {
|
|
||||||
@OdinCaption("instant")
|
|
||||||
@OdinDate(type = OdinDate.OdinDateType.DATETIME)
|
|
||||||
private Instant instant;
|
|
||||||
@OdinCaption("date")
|
|
||||||
private Date date;
|
|
||||||
@OdinCaption("localdate")
|
|
||||||
private LocalDate localDate;
|
|
||||||
@OdinCaption("localtime")
|
|
||||||
@OdinDate(type = OdinDate.OdinDateType.TIME)
|
|
||||||
private LocalTime localTime;
|
|
||||||
@OdinCaption("localdatetime")
|
|
||||||
@OdinDate(type = OdinDate.OdinDateType.DATETIME)
|
|
||||||
private LocalDateTime localDateTime;
|
|
||||||
@OdinCaption("int")
|
|
||||||
private int intval;
|
|
||||||
@OdinCaption("int+settings")
|
|
||||||
@OdinNumeric(precision = 5, scale = 2)
|
|
||||||
private int intvalset;
|
|
||||||
@OdinCaption("float")
|
|
||||||
private float floatval;
|
|
||||||
@OdinCaption("double")
|
|
||||||
private double aDouble;
|
|
||||||
@OdinCaption("double+set")
|
|
||||||
@OdinNumeric(precision = 5, scale = 3)
|
|
||||||
private double aDoubles;
|
|
||||||
@OdinCaption("int+positive")
|
|
||||||
@OdinNumeric(positiveOnly = true, scale = 2)
|
|
||||||
private int invalpos;
|
|
||||||
|
|
||||||
public OdinExampleListDto() {
|
|
||||||
this.instant = Instant.now();
|
|
||||||
this.date = new Date();
|
|
||||||
this.localDate = LocalDate.now();
|
|
||||||
this.localTime = LocalTime.now();
|
|
||||||
this.localDateTime = LocalDateTime.now();
|
|
||||||
intval = -134;
|
|
||||||
intvalset = 1343423232;
|
|
||||||
floatval = 2323.44F;
|
|
||||||
aDouble = -232323.43434;
|
|
||||||
aDoubles = 0.456456456;
|
|
||||||
invalpos = -23232323;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Date getInstant() {
|
|
||||||
return DateUtils.instantToDate(instant);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getLocalDate() {
|
|
||||||
return DateUtils.localDateToDate(localDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getLocalTime() {
|
|
||||||
return DateUtils.localTimeToDate(localTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getLocalDateTime() {
|
|
||||||
return DateUtils.localDateTimeToDate(localDateTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIntval() {
|
|
||||||
return intval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIntvalset() {
|
|
||||||
return intvalset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getFloatval() {
|
|
||||||
return floatval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getaDouble() {
|
|
||||||
return aDouble;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getaDoubles() {
|
|
||||||
return aDoubles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getInvalpos() {
|
|
||||||
return invalpos;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
package ru.ulstu.odinexample.service;
|
|
||||||
|
|
||||||
public class OdinExampleService {
|
|
||||||
}
|
|
@ -40,7 +40,7 @@ public class PaperRestController {
|
|||||||
|
|
||||||
@GetMapping("/{paper-id}")
|
@GetMapping("/{paper-id}")
|
||||||
public Response<PaperDto> getPaper(@PathVariable("paper-id") Integer paperId) {
|
public Response<PaperDto> getPaper(@PathVariable("paper-id") Integer paperId) {
|
||||||
return new Response(paperService.findById(paperId));
|
return new Response<>(paperService.findById(paperId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ -56,7 +56,7 @@ public class PaperRestController {
|
|||||||
@DeleteMapping("/{paper-id}")
|
@DeleteMapping("/{paper-id}")
|
||||||
public Response<Boolean> delete(@PathVariable("paper-id") Integer paperId) throws IOException {
|
public Response<Boolean> delete(@PathVariable("paper-id") Integer paperId) throws IOException {
|
||||||
paperService.delete(paperId);
|
paperService.delete(paperId);
|
||||||
return new Response<>(true);
|
return new Response<>(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/filter")
|
@PostMapping("/filter")
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package ru.ulstu.paper.error;
|
|
||||||
|
|
||||||
public class PaperConferenceRelationExistException extends RuntimeException {
|
|
||||||
public PaperConferenceRelationExistException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,6 @@ package ru.ulstu.paper.model;
|
|||||||
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.conference.model.Conference;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.core.model.EventSource;
|
import ru.ulstu.core.model.EventSource;
|
||||||
@ -26,6 +25,7 @@ import javax.persistence.OneToMany;
|
|||||||
import javax.persistence.OrderBy;
|
import javax.persistence.OrderBy;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -48,7 +48,7 @@ public class Paper extends BaseEntity implements UserActivity, EventSource {
|
|||||||
DRAFT("Черновик"),
|
DRAFT("Черновик"),
|
||||||
FAILED("Провалены сроки");
|
FAILED("Провалены сроки");
|
||||||
|
|
||||||
private String statusName;
|
private final String statusName;
|
||||||
|
|
||||||
PaperStatus(String name) {
|
PaperStatus(String name) {
|
||||||
this.statusName = name;
|
this.statusName = name;
|
||||||
@ -65,7 +65,7 @@ public class Paper extends BaseEntity implements UserActivity, EventSource {
|
|||||||
SCOPUS("Scopus"),
|
SCOPUS("Scopus"),
|
||||||
WEB_OF_SCIENCE("Web Of Science");
|
WEB_OF_SCIENCE("Web Of Science");
|
||||||
|
|
||||||
private String typeName;
|
private final String typeName;
|
||||||
|
|
||||||
PaperType(String name) {
|
PaperType(String name) {
|
||||||
this.typeName = name;
|
this.typeName = name;
|
||||||
@ -201,7 +201,7 @@ public class Paper extends BaseEntity implements UserActivity, EventSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getRecipients() {
|
public List<User> getRecipients() {
|
||||||
return new ArrayList(authors);
|
return new ArrayList<>(authors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,11 +3,11 @@ package ru.ulstu.paper.model;
|
|||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.file.model.FileDataDto;
|
import ru.ulstu.file.model.FileDataDto;
|
||||||
import ru.ulstu.user.model.UserDto;
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -8,7 +8,7 @@ public class ReferenceDto {
|
|||||||
ARTICLE("Статья"),
|
ARTICLE("Статья"),
|
||||||
BOOK("Книга");
|
BOOK("Книга");
|
||||||
|
|
||||||
private String typeName;
|
private final String typeName;
|
||||||
|
|
||||||
ReferenceType(String name) {
|
ReferenceType(String name) {
|
||||||
this.typeName = name;
|
this.typeName = name;
|
||||||
@ -23,7 +23,7 @@ public class ReferenceDto {
|
|||||||
GOST("ГОСТ"),
|
GOST("ГОСТ"),
|
||||||
SPRINGER("Springer");
|
SPRINGER("Springer");
|
||||||
|
|
||||||
private String standardName;
|
private final String standardName;
|
||||||
|
|
||||||
FormatStandard(String name) {
|
FormatStandard(String name) {
|
||||||
this.standardName = name;
|
this.standardName = name;
|
||||||
|
@ -12,11 +12,11 @@ import java.nio.file.Files;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class LatexService {
|
public class LatexService {
|
||||||
private final String pdfLatexError = "Errors occurred while executing pdfLaTeX.";
|
private static final String PDF_LATEX_ERROR = "Errors occurred while executing pdfLaTeX.";
|
||||||
private final String bibtexError = "Errors occurred while executing bibtex.";
|
private static final String BIBTEX_ERROR = "Errors occurred while executing bibtex.";
|
||||||
private String errorMessage;
|
private String errorMessage;
|
||||||
private File pdfFile;
|
private File pdfFile;
|
||||||
private FileService fileService;
|
private final FileService fileService;
|
||||||
|
|
||||||
public LatexService(FileService fileService) {
|
public LatexService(FileService fileService) {
|
||||||
this.fileService = fileService;
|
this.fileService = fileService;
|
||||||
@ -56,9 +56,9 @@ public class LatexService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean generate(String filename, File dir) throws IOException, InterruptedException {
|
private boolean generate(String filename, File dir) throws IOException, InterruptedException {
|
||||||
startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError);
|
startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, PDF_LATEX_ERROR);
|
||||||
startProcess(new String[]{"bibtex", filename}, dir, bibtexError);
|
startProcess(new String[]{"bibtex", filename}, dir, BIBTEX_ERROR);
|
||||||
if (startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError) != 0) {
|
if (startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, PDF_LATEX_ERROR) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return checkPdf(filename, dir);
|
return checkPdf(filename, dir);
|
||||||
|
@ -85,7 +85,7 @@ public class PaperService {
|
|||||||
return papers;
|
return papers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Paper> findAllActive() {
|
private List<Paper> findAllActive() {
|
||||||
return findAll()
|
return findAll()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(paper -> paper.getStatus() != COMPLETED && paper.getStatus() != FAILED)
|
.filter(paper -> paper.getStatus() != COMPLETED && paper.getStatus() != FAILED)
|
||||||
@ -97,7 +97,7 @@ public class PaperService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PaperDto findOneDto(Integer id) {
|
public PaperDto findOneDto(Integer id) {
|
||||||
return new PaperDto(paperRepository.findOne(id));
|
return new PaperDto(paperRepository.getOne(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@ -139,7 +139,7 @@ public class PaperService {
|
|||||||
return paper;
|
return paper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Reference> saveOrCreateReferences(List<ReferenceDto> references) {
|
private List<Reference> saveOrCreateReferences(List<ReferenceDto> references) {
|
||||||
return references
|
return references
|
||||||
.stream()
|
.stream()
|
||||||
.filter(reference -> !reference.getDeleted())
|
.filter(reference -> !reference.getDeleted())
|
||||||
@ -148,15 +148,15 @@ public class PaperService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Reference updateReference(ReferenceDto referenceDto) {
|
private Reference updateReference(ReferenceDto referenceDto) {
|
||||||
Reference updateReference = referenceRepository.findOne(referenceDto.getId());
|
Reference updateReference = referenceRepository.getOne(referenceDto.getId());
|
||||||
copyFromDto(updateReference, referenceDto);
|
copyFromDto(updateReference, referenceDto);
|
||||||
referenceRepository.save(updateReference);
|
referenceRepository.save(updateReference);
|
||||||
return updateReference;
|
return updateReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Reference createReference(ReferenceDto referenceDto) {
|
private Reference createReference(ReferenceDto referenceDto) {
|
||||||
Reference newReference = new Reference();
|
Reference newReference = new Reference();
|
||||||
copyFromDto(newReference, referenceDto);
|
copyFromDto(newReference, referenceDto);
|
||||||
newReference = referenceRepository.save(newReference);
|
newReference = referenceRepository.save(newReference);
|
||||||
@ -176,7 +176,7 @@ public class PaperService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Integer update(PaperDto paperDto) throws IOException {
|
public Integer update(PaperDto paperDto) throws IOException {
|
||||||
Paper paper = paperRepository.findOne(paperDto.getId());
|
Paper paper = paperRepository.getOne(paperDto.getId());
|
||||||
Paper.PaperStatus oldStatus = paper.getStatus();
|
Paper.PaperStatus oldStatus = paper.getStatus();
|
||||||
Set<User> oldAuthors = new HashSet<>(paper.getAuthors());
|
Set<User> oldAuthors = new HashSet<>(paper.getAuthors());
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ public class PaperService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delete(Integer paperId) {
|
public void delete(Integer paperId) {
|
||||||
Paper paper = paperRepository.findOne(paperId);
|
Paper paper = paperRepository.getOne(paperId);
|
||||||
paperRepository.delete(paper);
|
paperRepository.delete(paper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,11 +293,11 @@ public class PaperService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PaperDto findById(Integer paperId) {
|
public PaperDto findById(Integer paperId) {
|
||||||
return new PaperDto(paperRepository.findOne(paperId));
|
return new PaperDto(paperRepository.getOne(paperId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Paper findPaperById(Integer paperId) {
|
public Paper findPaperById(Integer paperId) {
|
||||||
return paperRepository.findOne(paperId);
|
return paperRepository.getOne(paperId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Paper> findAllNotSelect(List<Integer> paperIds) {
|
public List<Paper> findAllNotSelect(List<Integer> paperIds) {
|
||||||
@ -358,7 +358,7 @@ public class PaperService {
|
|||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGostReference(ReferenceDto referenceDto) {
|
private String getGostReference(ReferenceDto referenceDto) {
|
||||||
return MessageFormat.format(referenceDto.getReferenceType() == BOOK ? "{0} {1} - {2}{3}. - {4}с." : "{0} {1}{5} {2}{3}. С. {4}.",
|
return MessageFormat.format(referenceDto.getReferenceType() == BOOK ? "{0} {1} - {2}{3}. - {4}с." : "{0} {1}{5} {2}{3}. С. {4}.",
|
||||||
referenceDto.getAuthors(),
|
referenceDto.getAuthors(),
|
||||||
referenceDto.getPublicationTitle(),
|
referenceDto.getPublicationTitle(),
|
||||||
@ -368,7 +368,7 @@ public class PaperService {
|
|||||||
StringUtils.isEmpty(referenceDto.getJournalOrCollectionTitle()) ? "." : " // " + referenceDto.getJournalOrCollectionTitle() + ".");
|
StringUtils.isEmpty(referenceDto.getJournalOrCollectionTitle()) ? "." : " // " + referenceDto.getJournalOrCollectionTitle() + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSpringerReference(ReferenceDto referenceDto) {
|
private String getSpringerReference(ReferenceDto referenceDto) {
|
||||||
return MessageFormat.format("{0} ({1}) {2}.{3} {4}pp {5}",
|
return MessageFormat.format("{0} ({1}) {2}.{3} {4}pp {5}",
|
||||||
referenceDto.getAuthors(),
|
referenceDto.getAuthors(),
|
||||||
referenceDto.getPublicationYear() != null ? referenceDto.getPublicationYear().toString() : "",
|
referenceDto.getPublicationYear() != null ? referenceDto.getPublicationYear().toString() : "",
|
||||||
|
@ -17,14 +17,12 @@ import java.util.List;
|
|||||||
public class PingService {
|
public class PingService {
|
||||||
private final PingRepository pingRepository;
|
private final PingRepository pingRepository;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final PingScheduler pingScheduler;
|
|
||||||
|
|
||||||
public PingService(PingRepository pingRepository,
|
public PingService(PingRepository pingRepository,
|
||||||
UserService userService,
|
UserService userService,
|
||||||
PingScheduler pingScheduler) {
|
PingScheduler pingScheduler) {
|
||||||
this.pingRepository = pingRepository;
|
this.pingRepository = pingRepository;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.pingScheduler = pingScheduler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -2,7 +2,6 @@ package ru.ulstu.project.model;
|
|||||||
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.core.model.EventSource;
|
import ru.ulstu.core.model.EventSource;
|
||||||
import ru.ulstu.core.model.UserActivity;
|
import ru.ulstu.core.model.UserActivity;
|
||||||
@ -23,6 +22,7 @@ import javax.persistence.JoinTable;
|
|||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -42,7 +42,7 @@ public class Project extends BaseEntity implements UserActivity, EventSource {
|
|||||||
CLOSED("Закрыт"),
|
CLOSED("Закрыт"),
|
||||||
FAILED("Провалены сроки");
|
FAILED("Провалены сроки");
|
||||||
|
|
||||||
private String statusName;
|
private final String statusName;
|
||||||
|
|
||||||
ProjectStatus(String statusName) {
|
ProjectStatus(String statusName) {
|
||||||
this.statusName = statusName;
|
this.statusName = statusName;
|
||||||
|
@ -2,7 +2,6 @@ package ru.ulstu.project.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
|
||||||
import org.thymeleaf.util.StringUtils;
|
import org.thymeleaf.util.StringUtils;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.file.model.FileDataDto;
|
import ru.ulstu.file.model.FileDataDto;
|
||||||
@ -10,6 +9,7 @@ import ru.ulstu.grant.model.GrantDto;
|
|||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import ru.ulstu.user.model.UserDto;
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -65,7 +65,7 @@ public class ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ProjectDto findOneDto(Integer id) {
|
public ProjectDto findOneDto(Integer id) {
|
||||||
return new ProjectDto(projectRepository.findOne(id));
|
return new ProjectDto(projectRepository.getOne(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Project.ProjectStatus> getProjectStatuses() {
|
public List<Project.ProjectStatus> getProjectStatuses() {
|
||||||
@ -81,8 +81,8 @@ public class ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Project update(ProjectDto projectDto) throws IOException {
|
private Project update(ProjectDto projectDto) throws IOException {
|
||||||
Project project = projectRepository.findOne(projectDto.getId());
|
Project project = projectRepository.getOne(projectDto.getId());
|
||||||
projectRepository.save(copyFromDto(project, projectDto));
|
projectRepository.save(copyFromDto(project, projectDto));
|
||||||
eventService.updateProjectDeadlines(project);
|
eventService.updateProjectDeadlines(project);
|
||||||
for (FileDataDto file : projectDto.getFiles().stream()
|
for (FileDataDto file : projectDto.getFiles().stream()
|
||||||
@ -95,8 +95,8 @@ public class ProjectService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean delete(Integer projectId) throws IOException {
|
public boolean delete(Integer projectId) throws IOException {
|
||||||
if (projectRepository.exists(projectId)) {
|
if (projectRepository.existsById(projectId)) {
|
||||||
Project project = projectRepository.findOne(projectId);
|
Project project = projectRepository.getOne(projectId);
|
||||||
projectRepository.delete(project);
|
projectRepository.delete(project);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ public class ProjectService {
|
|||||||
project.setStatus(projectDto.getStatus() == null ? TECHNICAL_TASK : projectDto.getStatus());
|
project.setStatus(projectDto.getStatus() == null ? TECHNICAL_TASK : projectDto.getStatus());
|
||||||
project.setTitle(projectDto.getTitle());
|
project.setTitle(projectDto.getTitle());
|
||||||
if (projectDto.getGrant() != null && projectDto.getGrant().getId() != null) {
|
if (projectDto.getGrant() != null && projectDto.getGrant().getId() != null) {
|
||||||
project.setGrant(grantRepository.findOne(projectDto.getGrant().getId()));
|
project.setGrant(grantRepository.getOne(projectDto.getGrant().getId()));
|
||||||
}
|
}
|
||||||
project.setRepository(projectDto.getRepository());
|
project.setRepository(projectDto.getRepository());
|
||||||
project.setDeadlines(deadlineService.saveOrCreate(projectDto.getDeadlines()));
|
project.setDeadlines(deadlineService.saveOrCreate(projectDto.getDeadlines()));
|
||||||
@ -139,12 +139,11 @@ public class ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Project findById(Integer id) {
|
public Project findById(Integer id) {
|
||||||
return projectRepository.findOne(id);
|
return projectRepository.getOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> getProjectExecutors(ProjectDto projectDto) {
|
public List<User> getProjectExecutors(ProjectDto projectDto) {
|
||||||
List<User> users = userService.findAll();
|
return userService.findAll();
|
||||||
return users;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@ -153,12 +152,11 @@ public class ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<GrantDto> getAllGrants() {
|
public List<GrantDto> getAllGrants() {
|
||||||
List<GrantDto> grants = convert(grantRepository.findAll(), GrantDto::new);
|
return convert(grantRepository.findAll(), GrantDto::new);
|
||||||
return grants;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GrantDto> getProjectGrants(List<Integer> grantIds) {
|
private List<GrantDto> getProjectGrants(List<Integer> grantIds) {
|
||||||
return convert(grantRepository.findAll(grantIds), GrantDto::new);
|
return convert(grantRepository.findAllById(grantIds), GrantDto::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachGrant(ProjectDto projectDto) {
|
public void attachGrant(ProjectDto projectDto) {
|
||||||
|
@ -11,7 +11,7 @@ public abstract class EntityCreateStrategy<T extends UserActivity> {
|
|||||||
|
|
||||||
protected abstract void createEntity(User user);
|
protected abstract void createEntity(User user);
|
||||||
|
|
||||||
protected void createDefaultEntityIfNeed(List<User> allUsers, List<? extends UserActivity> entities) {
|
private void createDefaultEntityIfNeed(List<User> allUsers, List<? extends UserActivity> entities) {
|
||||||
allUsers.forEach(user -> {
|
allUsers.forEach(user -> {
|
||||||
if (entities
|
if (entities
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -2,7 +2,7 @@ package ru.ulstu.students.controller;
|
|||||||
|
|
||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
|
|
||||||
public class Navigation {
|
class Navigation {
|
||||||
public static final String REDIRECT_TO = "redirect:%s";
|
public static final String REDIRECT_TO = "redirect:%s";
|
||||||
public static final String TASKS_PAGE = "/students/tasks";
|
public static final String TASKS_PAGE = "/students/tasks";
|
||||||
public static final String TASK_PAGE = "/students/task";
|
public static final String TASK_PAGE = "/students/task";
|
||||||
|
@ -2,14 +2,12 @@ package ru.ulstu.students.model;
|
|||||||
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.core.model.EventSource;
|
import ru.ulstu.core.model.EventSource;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.tags.model.Tag;
|
import ru.ulstu.tags.model.Tag;
|
||||||
import ru.ulstu.timeline.model.Event;
|
import ru.ulstu.timeline.model.Event;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import ru.ulstu.user.service.UserService;
|
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@ -24,7 +22,7 @@ import javax.persistence.OneToMany;
|
|||||||
import javax.persistence.OrderBy;
|
import javax.persistence.OrderBy;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
import javax.persistence.Transient;
|
import javax.validation.constraints.NotBlank;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -39,7 +37,7 @@ public class Task extends BaseEntity implements EventSource {
|
|||||||
FAILED("Провалены сроки"),
|
FAILED("Провалены сроки"),
|
||||||
LOADED_FROM_KIAS("Загружен автоматически");
|
LOADED_FROM_KIAS("Загружен автоматически");
|
||||||
|
|
||||||
private String statusName;
|
private final String statusName;
|
||||||
|
|
||||||
TaskStatus(String name) {
|
TaskStatus(String name) {
|
||||||
this.statusName = name;
|
this.statusName = name;
|
||||||
@ -55,17 +53,10 @@ public class Task extends BaseEntity implements EventSource {
|
|||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Transient
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
public Task() {
|
public Task() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task(UserService userService) {
|
|
||||||
this.userService = userService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Enumerated(value = EnumType.STRING)
|
@Enumerated(value = EnumType.STRING)
|
||||||
private TaskStatus status = TaskStatus.IN_WORK;
|
private TaskStatus status = TaskStatus.IN_WORK;
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@ package ru.ulstu.students.model;
|
|||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.tags.model.Tag;
|
import ru.ulstu.tags.model.Tag;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -38,8 +38,8 @@ public class SchedulerService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
private void delete(Integer schedulerId) {
|
private void delete(Integer schedulerId) {
|
||||||
if (schedulerRepository.exists(schedulerId)) {
|
if (schedulerRepository.existsById(schedulerId)) {
|
||||||
schedulerRepository.delete(schedulerId);
|
schedulerRepository.deleteById(schedulerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class TaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TaskDto findOneDto(Integer id) {
|
public TaskDto findOneDto(Integer id) {
|
||||||
return new TaskDto(taskRepository.findOne(id));
|
return new TaskDto(taskRepository.getOne(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TaskDto> filter(TaskFilterDto filterDto) {
|
public List<TaskDto> filter(TaskFilterDto filterDto) {
|
||||||
@ -101,8 +101,8 @@ public class TaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Integer update(TaskDto taskDto) throws IOException {
|
private Integer update(TaskDto taskDto) throws IOException {
|
||||||
Task task = taskRepository.findOne(taskDto.getId());
|
Task task = taskRepository.getOne(taskDto.getId());
|
||||||
taskRepository.save(copyFromDto(task, taskDto));
|
taskRepository.save(copyFromDto(task, taskDto));
|
||||||
eventService.updateTaskDeadlines(task);
|
eventService.updateTaskDeadlines(task);
|
||||||
return task.getId();
|
return task.getId();
|
||||||
@ -110,13 +110,13 @@ public class TaskService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean delete(Integer taskId) throws IOException {
|
public boolean delete(Integer taskId) throws IOException {
|
||||||
if (taskRepository.exists(taskId)) {
|
if (taskRepository.existsById(taskId)) {
|
||||||
Task scheduleTask = taskRepository.findOne(taskId);
|
Task scheduleTask = taskRepository.getOne(taskId);
|
||||||
Scheduler sch = schedulerRepository.findOneByTask(scheduleTask);
|
Scheduler sch = schedulerRepository.findOneByTask(scheduleTask);
|
||||||
if (sch != null) {
|
if (sch != null) {
|
||||||
schedulerRepository.delete(sch.getId());
|
schedulerRepository.deleteById(sch.getId());
|
||||||
}
|
}
|
||||||
taskRepository.delete(taskId);
|
taskRepository.deleteById(taskId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -2,12 +2,12 @@ package ru.ulstu.tags.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -33,17 +33,17 @@ public class TagService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Tag getExistById(Tag tag) {
|
private Tag getExistById(Tag tag) {
|
||||||
return tagRepository.findOne(tag.getId());
|
return tagRepository.getOne(tag.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Tag isExistByName(String tagName) {
|
private Tag isExistByName(String tagName) {
|
||||||
return tagRepository.findByName(tagName);
|
return tagRepository.findByName(tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Tag create(Tag tag) {
|
private Tag create(Tag tag) {
|
||||||
Tag newTag = new Tag();
|
Tag newTag = new Tag();
|
||||||
newTag.setTagName(tag.getTagName());
|
newTag.setTagName(tag.getTagName());
|
||||||
newTag = tagRepository.save(newTag);
|
newTag = tagRepository.save(newTag);
|
||||||
@ -55,7 +55,7 @@ public class TagService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Tag findById(Integer tagId) {
|
public Tag findById(Integer tagId) {
|
||||||
return tagRepository.findOne(tagId);
|
return tagRepository.getOne(tagId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,9 @@ import ru.ulstu.timeline.service.EventService;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static ru.ulstu.timeline.controller.EventController.URL;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(URL)
|
@RequestMapping(Constants.API_1_0 + "events")
|
||||||
public class EventController {
|
public class EventController {
|
||||||
public static final String URL = Constants.API_1_0 + "events";
|
|
||||||
|
|
||||||
private final EventService eventService;
|
private final EventService eventService;
|
||||||
|
|
||||||
@ -40,18 +37,18 @@ public class EventController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Response createEvent(@RequestBody @Valid EventDto timelineDto) {
|
public Response<Integer> createEvent(@RequestBody @Valid EventDto timelineDto) {
|
||||||
return new Response(eventService.create(timelineDto));
|
return new Response<>(eventService.create(timelineDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public Response updateEvent(@RequestBody @Valid EventDto eventDto) {
|
public Response<Integer> updateEvent(@RequestBody @Valid EventDto eventDto) {
|
||||||
return new Response(eventService.update(eventDto));
|
return new Response<>(eventService.update(eventDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{event-id}")
|
@DeleteMapping("/{event-id}")
|
||||||
public Response delete(@PathVariable("event-id") Integer eventId) {
|
public Response<Boolean> delete(@PathVariable("event-id") Integer eventId) {
|
||||||
eventService.delete(eventId);
|
eventService.delete(eventId);
|
||||||
return new Response(true);
|
return new Response<>(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package ru.ulstu.timeline.model;
|
package ru.ulstu.timeline.model;
|
||||||
|
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.conference.model.Conference;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.grant.model.Grant;
|
import ru.ulstu.grant.model.Grant;
|
||||||
@ -21,6 +20,7 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -31,7 +31,7 @@ public class Event extends BaseEntity {
|
|||||||
public enum EventStatus {
|
public enum EventStatus {
|
||||||
POSSIBLE("Возможное"), NEW("Новое"), IN_PROGRESS("В процессе"), COMPLETED("Завершено");
|
POSSIBLE("Возможное"), NEW("Новое"), IN_PROGRESS("В процессе"), COMPLETED("Завершено");
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
EventStatus(String name) {
|
EventStatus(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -2,7 +2,6 @@ package ru.ulstu.timeline.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
import ru.ulstu.conference.model.ConferenceDto;
|
import ru.ulstu.conference.model.ConferenceDto;
|
||||||
import ru.ulstu.grant.model.GrantDto;
|
import ru.ulstu.grant.model.GrantDto;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
@ -10,6 +9,7 @@ import ru.ulstu.project.model.ProjectDto;
|
|||||||
import ru.ulstu.students.model.TaskDto;
|
import ru.ulstu.students.model.TaskDto;
|
||||||
import ru.ulstu.user.model.UserDto;
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
package ru.ulstu.timeline.model;
|
|
||||||
|
|
||||||
public class EventStatusDto {
|
|
||||||
private final String id;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public EventStatusDto(Event.EventStatus status) {
|
|
||||||
this.id = status.name();
|
|
||||||
this.name = status.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,8 +8,8 @@ public enum PeriodEvent {
|
|||||||
EVERY_WEEK(Period.ofWeeks(1), "Каждую неделю"),
|
EVERY_WEEK(Period.ofWeeks(1), "Каждую неделю"),
|
||||||
EVERY_DAY(Period.ofDays(1), "Каждый день");
|
EVERY_DAY(Period.ofDays(1), "Каждый день");
|
||||||
|
|
||||||
private Period period;
|
private final Period period;
|
||||||
private String message;
|
private final String message;
|
||||||
|
|
||||||
PeriodEvent(Period period, String message) {
|
PeriodEvent(Period period, String message) {
|
||||||
this.period = period;
|
this.period = period;
|
||||||
|
@ -49,7 +49,7 @@ public class EventService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public int create(EventDto eventDto) {
|
public Integer create(EventDto eventDto) {
|
||||||
return eventRepository.save(copyFromDto(new Event(), eventDto)).getId();
|
return eventRepository.save(copyFromDto(new Event(), eventDto)).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class EventService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Integer update(EventDto eventDto) {
|
public Integer update(EventDto eventDto) {
|
||||||
Event event = eventRepository.findOne(eventDto.getId());
|
Event event = eventRepository.getOne(eventDto.getId());
|
||||||
return eventRepository.save(copyFromDto(event, eventDto)).getId();
|
return eventRepository.save(copyFromDto(event, eventDto)).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,13 +78,13 @@ public class EventService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delete(Integer eventId) {
|
public void delete(Integer eventId) {
|
||||||
Event event = eventRepository.findOne(eventId);
|
Event event = eventRepository.getOne(eventId);
|
||||||
event.setParents(null);
|
event.setParents(null);
|
||||||
eventRepository.delete(event);
|
eventRepository.delete(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Event> findByIds(List<Integer> ids) {
|
public List<Event> findByIds(List<Integer> ids) {
|
||||||
return eventRepository.findAll(ids);
|
return eventRepository.findAllById(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createBasedOn(Event event, Date executeDate) {
|
public void createBasedOn(Event event, Date executeDate) {
|
||||||
@ -99,7 +99,7 @@ public class EventService {
|
|||||||
event = eventRepository.save(event);
|
event = eventRepository.save(event);
|
||||||
|
|
||||||
//set child to parent
|
//set child to parent
|
||||||
Event parentEvent = eventRepository.findOne(parentEventId);
|
Event parentEvent = eventRepository.getOne(parentEventId);
|
||||||
parentEvent.setChild(event);
|
parentEvent.setChild(event);
|
||||||
eventRepository.save(parentEvent);
|
eventRepository.save(parentEvent);
|
||||||
}
|
}
|
||||||
@ -134,9 +134,10 @@ public class EventService {
|
|||||||
}
|
}
|
||||||
timelineService.save(timeline);
|
timelineService.save(timeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePaperDeadlines(Paper paper) {
|
public void updatePaperDeadlines(Paper paper) {
|
||||||
List<Event> foundEvents = eventRepository.findAllByPaper(paper);
|
List<Event> foundEvents = eventRepository.findAllByPaper(paper);
|
||||||
eventRepository.delete(foundEvents);
|
eventRepository.deleteAll(foundEvents);
|
||||||
createFromObject(paper, foundEvents, false, "статьи");
|
createFromObject(paper, foundEvents, false, "статьи");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +145,7 @@ public class EventService {
|
|||||||
return eventRepository.findByCurrentDate();
|
return eventRepository.findByCurrentDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Event> findAllFuture() {
|
private List<Event> findAllFuture() {
|
||||||
return eventRepository.findAllFuture();
|
return eventRepository.findAllFuture();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,27 +154,27 @@ public class EventService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateConferenceDeadlines(Conference conference) {
|
public void updateConferenceDeadlines(Conference conference) {
|
||||||
eventRepository.delete(eventRepository.findAllByConference(conference));
|
eventRepository.deleteAll(eventRepository.findAllByConference(conference));
|
||||||
createFromObject(conference, Collections.emptyList(), false, "конференции");
|
createFromObject(conference, Collections.emptyList(), false, "конференции");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateGrantDeadlines(Grant grant) {
|
public void updateGrantDeadlines(Grant grant) {
|
||||||
eventRepository.delete(eventRepository.findAllByGrant(grant));
|
eventRepository.deleteAll(eventRepository.findAllByGrant(grant));
|
||||||
createFromObject(grant, Collections.emptyList(), false, "гранта");
|
createFromObject(grant, Collections.emptyList(), false, "гранта");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateProjectDeadlines(Project project) {
|
public void updateProjectDeadlines(Project project) {
|
||||||
eventRepository.delete(eventRepository.findAllByProject(project));
|
eventRepository.deleteAll(eventRepository.findAllByProject(project));
|
||||||
createFromObject(project, Collections.emptyList(), false, "проекта");
|
createFromObject(project, Collections.emptyList(), false, "проекта");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeConferencesEvent(Conference conference) {
|
public void removeConferencesEvent(Conference conference) {
|
||||||
List<Event> eventList = eventRepository.findAllByConference(conference);
|
List<Event> eventList = eventRepository.findAllByConference(conference);
|
||||||
eventList.forEach(event -> eventRepository.delete(event.getId()));
|
eventList.forEach(event -> eventRepository.deleteById(event.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTaskDeadlines(Task task) {
|
public void updateTaskDeadlines(Task task) {
|
||||||
eventRepository.delete(eventRepository.findAllByTask(task));
|
eventRepository.deleteAll(eventRepository.findAllByTask(task));
|
||||||
createFromObject(task, Collections.emptyList(), true, "задачи");
|
createFromObject(task, Collections.emptyList(), true, "задачи");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -48,13 +48,13 @@ public class TimelineService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Integer update(TimelineDto timelineDto) {
|
public Integer update(TimelineDto timelineDto) {
|
||||||
Timeline timeline = timelineRepository.findOne(timelineDto.getId());
|
Timeline timeline = timelineRepository.getOne(timelineDto.getId());
|
||||||
return timelineRepository.save(copyFromDto(timeline, timelineDto)).getId();
|
return timelineRepository.save(copyFromDto(timeline, timelineDto)).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delete(Integer timelineId) {
|
public void delete(Integer timelineId) {
|
||||||
Timeline timeline = timelineRepository.findOne(timelineId);
|
Timeline timeline = timelineRepository.getOne(timelineId);
|
||||||
timelineRepository.delete(timeline);
|
timelineRepository.delete(timeline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import org.springframework.util.StringUtils;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
public final class IpAddressResolver {
|
final class IpAddressResolver {
|
||||||
private static final String CLIENT_IP_HEADER = "Client-IP";
|
private static final String CLIENT_IP_HEADER = "Client-IP";
|
||||||
private static final String FORWARDED_FOR_HEADER = "X-Forwarded-For";
|
private static final String FORWARDED_FOR_HEADER = "X-Forwarded-For";
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ import static ru.ulstu.user.controller.UserController.URL;
|
|||||||
public class UserController extends OdinController<UserListDto, UserDto> {
|
public class UserController extends OdinController<UserListDto, UserDto> {
|
||||||
public static final String URL = Constants.API_1_0 + "users";
|
public static final String URL = Constants.API_1_0 + "users";
|
||||||
public static final String ROLES_URL = "/roles";
|
public static final String ROLES_URL = "/roles";
|
||||||
public static final String ROLES_META_URL = ROLES_URL + OdinController.META_LIST_URL;
|
private static final String ROLES_META_URL = ROLES_URL + OdinController.META_LIST_URL;
|
||||||
public static final String SESSIONS_URL = "/sessions";
|
private static final String SESSIONS_URL = "/sessions";
|
||||||
public static final String SESSIONS_META_URL = SESSIONS_URL + OdinController.META_LIST_URL;
|
private static final String SESSIONS_META_URL = SESSIONS_URL + OdinController.META_LIST_URL;
|
||||||
public static final String REGISTER_URL = "/register";
|
public static final String REGISTER_URL = "/register";
|
||||||
public static final String ACTIVATE_URL = "/activate";
|
public static final String ACTIVATE_URL = "/activate";
|
||||||
public static final String PASSWORD_RESET_REQUEST_URL = "/password-reset-request";
|
public static final String PASSWORD_RESET_REQUEST_URL = "/password-reset-request";
|
||||||
|
@ -71,11 +71,4 @@ public class UserMvcController extends OdinController<UserListDto, UserDto> {
|
|||||||
"CONFERENCE", "Конференции");
|
"CONFERENCE", "Конференции");
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/pings")
|
|
||||||
public void getPings() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/block")
|
|
||||||
public void getBlock() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package ru.ulstu.user.model;
|
package ru.ulstu.user.model;
|
||||||
|
|
||||||
import org.hibernate.annotations.BatchSize;
|
import org.hibernate.annotations.BatchSize;
|
||||||
import org.hibernate.validator.constraints.Email;
|
|
||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
|
||||||
@ -16,6 +15,7 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.validation.constraints.Email;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
@ -100,7 +100,7 @@ public class User extends BaseEntity {
|
|||||||
CANDIDATE("Кандидат технических наук"),
|
CANDIDATE("Кандидат технических наук"),
|
||||||
DOCTOR("Доктор технических наук");
|
DOCTOR("Доктор технических наук");
|
||||||
|
|
||||||
private String degreeName;
|
private final String degreeName;
|
||||||
|
|
||||||
UserDegree(String degreeName) {
|
UserDegree(String degreeName) {
|
||||||
this.degreeName = degreeName;
|
this.degreeName = degreeName;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package ru.ulstu.user.model;
|
package ru.ulstu.user.model;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import org.hibernate.validator.constraints.Email;
|
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
import ru.ulstu.odin.model.OdinDto;
|
import ru.ulstu.odin.model.OdinDto;
|
||||||
@ -12,6 +10,8 @@ import ru.ulstu.odin.model.annotation.OdinString;
|
|||||||
import ru.ulstu.odin.model.annotation.OdinVisible;
|
import ru.ulstu.odin.model.annotation.OdinVisible;
|
||||||
import ru.ulstu.user.controller.UserController;
|
import ru.ulstu.user.controller.UserController;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Email;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -53,7 +53,7 @@ public class UserDto implements OdinDto {
|
|||||||
private boolean activated;
|
private boolean activated;
|
||||||
|
|
||||||
@OdinCaption("Роли")
|
@OdinCaption("Роли")
|
||||||
private LinkedHashSet<UserRoleDto> roles;
|
private final LinkedHashSet<UserRoleDto> roles;
|
||||||
|
|
||||||
@OdinString(type = PASSWORD)
|
@OdinString(type = PASSWORD)
|
||||||
@OdinVisible(type = OdinVisible.OdinVisibleType.ON_UPDATE)
|
@OdinVisible(type = OdinVisible.OdinVisibleType.ON_UPDATE)
|
||||||
@ -189,9 +189,9 @@ public class UserDto implements OdinDto {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public boolean isPasswordsValid() {
|
public boolean isPasswordsValid() {
|
||||||
if (StringUtils.isEmpty(password) || StringUtils.isEmpty(passwordConfirm)) {
|
if (StringUtils.isEmpty(password) || StringUtils.isEmpty(passwordConfirm)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
return Objects.equals(password, passwordConfirm);
|
return !Objects.equals(password, passwordConfirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
@ -11,19 +11,19 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public class UserListDto implements OdinDto {
|
public class UserListDto implements OdinDto {
|
||||||
@OdinVisible(type = OdinVisible.OdinVisibleType.NONE)
|
@OdinVisible(type = OdinVisible.OdinVisibleType.NONE)
|
||||||
private int id;
|
private final int id;
|
||||||
@OdinCaption("Логин")
|
@OdinCaption("Логин")
|
||||||
private String login;
|
private final String login;
|
||||||
@OdinCaption("Имя")
|
@OdinCaption("Имя")
|
||||||
private String firstName;
|
private final String firstName;
|
||||||
@OdinCaption("Фамилия")
|
@OdinCaption("Фамилия")
|
||||||
private String lastName;
|
private final String lastName;
|
||||||
@OdinCaption("E-Mail")
|
@OdinCaption("E-Mail")
|
||||||
private String email;
|
private final String email;
|
||||||
@OdinCaption("Аккаунт активен")
|
@OdinCaption("Аккаунт активен")
|
||||||
private boolean activated;
|
private final boolean activated;
|
||||||
@OdinCaption("Права администратора")
|
@OdinCaption("Права администратора")
|
||||||
private boolean admin;
|
private final boolean admin;
|
||||||
|
|
||||||
public UserListDto(User user) {
|
public UserListDto(User user) {
|
||||||
this.id = user.getId();
|
this.id = user.getId();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package ru.ulstu.user.model;
|
package ru.ulstu.user.model;
|
||||||
|
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
|
||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -7,19 +7,19 @@ import java.util.Date;
|
|||||||
|
|
||||||
public class UserSessionListDto {
|
public class UserSessionListDto {
|
||||||
@OdinCaption("Сессия")
|
@OdinCaption("Сессия")
|
||||||
private String sessionId;
|
private final String sessionId;
|
||||||
@OdinCaption("Пользователь")
|
@OdinCaption("Пользователь")
|
||||||
private String login;
|
private final String login;
|
||||||
@OdinCaption("IP адрес")
|
@OdinCaption("IP адрес")
|
||||||
private String ipAddress;
|
private final String ipAddress;
|
||||||
@OdinCaption("Хост")
|
@OdinCaption("Хост")
|
||||||
private String host;
|
private final String host;
|
||||||
@OdinCaption("Вход")
|
@OdinCaption("Вход")
|
||||||
@OdinDate(type = OdinDate.OdinDateType.DATETIME)
|
@OdinDate(type = OdinDate.OdinDateType.DATETIME)
|
||||||
private Date loginTime;
|
private final Date loginTime;
|
||||||
@OdinCaption("Выход")
|
@OdinCaption("Выход")
|
||||||
@OdinDate(type = OdinDate.OdinDateType.DATETIME)
|
@OdinDate(type = OdinDate.OdinDateType.DATETIME)
|
||||||
private Date logoutTime;
|
private final Date logoutTime;
|
||||||
|
|
||||||
public UserSessionListDto(UserSession userSession) {
|
public UserSessionListDto(UserSession userSession) {
|
||||||
this.sessionId = userSession.getSessionId();
|
this.sessionId = userSession.getSessionId();
|
||||||
|
@ -10,7 +10,7 @@ import org.springframework.mail.javamail.MimeMessageHelper;
|
|||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thymeleaf.context.Context;
|
import org.thymeleaf.context.Context;
|
||||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
import org.thymeleaf.spring5.SpringTemplateEngine;
|
||||||
import ru.ulstu.configuration.ApplicationProperties;
|
import ru.ulstu.configuration.ApplicationProperties;
|
||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
@ -39,7 +39,7 @@ public class MailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void sendEmail(String to, String subject, String content) throws MessagingException, MailException {
|
private void sendEmail(String to, String subject, String content) throws MessagingException, MailException {
|
||||||
log.debug("Send email to '{}' with subject '{}'", to, subject);
|
log.debug("Send email to '{}' with subject '{}'", to, subject);
|
||||||
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
||||||
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, false, StandardCharsets.UTF_8.name());
|
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, false, StandardCharsets.UTF_8.name());
|
||||||
@ -60,7 +60,7 @@ public class MailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void sendEmailFromTemplate(User user, String templateName, String subject) {
|
private void sendEmailFromTemplate(User user, String templateName, String subject) {
|
||||||
Context context = new Context();
|
Context context = new Context();
|
||||||
context.setVariable(USER, user);
|
context.setVariable(USER, user);
|
||||||
context.setVariable(BASE_URL, applicationProperties.getBaseUrl());
|
context.setVariable(BASE_URL, applicationProperties.getBaseUrl());
|
||||||
@ -99,7 +99,7 @@ public class MailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void sendEmailFromTemplate(Map<String, Object> variables, String templateName, String subject, String email)
|
private void sendEmailFromTemplate(Map<String, Object> variables, String templateName, String subject, String email)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
Context context = new Context();
|
Context context = new Context();
|
||||||
variables.entrySet().forEach(entry -> context.setVariable(entry.getKey(), entry.getValue()));
|
variables.entrySet().forEach(entry -> context.setVariable(entry.getKey(), entry.getValue()));
|
||||||
|
@ -26,7 +26,7 @@ public class UserMapper {
|
|||||||
public Set<UserRole> rolesFromDto(Set<UserRoleDto> strings) {
|
public Set<UserRole> rolesFromDto(Set<UserRoleDto> strings) {
|
||||||
return Optional.ofNullable(strings).orElse(Collections.emptySet()).stream()
|
return Optional.ofNullable(strings).orElse(Collections.emptySet()).stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(role -> userRoleRepository.findOne(role.getId().toString()))
|
.map(role -> userRoleRepository.getOne(role.getId().toString()))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ public class UserMapper {
|
|||||||
return new UserDto(userEntity);
|
return new UserDto(userEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserListDto userEntityToUserListDto(User userEntity) {
|
private UserListDto userEntityToUserListDto(User userEntity) {
|
||||||
if (userEntity == null) {
|
if (userEntity == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.mail.MailException;
|
import org.springframework.mail.MailException;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
@ -124,7 +125,7 @@ public class UserService implements UserDetailsService {
|
|||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public PageableItems<UserListDto> getAllUsers(int offset, int count) {
|
public PageableItems<UserListDto> getAllUsers(int offset, int count) {
|
||||||
final Page<User> page = userRepository.findAll(new OffsetablePageRequest(offset, count, new Sort("id")));
|
final Page<User> page = userRepository.findAll(new OffsetablePageRequest(offset, count, Sort.by("id")));
|
||||||
return new PageableItems<>(page.getTotalElements(), userMapper.userEntitiesToUserListDtos(page.getContent()));
|
return new PageableItems<>(page.getTotalElements(), userMapper.userEntitiesToUserListDtos(page.getContent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +153,7 @@ public class UserService implements UserDetailsService {
|
|||||||
if (getUserByEmail(userDto.getEmail()) != null) {
|
if (getUserByEmail(userDto.getEmail()) != null) {
|
||||||
throw new UserEmailExistsException(userDto.getEmail());
|
throw new UserEmailExistsException(userDto.getEmail());
|
||||||
}
|
}
|
||||||
if (!userDto.isPasswordsValid()) {
|
if (userDto.isPasswordsValid()) {
|
||||||
throw new UserPasswordsNotValidOrNotMatchException("");
|
throw new UserPasswordsNotValidOrNotMatchException("");
|
||||||
}
|
}
|
||||||
User user = userMapper.userDtoToUserEntity(userDto);
|
User user = userMapper.userDtoToUserEntity(userDto);
|
||||||
@ -194,7 +195,7 @@ public class UserService implements UserDetailsService {
|
|||||||
userDto.getId())) {
|
userDto.getId())) {
|
||||||
throw new UserLoginExistsException(userDto.getLogin());
|
throw new UserLoginExistsException(userDto.getLogin());
|
||||||
}
|
}
|
||||||
User user = userRepository.findOne(userDto.getId());
|
User user = userRepository.getOne(userDto.getId());
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new UserNotFoundException(userDto.getId().toString());
|
throw new UserNotFoundException(userDto.getId().toString());
|
||||||
}
|
}
|
||||||
@ -222,7 +223,7 @@ public class UserService implements UserDetailsService {
|
|||||||
? Collections.singleton(new UserRole(UserRoleConstants.USER))
|
? Collections.singleton(new UserRole(UserRoleConstants.USER))
|
||||||
: roles);
|
: roles);
|
||||||
if (!StringUtils.isEmpty(userDto.getOldPassword())) {
|
if (!StringUtils.isEmpty(userDto.getOldPassword())) {
|
||||||
if (!userDto.isPasswordsValid() || !userDto.isOldPasswordValid()) {
|
if (userDto.isPasswordsValid() || !userDto.isOldPasswordValid()) {
|
||||||
throw new UserPasswordsNotValidOrNotMatchException("");
|
throw new UserPasswordsNotValidOrNotMatchException("");
|
||||||
}
|
}
|
||||||
if (!passwordEncoder.matches(userDto.getOldPassword(), user.getPassword())) {
|
if (!passwordEncoder.matches(userDto.getOldPassword(), user.getPassword())) {
|
||||||
@ -300,7 +301,7 @@ public class UserService implements UserDetailsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UserDto deleteUser(Integer userId) {
|
public UserDto deleteUser(Integer userId) {
|
||||||
final User user = userRepository.findOne(userId);
|
final User user = userRepository.getOne(userId);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new UserNotFoundException(userId.toString());
|
throw new UserNotFoundException(userId.toString());
|
||||||
}
|
}
|
||||||
@ -332,15 +333,15 @@ public class UserService implements UserDetailsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<User> findByIds(List<Integer> ids) {
|
public List<User> findByIds(List<Integer> ids) {
|
||||||
return userRepository.findAll(ids);
|
return userRepository.findAllById(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
public User findById(Integer id) {
|
public User findById(Integer id) {
|
||||||
return userRepository.findOne(id);
|
return userRepository.getOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getCurrentUser() {
|
public User getCurrentUser() {
|
||||||
String login = UserUtils.getCurrentUserLogin();
|
String login = UserUtils.getCurrentUserLogin(SecurityContextHolder.getContext());
|
||||||
User user = userRepository.findOneByLoginIgnoreCase(login);
|
User user = userRepository.findOneByLoginIgnoreCase(login);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new UserNotFoundException(login);
|
throw new UserNotFoundException(login);
|
||||||
|
@ -3,7 +3,6 @@ package ru.ulstu.user.util;
|
|||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContext;
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
|
|
||||||
@ -18,12 +17,12 @@ public class UserUtils {
|
|||||||
return RandomStringUtils.randomNumeric(DEF_COUNT);
|
return RandomStringUtils.randomNumeric(DEF_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCurrentUserLogin() {
|
public static String getCurrentUserLogin(SecurityContext securityContext) {
|
||||||
final SecurityContext securityContext = SecurityContextHolder.getContext();
|
|
||||||
if (securityContext == null) {
|
if (securityContext == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final Authentication authentication = securityContext.getAuthentication();
|
final Authentication authentication = securityContext.getAuthentication();
|
||||||
|
|
||||||
if (authentication.getPrincipal() instanceof UserDetails) {
|
if (authentication.getPrincipal() instanceof UserDetails) {
|
||||||
final UserDetails springSecurityUser = (UserDetails) authentication.getPrincipal();
|
final UserDetails springSecurityUser = (UserDetails) authentication.getPrincipal();
|
||||||
return springSecurityUser.getUsername();
|
return springSecurityUser.getUsername();
|
||||||
|
@ -16,9 +16,9 @@ import java.util.List;
|
|||||||
|
|
||||||
public class TimetableService {
|
public class TimetableService {
|
||||||
private static final String TIMETABLE_URL = "http://timetable.athene.tech/api/1.0/timetable?filter=%s";
|
private static final String TIMETABLE_URL = "http://timetable.athene.tech/api/1.0/timetable?filter=%s";
|
||||||
private SimpleDateFormat lessonTimeFormat = new SimpleDateFormat("hh:mm");
|
private final SimpleDateFormat lessonTimeFormat = new SimpleDateFormat("hh:mm");
|
||||||
|
|
||||||
private long[] lessonsStarts = new long[]{
|
private final long[] lessonsStarts = new long[]{
|
||||||
lessonTimeFormat.parse("8:00:00").getTime(),
|
lessonTimeFormat.parse("8:00:00").getTime(),
|
||||||
lessonTimeFormat.parse("9:40:00").getTime(),
|
lessonTimeFormat.parse("9:40:00").getTime(),
|
||||||
lessonTimeFormat.parse("11:30:00").getTime(),
|
lessonTimeFormat.parse("11:30:00").getTime(),
|
||||||
|
@ -2,12 +2,11 @@
|
|||||||
spring.main.banner-mode=off
|
spring.main.banner-mode=off
|
||||||
server.port=8443
|
server.port=8443
|
||||||
server.http.port=8080
|
server.http.port=8080
|
||||||
spring.http.multipart.maxFileSize=20MB
|
multipart.maxFileSize=20MB
|
||||||
spring.http.multipart.maxRequestSize=20MB
|
multipart.maxRequestSize=20MB
|
||||||
# Thymeleaf Settings
|
# Thymeleaf Settings
|
||||||
spring.thymeleaf.cache=false
|
spring.thymeleaf.cache=false
|
||||||
# SSL Settings
|
# SSL Settings
|
||||||
security.require-ssl=true
|
|
||||||
server.ssl.key-store=classpath:sample.jks
|
server.ssl.key-store=classpath:sample.jks
|
||||||
server.ssl.key-store-password=secret
|
server.ssl.key-store-password=secret
|
||||||
server.ssl.key-password=password
|
server.ssl.key-password=password
|
||||||
@ -27,13 +26,12 @@ spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFact
|
|||||||
spring.datasource.url=jdbc:postgresql://localhost:5432/ng-tracker
|
spring.datasource.url=jdbc:postgresql://localhost:5432/ng-tracker
|
||||||
spring.datasource.username=postgres
|
spring.datasource.username=postgres
|
||||||
spring.datasource.password=postgres
|
spring.datasource.password=postgres
|
||||||
spring.datasource.driverclassName=org.postgresql.Driver
|
|
||||||
spring.jpa.hibernate.ddl-auto=validate
|
spring.jpa.hibernate.ddl-auto=validate
|
||||||
|
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
|
||||||
# Liquibase Settings
|
# Liquibase Settings
|
||||||
liquibase.drop-first=false
|
spring.liquibase.change-log=classpath:db/changelog-master.xml
|
||||||
liquibase.enabled=true
|
spring.liquibase.drop-first=false
|
||||||
liquibase.change-log=classpath:db/changelog-master.xml
|
spring.liquibase.enabled=true
|
||||||
|
|
||||||
# Application Settings
|
# Application Settings
|
||||||
ng-tracker.base-url=http://127.0.0.1:8080
|
ng-tracker.base-url=http://127.0.0.1:8080
|
||||||
ng-tracker.undead-user-login=admin
|
ng-tracker.undead-user-login=admin
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
<include file="db/changelog-20190419_000000-schema.xml"/>
|
<include file="db/changelog-20190419_000000-schema.xml"/>
|
||||||
<include file="db/changelog-20190421_000000-schema.xml"/>
|
<include file="db/changelog-20190421_000000-schema.xml"/>
|
||||||
<include file="db/changelog-20190422_000000-schema.xml"/>
|
<include file="db/changelog-20190422_000000-schema.xml"/>
|
||||||
|
<include file="db/common/changelog-20190423_100000-schema.xml"/>
|
||||||
<include file="db/changelog-20190424_000000-schema.xml"/>
|
<include file="db/changelog-20190424_000000-schema.xml"/>
|
||||||
<include file="db/changelog-20190426_000000-schema.xml"/>
|
<include file="db/changelog-20190426_000000-schema.xml"/>
|
||||||
<include file="db/changelog-20190430_000000-schema.xml"/>
|
<include file="db/changelog-20190430_000000-schema.xml"/>
|
||||||
|
@ -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="orion" id="20190423_100000-1">
|
||||||
|
<addColumn tableName="hibernate_sequences">
|
||||||
|
<column name="next_val" type="bigint"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -7,9 +7,9 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>
|
<p>
|
||||||
Аккаунт в системе NG-Tracker был создан. <br />
|
Аккаунт в системе NG-Tracker был создан. <br/>
|
||||||
Данные для входа: <br />
|
Данные для входа: <br/>
|
||||||
Логин - <span th:text="${email}"></span> <br />
|
Логин - <span th:text="${email}"></span> <br/>
|
||||||
Пароль - <span th:text="${password}"></span>
|
Пароль - <span th:text="${password}"></span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
@ -365,7 +365,7 @@ header.masthead .intro-text .intro-heading {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.portfolio-modal {
|
.portfolio-modal {
|
||||||
padding-right: 0px !important;
|
padding-right: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.portfolio-modal .modal-dialog {
|
.portfolio-modal .modal-dialog {
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
.loader {
|
.loader {
|
||||||
padding-left:50%
|
padding-left: 50%
|
||||||
}
|
}
|
@ -23,6 +23,7 @@ body {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.conference-row .d-flex .text-decoration:nth-child(1) {
|
.conference-row .d-flex .text-decoration:nth-child(1) {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
@ -44,7 +45,6 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.conference-row .d-flex {
|
.conference-row .d-flex {
|
||||||
margin: 0 15px;
|
margin: 0 15px;
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ body {
|
|||||||
|
|
||||||
.deadline-list {
|
.deadline-list {
|
||||||
height: 200px;
|
height: 200px;
|
||||||
padding: 0px;
|
padding: 0;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ body {
|
|||||||
|
|
||||||
.member-list {
|
.member-list {
|
||||||
height: 200px;
|
height: 200px;
|
||||||
padding: 0px;
|
padding: 0;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +82,7 @@ body {
|
|||||||
height: 40px;
|
height: 40px;
|
||||||
max-height: 40px;
|
max-height: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.member select {
|
.member select {
|
||||||
appearance: none;
|
appearance: none;
|
||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
@ -134,7 +135,7 @@ body {
|
|||||||
|
|
||||||
.paper-list {
|
.paper-list {
|
||||||
height: 200px;
|
height: 200px;
|
||||||
padding: 0px;
|
padding: 0;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +160,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.paper-name span:nth-child(1) {
|
.paper-name span:nth-child(1) {
|
||||||
margin: 3px 0px 3px 10px;
|
margin: 3px 0 3px 10px;
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +235,7 @@ body {
|
|||||||
background-color: #ff9973;
|
background-color: #ff9973;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 1199px) and (min-width: 768px){
|
@media (max-width: 1199px) and (min-width: 768px) {
|
||||||
.paper-control {
|
.paper-control {
|
||||||
display: block!important;
|
display: block!important;
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
.div-deadline-date {
|
.div-deadline-date {
|
||||||
padding-right: 0px;
|
padding-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-deadline-date{
|
.form-deadline-date {
|
||||||
padding-right: 3px;
|
padding-right: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.div-deadline-description{
|
.div-deadline-description {
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
}
|
}
|
||||||
@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.div-selected-papers {
|
.div-selected-papers {
|
||||||
border: 0px;
|
border: 0;
|
||||||
padding-left: 12px;
|
padding-left: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@
|
|||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.div-file-name{
|
.div-file-name {
|
||||||
padding-top: 6px;
|
padding-top: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,8 +52,7 @@
|
|||||||
Odin Paginator
|
Odin Paginator
|
||||||
*/
|
*/
|
||||||
.odin-paginator {
|
.odin-paginator {
|
||||||
margin: 0;
|
margin: 5px 0 0;
|
||||||
margin-top: 5px;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,18 +13,18 @@
|
|||||||
cursor: text;
|
cursor: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter .bootstrap-select{
|
.filter .bootstrap-select {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-option-inner-inner{
|
.filter-option-inner-inner {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
line-height: 25px;
|
line-height: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sorting .bootstrap-select{
|
.sorting .bootstrap-select {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,8 @@
|
|||||||
width: auto;
|
width: auto;
|
||||||
max-width: inherit;
|
max-width: inherit;
|
||||||
}
|
}
|
||||||
.tag-info{
|
|
||||||
|
.tag-info {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
color: white;
|
color: white;
|
||||||
padding: 5px 15px;
|
padding: 5px 15px;
|
||||||
@ -50,41 +51,41 @@
|
|||||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fa-question-circle{
|
.fa-question-circle {
|
||||||
|
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
color: #212529;
|
color: #212529;
|
||||||
cursor:pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fa-question-circle:hover .tag-info{
|
.fa-question-circle:hover .tag-info {
|
||||||
display:inline-block;
|
display: inline-block;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-row{
|
.task-row {
|
||||||
|
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-row .col:hover{
|
.task-row .col:hover {
|
||||||
|
|
||||||
background-color: #f8f9fa;
|
background-color: #f8f9fa;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-row .col > a{
|
.task-row .col > a {
|
||||||
display: block;
|
display: block;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-row .col:hover .remove-task{
|
.task-row .col:hover .remove-task {
|
||||||
|
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.remove-task{
|
.remove-task {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: -20px;
|
right: -20px;
|
||||||
@ -93,7 +94,7 @@
|
|||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remove-task:hover{
|
.remove-task:hover {
|
||||||
|
|
||||||
background-color: #ebebeb;
|
background-color: #ebebeb;
|
||||||
}
|
}
|
||||||
@ -119,7 +120,7 @@
|
|||||||
|
|
||||||
.tag-name span[data-role="remove"]:after {
|
.tag-name span[data-role="remove"]:after {
|
||||||
content: "x";
|
content: "x";
|
||||||
padding: 0px 2px;
|
padding: 0 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-name input[type="text"] {
|
.tag-name input[type="text"] {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('input[data-confirm]').click(function(ev) {
|
$('input[data-confirm]').click(function (ev) {
|
||||||
var value = $(this).attr('value');
|
var value = $(this).attr('value');
|
||||||
if (!$('#dataConfirmModal').length) {
|
if (!$('#dataConfirmModal').length) {
|
||||||
$('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' +
|
$('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' +
|
||||||
@ -13,8 +13,8 @@ $(document).ready(function () {
|
|||||||
' </div>\n' +
|
' </div>\n' +
|
||||||
|
|
||||||
' <div class="modal-footer">\n' +
|
' <div class="modal-footer">\n' +
|
||||||
' <button type="submit" name="deleteConference" class="btn btn-primary" id="deleteConference">Да</button>'+
|
' <button type="submit" name="deleteConference" class="btn btn-primary" id="deleteConference">Да</button>' +
|
||||||
' <button class="btn primary" data-dismiss="modal" aria-hidden="true">Нет</button>'+
|
' <button class="btn primary" data-dismiss="modal" aria-hidden="true">Нет</button>' +
|
||||||
' </div>\n' +
|
' </div>\n' +
|
||||||
' </div>\n' +
|
' </div>\n' +
|
||||||
' </div>\n' +
|
' </div>\n' +
|
||||||
@ -22,7 +22,7 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
$('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm'));
|
$('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm'));
|
||||||
$('#deleteConference').attr('value', value);
|
$('#deleteConference').attr('value', value);
|
||||||
$('#dataConfirmModal').modal({show:true});
|
$('#dataConfirmModal').modal({show: true});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -89,11 +89,6 @@ function getFromRest(url, callBack, errorCallBack) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exported getFromRestWithVersion */
|
|
||||||
function getFromRest(url, callBack, errorCallBack) {
|
|
||||||
getFromRestWithParams(url, "", callBack, errorCallBack);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* exported getFromRestWithVersionAndParams */
|
/* exported getFromRestWithVersionAndParams */
|
||||||
function getFromRestWithParams(url, params, callBack, errorCallBack) {
|
function getFromRestWithParams(url, params, callBack, errorCallBack) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -230,13 +225,13 @@ function sendPing(field, url) {
|
|||||||
id = document.getElementById(field).value
|
id = document.getElementById(field).value
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:url + `?${field}=` + id,
|
url: url + `?${field}=` + id,
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
success: function() {
|
success: function () {
|
||||||
showFeedbackMessage("Ping был отправлен", MessageTypesEnum.SUCCESS)
|
showFeedbackMessage("Ping был отправлен", MessageTypesEnum.SUCCESS)
|
||||||
},
|
},
|
||||||
error: function(errorData) {
|
error: function (errorData) {
|
||||||
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -12,7 +12,7 @@ $(document).ready(function () {
|
|||||||
$(projectRow).find(".remove-paper").addClass("d-none");
|
$(projectRow).find(".remove-paper").addClass("d-none");
|
||||||
});
|
});
|
||||||
|
|
||||||
$('a[data-confirm]').click(function(ev) {
|
$('a[data-confirm]').click(function (ev) {
|
||||||
var href = $(this).attr('href');
|
var href = $(this).attr('href');
|
||||||
if (!$('#dataConfirmModal').length) {
|
if (!$('#dataConfirmModal').length) {
|
||||||
$('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' +
|
$('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' +
|
||||||
@ -26,8 +26,8 @@ $(document).ready(function () {
|
|||||||
' </div>\n' +
|
' </div>\n' +
|
||||||
|
|
||||||
' <div class="modal-footer">\n' +
|
' <div class="modal-footer">\n' +
|
||||||
' <a class="btn btn-primary" id="dataConfirmOK">Да</a>'+
|
' <a class="btn btn-primary" id="dataConfirmOK">Да</a>' +
|
||||||
' <button class="btn primary" data-dismiss="modal" aria-hidden="true">Нет</button>'+
|
' <button class="btn primary" data-dismiss="modal" aria-hidden="true">Нет</button>' +
|
||||||
' </div>\n' +
|
' </div>\n' +
|
||||||
' </div>\n' +
|
' </div>\n' +
|
||||||
' </div>\n' +
|
' </div>\n' +
|
||||||
@ -35,7 +35,7 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
$('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm'));
|
$('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm'));
|
||||||
$('#dataConfirmOK').attr('href', href);
|
$('#dataConfirmOK').attr('href', href);
|
||||||
$('#dataConfirmModal').modal({show:true});
|
$('#dataConfirmModal').modal({show: true});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
/*<![CDATA[*/
|
/*<![CDATA[*/
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
$("#tags .tag .tag-name input[type=text]").each(function() {
|
$("#tags .tag .tag-name input[type=text]").each(function () {
|
||||||
$(this).attr("size", $(this).val().length)
|
$(this).attr("size", $(this).val().length)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$("#task-form").keydown(function(event){
|
$("#task-form").keydown(function (event) {
|
||||||
if(event.keyCode == 13) {
|
if (event.keyCode == 13) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function removeTag () {
|
function removeTag() {
|
||||||
$(this).parent().parent().remove();
|
$(this).parent().parent().remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$("#input-tag").keyup(function (event) {
|
$("#input-tag").keyup(function (event) {
|
||||||
if(event.keyCode == 13) {
|
if (event.keyCode == 13) {
|
||||||
var tagNumber = $("#tags .tag").length;
|
var tagNumber = $("#tags .tag").length;
|
||||||
if(tagNumber > 0) {
|
if (tagNumber > 0) {
|
||||||
tagNumber = $("#tags .tag").last()
|
tagNumber = $("#tags .tag").last()
|
||||||
.children('input')
|
.children('input')
|
||||||
.attr("name")
|
.attr("name")
|
||||||
@ -32,14 +32,14 @@ $(document).ready(function () {
|
|||||||
var tagName = $.trim($(this).val());
|
var tagName = $.trim($(this).val());
|
||||||
var addTag = true;
|
var addTag = true;
|
||||||
// проверка, добавлен ли этот тег
|
// проверка, добавлен ли этот тег
|
||||||
$("#tags .tag .tag-name input[type=text]").each(function() {
|
$("#tags .tag .tag-name input[type=text]").each(function () {
|
||||||
if(tagName === $(this).val()) {
|
if (tagName === $(this).val()) {
|
||||||
addTag = false;
|
addTag = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// если тег не добавлен
|
// если тег не добавлен
|
||||||
if(addTag) {
|
if (addTag) {
|
||||||
// контейнер тега
|
// контейнер тега
|
||||||
var newTagRow = $("<div/>")
|
var newTagRow = $("<div/>")
|
||||||
.attr("id", 'tags' + tagNumber)
|
.attr("id", 'tags' + tagNumber)
|
||||||
|
@ -14,7 +14,7 @@ function changePassword() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"/api/1.0/users/changePassword",
|
url: "/api/1.0/users/changePassword",
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
"oldPassword": oldPassword,
|
"oldPassword": oldPassword,
|
||||||
@ -22,12 +22,12 @@ function changePassword() {
|
|||||||
"confirmPassword": confirmPassword,
|
"confirmPassword": confirmPassword,
|
||||||
}),
|
}),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
success: function() {
|
success: function () {
|
||||||
$("#closeModalPassword").click();
|
$("#closeModalPassword").click();
|
||||||
showFeedbackMessage("Пароль был обновлен", MessageTypesEnum.SUCCESS)
|
showFeedbackMessage("Пароль был обновлен", MessageTypesEnum.SUCCESS)
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function(errorData) {
|
error: function (errorData) {
|
||||||
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -41,14 +41,14 @@ function inviteUser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"/api/1.0/users/invite?email=" + email,
|
url: "/api/1.0/users/invite?email=" + email,
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
success: function() {
|
success: function () {
|
||||||
$("#closeModalInvite").click();
|
$("#closeModalInvite").click();
|
||||||
showFeedbackMessage("Пользователь был успешно приглашен", MessageTypesEnum.SUCCESS)
|
showFeedbackMessage("Пользователь был успешно приглашен", MessageTypesEnum.SUCCESS)
|
||||||
},
|
},
|
||||||
error: function(errorData) {
|
error: function (errorData) {
|
||||||
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -64,10 +64,10 @@ function requestResetPassword() {
|
|||||||
$("#dvloader").show();
|
$("#dvloader").show();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"/api/1.0/users/password-reset-request?email=" + email,
|
url: "/api/1.0/users/password-reset-request?email=" + email,
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
success: function() {
|
success: function () {
|
||||||
showFeedbackMessage("Проверочный код был отправлен на указанный почтовый ящик", MessageTypesEnum.SUCCESS)
|
showFeedbackMessage("Проверочный код был отправлен на указанный почтовый ящик", MessageTypesEnum.SUCCESS)
|
||||||
$("#passwordNew").show()
|
$("#passwordNew").show()
|
||||||
$("#passwordConfirm").show()
|
$("#passwordConfirm").show()
|
||||||
@ -78,7 +78,7 @@ function requestResetPassword() {
|
|||||||
$("#dvloader").hide()
|
$("#dvloader").hide()
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function(errorData) {
|
error: function (errorData) {
|
||||||
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
||||||
$("#dvloader").hide()
|
$("#dvloader").hide()
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ function resetPassword() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"/api/1.0/users/password-reset",
|
url: "/api/1.0/users/password-reset",
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
@ -110,11 +110,11 @@ function resetPassword() {
|
|||||||
"passwordConfirm": passwordConfirm,
|
"passwordConfirm": passwordConfirm,
|
||||||
"resetKey": resetKey,
|
"resetKey": resetKey,
|
||||||
}),
|
}),
|
||||||
success: function() {
|
success: function () {
|
||||||
showFeedbackMessage("Пользователь был успешно приглашен", MessageTypesEnum.SUCCESS)
|
showFeedbackMessage("Пользователь был успешно приглашен", MessageTypesEnum.SUCCESS)
|
||||||
window.location.href = "/login"
|
window.location.href = "/login"
|
||||||
},
|
},
|
||||||
error: function(errorData) {
|
error: function (errorData) {
|
||||||
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -123,13 +123,13 @@ function resetPassword() {
|
|||||||
function blockUser() {
|
function blockUser() {
|
||||||
userId = $('#userId').val();
|
userId = $('#userId').val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"/api/1.0/users/block?userId=" + userId,
|
url: "/api/1.0/users/block?userId=" + userId,
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
success: function() {
|
success: function () {
|
||||||
showFeedbackMessage("Пользователь заблокирован", MessageTypesEnum.SUCCESS)
|
showFeedbackMessage("Пользователь заблокирован", MessageTypesEnum.SUCCESS)
|
||||||
},
|
},
|
||||||
error: function(errorData) {
|
error: function (errorData) {
|
||||||
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -144,16 +144,16 @@ function drawChart() {
|
|||||||
userId = $('#author :selected').val()
|
userId = $('#author :selected').val()
|
||||||
activity = $('#activity :selected').val()
|
activity = $('#activity :selected').val()
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:`/api/1.0/users/activities/pings?userId=${userId}&activity=${activity}`,
|
url: `/api/1.0/users/activities/pings?userId=${userId}&activity=${activity}`,
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
success: function(response) {
|
success: function (response) {
|
||||||
if (response.data.length == 0) {
|
if (response.data.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
array = [['Активности', 'Количество']]
|
array = [['Активности', 'Количество']]
|
||||||
|
|
||||||
Object.keys(response.data).forEach(function(key) {
|
Object.keys(response.data).forEach(function (key) {
|
||||||
console.table('Key : ' + key + ', Value : ' + response.data[key])
|
console.table('Key : ' + key + ', Value : ' + response.data[key])
|
||||||
array.push([key, response.data[key]])
|
array.push([key, response.data[key]])
|
||||||
})
|
})
|
||||||
@ -166,7 +166,7 @@ function drawChart() {
|
|||||||
var chart = new google.visualization.PieChart(document.getElementById('air'));
|
var chart = new google.visualization.PieChart(document.getElementById('air'));
|
||||||
chart.draw(data, options);
|
chart.draw(data, options);
|
||||||
},
|
},
|
||||||
error: function(errorData) {
|
error: function (errorData) {
|
||||||
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -126,7 +126,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/template" id="choseTable">
|
<script type="text/template" id="choseTable">
|
||||||
<div id="table-block" class=\"panel-body odin-kill-padding\"></div>
|
<div id="table-block" class="panel-body odin-kill-padding"></div>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/template" id="formTabs">
|
<script type="text/template" id="formTabs">
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<html lang="en"
|
<html lang="en"
|
||||||
xmlns:th="http://www.thymeleaf.org"
|
xmlns:th="http://www.thymeleaf.org"
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
layout:decorator="default">
|
layout:decorate="~{default}">
|
||||||
<head>
|
<head>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user