Compare commits
129 Commits
93-activit
...
dev
Author | SHA1 | Date |
---|---|---|
romanov73 | 70c2ab3f8c | 1 month ago |
romanov73 | 9c2fcef028 | 1 month ago |
Anton Romanov | 0a8a5f2df4 | 2 months ago |
Anton Romanov | 7713078596 | 2 months ago |
Anton Romanov | e6b4ed9f2c | 2 months ago |
Anton Romanov | 6dc88fdada | 2 months ago |
Anton Romanov | 234b043d72 | 2 months ago |
Anton Romanov | f522ed9b81 | 2 months ago |
Anton Romanov | 6f6a8b0eac | 2 months ago |
Anton Romanov | eb5ad650c9 | 2 months ago |
Anton Romanov | 9274dfc3d0 | 2 months ago |
Anton Romanov | 41b5d42330 | 2 months ago |
Anton Romanov | c6c0db0232 | 2 months ago |
Anton Romanov | 6a04b5e037 | 2 months ago |
Anton Romanov | a9c617075f | 2 months ago |
romanov73 | db4620694c | 2 months ago |
Anton Romanov | 70c950cdd7 | 2 months ago |
Anton Romanov | a9e8336986 | 2 months ago |
Anton Romanov | 23797bae9e | 2 months ago |
Anton Romanov | 37c1d0db08 | 2 months ago |
Anton Romanov | b49adee62a | 2 months ago |
Anton Romanov | c8382c4aea | 3 months ago |
Anton Romanov | 6e40343d6c | 3 months ago |
Anton Romanov | 55a76daa5a | 3 months ago |
Anton Romanov | 5371df1f50 | 3 months ago |
Anton Romanov | 4ab3637d9c | 4 years ago |
Anton Romanov | 893f7ae1f2 | 4 years ago |
Anton Romanov | 06f657f5c2 | 4 years ago |
Anton Romanov | b13f331f2c | 4 years ago |
Anton Romanov | 12973109d3 | 4 years ago |
Anton Romanov | 278e2135bb | 4 years ago |
Anton Romanov | b662437afe | 4 years ago |
Anton Romanov | 5ae17fbe83 | 4 years ago |
Anton Romanov | 3f16c8a078 | 4 years ago |
Anton Romanov | e3da8c710f | 4 years ago |
Anton Romanov | 54b992a7f3 | 4 years ago |
Anton Romanov | e20fb468f9 | 4 years ago |
Anton Romanov | 1a3ffb7bab | 4 years ago |
Anton Romanov | d29416fb76 | 4 years ago |
Anton Romanov | 37053d853b | 4 years ago |
Anton Romanov | b961c8e3dc | 4 years ago |
Anton Romanov | 3dd6210f42 | 4 years ago |
Anton Romanov | 5520f19357 | 4 years ago |
Anton Romanov | 2cc3008dc5 | 4 years ago |
Anton Romanov | 708a1a6d32 | 4 years ago |
Anton Romanov | 751195bf96 | 4 years ago |
Anton Romanov | 6adb3fec71 | 4 years ago |
Anton Romanov | ae0a1f3532 | 4 years ago |
Anton Romanov | e167a68bc6 | 4 years ago |
Anton Romanov | 6b717f26d3 | 4 years ago |
Anton Romanov | b20ab96b55 | 4 years ago |
Anton Romanov | 2c55293e0e | 4 years ago |
Anton Romanov | a14735699c | 4 years ago |
Anton Romanov | 9f21850767 | 4 years ago |
Anton Romanov | abde7f311c | 4 years ago |
Anton Romanov | 5333258c62 | 4 years ago |
Anton Romanov | 2149dfd32f | 4 years ago |
Anton Romanov | 34c5e79cbb | 4 years ago |
Anton Romanov | 2110c21be7 | 4 years ago |
Anton Romanov | 30e06335e9 | 4 years ago |
Anton Romanov | c528711431 | 4 years ago |
Anton Romanov | 0bb9768bda | 4 years ago |
Anton Romanov | 52d6210875 | 4 years ago |
Anton Romanov | 65569732d6 | 4 years ago |
Anton Romanov | 1d0c90d932 | 4 years ago |
Anton Romanov | 440def2b71 | 4 years ago |
Anton Romanov | 1460e26127 | 4 years ago |
Anton Romanov | 1f5cde4b66 | 4 years ago |
Anton Romanov | 10a99d42cf | 4 years ago |
Anton Romanov | 90c11c6946 | 4 years ago |
Anton Romanov | 134f75666c | 4 years ago |
Anton Romanov | b8d492724c | 4 years ago |
Anton Romanov | bc48a486ee | 4 years ago |
Anton Romanov | c36876f7e7 | 4 years ago |
Anton Romanov | a136acb0b4 | 5 years ago |
Anton Romanov | 7d1f5e9059 | 5 years ago |
Anton Romanov | 4c4c1b2015 | 5 years ago |
Anton Romanov | 6b90d7b0c0 | 5 years ago |
Anton Romanov | fa03edf32d | 5 years ago |
Anton Romanov | 4e1d99392a | 5 years ago |
Anton Romanov | ac55481bc6 | 5 years ago |
Anton Romanov | 71448364d7 | 5 years ago |
Anton Romanov | c57914db7c | 5 years ago |
Anton Romanov | ab20b3843f | 5 years ago |
Anton Romanov | 268a311a87 | 5 years ago |
Anton Romanov | a67eb23714 | 5 years ago |
Anton Romanov | 5ee1f33de1 | 5 years ago |
Anton Romanov | 107ddb90ac | 5 years ago |
Anton Romanov | ac6bd13c6c | 5 years ago |
Anton Romanov | e7061f4545 | 5 years ago |
Anton Romanov | d741bd019a | 5 years ago |
Anton Romanov | 846d94bb46 | 5 years ago |
Anton Romanov | 5755cf2f92 | 5 years ago |
Anton Romanov | 7587ff7a51 | 5 years ago |
Anton Romanov | 6c220355ee | 5 years ago |
Anton Romanov | 779f286988 | 5 years ago |
Anton Romanov | 7753dd104c | 5 years ago |
Anton Romanov | 48955b9cfd | 5 years ago |
Anton Romanov | 9665653234 | 5 years ago |
Anton Romanov | 04f545db1c | 5 years ago |
Anton Romanov | 746f443931 | 5 years ago |
Anton Romanov | 1be74769bf | 5 years ago |
Anton Romanov | 2cdec4bcda | 5 years ago |
Anton Romanov | a17dac55e2 | 5 years ago |
Anton Romanov | 9e6993f136 | 5 years ago |
Anton Romanov | 0647438bfb | 5 years ago |
Anton Romanov | 41c4ee7997 | 5 years ago |
Anton Romanov | 9d3ee273f6 | 5 years ago |
Anton Romanov | 3267138524 | 5 years ago |
Anton Romanov | df1bf873ff | 5 years ago |
Anton Romanov | 24f447aed7 | 5 years ago |
Anton Romanov | 36c4e52e37 | 5 years ago |
Anton Romanov | 529db0442c | 5 years ago |
Anton Romanov | db97892af2 | 5 years ago |
Anton Romanov | ff19001f1f | 5 years ago |
Anton Romanov | 2012a58fc2 | 5 years ago |
Anton Romanov | 4d2d7fa113 | 5 years ago |
Anton Romanov | 9393fbe326 | 5 years ago |
Anton Romanov | 955bdaa438 | 5 years ago |
Anton Romanov | 60dfad5d76 | 5 years ago |
Anton Romanov | e16b1da761 | 5 years ago |
Anton Romanov | 09cae66ca4 | 5 years ago |
Anton Romanov | 7684bac74d | 5 years ago |
Anton Romanov | 2cf3e52596 | 5 years ago |
Anton Romanov | 167de9bf65 | 5 years ago |
Anton Romanov | 993a034527 | 5 years ago |
Anton Romanov | 9bd954ea9b | 5 years ago |
Anton Romanov | 1487affb8e | 5 years ago |
Anton Romanov | e74261184f | 5 years ago |
@ -0,0 +1,19 @@
|
||||
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])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package ru.ulstu.activity.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import ru.ulstu.activity.service.ActivityService;
|
||||
|
||||
@Controller()
|
||||
@RequestMapping(value = "/activities")
|
||||
public class ActivityController {
|
||||
private ActivityService activityService;
|
||||
|
||||
public ActivityController(ActivityService activityService) {
|
||||
this.activityService = activityService;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package ru.ulstu.activity.model;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import ru.ulstu.core.model.BaseEntity;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "activity")
|
||||
public class Activity extends BaseEntity {
|
||||
|
||||
public enum ActivityState {
|
||||
TOOK_IN_WORK("Взято в работу"),
|
||||
COMPLETED("Выполнено");
|
||||
|
||||
private String statusName;
|
||||
|
||||
ActivityState(String statusName) {
|
||||
this.statusName = statusName;
|
||||
}
|
||||
|
||||
public String getStatusName() {
|
||||
return this.statusName;
|
||||
}
|
||||
}
|
||||
|
||||
@ManyToOne()
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date date;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@Column(name = "state")
|
||||
private ActivityState activityState;
|
||||
|
||||
public Activity(User user, ActivityState activityState) {
|
||||
this.user = user;
|
||||
this.date = new Date();
|
||||
this.activityState = activityState;
|
||||
}
|
||||
|
||||
public Activity() {
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public ActivityState getActivityState() {
|
||||
return activityState;
|
||||
}
|
||||
|
||||
public void setActivityState(ActivityState activityState) {
|
||||
this.activityState = activityState;
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package ru.ulstu.activity.model;
|
||||
|
||||
public class ActivityElement {
|
||||
private int startedCount = 0;
|
||||
private int completedCount = 0;
|
||||
|
||||
public ActivityElement() {
|
||||
}
|
||||
|
||||
public ActivityElement(int startedCount, int completedCount) {
|
||||
this.startedCount = startedCount;
|
||||
this.completedCount = completedCount;
|
||||
}
|
||||
|
||||
public int getStartedCount() {
|
||||
return startedCount;
|
||||
}
|
||||
|
||||
public void setStartedCount(int startedCount) {
|
||||
this.startedCount = startedCount;
|
||||
}
|
||||
|
||||
public int getCompletedCount() {
|
||||
return completedCount;
|
||||
}
|
||||
|
||||
public void setCompletedCount(int completedCount) {
|
||||
this.completedCount = completedCount;
|
||||
}
|
||||
|
||||
public void incrementStartedCount() {
|
||||
this.startedCount++;
|
||||
}
|
||||
|
||||
public void incrementCompletedCount() {
|
||||
this.completedCount++;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package ru.ulstu.activity.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.activity.model.Activity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ActivityRepository extends JpaRepository<Activity, Integer> {
|
||||
|
||||
@Query("SELECT a FROM Activity a WHERE (:userId IS NULL OR a.user.id = :userId) " +
|
||||
"AND (CAST(:dateFrom AS date) IS NULL OR :dateFrom < a.date) " +
|
||||
"AND (CAST(:dateTo AS date) IS NULL OR :dateTo > a.date)")
|
||||
List<Activity> getByUserAndDateInterval(@Param("userId") Integer userId,
|
||||
@Param("dateFrom") Date dateFrom,
|
||||
@Param("dateTo") Date dateTo);
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package ru.ulstu.activity.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.activity.model.Activity;
|
||||
import ru.ulstu.activity.model.ActivityElement;
|
||||
import ru.ulstu.activity.repository.ActivityRepository;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class ActivityService {
|
||||
private ActivityRepository activityRepository;
|
||||
|
||||
public ActivityService(ActivityRepository activityRepository) {
|
||||
this.activityRepository = activityRepository;
|
||||
}
|
||||
|
||||
public void createActivity(List<User> users, Activity.ActivityState state) {
|
||||
List<Activity> activities = new ArrayList<>();
|
||||
for (User user : users) {
|
||||
activities.add(new Activity(user, state));
|
||||
}
|
||||
activityRepository.save(activities);
|
||||
}
|
||||
|
||||
public Map<String, ActivityElement> getUsersActivity(Integer userId, Date dateFrom, Date dateTo) {
|
||||
List<Activity> activities = activityRepository.getByUserAndDateInterval(userId, dateFrom, dateTo);
|
||||
Map<String, ActivityElement> dateActivities = new HashMap<>();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (Activity activity : activities) {
|
||||
String dt = formatter.format(activity.getDate());
|
||||
ActivityElement element;
|
||||
if (!dateActivities.containsKey(dt)) {
|
||||
element = new ActivityElement();
|
||||
} else {
|
||||
element = dateActivities.get(dt);
|
||||
}
|
||||
switch (activity.getActivityState()) {
|
||||
case TOOK_IN_WORK:
|
||||
element.incrementStartedCount();
|
||||
break;
|
||||
case COMPLETED:
|
||||
element.incrementCompletedCount();
|
||||
break;
|
||||
}
|
||||
dateActivities.put(dt, element);
|
||||
}
|
||||
return dateActivities;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
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,116 +1,115 @@
|
||||
package ru.ulstu.core.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import ru.ulstu.core.error.EntityIdIsNullException;
|
||||
import ru.ulstu.core.model.ErrorConstants;
|
||||
import ru.ulstu.core.model.response.Response;
|
||||
import ru.ulstu.core.model.response.ResponseExtended;
|
||||
import ru.ulstu.user.error.UserActivationError;
|
||||
import ru.ulstu.user.error.UserEmailExistsException;
|
||||
import ru.ulstu.user.error.UserIdExistsException;
|
||||
import ru.ulstu.user.error.UserIsUndeadException;
|
||||
import ru.ulstu.user.error.UserLoginExistsException;
|
||||
import ru.ulstu.user.error.UserNotActivatedException;
|
||||
import ru.ulstu.user.error.UserNotFoundException;
|
||||
import ru.ulstu.user.error.UserPasswordsNotValidOrNotMatchException;
|
||||
import ru.ulstu.user.error.UserResetKeyError;
|
||||
import ru.ulstu.user.error.UserSendingMailException;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ControllerAdvice
|
||||
public class AdviceController {
|
||||
private final Logger log = LoggerFactory.getLogger(AdviceController.class);
|
||||
private final UserService userService;
|
||||
|
||||
public AdviceController(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@ModelAttribute("flashMessage")
|
||||
public String getFlashMessage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Response<Void> handleException(ErrorConstants error) {
|
||||
log.warn(error.toString());
|
||||
return new Response<>(error);
|
||||
}
|
||||
|
||||
private <E> ResponseExtended<E> handleException(ErrorConstants error, E errorData) {
|
||||
log.warn(error.toString());
|
||||
return new ResponseExtended<>(error, errorData);
|
||||
}
|
||||
|
||||
@ExceptionHandler(EntityIdIsNullException.class)
|
||||
public Response<Void> handleEntityIdIsNullException(Throwable e) {
|
||||
return handleException(ErrorConstants.ID_IS_NULL);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResponseExtended<Set<String>> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||
final Set<String> errors = e.getBindingResult().getAllErrors().stream()
|
||||
.filter(error -> error instanceof FieldError)
|
||||
.map(error -> ((FieldError) error).getField())
|
||||
.collect(Collectors.toSet());
|
||||
return handleException(ErrorConstants.VALIDATION_ERROR, errors);
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserIdExistsException.class)
|
||||
public Response<Void> handleUserIdExistsException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_ID_EXISTS);
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserActivationError.class)
|
||||
public ResponseExtended<String> handleUserActivationError(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_ACTIVATION_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserLoginExistsException.class)
|
||||
public ResponseExtended<String> handleUserLoginExistsException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_LOGIN_EXISTS, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserEmailExistsException.class)
|
||||
public ResponseExtended<String> handleUserEmailExistsException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_EMAIL_EXISTS, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserPasswordsNotValidOrNotMatchException.class)
|
||||
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) {
|
||||
return handleException(ErrorConstants.USER_NOT_FOUND, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserNotActivatedException.class)
|
||||
public Response<Void> handleUserNotActivatedException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_NOT_ACTIVATED);
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserResetKeyError.class)
|
||||
public ResponseExtended<String> handleUserResetKeyError(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_RESET_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserIsUndeadException.class)
|
||||
public ResponseExtended<String> handleUserIsUndeadException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_UNDEAD_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserSendingMailException.class)
|
||||
public ResponseExtended<String> handleUserSendingMailException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_SENDING_MAIL_EXCEPTION, e.getMessage());
|
||||
}
|
||||
}
|
||||
package ru.ulstu.core.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import ru.ulstu.core.error.EntityIdIsNullException;
|
||||
import ru.ulstu.core.model.ErrorConstants;
|
||||
import ru.ulstu.core.model.response.Response;
|
||||
import ru.ulstu.core.model.response.ResponseExtended;
|
||||
import ru.ulstu.user.error.UserActivationError;
|
||||
import ru.ulstu.user.error.UserEmailExistsException;
|
||||
import ru.ulstu.user.error.UserIdExistsException;
|
||||
import ru.ulstu.user.error.UserIsUndeadException;
|
||||
import ru.ulstu.user.error.UserLoginExistsException;
|
||||
import ru.ulstu.user.error.UserNotActivatedException;
|
||||
import ru.ulstu.user.error.UserNotFoundException;
|
||||
import ru.ulstu.user.error.UserPasswordsNotValidOrNotMatchException;
|
||||
import ru.ulstu.user.error.UserResetKeyError;
|
||||
import ru.ulstu.user.error.UserSendingMailException;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
//@ControllerAdvice
|
||||
public class AdviceController {
|
||||
private final Logger log = LoggerFactory.getLogger(AdviceController.class);
|
||||
private final UserService userService;
|
||||
|
||||
public AdviceController(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@ModelAttribute("flashMessage")
|
||||
public String getFlashMessage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Response<Void> handleException(ErrorConstants error) {
|
||||
log.warn(error.toString());
|
||||
return new Response<>(error);
|
||||
}
|
||||
|
||||
private <E> ResponseExtended<E> handleException(ErrorConstants error, E errorData) {
|
||||
log.warn(error.toString());
|
||||
return new ResponseExtended<>(error, errorData);
|
||||
}
|
||||
|
||||
@ExceptionHandler(EntityIdIsNullException.class)
|
||||
public Response<Void> handleEntityIdIsNullException(Throwable e) {
|
||||
return handleException(ErrorConstants.ID_IS_NULL);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResponseExtended<Set<String>> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||
final Set<String> errors = e.getBindingResult().getAllErrors().stream()
|
||||
.filter(error -> error instanceof FieldError)
|
||||
.map(error -> ((FieldError) error).getField())
|
||||
.collect(Collectors.toSet());
|
||||
return handleException(ErrorConstants.VALIDATION_ERROR, errors);
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserIdExistsException.class)
|
||||
public Response<Void> handleUserIdExistsException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_ID_EXISTS);
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserActivationError.class)
|
||||
public ResponseExtended<String> handleUserActivationError(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_ACTIVATION_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserLoginExistsException.class)
|
||||
public ResponseExtended<String> handleUserLoginExistsException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_LOGIN_EXISTS, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserEmailExistsException.class)
|
||||
public ResponseExtended<String> handleUserEmailExistsException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_EMAIL_EXISTS, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserPasswordsNotValidOrNotMatchException.class)
|
||||
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) {
|
||||
return handleException(ErrorConstants.USER_NOT_FOUND, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserNotActivatedException.class)
|
||||
public Response<Void> handleUserNotActivatedException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_NOT_ACTIVATED);
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserResetKeyError.class)
|
||||
public ResponseExtended<String> handleUserResetKeyError(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_RESET_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserIsUndeadException.class)
|
||||
public ResponseExtended<String> handleUserIsUndeadException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_UNDEAD_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserSendingMailException.class)
|
||||
public ResponseExtended<String> handleUserSendingMailException(Throwable e) {
|
||||
return handleException(ErrorConstants.USER_SENDING_MAIL_EXCEPTION, e.getMessage());
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 {
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package ru.ulstu.paper.error;
|
||||
|
||||
public class PaperConferenceRelationExistException extends RuntimeException {
|
||||
public PaperConferenceRelationExistException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue