create api for activities
This commit is contained in:
parent
7c0a8be51b
commit
119f5a52ab
31
src/main/java/ru/ulstu/activity/api/ActivityController.java
Normal file
31
src/main/java/ru/ulstu/activity/api/ActivityController.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package ru.ulstu.activity.api;
|
||||||
|
|
||||||
|
import ru.ulstu.activity.api.model.ActivityDashboardDto;
|
||||||
|
import ru.ulstu.activity.api.model.ActivityDto;
|
||||||
|
import ru.ulstu.activity.api.model.ActivityListDto;
|
||||||
|
import ru.ulstu.core.model.response.PageableItems;
|
||||||
|
import ru.ulstu.core.model.response.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Базовый API для контролеров активностей
|
||||||
|
*
|
||||||
|
* @param <LIST>
|
||||||
|
* @param <DASHBOARD>
|
||||||
|
* @param <ENTITYDTO>
|
||||||
|
*/
|
||||||
|
public interface ActivityController<LIST extends ActivityListDto, DASHBOARD extends ActivityDashboardDto, ENTITYDTO extends ActivityDto> {
|
||||||
|
|
||||||
|
Response<PageableItems<LIST>> getList(int offset, int count);
|
||||||
|
|
||||||
|
Response<PageableItems<DASHBOARD>> getDashboard(int offset, int count);
|
||||||
|
|
||||||
|
Response<ENTITYDTO> get(Integer entityId);
|
||||||
|
|
||||||
|
Response<ENTITYDTO> create(ENTITYDTO entity);
|
||||||
|
|
||||||
|
Response<ENTITYDTO> update(ENTITYDTO entity);
|
||||||
|
|
||||||
|
Response<Boolean> delete(Integer entityId);
|
||||||
|
|
||||||
|
void ping(int entityId);
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package ru.ulstu.name;
|
package ru.ulstu.activity.api;
|
||||||
|
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
public interface BaseRepository {
|
public interface ActivityRepository {
|
||||||
String findByNameAndNotId(@Param("name") String name, @Param("id") Integer id);
|
String findByNameAndNotId(@Param("name") String name, @Param("id") Integer id);
|
||||||
}
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package ru.ulstu.activity.api.model;
|
||||||
|
|
||||||
|
public interface ActivityDashboardDto {
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package ru.ulstu.activity.api.model;
|
||||||
|
|
||||||
|
public interface ActivityDto {
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package ru.ulstu.activity.api.model;
|
||||||
|
|
||||||
|
public abstract class ActivityListDto {
|
||||||
|
private final Integer id;
|
||||||
|
private final String title;
|
||||||
|
|
||||||
|
protected ActivityListDto(Integer id, String title) {
|
||||||
|
this.id = id;
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.utils.timetable;
|
package ru.ulstu.activity.boundary.timetable;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.springframework.web.client.RestClientException;
|
import org.springframework.web.client.RestClientException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import ru.ulstu.activity.boundary.timetable.errors.TimetableClientException;
|
||||||
|
import ru.ulstu.activity.boundary.timetable.model.Lesson;
|
||||||
|
import ru.ulstu.activity.boundary.timetable.model.TimetableResponse;
|
||||||
import ru.ulstu.core.util.DateUtils;
|
import ru.ulstu.core.util.DateUtils;
|
||||||
import ru.ulstu.utils.timetable.errors.TimetableClientException;
|
|
||||||
import ru.ulstu.utils.timetable.model.Lesson;
|
|
||||||
import ru.ulstu.utils.timetable.model.TimetableResponse;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.utils.timetable.errors;
|
package ru.ulstu.activity.boundary.timetable.errors;
|
||||||
|
|
||||||
public class TimetableClientException extends RuntimeException {
|
public class TimetableClientException extends RuntimeException {
|
||||||
public TimetableClientException(String message) {
|
public TimetableClientException(String message) {
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.utils.timetable.model;
|
package ru.ulstu.activity.boundary.timetable.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.utils.timetable.model;
|
package ru.ulstu.activity.boundary.timetable.model;
|
||||||
|
|
||||||
public class Lesson {
|
public class Lesson {
|
||||||
private String group;
|
private String group;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.utils.timetable.model;
|
package ru.ulstu.activity.boundary.timetable.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.utils.timetable.model;
|
package ru.ulstu.activity.boundary.timetable.model;
|
||||||
|
|
||||||
public class TimetableResponse {
|
public class TimetableResponse {
|
||||||
private Response response;
|
private Response response;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.utils.timetable.model;
|
package ru.ulstu.activity.boundary.timetable.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -1,6 +1,9 @@
|
|||||||
package ru.ulstu.boundary.model;
|
package ru.ulstu.activity.common.model;
|
||||||
|
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public abstract class AbstractActivity extends BaseEntity {
|
public abstract class AbstractActivity extends BaseEntity {
|
||||||
private String title;
|
private String title;
|
||||||
@ -12,4 +15,6 @@ public abstract class AbstractActivity extends BaseEntity {
|
|||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract Set<User> getActivityMembers();
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package ru.ulstu.core.model;
|
package ru.ulstu.activity.common.model;
|
||||||
|
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.timeline.model.Event;
|
import ru.ulstu.activity.timeline.model.Event;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,7 +1,8 @@
|
|||||||
package ru.ulstu.boundary.model;
|
package ru.ulstu.activity.common.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 ru.ulstu.activity.conference.model.ConferenceUser;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
@ -34,6 +35,13 @@ public class ScienceGroupMemberDto {
|
|||||||
this.lastName = user.getLastName();
|
this.lastName = user.getLastName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScienceGroupMemberDto(ConferenceUser conferenceUser) {
|
||||||
|
User user = conferenceUser.getUser();
|
||||||
|
this.id = user.getId();
|
||||||
|
this.firstName = user.getFirstName();
|
||||||
|
this.lastName = user.getLastName();
|
||||||
|
}
|
||||||
|
|
||||||
public String getFirstName() {
|
public String getFirstName() {
|
||||||
return firstName;
|
return firstName;
|
||||||
}
|
}
|
@ -1,13 +1,16 @@
|
|||||||
package ru.ulstu.boundary.service;
|
package ru.ulstu.activity.common.service;
|
||||||
|
|
||||||
import ru.ulstu.boundary.model.AbstractActivity;
|
import ru.ulstu.activity.api.ActivityRepository;
|
||||||
import ru.ulstu.boundary.model.ActivityDto;
|
import ru.ulstu.activity.api.model.ActivityDto;
|
||||||
import ru.ulstu.boundary.model.ActivityListDto;
|
import ru.ulstu.activity.api.model.ActivityListDto;
|
||||||
|
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||||
import ru.ulstu.core.model.response.PageableItems;
|
import ru.ulstu.core.model.response.PageableItems;
|
||||||
|
|
||||||
import static ru.ulstu.core.util.StreamApiUtils.convertPageable;
|
import static ru.ulstu.core.util.StreamApiUtils.convertPageable;
|
||||||
|
|
||||||
public abstract class AbstractActivityService<T extends AbstractActivity, D extends ActivityDto, L extends ActivityListDto> {
|
public abstract class AbstractActivityService<L extends ActivityListDto, T extends AbstractActivity, D extends ActivityDto> {
|
||||||
|
|
||||||
|
protected ActivityRepository activityRepository;
|
||||||
|
|
||||||
public abstract T create(T entity);
|
public abstract T create(T entity);
|
||||||
|
|
||||||
@ -26,4 +29,8 @@ public abstract class AbstractActivityService<T extends AbstractActivity, D exte
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract L getActivityListDto(T entity);
|
protected abstract L getActivityListDto(T entity);
|
||||||
|
|
||||||
|
protected boolean checkUniqueName(String title, Integer id) {
|
||||||
|
return title.equals(activityRepository.findByNameAndNotId(title, id));
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,21 +1,21 @@
|
|||||||
package ru.ulstu.strategy.api;
|
package ru.ulstu.activity.common.strategy.api;
|
||||||
|
|
||||||
import ru.ulstu.core.model.UserActivity;
|
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class EntityCreateStrategy<T extends UserActivity> {
|
public abstract class EntityCreateStrategy<T extends AbstractActivity> {
|
||||||
protected abstract List<T> getActiveEntities();
|
protected abstract List<T> getActiveEntities();
|
||||||
|
|
||||||
protected abstract void createEntity(User user);
|
protected abstract void createEntity(User user);
|
||||||
|
|
||||||
private void createDefaultEntityIfNeed(List<User> allUsers, List<? extends UserActivity> entities) {
|
private void createDefaultEntityIfNeed(List<User> allUsers, List<? extends AbstractActivity> entities) {
|
||||||
allUsers.forEach(user -> {
|
allUsers.forEach(user -> {
|
||||||
if (entities
|
if (entities
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entity -> entity.getActivityUsers().contains(user))
|
.filter(entity -> entity.getActivityMembers().contains(user))
|
||||||
.collect(Collectors.toSet()).isEmpty()) {
|
.collect(Collectors.toSet()).isEmpty()) {
|
||||||
createEntity(user);
|
createEntity(user);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.strategy.api;
|
package ru.ulstu.activity.common.strategy.api;
|
||||||
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
@ -1,14 +1,13 @@
|
|||||||
package ru.ulstu.conference.model;
|
package ru.ulstu.activity.conference.model;
|
||||||
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||||
import ru.ulstu.core.model.EventSource;
|
import ru.ulstu.activity.common.model.EventSource;
|
||||||
import ru.ulstu.core.model.UserActivity;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.activity.timeline.model.Event;
|
||||||
import ru.ulstu.timeline.model.Event;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
@ -36,7 +35,7 @@ import java.util.stream.Collectors;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "conference")
|
@Table(name = "conference")
|
||||||
@DiscriminatorValue("CONFERENCE")
|
@DiscriminatorValue("CONFERENCE")
|
||||||
public class Conference extends BaseEntity implements UserActivity, EventSource {
|
public class Conference extends AbstractActivity implements EventSource {
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String title;
|
private String title;
|
||||||
@ -79,6 +78,10 @@ public class Conference extends BaseEntity implements UserActivity, EventSource
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getRecipients() {
|
public List<User> getRecipients() {
|
||||||
List<User> list = new ArrayList<>();
|
List<User> list = new ArrayList<>();
|
||||||
@ -92,10 +95,6 @@ public class Conference extends BaseEntity implements UserActivity, EventSource
|
|||||||
event.setConference(this);
|
event.setConference(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
@ -170,7 +169,7 @@ public class Conference extends BaseEntity implements UserActivity, EventSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<User> getActivityUsers() {
|
public Set<User> getActivityMembers() {
|
||||||
return getUsers().stream().map(ConferenceUser::getUser).collect(Collectors.toSet());
|
return users.stream().map(conferenceUser -> conferenceUser.getUser()).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.conference.model;
|
package ru.ulstu.activity.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.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import ru.ulstu.activity.api.model.ActivityDto;
|
||||||
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
|
||||||
import ru.ulstu.name.NameContainer;
|
|
||||||
import ru.ulstu.paper.model.Paper;
|
|
||||||
|
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
@ -19,7 +19,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
public class ConferenceDto extends NameContainer {
|
public class ConferenceDto implements ActivityDto {
|
||||||
|
|
||||||
private final static String BEGIN_DATE = "Начало: ";
|
private final static String BEGIN_DATE = "Начало: ";
|
||||||
private final static String END_DATE = "Конец: ";
|
private final static String END_DATE = "Конец: ";
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.conference.model;
|
package ru.ulstu.activity.conference.model;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -0,0 +1,21 @@
|
|||||||
|
package ru.ulstu.activity.conference.model;
|
||||||
|
|
||||||
|
import ru.ulstu.activity.api.model.ActivityListDto;
|
||||||
|
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
|
public class ConferenceListDto extends ActivityListDto {
|
||||||
|
private final Set<ScienceGroupMemberDto> members;
|
||||||
|
|
||||||
|
public ConferenceListDto(Conference conference) {
|
||||||
|
super(conference.getId(), conference.getTitle());
|
||||||
|
this.members = convert(conference.getActivityMembers(), ScienceGroupMemberDto::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<ScienceGroupMemberDto> getAuthors() {
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.conference.model;
|
package ru.ulstu.activity.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;
|
@ -1,17 +1,17 @@
|
|||||||
package ru.ulstu.conference.repository;
|
package ru.ulstu.activity.conference.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.activity.api.ActivityRepository;
|
||||||
import ru.ulstu.name.BaseRepository;
|
import ru.ulstu.activity.conference.model.Conference;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ConferenceRepository extends JpaRepository<Conference, Integer>, BaseRepository {
|
public interface ConferenceRepository extends JpaRepository<Conference, Integer>, ActivityRepository {
|
||||||
@Query("SELECT c FROM Conference c LEFT JOIN c.users u WHERE (:user IS NULL OR u.user = :user) " +
|
@Query("SELECT c FROM Conference c LEFT JOIN c.users u WHERE (:user IS NULL OR u.user = :user) " +
|
||||||
"AND (YEAR(c.beginDate) = :year OR :year IS NULL) ORDER BY begin_date DESC")
|
"AND (YEAR(c.beginDate) = :year OR :year IS NULL) ORDER BY begin_date DESC")
|
||||||
List<Conference> findByUserAndYear(@Param("user") User user, @Param("year") Integer year);
|
List<Conference> findByUserAndYear(@Param("user") User user, @Param("year") Integer year);
|
@ -1,7 +1,7 @@
|
|||||||
package ru.ulstu.conference.repository;
|
package ru.ulstu.activity.conference.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import ru.ulstu.conference.model.ConferenceUser;
|
import ru.ulstu.activity.conference.model.ConferenceUser;
|
||||||
|
|
||||||
public interface ConferenceUserRepository extends JpaRepository<ConferenceUser, Integer> {
|
public interface ConferenceUserRepository extends JpaRepository<ConferenceUser, Integer> {
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
package ru.ulstu.conference.service;
|
package ru.ulstu.activity.conference.service;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.activity.conference.model.Conference;
|
||||||
|
import ru.ulstu.activity.ping.service.PingService;
|
||||||
import ru.ulstu.core.util.DateUtils;
|
import ru.ulstu.core.util.DateUtils;
|
||||||
import ru.ulstu.ping.service.PingService;
|
|
||||||
import ru.ulstu.user.service.MailService;
|
import ru.ulstu.user.service.MailService;
|
||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
@ -1,10 +1,12 @@
|
|||||||
package ru.ulstu.conference.service;
|
package ru.ulstu.activity.conference.service;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ConferenceScheduler {
|
public class ConferenceScheduler {
|
||||||
private final static boolean IS_DEADLINE_NOTIFICATION_BEFORE_WEEK = true;
|
private final static boolean IS_DEADLINE_NOTIFICATION_BEFORE_WEEK = true;
|
||||||
@ -24,14 +26,16 @@ public class ConferenceScheduler {
|
|||||||
@Scheduled(cron = "0 0 8 * * MON", zone = "Europe/Samara")
|
@Scheduled(cron = "0 0 8 * * MON", zone = "Europe/Samara")
|
||||||
public void checkDeadlineBeforeWeek() {
|
public void checkDeadlineBeforeWeek() {
|
||||||
log.debug("ConferenceScheduler.checkDeadlineBeforeWeek started");
|
log.debug("ConferenceScheduler.checkDeadlineBeforeWeek started");
|
||||||
conferenceNotificationService.sendDeadlineNotifications(conferenceService.findAll());
|
conferenceNotificationService.sendDeadlineNotifications(conferenceService.findAll(0, 100)
|
||||||
|
.getItems().stream().collect(Collectors.toList()));
|
||||||
log.debug("ConferenceScheduler.checkDeadlineBeforeWeek finished");
|
log.debug("ConferenceScheduler.checkDeadlineBeforeWeek finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 8 * * *", zone = "Europe/Samara")
|
@Scheduled(cron = "0 0 8 * * *", zone = "Europe/Samara")
|
||||||
public void checkNewPing() {
|
public void checkNewPing() {
|
||||||
log.debug("ConferenceScheduler.checkPing started");
|
log.debug("ConferenceScheduler.checkPing started");
|
||||||
conferenceNotificationService.sendPingNotifications(conferenceService.findAll());
|
conferenceNotificationService.sendPingNotifications(conferenceService.findAll(0, 100)
|
||||||
|
.getItems().stream().collect(Collectors.toList()));
|
||||||
log.debug("ConferenceScheduler.checkPing finished");
|
log.debug("ConferenceScheduler.checkPing finished");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,23 +1,25 @@
|
|||||||
package ru.ulstu.conference.service;
|
package ru.ulstu.activity.conference.service;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.activity.common.service.AbstractActivityService;
|
||||||
import ru.ulstu.conference.model.ConferenceDto;
|
import ru.ulstu.activity.conference.model.Conference;
|
||||||
import ru.ulstu.conference.model.ConferenceFilterDto;
|
import ru.ulstu.activity.conference.model.ConferenceDto;
|
||||||
import ru.ulstu.conference.model.ConferenceUser;
|
import ru.ulstu.activity.conference.model.ConferenceFilterDto;
|
||||||
import ru.ulstu.conference.repository.ConferenceRepository;
|
import ru.ulstu.activity.conference.model.ConferenceListDto;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.conference.model.ConferenceUser;
|
||||||
import ru.ulstu.deadline.service.DeadlineService;
|
import ru.ulstu.activity.conference.repository.ConferenceRepository;
|
||||||
import ru.ulstu.name.BaseService;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.activity.deadline.service.DeadlineService;
|
||||||
import ru.ulstu.paper.service.PaperService;
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
import ru.ulstu.ping.service.PingService;
|
import ru.ulstu.activity.paper.service.PaperService;
|
||||||
import ru.ulstu.timeline.service.EventService;
|
import ru.ulstu.activity.ping.service.PingService;
|
||||||
|
import ru.ulstu.activity.timeline.service.EventService;
|
||||||
|
import ru.ulstu.core.jpa.OffsetablePageRequest;
|
||||||
|
import ru.ulstu.core.model.response.PageableItems;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
@ -33,8 +35,7 @@ import static org.springframework.util.ObjectUtils.isEmpty;
|
|||||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ConferenceService extends BaseService {
|
public class ConferenceService extends AbstractActivityService<ConferenceListDto, Conference, ConferenceDto> {
|
||||||
private final static int MAX_DISPLAY_SIZE = 40;
|
|
||||||
|
|
||||||
private final ConferenceRepository conferenceRepository;
|
private final ConferenceRepository conferenceRepository;
|
||||||
private final ConferenceUserService conferenceUserService;
|
private final ConferenceUserService conferenceUserService;
|
||||||
@ -53,7 +54,7 @@ public class ConferenceService extends BaseService {
|
|||||||
PingService pingService,
|
PingService pingService,
|
||||||
ConferenceNotificationService conferenceNotificationService,
|
ConferenceNotificationService conferenceNotificationService,
|
||||||
EventService eventService) {
|
EventService eventService) {
|
||||||
this.baseRepository = conferenceRepository;
|
this.activityRepository = conferenceRepository;
|
||||||
this.conferenceRepository = conferenceRepository;
|
this.conferenceRepository = conferenceRepository;
|
||||||
this.conferenceUserService = conferenceUserService;
|
this.conferenceUserService = conferenceUserService;
|
||||||
this.deadlineService = deadlineService;
|
this.deadlineService = deadlineService;
|
||||||
@ -77,28 +78,18 @@ public class ConferenceService extends BaseService {
|
|||||||
return conferenceDto;
|
return conferenceDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageableItems<Conference> findAll(int offset, int count) {
|
||||||
public List<Conference> findAll() {
|
final Page<Conference> page = conferenceRepository.findAll(new OffsetablePageRequest(offset, count));
|
||||||
return conferenceRepository.findAll(new Sort(Sort.Direction.DESC, "beginDate"));
|
return new PageableItems<>(page.getTotalElements(), page.getContent());
|
||||||
}
|
|
||||||
|
|
||||||
public List<ConferenceDto> findAllDto() {
|
|
||||||
List<ConferenceDto> conferences = convert(findAll(), ConferenceDto::new);
|
|
||||||
conferences.forEach(conferenceDto -> conferenceDto.setTitle(StringUtils.abbreviate(conferenceDto.getTitle(), MAX_DISPLAY_SIZE)));
|
|
||||||
return conferences;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean save(ConferenceDto conferenceDto, Errors errors) throws IOException {
|
public boolean save(ConferenceDto conferenceDto, Errors errors) throws IOException {
|
||||||
conferenceDto.setName(conferenceDto.getTitle());
|
conferenceDto.setTitle(conferenceDto.getTitle());
|
||||||
filterEmptyDeadlines(conferenceDto);
|
filterEmptyDeadlines(conferenceDto);
|
||||||
checkEmptyFieldsOfDeadline(conferenceDto, errors);
|
checkEmptyFieldsOfDeadline(conferenceDto, errors);
|
||||||
checkEmptyFieldsOfDates(conferenceDto, errors);
|
checkEmptyFieldsOfDates(conferenceDto, errors);
|
||||||
checkUniqueName(conferenceDto,
|
if (!checkUniqueName(conferenceDto.getTitle(), conferenceDto.getId())) {
|
||||||
errors,
|
throw new RuntimeException("Название не уникально");
|
||||||
conferenceDto.getId(),
|
|
||||||
"Конференция с таким именем уже существует");
|
|
||||||
if (errors.hasErrors()) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(conferenceDto.getId())) {
|
if (isEmpty(conferenceDto.getId())) {
|
||||||
@ -111,29 +102,51 @@ public class ConferenceService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Conference create(ConferenceDto conferenceDto) throws IOException {
|
@Override
|
||||||
Conference newConference = copyFromDto(new Conference(), conferenceDto);
|
public ConferenceDto create(ConferenceDto conferenceDto) {
|
||||||
newConference = conferenceRepository.save(newConference);
|
Conference newConference;
|
||||||
conferenceNotificationService.sendCreateNotification(newConference);
|
try {
|
||||||
eventService.createFromObject(newConference, Collections.emptyList(), false, "конференции");
|
newConference = copyFromDto(new Conference(), conferenceDto);
|
||||||
return newConference;
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return new ConferenceDto(create(newConference));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
private Conference update(ConferenceDto conferenceDto) throws IOException {
|
@Override
|
||||||
|
public Conference create(Conference conference) {
|
||||||
|
conference = conferenceRepository.save(conference);
|
||||||
|
conferenceNotificationService.sendCreateNotification(conference);
|
||||||
|
eventService.createFromObject(conference, Collections.emptyList(), false, "конференции");
|
||||||
|
return conference;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public ConferenceDto update(ConferenceDto conferenceDto) {
|
||||||
Conference conference = conferenceRepository.getOne(conferenceDto.getId());
|
Conference conference = conferenceRepository.getOne(conferenceDto.getId());
|
||||||
|
try {
|
||||||
|
conferenceRepository.save(copyFromDto(conference, conferenceDto));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return new ConferenceDto(update(conference));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public Conference update(Conference conference) {
|
||||||
List<Deadline> oldDeadlines = conference.getDeadlines().stream()
|
List<Deadline> oldDeadlines = conference.getDeadlines().stream()
|
||||||
.map(this::copyDeadline)
|
.map(this::copyDeadline)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
Date oldBeginDate = conference.getBeginDate();
|
Date oldBeginDate = conference.getBeginDate();
|
||||||
Date oldEndDate = conference.getEndDate();
|
Date oldEndDate = conference.getEndDate();
|
||||||
conferenceRepository.save(copyFromDto(conference, conferenceDto));
|
|
||||||
eventService.updateConferenceDeadlines(conference);
|
eventService.updateConferenceDeadlines(conference);
|
||||||
sendNotificationAfterUpdateDeadlines(conference, oldDeadlines);
|
sendNotificationAfterUpdateDeadlines(conference, oldDeadlines);
|
||||||
if (!conference.getBeginDate().equals(oldBeginDate) || !conference.getEndDate().equals(oldEndDate)) {
|
if (!conference.getBeginDate().equals(oldBeginDate) || !conference.getEndDate().equals(oldEndDate)) {
|
||||||
conferenceNotificationService.updateConferencesDatesNotification(conference, oldBeginDate, oldEndDate);
|
conferenceNotificationService.updateConferencesDatesNotification(conference, oldBeginDate, oldEndDate);
|
||||||
}
|
}
|
||||||
conferenceDto.getRemovedDeadlineIds().forEach(deadlineService::remove);
|
|
||||||
return conference;
|
return conference;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,6 +160,11 @@ public class ConferenceService extends BaseService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ConferenceListDto getActivityListDto(Conference entity) {
|
||||||
|
return new ConferenceListDto(entity);
|
||||||
|
}
|
||||||
|
|
||||||
public ConferenceDto addDeadline(ConferenceDto conferenceDto) {
|
public ConferenceDto addDeadline(ConferenceDto conferenceDto) {
|
||||||
conferenceDto.getDeadlines().add(new Deadline());
|
conferenceDto.getDeadlines().add(new Deadline());
|
||||||
return conferenceDto;
|
return conferenceDto;
|
@ -1,9 +1,9 @@
|
|||||||
package ru.ulstu.conference.service;
|
package ru.ulstu.activity.conference.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import ru.ulstu.conference.model.ConferenceUser;
|
import ru.ulstu.activity.conference.model.ConferenceUser;
|
||||||
import ru.ulstu.conference.repository.ConferenceUserRepository;
|
import ru.ulstu.activity.conference.repository.ConferenceUserRepository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.deadline.model;
|
package ru.ulstu.activity.deadline.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;
|
@ -1,10 +1,10 @@
|
|||||||
package ru.ulstu.deadline.repository;
|
package ru.ulstu.activity.deadline.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.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package ru.ulstu.deadline.service;
|
package ru.ulstu.activity.deadline.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.deadline.repository.DeadlineRepository;
|
import ru.ulstu.activity.deadline.repository.DeadlineRepository;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.file;
|
package ru.ulstu.activity.file;
|
||||||
|
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@ -10,11 +10,11 @@ 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 org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import ru.ulstu.activity.file.model.FileData;
|
||||||
|
import ru.ulstu.activity.file.model.FileDataDto;
|
||||||
|
import ru.ulstu.activity.file.service.FileService;
|
||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
import ru.ulstu.core.model.response.Response;
|
import ru.ulstu.core.model.response.Response;
|
||||||
import ru.ulstu.file.model.FileData;
|
|
||||||
import ru.ulstu.file.model.FileDataDto;
|
|
||||||
import ru.ulstu.file.service.FileService;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.file.model;
|
package ru.ulstu.activity.file.model;
|
||||||
|
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.file.model;
|
package ru.ulstu.activity.file.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;
|
@ -1,7 +1,7 @@
|
|||||||
package ru.ulstu.file.repostory;
|
package ru.ulstu.activity.file.repostory;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import ru.ulstu.file.model.FileData;
|
import ru.ulstu.activity.file.model.FileData;
|
||||||
|
|
||||||
public interface FileRepository extends JpaRepository<FileData, Integer> {
|
public interface FileRepository extends JpaRepository<FileData, Integer> {
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.file.service;
|
package ru.ulstu.activity.file.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import ru.ulstu.file.model.FileData;
|
import ru.ulstu.activity.file.model.FileData;
|
||||||
import ru.ulstu.file.model.FileDataDto;
|
import ru.ulstu.activity.file.model.FileDataDto;
|
||||||
import ru.ulstu.file.repostory.FileRepository;
|
import ru.ulstu.activity.file.repostory.FileRepository;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.activity.paper.model.PaperDto;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
@ -1,10 +1,10 @@
|
|||||||
package ru.ulstu.grant.controller;
|
package ru.ulstu.activity.grant.controller;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import ru.ulstu.activity.grant.service.GrantService;
|
||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
import ru.ulstu.grant.service.GrantService;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
@ -1,15 +1,14 @@
|
|||||||
package ru.ulstu.grant.model;
|
package ru.ulstu.activity.grant.model;
|
||||||
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||||
import ru.ulstu.core.model.EventSource;
|
import ru.ulstu.activity.common.model.EventSource;
|
||||||
import ru.ulstu.core.model.UserActivity;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.file.model.FileData;
|
||||||
import ru.ulstu.file.model.FileData;
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.activity.project.model.Project;
|
||||||
import ru.ulstu.project.model.Project;
|
import ru.ulstu.activity.timeline.model.Event;
|
||||||
import ru.ulstu.timeline.model.Event;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
@ -39,7 +38,7 @@ import java.util.Set;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "grants")
|
@Table(name = "grants")
|
||||||
@DiscriminatorValue("GRANT")
|
@DiscriminatorValue("GRANT")
|
||||||
public class Grant extends BaseEntity implements UserActivity, EventSource {
|
public class Grant extends AbstractActivity implements EventSource {
|
||||||
public enum GrantStatus {
|
public enum GrantStatus {
|
||||||
APPLICATION("Заявка"),
|
APPLICATION("Заявка"),
|
||||||
ON_COMPETITION("Отправлен на конкурс"),
|
ON_COMPETITION("Отправлен на конкурс"),
|
||||||
@ -138,6 +137,10 @@ public class Grant extends BaseEntity implements UserActivity, EventSource {
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getRecipients() {
|
public List<User> getRecipients() {
|
||||||
return authors != null ? new ArrayList<>(authors) : Collections.emptyList();
|
return authors != null ? new ArrayList<>(authors) : Collections.emptyList();
|
||||||
@ -148,10 +151,6 @@ public class Grant extends BaseEntity implements UserActivity, EventSource {
|
|||||||
event.setGrant(this);
|
event.setGrant(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Project getProject() {
|
public Project getProject() {
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
@ -169,8 +168,8 @@ public class Grant extends BaseEntity implements UserActivity, EventSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<User> getActivityUsers() {
|
public Set<User> getActivityMembers() {
|
||||||
return getAuthors();
|
return authors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getLeader() {
|
public User getLeader() {
|
@ -1,14 +1,14 @@
|
|||||||
package ru.ulstu.grant.model;
|
package ru.ulstu.activity.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 ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.api.model.ActivityDto;
|
||||||
import ru.ulstu.file.model.FileDataDto;
|
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||||
import ru.ulstu.name.NameContainer;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.activity.file.model.FileDataDto;
|
||||||
import ru.ulstu.project.model.ProjectDto;
|
import ru.ulstu.activity.paper.model.PaperDto;
|
||||||
import ru.ulstu.user.model.UserDto;
|
import ru.ulstu.activity.project.model.ProjectDto;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -19,7 +19,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
public class GrantDto extends NameContainer {
|
public class GrantDto implements ActivityDto {
|
||||||
private final static int MAX_AUTHORS_LENGTH = 60;
|
private final static int MAX_AUTHORS_LENGTH = 60;
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
@ -31,7 +31,7 @@ public class GrantDto extends NameContainer {
|
|||||||
private List<FileDataDto> files = new ArrayList<>();
|
private List<FileDataDto> files = new ArrayList<>();
|
||||||
private ProjectDto project;
|
private ProjectDto project;
|
||||||
private Set<Integer> authorIds;
|
private Set<Integer> authorIds;
|
||||||
private Set<UserDto> authors;
|
private Set<ScienceGroupMemberDto> members;
|
||||||
private Integer leaderId;
|
private Integer leaderId;
|
||||||
private boolean wasLeader;
|
private boolean wasLeader;
|
||||||
private boolean hasAge;
|
private boolean hasAge;
|
||||||
@ -55,7 +55,7 @@ public class GrantDto extends NameContainer {
|
|||||||
@JsonProperty("files") List<FileDataDto> files,
|
@JsonProperty("files") List<FileDataDto> files,
|
||||||
@JsonProperty("project") ProjectDto project,
|
@JsonProperty("project") ProjectDto project,
|
||||||
@JsonProperty("authorIds") Set<Integer> authorIds,
|
@JsonProperty("authorIds") Set<Integer> authorIds,
|
||||||
@JsonProperty("authors") Set<UserDto> authors,
|
@JsonProperty("members") Set<ScienceGroupMemberDto> members,
|
||||||
@JsonProperty("leaderId") Integer leaderId,
|
@JsonProperty("leaderId") Integer leaderId,
|
||||||
@JsonProperty("wasLeader") boolean wasLeader,
|
@JsonProperty("wasLeader") boolean wasLeader,
|
||||||
@JsonProperty("hasAge") boolean hasAge,
|
@JsonProperty("hasAge") boolean hasAge,
|
||||||
@ -70,7 +70,7 @@ public class GrantDto extends NameContainer {
|
|||||||
this.files = files;
|
this.files = files;
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.authorIds = authorIds;
|
this.authorIds = authorIds;
|
||||||
this.authors = authors;
|
this.members = members;
|
||||||
this.leaderId = leaderId;
|
this.leaderId = leaderId;
|
||||||
this.wasLeader = wasLeader;
|
this.wasLeader = wasLeader;
|
||||||
this.hasAge = hasAge;
|
this.hasAge = hasAge;
|
||||||
@ -88,7 +88,7 @@ public class GrantDto extends NameContainer {
|
|||||||
this.files = convert(grant.getFiles(), FileDataDto::new);
|
this.files = convert(grant.getFiles(), FileDataDto::new);
|
||||||
this.project = grant.getProject() == null ? null : new ProjectDto(grant.getProject());
|
this.project = grant.getProject() == null ? null : new ProjectDto(grant.getProject());
|
||||||
this.authorIds = convert(grant.getAuthors(), user -> user.getId());
|
this.authorIds = convert(grant.getAuthors(), user -> user.getId());
|
||||||
this.authors = convert(grant.getAuthors(), UserDto::new);
|
this.members = convert(grant.getAuthors(), ScienceGroupMemberDto::new);
|
||||||
this.leaderId = grant.getLeader().getId();
|
this.leaderId = grant.getLeader().getId();
|
||||||
this.wasLeader = false;
|
this.wasLeader = false;
|
||||||
this.hasAge = false;
|
this.hasAge = false;
|
||||||
@ -167,16 +167,16 @@ public class GrantDto extends NameContainer {
|
|||||||
this.authorIds = authorIds;
|
this.authorIds = authorIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<UserDto> getAuthors() {
|
public Set<ScienceGroupMemberDto> getMembers() {
|
||||||
return authors;
|
return members;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthors(Set<UserDto> authors) {
|
public void setMembers(Set<ScienceGroupMemberDto> members) {
|
||||||
this.authors = authors;
|
this.members = members;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthorsString() {
|
public String getAuthorsString() {
|
||||||
return StringUtils.abbreviate(authors
|
return StringUtils.abbreviate(members
|
||||||
.stream()
|
.stream()
|
||||||
.map(author -> author.getLastName())
|
.map(author -> author.getLastName())
|
||||||
.collect(Collectors.joining(", ")), MAX_AUTHORS_LENGTH);
|
.collect(Collectors.joining(", ")), MAX_AUTHORS_LENGTH);
|
@ -0,0 +1,28 @@
|
|||||||
|
package ru.ulstu.activity.grant.model;
|
||||||
|
|
||||||
|
import ru.ulstu.activity.api.model.ActivityListDto;
|
||||||
|
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
|
public class GrantListDto extends ActivityListDto {
|
||||||
|
|
||||||
|
private final Grant.GrantStatus status;
|
||||||
|
private final Set<ScienceGroupMemberDto> members;
|
||||||
|
|
||||||
|
public GrantListDto(Grant grant) {
|
||||||
|
super(grant.getId(), grant.getTitle());
|
||||||
|
this.status = grant.getStatus();
|
||||||
|
this.members = convert(grant.getActivityMembers(), ScienceGroupMemberDto::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Grant.GrantStatus getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<ScienceGroupMemberDto> getAuthors() {
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.grant.page;
|
package ru.ulstu.activity.grant.page;
|
||||||
|
|
||||||
import com.gargoylesoftware.htmlunit.html.DomNode;
|
import com.gargoylesoftware.htmlunit.html.DomNode;
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlElement;
|
import com.gargoylesoftware.htmlunit.html.HtmlElement;
|
@ -1,14 +1,14 @@
|
|||||||
package ru.ulstu.grant.repository;
|
package ru.ulstu.activity.grant.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.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import ru.ulstu.grant.model.Grant;
|
import ru.ulstu.activity.api.ActivityRepository;
|
||||||
import ru.ulstu.name.BaseRepository;
|
import ru.ulstu.activity.grant.model.Grant;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface GrantRepository extends JpaRepository<Grant, Integer>, BaseRepository {
|
public interface GrantRepository extends JpaRepository<Grant, Integer>, ActivityRepository {
|
||||||
|
|
||||||
List<Grant> findByStatus(Grant.GrantStatus status);
|
List<Grant> findByStatus(Grant.GrantStatus status);
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package ru.ulstu.grant.service;
|
package ru.ulstu.activity.grant.service;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.activity.grant.model.Grant;
|
||||||
import ru.ulstu.core.util.DateUtils;
|
import ru.ulstu.core.util.DateUtils;
|
||||||
import ru.ulstu.grant.model.Grant;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import ru.ulstu.user.service.MailService;
|
import ru.ulstu.user.service.MailService;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.grant.service;
|
package ru.ulstu.activity.grant.service;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
@ -1,27 +1,30 @@
|
|||||||
package ru.ulstu.grant.service;
|
package ru.ulstu.activity.grant.service;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
|
import ru.ulstu.activity.common.service.AbstractActivityService;
|
||||||
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.activity.deadline.service.DeadlineService;
|
||||||
|
import ru.ulstu.activity.file.service.FileService;
|
||||||
|
import ru.ulstu.activity.grant.model.Grant;
|
||||||
|
import ru.ulstu.activity.grant.model.GrantDto;
|
||||||
|
import ru.ulstu.activity.grant.model.GrantListDto;
|
||||||
|
import ru.ulstu.activity.grant.repository.GrantRepository;
|
||||||
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperDto;
|
||||||
|
import ru.ulstu.activity.paper.service.PaperService;
|
||||||
|
import ru.ulstu.activity.ping.service.PingService;
|
||||||
|
import ru.ulstu.activity.project.model.ProjectDto;
|
||||||
|
import ru.ulstu.activity.project.service.ProjectService;
|
||||||
|
import ru.ulstu.activity.timeline.service.EventService;
|
||||||
|
import ru.ulstu.core.jpa.OffsetablePageRequest;
|
||||||
|
import ru.ulstu.core.model.response.PageableItems;
|
||||||
import ru.ulstu.core.util.DateUtils;
|
import ru.ulstu.core.util.DateUtils;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
|
||||||
import ru.ulstu.deadline.service.DeadlineService;
|
|
||||||
import ru.ulstu.file.model.FileDataDto;
|
|
||||||
import ru.ulstu.file.service.FileService;
|
|
||||||
import ru.ulstu.grant.model.Grant;
|
|
||||||
import ru.ulstu.grant.model.GrantDto;
|
|
||||||
import ru.ulstu.grant.repository.GrantRepository;
|
|
||||||
import ru.ulstu.name.BaseService;
|
|
||||||
import ru.ulstu.paper.model.Paper;
|
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
|
||||||
import ru.ulstu.paper.service.PaperService;
|
|
||||||
import ru.ulstu.ping.service.PingService;
|
|
||||||
import ru.ulstu.project.model.ProjectDto;
|
|
||||||
import ru.ulstu.project.service.ProjectService;
|
|
||||||
import ru.ulstu.timeline.service.EventService;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
@ -37,11 +40,11 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
import static org.springframework.util.ObjectUtils.isEmpty;
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||||
|
import static ru.ulstu.activity.grant.model.Grant.GrantStatus.APPLICATION;
|
||||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
import static ru.ulstu.grant.model.Grant.GrantStatus.APPLICATION;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class GrantService extends BaseService {
|
public class GrantService extends AbstractActivityService<GrantListDto, Grant, GrantDto> {
|
||||||
private final Logger log = LoggerFactory.getLogger(GrantService.class);
|
private final Logger log = LoggerFactory.getLogger(GrantService.class);
|
||||||
|
|
||||||
private final GrantRepository grantRepository;
|
private final GrantRepository grantRepository;
|
||||||
@ -67,7 +70,7 @@ public class GrantService extends BaseService {
|
|||||||
PingService pingService) {
|
PingService pingService) {
|
||||||
this.grantRepository = grantRepository;
|
this.grantRepository = grantRepository;
|
||||||
this.kiasService = kiasService;
|
this.kiasService = kiasService;
|
||||||
this.baseRepository = grantRepository;
|
this.activityRepository = grantRepository;
|
||||||
this.fileService = fileService;
|
this.fileService = fileService;
|
||||||
this.deadlineService = deadlineService;
|
this.deadlineService = deadlineService;
|
||||||
this.projectService = projectService;
|
this.projectService = projectService;
|
||||||
@ -82,21 +85,65 @@ public class GrantService extends BaseService {
|
|||||||
return new GrantDto(findById(id));
|
return new GrantDto(findById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Grant> findAll() {
|
@Override
|
||||||
return grantRepository.findAll();
|
public PageableItems<Grant> findAll(int offset, int count) {
|
||||||
|
final Page<Grant> page = grantRepository.findAll(new OffsetablePageRequest(offset, count));
|
||||||
|
return new PageableItems<>(page.getTotalElements(), page.getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GrantDto> findAllDto() {
|
@Override
|
||||||
return convert(findAll(), GrantDto::new);
|
protected GrantListDto getActivityListDto(Grant entity) {
|
||||||
|
return new GrantListDto(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Grant create(GrantDto grantDto) throws IOException {
|
@Override
|
||||||
Grant newGrant = copyFromDto(new Grant(), grantDto);
|
public GrantDto create(GrantDto grantDto) {
|
||||||
newGrant = grantRepository.save(newGrant);
|
Grant newGrant;
|
||||||
eventService.createFromObject(newGrant, Collections.emptyList(), false, "гранта");
|
try {
|
||||||
grantNotificationService.sendCreateNotification(newGrant);
|
newGrant = copyFromDto(new Grant(), grantDto);
|
||||||
return newGrant;
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return new GrantDto(create(newGrant));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public Grant create(Grant grant) {
|
||||||
|
grant = grantRepository.save(grant);
|
||||||
|
eventService.createFromObject(grant, Collections.emptyList(), false, "гранта");
|
||||||
|
grantNotificationService.sendCreateNotification(grant);
|
||||||
|
return grant;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public GrantDto update(GrantDto grantDto) {
|
||||||
|
Grant grant = findById(grantDto.getId());
|
||||||
|
return new GrantDto(update(grant));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public Grant update(Grant grant) {
|
||||||
|
Set<User> oldAuthors = new HashSet<>(grant.getAuthors());
|
||||||
|
User oldLeader = grant.getLeader();
|
||||||
|
grant.getAuthors().forEach(author -> {
|
||||||
|
if (!oldAuthors.contains(author)) {
|
||||||
|
grantNotificationService.sendAuthorsChangeNotification(grant, oldAuthors);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
oldAuthors.forEach(oldAuthor -> {
|
||||||
|
if (!grant.getAuthors().contains(oldAuthor)) {
|
||||||
|
grantNotificationService.sendAuthorsChangeNotification(grant, oldAuthors);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (grant.getLeader() != oldLeader) {
|
||||||
|
grantNotificationService.sendLeaderChangeNotification(grant, oldLeader);
|
||||||
|
}
|
||||||
|
eventService.updateGrantDeadlines(grant);
|
||||||
|
return grant;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Grant copyFromDto(Grant grant, GrantDto grantDto) throws IOException {
|
private Grant copyFromDto(Grant grant, GrantDto grantDto) throws IOException {
|
||||||
@ -133,37 +180,7 @@ public class GrantService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
private Integer update(GrantDto grantDto) throws IOException {
|
public boolean delete(Integer grantId) {
|
||||||
Grant grant = findById(grantDto.getId());
|
|
||||||
Set<User> oldAuthors = new HashSet<>(grant.getAuthors());
|
|
||||||
User oldLeader = grant.getLeader();
|
|
||||||
for (FileDataDto file : grantDto.getFiles().stream()
|
|
||||||
.filter(f -> f.isDeleted() && f.getId() != null)
|
|
||||||
.collect(toList())) {
|
|
||||||
fileService.delete(file.getId());
|
|
||||||
}
|
|
||||||
grantDto.getRemovedDeadlineIds().forEach(deadlineService::remove);
|
|
||||||
grantRepository.save(copyFromDto(grant, grantDto));
|
|
||||||
|
|
||||||
grant.getAuthors().forEach(author -> {
|
|
||||||
if (!oldAuthors.contains(author)) {
|
|
||||||
grantNotificationService.sendAuthorsChangeNotification(grant, oldAuthors);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
oldAuthors.forEach(oldAuthor -> {
|
|
||||||
if (!grant.getAuthors().contains(oldAuthor)) {
|
|
||||||
grantNotificationService.sendAuthorsChangeNotification(grant, oldAuthors);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (grant.getLeader() != oldLeader) {
|
|
||||||
grantNotificationService.sendLeaderChangeNotification(grant, oldLeader);
|
|
||||||
}
|
|
||||||
eventService.updateGrantDeadlines(grant);
|
|
||||||
return grant.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public boolean delete(Integer grantId) throws IOException {
|
|
||||||
Grant grant = findById(grantId);
|
Grant grant = findById(grantId);
|
||||||
if (grant != null) {
|
if (grant != null) {
|
||||||
grantRepository.delete(grant);
|
grantRepository.delete(grant);
|
||||||
@ -177,11 +194,11 @@ public class GrantService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean save(GrantDto grantDto, Errors errors) throws IOException {
|
public boolean save(GrantDto grantDto, Errors errors) throws IOException {
|
||||||
grantDto.setName(grantDto.getTitle());
|
grantDto.setTitle(grantDto.getTitle());
|
||||||
filterEmptyDeadlines(grantDto);
|
filterEmptyDeadlines(grantDto);
|
||||||
checkEmptyDeadlines(grantDto, errors);
|
checkEmptyDeadlines(grantDto, errors);
|
||||||
checkEmptyLeader(grantDto, errors);
|
checkEmptyLeader(grantDto, errors);
|
||||||
checkUniqueName(grantDto, errors, grantDto.getId(), "Грант с таким именем уже существует");
|
checkUniqueName(grantDto.getTitle(), grantDto.getId());
|
||||||
if (errors.hasErrors()) {
|
if (errors.hasErrors()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -194,10 +211,9 @@ public class GrantService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean saveFromKias(GrantDto grantDto) throws IOException {
|
private boolean saveFromKias(GrantDto grantDto) throws IOException {
|
||||||
grantDto.setName(grantDto.getTitle());
|
grantDto.setTitle(grantDto.getTitle());
|
||||||
String title = checkUniqueName(grantDto, grantDto.getId()); //проверка уникальности имени
|
if (checkUniqueName(grantDto.getTitle(), grantDto.getId())) {
|
||||||
if (title != null) {
|
Grant grantFromDB = grantRepository.findByTitle(grantDto.getTitle()); //грант с таким же названием из бд
|
||||||
Grant grantFromDB = grantRepository.findByTitle(title); //грант с таким же названием из бд
|
|
||||||
if (checkSameDeadline(grantDto, grantFromDB.getId())) { //если дедайны тоже совпадают
|
if (checkSameDeadline(grantDto, grantFromDB.getId())) { //если дедайны тоже совпадают
|
||||||
return false;
|
return false;
|
||||||
} else { //иначе грант уже был в системе, но в другом году, поэтому надо создать
|
} else { //иначе грант уже был в системе, но в другом году, поэтому надо создать
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.grant.service;
|
package ru.ulstu.activity.grant.service;
|
||||||
|
|
||||||
import com.gargoylesoftware.htmlunit.WebClient;
|
import com.gargoylesoftware.htmlunit.WebClient;
|
||||||
import com.gargoylesoftware.htmlunit.html.DomNode;
|
import com.gargoylesoftware.htmlunit.html.DomNode;
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.activity.grant.model.GrantDto;
|
||||||
|
import ru.ulstu.activity.grant.page.KiasPage;
|
||||||
import ru.ulstu.configuration.ApplicationProperties;
|
import ru.ulstu.configuration.ApplicationProperties;
|
||||||
import ru.ulstu.grant.model.GrantDto;
|
|
||||||
import ru.ulstu.grant.page.KiasPage;
|
|
||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.paper.controller;
|
package ru.ulstu.activity.paper.controller;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -9,24 +9,24 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
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.activity.api.ActivityController;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperDashboardDto;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperDto;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperListDto;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperStatusDto;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperTypeDto;
|
||||||
|
import ru.ulstu.activity.paper.service.PaperService;
|
||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
import ru.ulstu.core.model.response.PageableItems;
|
import ru.ulstu.core.model.response.PageableItems;
|
||||||
import ru.ulstu.core.model.response.Response;
|
import ru.ulstu.core.model.response.Response;
|
||||||
import ru.ulstu.paper.model.PaperDashboardDto;
|
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
|
||||||
import ru.ulstu.paper.model.PaperListDto;
|
|
||||||
import ru.ulstu.paper.model.PaperStatusDto;
|
|
||||||
import ru.ulstu.paper.model.PaperTypeDto;
|
|
||||||
import ru.ulstu.paper.service.PaperService;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(Constants.API_1_0 + "papers")
|
@RequestMapping(Constants.API_1_0 + "papers")
|
||||||
public class PaperController {
|
public class PaperController implements ActivityController<PaperListDto, PaperDashboardDto, PaperDto> {
|
||||||
private final PaperService paperService;
|
private final PaperService paperService;
|
||||||
|
|
||||||
public PaperController(PaperService paperService) {
|
public PaperController(PaperService paperService) {
|
||||||
@ -34,7 +34,7 @@ public class PaperController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("list")
|
@GetMapping("list")
|
||||||
public Response<PageableItems<PaperListDto>> getPapers(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
public Response<PageableItems<PaperListDto>> getList(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
||||||
@RequestParam(value = "count", defaultValue = "10") int count) {
|
@RequestParam(value = "count", defaultValue = "10") int count) {
|
||||||
return new Response<>(paperService.findAllDto(offset, count));
|
return new Response<>(paperService.findAllDto(offset, count));
|
||||||
}
|
}
|
||||||
@ -46,17 +46,17 @@ public class PaperController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{paper-id}")
|
@GetMapping("{paper-id}")
|
||||||
public Response<PaperDto> getPaper(@PathVariable("paper-id") Integer paperId) {
|
public Response<PaperDto> get(@PathVariable("paper-id") Integer paperId) {
|
||||||
return new Response<>(paperService.findById(paperId));
|
return new Response<>(paperService.findById(paperId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Response<PaperDto> createPaper(@RequestBody @Valid PaperDto paperDto) {
|
public Response<PaperDto> create(@RequestBody @Valid PaperDto paperDto) {
|
||||||
return new Response<>(paperService.create(paperDto));
|
return new Response<>(paperService.create(paperDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public Response<PaperDto> updatePaper(@RequestBody @Valid PaperDto paperDto) {
|
public Response<PaperDto> update(@RequestBody @Valid PaperDto paperDto) {
|
||||||
return new Response<>(paperService.update(paperDto));
|
return new Response<>(paperService.update(paperDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ public class PaperController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("ping/{paper-id}")
|
@PostMapping("ping/{paper-id}")
|
||||||
public void ping(@PathVariable("paper-id") int paperId) throws IOException {
|
public void ping(@PathVariable("paper-id") int paperId) {
|
||||||
paperService.ping(paperId);
|
paperService.ping(paperId);
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.paper.model;
|
package ru.ulstu.activity.paper.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,15 +1,14 @@
|
|||||||
package ru.ulstu.paper.model;
|
package ru.ulstu.activity.paper.model;
|
||||||
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import ru.ulstu.boundary.model.AbstractActivity;
|
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.activity.common.model.EventSource;
|
||||||
import ru.ulstu.core.model.EventSource;
|
import ru.ulstu.activity.conference.model.Conference;
|
||||||
import ru.ulstu.core.model.UserActivity;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.file.model.FileData;
|
||||||
import ru.ulstu.file.model.FileData;
|
import ru.ulstu.activity.grant.model.Grant;
|
||||||
import ru.ulstu.grant.model.Grant;
|
import ru.ulstu.activity.timeline.model.Event;
|
||||||
import ru.ulstu.timeline.model.Event;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
@ -37,7 +36,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@DiscriminatorValue("PAPER")
|
@DiscriminatorValue("PAPER")
|
||||||
public class Paper extends AbstractActivity implements UserActivity, EventSource {
|
public class Paper extends AbstractActivity implements EventSource {
|
||||||
public enum PaperStatus {
|
public enum PaperStatus {
|
||||||
ATTENTION("Обратить внимание"),
|
ATTENTION("Обратить внимание"),
|
||||||
ON_PREPARATION("На подготовке"),
|
ON_PREPARATION("На подготовке"),
|
||||||
@ -199,6 +198,10 @@ public class Paper extends AbstractActivity implements UserActivity, EventSource
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getRecipients() {
|
public List<User> getRecipients() {
|
||||||
return new ArrayList<>(authors);
|
return new ArrayList<>(authors);
|
||||||
@ -209,10 +212,6 @@ public class Paper extends AbstractActivity implements UserActivity, EventSource
|
|||||||
event.setPaper(this);
|
event.setPaper(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<User> getAuthors() {
|
public Set<User> getAuthors() {
|
||||||
return authors;
|
return authors;
|
||||||
}
|
}
|
||||||
@ -262,8 +261,8 @@ public class Paper extends AbstractActivity implements UserActivity, EventSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<User> getActivityUsers() {
|
public Set<User> getActivityMembers() {
|
||||||
return getAuthors();
|
return authors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Reference> getReferences() {
|
public List<Reference> getReferences() {
|
@ -1,12 +1,13 @@
|
|||||||
package ru.ulstu.paper.model;
|
package ru.ulstu.activity.paper.model;
|
||||||
|
|
||||||
import ru.ulstu.boundary.model.ScienceGroupMemberDto;
|
import ru.ulstu.activity.api.model.ActivityDashboardDto;
|
||||||
|
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
public class PaperDashboardDto {
|
public class PaperDashboardDto implements ActivityDashboardDto {
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private String title;
|
private String title;
|
@ -1,11 +1,11 @@
|
|||||||
package ru.ulstu.paper.model;
|
package ru.ulstu.activity.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 ru.ulstu.boundary.model.ActivityDto;
|
import ru.ulstu.activity.api.model.ActivityDto;
|
||||||
import ru.ulstu.boundary.model.ScienceGroupMemberDto;
|
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.file.model.FileDataDto;
|
import ru.ulstu.activity.file.model.FileDataDto;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.paper.model;
|
package ru.ulstu.activity.paper.model;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -0,0 +1,27 @@
|
|||||||
|
package ru.ulstu.activity.paper.model;
|
||||||
|
|
||||||
|
import ru.ulstu.activity.api.model.ActivityListDto;
|
||||||
|
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
|
public class PaperListDto extends ActivityListDto {
|
||||||
|
private final Paper.PaperStatus status;
|
||||||
|
private final Set<ScienceGroupMemberDto> authors;
|
||||||
|
|
||||||
|
public PaperListDto(Paper paper) {
|
||||||
|
super(paper.getId(), paper.getTitle());
|
||||||
|
this.status = paper.getStatus();
|
||||||
|
this.authors = convert(paper.getAuthors(), ScienceGroupMemberDto::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Paper.PaperStatus getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<ScienceGroupMemberDto> getAuthors() {
|
||||||
|
return authors;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.paper.model;
|
package ru.ulstu.activity.paper.model;
|
||||||
|
|
||||||
public class PaperStatusDto {
|
public class PaperStatusDto {
|
||||||
private final String id;
|
private final String id;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.paper.model;
|
package ru.ulstu.activity.paper.model;
|
||||||
|
|
||||||
public class PaperTypeDto {
|
public class PaperTypeDto {
|
||||||
private final String id;
|
private final String id;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.paper.model;
|
package ru.ulstu.activity.paper.model;
|
||||||
|
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.paper.model;
|
package ru.ulstu.activity.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;
|
@ -1,11 +1,11 @@
|
|||||||
package ru.ulstu.paper.repository;
|
package ru.ulstu.activity.paper.repository;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
import ru.ulstu.core.repository.JpaDetachableRepository;
|
import ru.ulstu.core.repository.JpaDetachableRepository;
|
||||||
import ru.ulstu.paper.model.Paper;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,8 +1,8 @@
|
|||||||
package ru.ulstu.paper.repository;
|
package ru.ulstu.activity.paper.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.jpa.repository.Query;
|
||||||
import ru.ulstu.paper.model.Reference;
|
import ru.ulstu.activity.paper.model.Reference;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package ru.ulstu.paper.service;
|
package ru.ulstu.activity.paper.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import ru.ulstu.file.service.FileService;
|
import ru.ulstu.activity.file.service.FileService;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.activity.paper.model.PaperDto;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
@ -1,9 +1,9 @@
|
|||||||
package ru.ulstu.paper.service;
|
package ru.ulstu.activity.paper.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.activity.common.strategy.api.EntityCreateStrategy;
|
||||||
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
import ru.ulstu.core.util.DateUtils;
|
import ru.ulstu.core.util.DateUtils;
|
||||||
import ru.ulstu.paper.model.Paper;
|
|
||||||
import ru.ulstu.strategy.api.EntityCreateStrategy;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
@ -1,10 +1,10 @@
|
|||||||
package ru.ulstu.paper.service;
|
package ru.ulstu.activity.paper.service;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
import ru.ulstu.core.model.response.PageableItems;
|
import ru.ulstu.core.model.response.PageableItems;
|
||||||
import ru.ulstu.core.util.DateUtils;
|
import ru.ulstu.core.util.DateUtils;
|
||||||
import ru.ulstu.paper.model.Paper;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import ru.ulstu.user.service.MailService;
|
import ru.ulstu.user.service.MailService;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.paper.service;
|
package ru.ulstu.activity.paper.service;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
@ -1,25 +1,25 @@
|
|||||||
package ru.ulstu.paper.service;
|
package ru.ulstu.activity.paper.service;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import ru.ulstu.boundary.service.AbstractActivityService;
|
import ru.ulstu.activity.common.service.AbstractActivityService;
|
||||||
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.activity.deadline.service.DeadlineService;
|
||||||
|
import ru.ulstu.activity.file.model.FileDataDto;
|
||||||
|
import ru.ulstu.activity.file.service.FileService;
|
||||||
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperDashboardDto;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperDto;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperFilterListDto;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperListDto;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperStatusDto;
|
||||||
|
import ru.ulstu.activity.paper.model.PaperTypeDto;
|
||||||
|
import ru.ulstu.activity.paper.repository.PaperRepository;
|
||||||
|
import ru.ulstu.activity.ping.service.PingService;
|
||||||
|
import ru.ulstu.activity.timeline.service.EventService;
|
||||||
import ru.ulstu.core.jpa.OffsetablePageRequest;
|
import ru.ulstu.core.jpa.OffsetablePageRequest;
|
||||||
import ru.ulstu.core.model.response.PageableItems;
|
import ru.ulstu.core.model.response.PageableItems;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
|
||||||
import ru.ulstu.deadline.service.DeadlineService;
|
|
||||||
import ru.ulstu.file.model.FileDataDto;
|
|
||||||
import ru.ulstu.file.service.FileService;
|
|
||||||
import ru.ulstu.paper.model.Paper;
|
|
||||||
import ru.ulstu.paper.model.PaperDashboardDto;
|
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
|
||||||
import ru.ulstu.paper.model.PaperFilterListDto;
|
|
||||||
import ru.ulstu.paper.model.PaperListDto;
|
|
||||||
import ru.ulstu.paper.model.PaperStatusDto;
|
|
||||||
import ru.ulstu.paper.model.PaperTypeDto;
|
|
||||||
import ru.ulstu.paper.repository.PaperRepository;
|
|
||||||
import ru.ulstu.ping.service.PingService;
|
|
||||||
import ru.ulstu.timeline.service.EventService;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
@ -34,17 +34,17 @@ import java.util.Set;
|
|||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpty;
|
import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpty;
|
||||||
import static org.springframework.util.ObjectUtils.isEmpty;
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||||
|
import static ru.ulstu.activity.paper.model.Paper.PaperStatus.ATTENTION;
|
||||||
|
import static ru.ulstu.activity.paper.model.Paper.PaperStatus.COMPLETED;
|
||||||
|
import static ru.ulstu.activity.paper.model.Paper.PaperStatus.DRAFT;
|
||||||
|
import static ru.ulstu.activity.paper.model.Paper.PaperStatus.FAILED;
|
||||||
|
import static ru.ulstu.activity.paper.model.Paper.PaperStatus.ON_PREPARATION;
|
||||||
|
import static ru.ulstu.activity.paper.model.Paper.PaperType.OTHER;
|
||||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
import static ru.ulstu.core.util.StreamApiUtils.convertPageable;
|
import static ru.ulstu.core.util.StreamApiUtils.convertPageable;
|
||||||
import static ru.ulstu.paper.model.Paper.PaperStatus.ATTENTION;
|
|
||||||
import static ru.ulstu.paper.model.Paper.PaperStatus.COMPLETED;
|
|
||||||
import static ru.ulstu.paper.model.Paper.PaperStatus.DRAFT;
|
|
||||||
import static ru.ulstu.paper.model.Paper.PaperStatus.FAILED;
|
|
||||||
import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION;
|
|
||||||
import static ru.ulstu.paper.model.Paper.PaperType.OTHER;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PaperService extends AbstractActivityService<Paper, PaperDto, PaperListDto> {
|
public class PaperService extends AbstractActivityService<PaperListDto, Paper, PaperDto> {
|
||||||
private final PaperNotificationService paperNotificationService;
|
private final PaperNotificationService paperNotificationService;
|
||||||
private final PaperRepository paperRepository;
|
private final PaperRepository paperRepository;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
@ -264,7 +264,7 @@ public class PaperService extends AbstractActivityService<Paper, PaperDto, Paper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void ping(int paperId) throws IOException {
|
public void ping(int paperId) {
|
||||||
pingService.addPing(findPaperById(paperId));
|
pingService.addPing(findPaperById(paperId));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +1,15 @@
|
|||||||
package ru.ulstu.ping.model;
|
package ru.ulstu.activity.ping.model;
|
||||||
|
|
||||||
import org.hibernate.annotations.Any;
|
import org.hibernate.annotations.Any;
|
||||||
import org.hibernate.annotations.AnyMetaDef;
|
import org.hibernate.annotations.AnyMetaDef;
|
||||||
import org.hibernate.annotations.MetaValue;
|
import org.hibernate.annotations.MetaValue;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||||
|
import ru.ulstu.activity.conference.model.Conference;
|
||||||
|
import ru.ulstu.activity.grant.model.Grant;
|
||||||
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
|
import ru.ulstu.activity.project.model.Project;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.core.model.UserActivity;
|
|
||||||
import ru.ulstu.grant.model.Grant;
|
|
||||||
import ru.ulstu.paper.model.Paper;
|
|
||||||
import ru.ulstu.project.model.Project;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@ -50,7 +50,7 @@ public class Ping extends BaseEntity {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
@JoinColumn(name = "activity_id")
|
@JoinColumn(name = "activity_id")
|
||||||
private UserActivity activity;
|
private AbstractActivity activity;
|
||||||
|
|
||||||
public Ping() {
|
public Ping() {
|
||||||
}
|
}
|
||||||
@ -76,11 +76,11 @@ public class Ping extends BaseEntity {
|
|||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserActivity getActivity() {
|
public AbstractActivity getActivity() {
|
||||||
return this.activity;
|
return this.activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivity(UserActivity activity) {
|
public void setActivity(AbstractActivity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.ping.model;
|
package ru.ulstu.activity.ping.model;
|
||||||
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
package ru.ulstu.ping.repository;
|
package ru.ulstu.activity.ping.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.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.activity.conference.model.Conference;
|
||||||
import ru.ulstu.ping.model.Ping;
|
import ru.ulstu.activity.ping.model.Ping;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,14 +1,14 @@
|
|||||||
package ru.ulstu.ping.service;
|
package ru.ulstu.activity.ping.service;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import ru.ulstu.core.model.UserActivity;
|
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||||
import ru.ulstu.ping.model.Ping;
|
import ru.ulstu.activity.ping.model.Ping;
|
||||||
import ru.ulstu.ping.model.PingInfo;
|
import ru.ulstu.activity.ping.model.PingInfo;
|
||||||
import ru.ulstu.ping.repository.PingRepository;
|
import ru.ulstu.activity.ping.repository.PingRepository;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import ru.ulstu.user.service.MailService;
|
import ru.ulstu.user.service.MailService;
|
||||||
|
|
||||||
@ -37,8 +37,8 @@ public class PingScheduler {
|
|||||||
List<PingInfo> pingInfos = new ArrayList<>();
|
List<PingInfo> pingInfos = new ArrayList<>();
|
||||||
|
|
||||||
for (Ping ping : pingRepository.findByDate(java.sql.Date.valueOf(LocalDate.now().minusWeeks(1)))) {
|
for (Ping ping : pingRepository.findByDate(java.sql.Date.valueOf(LocalDate.now().minusWeeks(1)))) {
|
||||||
UserActivity pingActivity = ping.getActivity();
|
AbstractActivity pingActivity = ping.getActivity();
|
||||||
Set<User> users = pingActivity.getActivityUsers();
|
Set<User> users = pingActivity.getActivityMembers();
|
||||||
|
|
||||||
for (User user : users) {
|
for (User user : users) {
|
||||||
PingInfo userPing = pingInfos.stream().filter(u -> u.getUser() == user).findFirst().orElse(null);
|
PingInfo userPing = pingInfos.stream().filter(u -> u.getUser() == user).findFirst().orElse(null);
|
@ -1,14 +1,13 @@
|
|||||||
package ru.ulstu.ping.service;
|
package ru.ulstu.activity.ping.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||||
import ru.ulstu.core.model.UserActivity;
|
import ru.ulstu.activity.conference.model.Conference;
|
||||||
import ru.ulstu.ping.model.Ping;
|
import ru.ulstu.activity.ping.model.Ping;
|
||||||
import ru.ulstu.ping.repository.PingRepository;
|
import ru.ulstu.activity.ping.repository.PingRepository;
|
||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -26,7 +25,7 @@ public class PingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Ping addPing(UserActivity activity) throws IOException {
|
public Ping addPing(AbstractActivity activity) {
|
||||||
Ping newPing = new Ping(new Date(), userService.getCurrentUser());
|
Ping newPing = new Ping(new Date(), userService.getCurrentUser());
|
||||||
newPing.setActivity(activity);
|
newPing.setActivity(activity);
|
||||||
return pingRepository.save(newPing);
|
return pingRepository.save(newPing);
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.project.controller;
|
package ru.ulstu.activity.project.controller;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
@ -10,11 +10,11 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
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.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.grant.model.GrantDto;
|
import ru.ulstu.activity.grant.model.GrantDto;
|
||||||
import ru.ulstu.project.model.Project;
|
import ru.ulstu.activity.project.model.Project;
|
||||||
import ru.ulstu.project.model.ProjectDto;
|
import ru.ulstu.activity.project.model.ProjectDto;
|
||||||
import ru.ulstu.project.service.ProjectService;
|
import ru.ulstu.activity.project.service.ProjectService;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
@ -1,14 +1,13 @@
|
|||||||
package ru.ulstu.project.model;
|
package ru.ulstu.activity.project.model;
|
||||||
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||||
import ru.ulstu.core.model.EventSource;
|
import ru.ulstu.activity.common.model.EventSource;
|
||||||
import ru.ulstu.core.model.UserActivity;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.file.model.FileData;
|
||||||
import ru.ulstu.file.model.FileData;
|
import ru.ulstu.activity.grant.model.Grant;
|
||||||
import ru.ulstu.grant.model.Grant;
|
import ru.ulstu.activity.timeline.model.Event;
|
||||||
import ru.ulstu.timeline.model.Event;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
@ -32,7 +31,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@DiscriminatorValue("PROJECT")
|
@DiscriminatorValue("PROJECT")
|
||||||
public class Project extends BaseEntity implements UserActivity, EventSource {
|
public class Project extends AbstractActivity implements EventSource {
|
||||||
|
|
||||||
public enum ProjectStatus {
|
public enum ProjectStatus {
|
||||||
TECHNICAL_TASK("Техническое задание"),
|
TECHNICAL_TASK("Техническое задание"),
|
||||||
@ -96,6 +95,10 @@ public class Project extends BaseEntity implements UserActivity, EventSource {
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<User> getRecipients() {
|
public List<User> getRecipients() {
|
||||||
return executors != null ? new ArrayList<>(executors) : Collections.emptyList();
|
return executors != null ? new ArrayList<>(executors) : Collections.emptyList();
|
||||||
@ -106,10 +109,6 @@ public class Project extends BaseEntity implements UserActivity, EventSource {
|
|||||||
event.setProject(this);
|
event.setProject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectStatus getStatus() {
|
public ProjectStatus getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -179,7 +178,7 @@ public class Project extends BaseEntity implements UserActivity, EventSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<User> getActivityUsers() {
|
public Set<User> getActivityMembers() {
|
||||||
return new HashSet<>();
|
return new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
package ru.ulstu.project.model;
|
package ru.ulstu.activity.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.thymeleaf.util.StringUtils;
|
import org.thymeleaf.util.StringUtils;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.file.model.FileDataDto;
|
import ru.ulstu.activity.file.model.FileDataDto;
|
||||||
import ru.ulstu.grant.model.GrantDto;
|
import ru.ulstu.activity.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;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package ru.ulstu.project.repository;
|
package ru.ulstu.activity.project.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import ru.ulstu.project.model.Project;
|
import ru.ulstu.activity.project.model.Project;
|
||||||
|
|
||||||
public interface ProjectRepository extends JpaRepository<Project, Integer> {
|
public interface ProjectRepository extends JpaRepository<Project, Integer> {
|
||||||
|
|
@ -1,18 +1,18 @@
|
|||||||
package ru.ulstu.project.service;
|
package ru.ulstu.activity.project.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.thymeleaf.util.StringUtils;
|
import org.thymeleaf.util.StringUtils;
|
||||||
import ru.ulstu.deadline.service.DeadlineService;
|
import ru.ulstu.activity.deadline.service.DeadlineService;
|
||||||
import ru.ulstu.file.model.FileDataDto;
|
import ru.ulstu.activity.file.model.FileDataDto;
|
||||||
import ru.ulstu.file.service.FileService;
|
import ru.ulstu.activity.file.service.FileService;
|
||||||
import ru.ulstu.grant.model.GrantDto;
|
import ru.ulstu.activity.grant.model.GrantDto;
|
||||||
import ru.ulstu.grant.repository.GrantRepository;
|
import ru.ulstu.activity.grant.repository.GrantRepository;
|
||||||
import ru.ulstu.ping.service.PingService;
|
import ru.ulstu.activity.ping.service.PingService;
|
||||||
import ru.ulstu.project.model.Project;
|
import ru.ulstu.activity.project.model.Project;
|
||||||
import ru.ulstu.project.model.ProjectDto;
|
import ru.ulstu.activity.project.model.ProjectDto;
|
||||||
import ru.ulstu.project.repository.ProjectRepository;
|
import ru.ulstu.activity.project.repository.ProjectRepository;
|
||||||
import ru.ulstu.timeline.service.EventService;
|
import ru.ulstu.activity.timeline.service.EventService;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
@ -23,8 +23,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
import static org.springframework.util.ObjectUtils.isEmpty;
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||||
|
import static ru.ulstu.activity.project.model.Project.ProjectStatus.TECHNICAL_TASK;
|
||||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
import static ru.ulstu.project.model.Project.ProjectStatus.TECHNICAL_TASK;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ProjectService {
|
public class ProjectService {
|
||||||
@ -147,7 +147,7 @@ public class ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void ping(int projectId) throws IOException {
|
public void ping(int projectId) {
|
||||||
pingService.addPing(findById(projectId));
|
pingService.addPing(findById(projectId));
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.students.controller;
|
package ru.ulstu.activity.students.controller;
|
||||||
|
|
||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.students.controller;
|
package ru.ulstu.activity.students.controller;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
@ -9,12 +9,12 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
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 ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.students.model.Task;
|
import ru.ulstu.activity.students.model.Task;
|
||||||
import ru.ulstu.students.model.TaskDto;
|
import ru.ulstu.activity.students.model.TaskDto;
|
||||||
import ru.ulstu.students.model.TaskFilterDto;
|
import ru.ulstu.activity.students.model.TaskFilterDto;
|
||||||
import ru.ulstu.students.service.TaskService;
|
import ru.ulstu.activity.students.service.TaskService;
|
||||||
import ru.ulstu.tags.model.Tag;
|
import ru.ulstu.activity.tags.model.Tag;
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@ -23,9 +23,9 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.springframework.util.StringUtils.isEmpty;
|
import static org.springframework.util.StringUtils.isEmpty;
|
||||||
import static ru.ulstu.students.controller.Navigation.REDIRECT_TO;
|
import static ru.ulstu.activity.students.controller.Navigation.REDIRECT_TO;
|
||||||
import static ru.ulstu.students.controller.Navigation.TASKS_PAGE;
|
import static ru.ulstu.activity.students.controller.Navigation.TASKS_PAGE;
|
||||||
import static ru.ulstu.students.controller.Navigation.TASK_PAGE;
|
import static ru.ulstu.activity.students.controller.Navigation.TASK_PAGE;
|
||||||
|
|
||||||
@Controller()
|
@Controller()
|
||||||
@RequestMapping(value = "/students")
|
@RequestMapping(value = "/students")
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.students.model;
|
package ru.ulstu.activity.students.model;
|
||||||
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.students.model;
|
package ru.ulstu.activity.students.model;
|
||||||
|
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
import ru.ulstu.activity.common.model.EventSource;
|
||||||
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.activity.tags.model.Tag;
|
||||||
|
import ru.ulstu.activity.timeline.model.Event;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.core.model.EventSource;
|
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
|
||||||
import ru.ulstu.tags.model.Tag;
|
|
||||||
import ru.ulstu.timeline.model.Event;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
@ -1,10 +1,10 @@
|
|||||||
package ru.ulstu.students.model;
|
package ru.ulstu.activity.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 ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.tags.model.Tag;
|
import ru.ulstu.activity.tags.model.Tag;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.students.model;
|
package ru.ulstu.activity.students.model;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package ru.ulstu.students.repository;
|
package ru.ulstu.activity.students.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import ru.ulstu.students.model.Scheduler;
|
import ru.ulstu.activity.students.model.Scheduler;
|
||||||
import ru.ulstu.students.model.Task;
|
import ru.ulstu.activity.students.model.Task;
|
||||||
|
|
||||||
public interface SchedulerRepository extends JpaRepository<Scheduler, Integer> {
|
public interface SchedulerRepository extends JpaRepository<Scheduler, Integer> {
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
package ru.ulstu.students.repository;
|
package ru.ulstu.activity.students.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.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import ru.ulstu.students.model.Task;
|
import ru.ulstu.activity.students.model.Task;
|
||||||
import ru.ulstu.tags.model.Tag;
|
import ru.ulstu.activity.tags.model.Tag;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,11 +1,11 @@
|
|||||||
package ru.ulstu.students.service;
|
package ru.ulstu.activity.students.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import ru.ulstu.students.model.Scheduler;
|
import ru.ulstu.activity.students.model.Scheduler;
|
||||||
import ru.ulstu.students.model.Task;
|
import ru.ulstu.activity.students.model.Task;
|
||||||
import ru.ulstu.students.repository.SchedulerRepository;
|
import ru.ulstu.activity.students.repository.SchedulerRepository;
|
||||||
import ru.ulstu.tags.model.Tag;
|
import ru.ulstu.activity.tags.model.Tag;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.students.service;
|
package ru.ulstu.activity.students.service;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
@ -1,21 +1,21 @@
|
|||||||
package ru.ulstu.students.service;
|
package ru.ulstu.activity.students.service;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.activity.deadline.service.DeadlineService;
|
||||||
|
import ru.ulstu.activity.students.model.Scheduler;
|
||||||
|
import ru.ulstu.activity.students.model.Task;
|
||||||
|
import ru.ulstu.activity.students.model.TaskDto;
|
||||||
|
import ru.ulstu.activity.students.model.TaskFilterDto;
|
||||||
|
import ru.ulstu.activity.students.repository.SchedulerRepository;
|
||||||
|
import ru.ulstu.activity.students.repository.TaskRepository;
|
||||||
|
import ru.ulstu.activity.tags.model.Tag;
|
||||||
|
import ru.ulstu.activity.tags.service.TagService;
|
||||||
|
import ru.ulstu.activity.timeline.service.EventService;
|
||||||
import ru.ulstu.core.util.DateUtils;
|
import ru.ulstu.core.util.DateUtils;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
|
||||||
import ru.ulstu.deadline.service.DeadlineService;
|
|
||||||
import ru.ulstu.students.model.Scheduler;
|
|
||||||
import ru.ulstu.students.model.Task;
|
|
||||||
import ru.ulstu.students.model.TaskDto;
|
|
||||||
import ru.ulstu.students.model.TaskFilterDto;
|
|
||||||
import ru.ulstu.students.repository.SchedulerRepository;
|
|
||||||
import ru.ulstu.students.repository.TaskRepository;
|
|
||||||
import ru.ulstu.tags.model.Tag;
|
|
||||||
import ru.ulstu.tags.service.TagService;
|
|
||||||
import ru.ulstu.timeline.service.EventService;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -30,8 +30,8 @@ import java.util.TreeMap;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.springframework.util.ObjectUtils.isEmpty;
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||||
|
import static ru.ulstu.activity.students.model.Task.TaskStatus.IN_WORK;
|
||||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
import static ru.ulstu.students.model.Task.TaskStatus.IN_WORK;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class TaskService {
|
public class TaskService {
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.tags.model;
|
package ru.ulstu.activity.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;
|
@ -1,9 +1,9 @@
|
|||||||
package ru.ulstu.tags.repository;
|
package ru.ulstu.activity.tags.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.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import ru.ulstu.tags.model.Tag;
|
import ru.ulstu.activity.tags.model.Tag;
|
||||||
|
|
||||||
public interface TagRepository extends JpaRepository<Tag, Integer> {
|
public interface TagRepository extends JpaRepository<Tag, Integer> {
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package ru.ulstu.tags.service;
|
package ru.ulstu.activity.tags.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import ru.ulstu.tags.model.Tag;
|
import ru.ulstu.activity.tags.model.Tag;
|
||||||
import ru.ulstu.tags.repository.TagRepository;
|
import ru.ulstu.activity.tags.repository.TagRepository;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.timeline.controller;
|
package ru.ulstu.activity.timeline.controller;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -8,10 +8,10 @@ import org.springframework.web.bind.annotation.PutMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import ru.ulstu.activity.timeline.model.EventDto;
|
||||||
|
import ru.ulstu.activity.timeline.service.EventService;
|
||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
import ru.ulstu.core.model.response.Response;
|
import ru.ulstu.core.model.response.Response;
|
||||||
import ru.ulstu.timeline.model.EventDto;
|
|
||||||
import ru.ulstu.timeline.service.EventService;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,11 +1,11 @@
|
|||||||
package ru.ulstu.timeline.model;
|
package ru.ulstu.activity.timeline.model;
|
||||||
|
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.activity.conference.model.Conference;
|
||||||
|
import ru.ulstu.activity.grant.model.Grant;
|
||||||
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
|
import ru.ulstu.activity.project.model.Project;
|
||||||
|
import ru.ulstu.activity.students.model.Task;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.grant.model.Grant;
|
|
||||||
import ru.ulstu.paper.model.Paper;
|
|
||||||
import ru.ulstu.project.model.Project;
|
|
||||||
import ru.ulstu.students.model.Task;
|
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
@ -1,12 +1,12 @@
|
|||||||
package ru.ulstu.timeline.model;
|
package ru.ulstu.activity.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 ru.ulstu.conference.model.ConferenceDto;
|
import ru.ulstu.activity.conference.model.ConferenceDto;
|
||||||
import ru.ulstu.grant.model.GrantDto;
|
import ru.ulstu.activity.grant.model.GrantDto;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.activity.paper.model.PaperDto;
|
||||||
import ru.ulstu.project.model.ProjectDto;
|
import ru.ulstu.activity.project.model.ProjectDto;
|
||||||
import ru.ulstu.students.model.TaskDto;
|
import ru.ulstu.activity.students.model.TaskDto;
|
||||||
import ru.ulstu.user.model.UserDto;
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.timeline.model;
|
package ru.ulstu.activity.timeline.model;
|
||||||
|
|
||||||
import java.time.Period;
|
import java.time.Period;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.timeline.model;
|
package ru.ulstu.activity.timeline.model;
|
||||||
|
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package ru.ulstu.timeline.model;
|
package ru.ulstu.activity.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;
|
@ -1,13 +1,13 @@
|
|||||||
package ru.ulstu.timeline.repository;
|
package ru.ulstu.activity.timeline.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.jpa.repository.Query;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.activity.conference.model.Conference;
|
||||||
import ru.ulstu.grant.model.Grant;
|
import ru.ulstu.activity.grant.model.Grant;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
import ru.ulstu.project.model.Project;
|
import ru.ulstu.activity.project.model.Project;
|
||||||
import ru.ulstu.students.model.Task;
|
import ru.ulstu.activity.students.model.Task;
|
||||||
import ru.ulstu.timeline.model.Event;
|
import ru.ulstu.activity.timeline.model.Event;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package ru.ulstu.timeline.repository;
|
package ru.ulstu.activity.timeline.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import ru.ulstu.timeline.model.Timeline;
|
import ru.ulstu.activity.timeline.model.Timeline;
|
||||||
|
|
||||||
public interface TimelineRepository extends JpaRepository<Timeline, Integer> {
|
public interface TimelineRepository extends JpaRepository<Timeline, Integer> {
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
package ru.ulstu.timeline.service;
|
package ru.ulstu.activity.timeline.service;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.activity.timeline.model.Event;
|
||||||
|
import ru.ulstu.activity.timeline.model.PeriodEvent;
|
||||||
import ru.ulstu.core.util.DateUtils;
|
import ru.ulstu.core.util.DateUtils;
|
||||||
import ru.ulstu.timeline.model.Event;
|
|
||||||
import ru.ulstu.timeline.model.PeriodEvent;
|
|
||||||
import ru.ulstu.user.service.MailService;
|
import ru.ulstu.user.service.MailService;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
@ -1,20 +1,20 @@
|
|||||||
package ru.ulstu.timeline.service;
|
package ru.ulstu.activity.timeline.service;
|
||||||
|
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.activity.common.model.EventSource;
|
||||||
import ru.ulstu.core.model.EventSource;
|
import ru.ulstu.activity.conference.model.Conference;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.activity.deadline.model.Deadline;
|
||||||
import ru.ulstu.grant.model.Grant;
|
import ru.ulstu.activity.grant.model.Grant;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.activity.paper.model.Paper;
|
||||||
import ru.ulstu.project.model.Project;
|
import ru.ulstu.activity.project.model.Project;
|
||||||
import ru.ulstu.students.model.Task;
|
import ru.ulstu.activity.students.model.Task;
|
||||||
import ru.ulstu.timeline.model.Event;
|
import ru.ulstu.activity.timeline.model.Event;
|
||||||
import ru.ulstu.timeline.model.EventDto;
|
import ru.ulstu.activity.timeline.model.EventDto;
|
||||||
import ru.ulstu.timeline.model.Timeline;
|
import ru.ulstu.activity.timeline.model.Timeline;
|
||||||
import ru.ulstu.timeline.repository.EventRepository;
|
import ru.ulstu.activity.timeline.repository.EventRepository;
|
||||||
import ru.ulstu.user.model.UserDto;
|
import ru.ulstu.user.model.UserDto;
|
||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
package ru.ulstu.timeline.service;
|
package ru.ulstu.activity.timeline.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import ru.ulstu.timeline.model.EventDto;
|
import ru.ulstu.activity.timeline.model.EventDto;
|
||||||
import ru.ulstu.timeline.model.Timeline;
|
import ru.ulstu.activity.timeline.model.Timeline;
|
||||||
import ru.ulstu.timeline.model.TimelineDto;
|
import ru.ulstu.activity.timeline.model.TimelineDto;
|
||||||
import ru.ulstu.timeline.repository.TimelineRepository;
|
import ru.ulstu.activity.timeline.repository.TimelineRepository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user