WIP: Resolve "Статистика по активностям" #232
@ -67,6 +67,14 @@ public class Conference extends BaseEntity {
|
||||
@Fetch(FetchMode.SUBSELECT)
|
||||
private List<ConferenceUser> users = new ArrayList<>();
|
||||
|
||||
@Column(name = "create_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate = new Date();
|
||||
|
||||
@Column(name = "update_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updateDate = new Date();
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import ru.ulstu.timeline.model.Event;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@ -24,6 +25,8 @@ import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderBy;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
@ -98,6 +101,14 @@ public class Grant extends BaseEntity implements UserContainer {
|
||||
@JoinColumn(name = "grant_id")
|
||||
private List<Event> events = new ArrayList<>();
|
||||
|
||||
@Column(name = "create_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate = new Date();
|
||||
|
||||
@Column(name = "update_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updateDate = new Date();
|
||||
|
||||
public GrantStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
@ -4,8 +4,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.grant.model.Grant;
|
||||
import ru.ulstu.user.model.User;
|
||||
import ru.ulstu.name.BaseRepository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface GrantRepository extends JpaRepository<Grant, Integer>, BaseRepository {
|
||||
@ -20,4 +22,11 @@ public interface GrantRepository extends JpaRepository<Grant, Integer>, BaseRepo
|
||||
|
||||
@Query("SELECT g FROM Grant g WHERE (g.status <> 'SKIPPED') AND (g.status <> 'COMPLETED')")
|
||||
List<Grant> findAllActive();
|
||||
|
||||
@Query("SELECT g FROM Grant g WHERE (:user IS NULL OR user MEMBER OF g.authors) AND (:status IS NULL OR :status = p.status) " +
|
||||
" AND (:dateFrom IS NULL OR :dateFrom < p.updateDate) AND (:dateTo IS NULL OR :dateTo > p.updateDate)")
|
||||
List<Grant> findByAuthorHasAndStatus(@Param("user") User user,
|
||||
@Param("status") Grant.GrantStatus status,
|
||||
@Param("dateFrom") Date dateFrom,
|
||||
@Param("dateTo") Date dateTo);
|
||||
}
|
||||
|
@ -334,4 +334,8 @@ public class GrantService extends BaseService {
|
||||
private List<Grant> findAllActive() {
|
||||
return grantRepository.findAllActive();
|
||||
}
|
||||
|
||||
public List<Grant> getByUserAndStatusAndInterval(User user, Grant.GrantStatus status, Date dateFrom, Date dateTo) {
|
||||
return grantRepository.findByAuthorHasAndStatus(user, status, dateFrom, dateTo);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface PaperRepository extends JpaRepository<Paper, Integer> {
|
||||
@ -24,4 +25,11 @@ public interface PaperRepository extends JpaRepository<Paper, Integer> {
|
||||
List<Paper> findByConferencesIsNullAndStatusNot(Paper.PaperStatus status);
|
||||
|
||||
List<Paper> findByIdNotInAndConferencesIsNullAndStatusNot(List<Integer> paperIds, Paper.PaperStatus status);
|
||||
|
||||
@Query("SELECT p FROM Paper g WHERE (:user IS NULL OR user MEMBER OF p.authors) AND (:status IS NULL OR :status = p.status) " +
|
||||
"AND (:dateFrom IS NULL OR :dateFrom < p.updateDate) AND (:dateTo IS NULL OR :dateTo > p.updateDate)")
|
||||
List<Paper> findByAuthorHasAndStatus(@Param("user") User user,
|
||||
@Param("status") Paper.PaperStatus status,
|
||||
@Param("dateFrom") Date dateFrom,
|
||||
@Param("dateTo") Date dateTo);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ 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.paper.model.AutoCompleteData;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.paper.model.PaperDto;
|
||||
@ -391,4 +392,8 @@ public class PaperService {
|
||||
autoCompleteData.setPublishers(referenceRepository.findDistinctPublishers());
|
||||
return autoCompleteData;
|
||||
}
|
||||
|
||||
public List<Paper> getByUserAndStatusAndInterval(User user, Paper.PaperStatus status, Date dateFrom, Date dateTo) {
|
||||
return paperRepository.findByAuthorHasAndStatus(user, status, dateFrom, dateTo);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import ru.ulstu.grant.model.Grant;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@ -17,9 +18,12 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -72,6 +76,14 @@ public class Project extends BaseEntity implements UserContainer {
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
private List<User> executors = new ArrayList<>();
|
||||
|
||||
@Column(name = "create_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate = new Date();
|
||||
|
||||
@Column(name = "update_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updateDate = new Date();
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
@ -1,8 +1,21 @@
|
||||
package ru.ulstu.project.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.project.model.Project;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ProjectRepository extends JpaRepository<Project, Integer> {
|
||||
@Query("SELECT p FROM Project p WHERE (:user IS NULL OR user MEMBER OF p.authors) AND (:status IS NULL OR :status = p.status) " +
|
||||
"AND (:dateFrom IS NULL OR :dateFrom < p.updateDate) AND (:dateTo IS NULL OR :dateTo > p.updateDate)")
|
||||
List<Project> findByAuthorHasAndStatus(@Param("user") User user,
|
||||
@Param("status") Project.ProjectStatus status,
|
||||
@Param("dateFrom") Date dateFrom,
|
||||
@Param("dateTo") Date dateTo);
|
||||
|
||||
}
|
||||
|
@ -11,9 +11,11 @@ import ru.ulstu.project.model.ProjectDto;
|
||||
import ru.ulstu.project.repository.ProjectRepository;
|
||||
import ru.ulstu.user.model.User;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||
@ -126,6 +128,10 @@ public class ProjectService {
|
||||
return projectRepository.findOne(id);
|
||||
}
|
||||
|
||||
public List<Project> getByUserAndStatusAndInterval(User user, Project.ProjectStatus status, Date dateFrom, Date dateTo) {
|
||||
return projectRepository.findByAuthorHasAndStatus(user, status, dateFrom, dateTo);
|
||||
}
|
||||
|
||||
public List<User> getProjectExecutors(ProjectDto projectDto) {
|
||||
List<User> users = userService.findAll();
|
||||
return users;
|
||||
|
@ -20,6 +20,12 @@ import ru.ulstu.core.error.EntityIdIsNullException;
|
||||
import ru.ulstu.core.jpa.OffsetablePageRequest;
|
||||
import ru.ulstu.core.model.BaseEntity;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
import ru.ulstu.grant.model.Grant;
|
||||
import ru.ulstu.grant.service.GrantService;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.paper.service.PaperService;
|
||||
import ru.ulstu.project.model.Project;
|
||||
import ru.ulstu.project.service.ProjectService;
|
||||
import ru.ulstu.user.error.UserActivationError;
|
||||
import ru.ulstu.user.error.UserEmailExistsException;
|
||||
import ru.ulstu.user.error.UserIdExistsException;
|
||||
|
Loading…
Reference in New Issue
Block a user