Compare commits
2 Commits
dev
...
99-project
Author | SHA1 | Date |
---|---|---|
|
997e7776b6 | 5 years ago |
|
26c1b78960 | 5 years ago |
@ -1,19 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
stages {
|
|
||||||
stage('Test') {
|
|
||||||
steps {
|
|
||||||
sh "./gradlew clean test --info"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
post {
|
|
||||||
always {
|
|
||||||
script {
|
|
||||||
if (currentBuild.currentResult == 'FAILURE') {
|
|
||||||
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "a.romanov@ulstu.ru", sendToIndividuals: true])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,30 @@
|
|||||||
|
package ru.ulstu.configuration;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
||||||
|
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
||||||
|
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
||||||
|
import org.springframework.boot.context.embedded.jetty.JettyServerCustomizer;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class HttpListenerConfiguration implements EmbeddedServletContainerCustomizer {
|
||||||
|
@Value("${server.http.port}")
|
||||||
|
private int httpPort;
|
||||||
|
|
||||||
|
private void configureJetty(JettyEmbeddedServletContainerFactory jettyFactory) {
|
||||||
|
jettyFactory.addServerCustomizers((JettyServerCustomizer) server -> {
|
||||||
|
ServerConnector serverConnector = new ServerConnector(server);
|
||||||
|
serverConnector.setPort(httpPort);
|
||||||
|
server.addConnector(serverConnector);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customize(ConfigurableEmbeddedServletContainer container) {
|
||||||
|
if (container instanceof JettyEmbeddedServletContainerFactory) {
|
||||||
|
configureJetty((JettyEmbeddedServletContainerFactory) container);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package ru.ulstu.configuration;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
|
public class SwaggerConfiguration {
|
||||||
|
@Bean
|
||||||
|
public Docket swaggerApi() {
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.any())
|
||||||
|
.paths(Predicates.not(PathSelectors.regex("/error")))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
@ -1,115 +1,116 @@
|
|||||||
package ru.ulstu.core.controller;
|
package ru.ulstu.core.controller;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.validation.FieldError;
|
import org.springframework.validation.FieldError;
|
||||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import ru.ulstu.core.error.EntityIdIsNullException;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import ru.ulstu.core.model.ErrorConstants;
|
import ru.ulstu.core.error.EntityIdIsNullException;
|
||||||
import ru.ulstu.core.model.response.Response;
|
import ru.ulstu.core.model.ErrorConstants;
|
||||||
import ru.ulstu.core.model.response.ResponseExtended;
|
import ru.ulstu.core.model.response.Response;
|
||||||
import ru.ulstu.user.error.UserActivationError;
|
import ru.ulstu.core.model.response.ResponseExtended;
|
||||||
import ru.ulstu.user.error.UserEmailExistsException;
|
import ru.ulstu.user.error.UserActivationError;
|
||||||
import ru.ulstu.user.error.UserIdExistsException;
|
import ru.ulstu.user.error.UserEmailExistsException;
|
||||||
import ru.ulstu.user.error.UserIsUndeadException;
|
import ru.ulstu.user.error.UserIdExistsException;
|
||||||
import ru.ulstu.user.error.UserLoginExistsException;
|
import ru.ulstu.user.error.UserIsUndeadException;
|
||||||
import ru.ulstu.user.error.UserNotActivatedException;
|
import ru.ulstu.user.error.UserLoginExistsException;
|
||||||
import ru.ulstu.user.error.UserNotFoundException;
|
import ru.ulstu.user.error.UserNotActivatedException;
|
||||||
import ru.ulstu.user.error.UserPasswordsNotValidOrNotMatchException;
|
import ru.ulstu.user.error.UserNotFoundException;
|
||||||
import ru.ulstu.user.error.UserResetKeyError;
|
import ru.ulstu.user.error.UserPasswordsNotValidOrNotMatchException;
|
||||||
import ru.ulstu.user.error.UserSendingMailException;
|
import ru.ulstu.user.error.UserResetKeyError;
|
||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.error.UserSendingMailException;
|
||||||
|
import ru.ulstu.user.service.UserService;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
//@ControllerAdvice
|
|
||||||
public class AdviceController {
|
@ControllerAdvice
|
||||||
private final Logger log = LoggerFactory.getLogger(AdviceController.class);
|
public class AdviceController {
|
||||||
private final UserService userService;
|
private final Logger log = LoggerFactory.getLogger(AdviceController.class);
|
||||||
|
private final UserService userService;
|
||||||
public AdviceController(UserService userService) {
|
|
||||||
this.userService = userService;
|
public AdviceController(UserService userService) {
|
||||||
}
|
this.userService = userService;
|
||||||
|
}
|
||||||
@ModelAttribute("flashMessage")
|
|
||||||
public String getFlashMessage() {
|
@ModelAttribute("flashMessage")
|
||||||
return null;
|
public String getFlashMessage() {
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
private Response<Void> handleException(ErrorConstants error) {
|
|
||||||
log.warn(error.toString());
|
private Response<Void> handleException(ErrorConstants error) {
|
||||||
return new Response<>(error);
|
log.warn(error.toString());
|
||||||
}
|
return new Response<>(error);
|
||||||
|
}
|
||||||
private <E> ResponseExtended<E> handleException(ErrorConstants error, E errorData) {
|
|
||||||
log.warn(error.toString());
|
private <E> ResponseExtended<E> handleException(ErrorConstants error, E errorData) {
|
||||||
return new ResponseExtended<>(error, errorData);
|
log.warn(error.toString());
|
||||||
}
|
return new ResponseExtended<>(error, errorData);
|
||||||
|
}
|
||||||
@ExceptionHandler(EntityIdIsNullException.class)
|
|
||||||
public Response<Void> handleEntityIdIsNullException(Throwable e) {
|
@ExceptionHandler(EntityIdIsNullException.class)
|
||||||
return handleException(ErrorConstants.ID_IS_NULL);
|
public Response<Void> handleEntityIdIsNullException(Throwable e) {
|
||||||
}
|
return handleException(ErrorConstants.ID_IS_NULL);
|
||||||
|
}
|
||||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
|
||||||
public ResponseExtended<Set<String>> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||||
final Set<String> errors = e.getBindingResult().getAllErrors().stream()
|
public ResponseExtended<Set<String>> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||||
.filter(error -> error instanceof FieldError)
|
final Set<String> errors = e.getBindingResult().getAllErrors().stream()
|
||||||
.map(error -> ((FieldError) error).getField())
|
.filter(error -> error instanceof FieldError)
|
||||||
.collect(Collectors.toSet());
|
.map(error -> ((FieldError) error).getField())
|
||||||
return handleException(ErrorConstants.VALIDATION_ERROR, errors);
|
.collect(Collectors.toSet());
|
||||||
}
|
return handleException(ErrorConstants.VALIDATION_ERROR, errors);
|
||||||
|
}
|
||||||
@ExceptionHandler(UserIdExistsException.class)
|
|
||||||
public Response<Void> handleUserIdExistsException(Throwable e) {
|
@ExceptionHandler(UserIdExistsException.class)
|
||||||
return handleException(ErrorConstants.USER_ID_EXISTS);
|
public Response<Void> handleUserIdExistsException(Throwable e) {
|
||||||
}
|
return handleException(ErrorConstants.USER_ID_EXISTS);
|
||||||
|
}
|
||||||
@ExceptionHandler(UserActivationError.class)
|
|
||||||
public ResponseExtended<String> handleUserActivationError(Throwable e) {
|
@ExceptionHandler(UserActivationError.class)
|
||||||
return handleException(ErrorConstants.USER_ACTIVATION_ERROR, e.getMessage());
|
public ResponseExtended<String> handleUserActivationError(Throwable e) {
|
||||||
}
|
return handleException(ErrorConstants.USER_ACTIVATION_ERROR, e.getMessage());
|
||||||
|
}
|
||||||
@ExceptionHandler(UserLoginExistsException.class)
|
|
||||||
public ResponseExtended<String> handleUserLoginExistsException(Throwable e) {
|
@ExceptionHandler(UserLoginExistsException.class)
|
||||||
return handleException(ErrorConstants.USER_LOGIN_EXISTS, e.getMessage());
|
public ResponseExtended<String> handleUserLoginExistsException(Throwable e) {
|
||||||
}
|
return handleException(ErrorConstants.USER_LOGIN_EXISTS, e.getMessage());
|
||||||
|
}
|
||||||
@ExceptionHandler(UserEmailExistsException.class)
|
|
||||||
public ResponseExtended<String> handleUserEmailExistsException(Throwable e) {
|
@ExceptionHandler(UserEmailExistsException.class)
|
||||||
return handleException(ErrorConstants.USER_EMAIL_EXISTS, e.getMessage());
|
public ResponseExtended<String> handleUserEmailExistsException(Throwable e) {
|
||||||
}
|
return handleException(ErrorConstants.USER_EMAIL_EXISTS, e.getMessage());
|
||||||
|
}
|
||||||
@ExceptionHandler(UserPasswordsNotValidOrNotMatchException.class)
|
|
||||||
public Response<Void> handleUserPasswordsNotValidOrNotMatchException(Throwable e) {
|
@ExceptionHandler(UserPasswordsNotValidOrNotMatchException.class)
|
||||||
return handleException(ErrorConstants.USER_PASSWORDS_NOT_VALID_OR_NOT_MATCH);
|
public Response<Void> handleUserPasswordsNotValidOrNotMatchException(Throwable e) {
|
||||||
}
|
return handleException(ErrorConstants.USER_PASSWORDS_NOT_VALID_OR_NOT_MATCH);
|
||||||
|
}
|
||||||
@ExceptionHandler(UserNotFoundException.class)
|
|
||||||
public ResponseExtended<String> handleUserNotFoundException(Throwable e) {
|
@ExceptionHandler(UserNotFoundException.class)
|
||||||
return handleException(ErrorConstants.USER_NOT_FOUND, e.getMessage());
|
public ResponseExtended<String> handleUserNotFoundException(Throwable e) {
|
||||||
}
|
return handleException(ErrorConstants.USER_NOT_FOUND, e.getMessage());
|
||||||
|
}
|
||||||
@ExceptionHandler(UserNotActivatedException.class)
|
|
||||||
public Response<Void> handleUserNotActivatedException(Throwable e) {
|
@ExceptionHandler(UserNotActivatedException.class)
|
||||||
return handleException(ErrorConstants.USER_NOT_ACTIVATED);
|
public Response<Void> handleUserNotActivatedException(Throwable e) {
|
||||||
}
|
return handleException(ErrorConstants.USER_NOT_ACTIVATED);
|
||||||
|
}
|
||||||
@ExceptionHandler(UserResetKeyError.class)
|
|
||||||
public ResponseExtended<String> handleUserResetKeyError(Throwable e) {
|
@ExceptionHandler(UserResetKeyError.class)
|
||||||
return handleException(ErrorConstants.USER_RESET_ERROR, e.getMessage());
|
public ResponseExtended<String> handleUserResetKeyError(Throwable e) {
|
||||||
}
|
return handleException(ErrorConstants.USER_RESET_ERROR, e.getMessage());
|
||||||
|
}
|
||||||
@ExceptionHandler(UserIsUndeadException.class)
|
|
||||||
public ResponseExtended<String> handleUserIsUndeadException(Throwable e) {
|
@ExceptionHandler(UserIsUndeadException.class)
|
||||||
return handleException(ErrorConstants.USER_UNDEAD_ERROR, e.getMessage());
|
public ResponseExtended<String> handleUserIsUndeadException(Throwable e) {
|
||||||
}
|
return handleException(ErrorConstants.USER_UNDEAD_ERROR, e.getMessage());
|
||||||
|
}
|
||||||
@ExceptionHandler(UserSendingMailException.class)
|
|
||||||
public ResponseExtended<String> handleUserSendingMailException(Throwable e) {
|
@ExceptionHandler(UserSendingMailException.class)
|
||||||
return handleException(ErrorConstants.USER_SENDING_MAIL_EXCEPTION, e.getMessage());
|
public ResponseExtended<String> handleUserSendingMailException(Throwable e) {
|
||||||
}
|
return handleException(ErrorConstants.USER_SENDING_MAIL_EXCEPTION, e.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package ru.ulstu.core.model;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.security.core.AuthenticationException;
|
|
||||||
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import ru.ulstu.user.error.UserBlockedException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class AuthFailureHandler implements AuthenticationFailureHandler {
|
|
||||||
@Override
|
|
||||||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
|
|
||||||
AuthenticationException ex) throws IOException {
|
|
||||||
if (ex.getClass() == UserBlockedException.class) {
|
|
||||||
response.sendRedirect("/users/block");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,34 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
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);
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
package ru.ulstu.core.model;
|
|
||||||
|
|
||||||
import ru.ulstu.user.model.User;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public interface UserActivity {
|
|
||||||
String getTitle();
|
|
||||||
|
|
||||||
Set<User> getActivityUsers();
|
|
||||||
}
|
|
@ -0,0 +1,9 @@
|
|||||||
|
package ru.ulstu.core.model;
|
||||||
|
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public interface UserContainer {
|
||||||
|
Set<User> getUsers();
|
||||||
|
}
|
@ -1,69 +0,0 @@
|
|||||||
package ru.ulstu.core.navigation;
|
|
||||||
|
|
||||||
public class Page {
|
|
||||||
public static final String INDEX = "/index.html";
|
|
||||||
public static final String PAPER = "/paper/paper.html";
|
|
||||||
public static final String PAPER_LIST = "/paper/papers.html";
|
|
||||||
public static final String PAPER_DASHBOARD = "/paper/dashboard.html";
|
|
||||||
public static final String GRANT = "/grant/grant.html";
|
|
||||||
public static final String GRANT_LIST = "/grant/grants.html";
|
|
||||||
public static final String GRANT_DASHBOARD = "/grant/dashboard.html";
|
|
||||||
public static final String USER_LIST = "/admin/users.html";
|
|
||||||
public static final String LOGOUT = "/logout";
|
|
||||||
public static final String CONFERENCE = "/conference/conference.html";
|
|
||||||
public static final String CONFERENCE_DASHBOARD = "/conference/dashboard.html";
|
|
||||||
public static final String CONFERENCE_LIST = "/conference/conferences.html";
|
|
||||||
public static final String PROJECT_DASHBOARD = "/conference/dashboard.html";
|
|
||||||
|
|
||||||
public String getIndex() {
|
|
||||||
return INDEX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPaperList() {
|
|
||||||
return PAPER_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPaperDashboard() {
|
|
||||||
return PAPER_DASHBOARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserList() {
|
|
||||||
return USER_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLogout() {
|
|
||||||
return LOGOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGrantList() {
|
|
||||||
return GRANT_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGrantDashboard() {
|
|
||||||
return GRANT_DASHBOARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPaper() {
|
|
||||||
return PAPER;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGrant() {
|
|
||||||
return GRANT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getConferenceDashboard() {
|
|
||||||
return CONFERENCE_DASHBOARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProjectDashboard() {
|
|
||||||
return PROJECT_DASHBOARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getConference() {
|
|
||||||
return CONFERENCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getConferenceList() {
|
|
||||||
return CONFERENCE_LIST;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,17 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,29 +0,0 @@
|
|||||||
package ru.ulstu.grant.controller;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import ru.ulstu.configuration.Constants;
|
|
||||||
import ru.ulstu.grant.service.GrantService;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.ParseException;
|
|
||||||
|
|
||||||
import static ru.ulstu.paper.controller.PaperRestController.URL;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(URL)
|
|
||||||
public class GrantRestController {
|
|
||||||
public static final String URL = Constants.API_1_0 + "grants";
|
|
||||||
|
|
||||||
private final GrantService grantService;
|
|
||||||
|
|
||||||
public GrantRestController(GrantService grantService) {
|
|
||||||
this.grantService = grantService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/grab")
|
|
||||||
public void grab() throws IOException, ParseException {
|
|
||||||
grantService.createFromKias();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package ru.ulstu.index.model;
|
|
||||||
|
|
||||||
public class Section {
|
|
||||||
private final String title;
|
|
||||||
private final String image;
|
|
||||||
private final String href;
|
|
||||||
|
|
||||||
public Section(String title, String href, String image) {
|
|
||||||
this.title = title;
|
|
||||||
this.image = image;
|
|
||||||
this.href = href;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getImage() {
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHref() {
|
|
||||||
return href;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,4 @@
|
|||||||
|
package ru.ulstu.odinexample.controller;
|
||||||
|
|
||||||
|
public class OdinExampleController {
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package ru.ulstu.odinexample.model;
|
||||||
|
|
||||||
|
public class OdinExampleDto {
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package ru.ulstu.odinexample.service;
|
||||||
|
|
||||||
|
public class OdinExampleService {
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.paper.error;
|
||||||
|
|
||||||
|
public class PaperConferenceRelationExistException extends RuntimeException {
|
||||||
|
public PaperConferenceRelationExistException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
@ -1,35 +0,0 @@
|
|||||||
package ru.ulstu.ping.model;
|
|
||||||
|
|
||||||
import ru.ulstu.user.model.User;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PingInfo {
|
|
||||||
private User user;
|
|
||||||
private List<Ping> pings = new ArrayList<>();
|
|
||||||
|
|
||||||
public PingInfo(User user) {
|
|
||||||
this.user = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUser(User user) {
|
|
||||||
this.user = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Ping> getPings() {
|
|
||||||
return pings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPings(List<Ping> pings) {
|
|
||||||
this.pings = pings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPing(Ping ping) {
|
|
||||||
this.pings.add(ping);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
package ru.ulstu.ping.service;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import ru.ulstu.core.model.UserActivity;
|
|
||||||
import ru.ulstu.ping.model.Ping;
|
|
||||||
import ru.ulstu.ping.model.PingInfo;
|
|
||||||
import ru.ulstu.ping.repository.PingRepository;
|
|
||||||
import ru.ulstu.user.model.User;
|
|
||||||
import ru.ulstu.user.service.MailService;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class PingScheduler {
|
|
||||||
private final Logger log = LoggerFactory.getLogger(PingScheduler.class);
|
|
||||||
private final PingRepository pingRepository;
|
|
||||||
private final MailService mailService;
|
|
||||||
private final static String PING_MAIL_SUBJECT = "Ping статистика";
|
|
||||||
|
|
||||||
public PingScheduler(PingRepository pingRepository, MailService mailService) {
|
|
||||||
this.pingRepository = pingRepository;
|
|
||||||
this.mailService = mailService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 * * 1 ?")
|
|
||||||
public void sendPingsInfo() {
|
|
||||||
log.debug("Scheduler.sendPingsInfo started");
|
|
||||||
|
|
||||||
List<PingInfo> pingInfos = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Ping ping : pingRepository.findByDate(java.sql.Date.valueOf(LocalDate.now().minusWeeks(1)))) {
|
|
||||||
UserActivity pingActivity = ping.getActivity();
|
|
||||||
Set<User> users = pingActivity.getActivityUsers();
|
|
||||||
|
|
||||||
for (User user : users) {
|
|
||||||
PingInfo userPing = pingInfos.stream().filter(u -> u.getUser() == user).findFirst().orElse(null);
|
|
||||||
if (userPing == null) {
|
|
||||||
userPing = new PingInfo(user);
|
|
||||||
pingInfos.add(userPing);
|
|
||||||
}
|
|
||||||
userPing.addPing(ping);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (PingInfo pingInfo : pingInfos) {
|
|
||||||
mailService.sendEmailFromTemplate(Map.of("pings", pingInfo.getPings()),
|
|
||||||
pingInfo.getUser(), "pingsInfoWeekEmail", PING_MAIL_SUBJECT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,13 @@
|
|||||||
package ru.ulstu.project.repository;
|
package ru.ulstu.project.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import ru.ulstu.name.BaseRepository;
|
||||||
import ru.ulstu.project.model.Project;
|
import ru.ulstu.project.model.Project;
|
||||||
|
|
||||||
public interface ProjectRepository extends JpaRepository<Project, Integer> {
|
public interface ProjectRepository extends JpaRepository<Project, Integer>, BaseRepository {
|
||||||
|
@Override
|
||||||
|
@Query("SELECT title FROM Project c WHERE (c.title = :name) AND (:id IS NULL OR c.id != :id) ")
|
||||||
|
String findByNameAndNotId(@Param("name") String name, @Param("id") Integer id);
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue