fix getting active activities

pull/244/head
Anton Romanov 5 years ago
parent f0f4a2f19c
commit a1d268a8c2

@ -92,6 +92,11 @@ public abstract class ActivityService<L extends ActivityListDto, T extends Abstr
return convertPageable(findAll(offset, count), entity -> getActivityListDto(entity));
}
public abstract PageableItems findAllActiveDto(int offset, int count);
public abstract PageableItems<T> findAllActive(int offset, int count);
protected abstract T copyFromDto(T t, D d) throws IOException;
protected abstract L getActivityListDto(T entity);

@ -112,7 +112,8 @@ public class ConferenceService extends ActivityService<ConferenceListDto, Confer
return convertPageable(findAllActive(offset, count), ConferenceDashboardDto::new);
}
private PageableItems<Conference> findAllActive(int offset, int count) {
@Override
public PageableItems<Conference> findAllActive(int offset, int count) {
Page<Conference> activeConferencePage = conferenceRepository
.findAllActive(new OffsetablePageRequest(offset, count), new Date());
return new PageableItems<>(activeConferencePage.getTotalElements(), activeConferencePage.getContent());

@ -92,6 +92,7 @@ public class GrantService extends ActivityService<GrantListDto, Grant, GrantDto>
}
protected Grant copyFromDto(Grant grant, GrantDto grantDto) throws IOException {
grant.setId(grantDto.getId());
grant.setComment(grantDto.getComment());
grant.setStatus(grantDto.getStatus() == null ? APPLICATION : grantDto.getStatus());
grant.setTitle(grantDto.getTitle());
@ -157,10 +158,12 @@ public class GrantService extends ActivityService<GrantListDto, Grant, GrantDto>
}
}
@Override
public PageableItems<GrantDashboardDto> findAllActiveDto(int offset, int count) {
return convertPageable(findAllActive(offset, count), GrantDashboardDto::new);
}
@Override
public PageableItems<Grant> findAllActive(int offset, int count) {
Page<Grant> activeGrantsPage = grantRepository.findAllActive(new OffsetablePageRequest(offset, count));
return new PageableItems<>(activeGrantsPage.getTotalElements(), activeGrantsPage.getContent());

@ -97,7 +97,8 @@ public class PaperService extends ActivityService<PaperListDto, Paper, PaperDto>
return new PaperDto(entity);
}
private PageableItems<Paper> findAllActive(int offset, int count) {
@Override
public PageableItems<Paper> findAllActive(int offset, int count) {
Page<Paper> activePapersPage = paperRepository.findAllWithoutStatuses(new OffsetablePageRequest(offset, count), COMPLETED, FAILED);
return new PageableItems<>(activePapersPage.getTotalElements(), sortPapers(activePapersPage.getContent()));
}

@ -45,11 +45,13 @@ public class ProjectService extends ActivityService<ProjectListDto, Project, Pro
this.eventService = eventService;
}
@Override
public PageableItems<ProjectDashboardDto> findAllActiveDto(int offset, int count) {
return convertPageable(findAllActive(offset, count), ProjectDashboardDto::new);
}
private PageableItems<Project> findAllActive(int offset, int count) {
@Override
public PageableItems<Project> findAllActive(int offset, int count) {
Page<Project> activeProjectPage = projectRepository.findAllWithoutStatuses(new OffsetablePageRequest(offset, count), CLOSED, FAILED);
return new PageableItems<>(activeProjectPage.getTotalElements(), activeProjectPage.getContent());
}

@ -243,11 +243,13 @@ public class TaskService extends ActivityService<TaskListDto, Task, TaskDto> {
return newTask;
}
@Override
public PageableItems<TaskDashboardDto> findAllActiveDto(int offset, int count) {
return convertPageable(findAllActive(offset, count), TaskDashboardDto::new);
}
private PageableItems<Task> findAllActive(int offset, int count) {
@Override
public PageableItems<Task> findAllActive(int offset, int count) {
return findAll(offset, count);
}

Loading…
Cancel
Save