use of py.org.fundacionparaguaya.pspserver.common.pagination.PspPageRequest in project FP-PSP-SERVER by FundacionParaguaya.
the class UserServiceImpl method listUsers.
@Override
public Page<UserDTO> listUsers(int page, int perPage, String orderBy, String sortBy, UserDetailsDTO userDetails) {
PageRequest pageRequest = new PspPageRequest(page, perPage, orderBy, "user." + sortBy);
Page<UserApplicationEntity> userApplicationPage = userApplicationRepository.findAll(Specifications.where(hasApplication(userDetails.getApplication())).and(hasOrganization(userDetails.getOrganization())).and(userIsActive()), pageRequest);
return userApplicationPage.map(userApplicationMapper::entityToUserDto);
}
use of py.org.fundacionparaguaya.pspserver.common.pagination.PspPageRequest in project FP-PSP-SERVER by FundacionParaguaya.
the class ApplicationController method getPaginatedApplications.
@GetMapping()
public ResponseEntity<PaginableList<ApplicationDTO>> getPaginatedApplications(@RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "per_page", required = false, defaultValue = "12") int perPage, @RequestParam(value = "sort_by", required = false, defaultValue = "name") String sortBy, @RequestParam(value = "order", required = false, defaultValue = "asc") String orderBy, @RequestParam(value = "filter", required = false, defaultValue = "") String filter, @AuthenticationPrincipal UserDetailsDTO userDetails) {
PageRequest pageRequest = new PspPageRequest(page, perPage, orderBy, sortBy);
Page<ApplicationDTO> pageProperties = applicationService.getPaginatedApplications(userDetails, filter, pageRequest);
PaginableList<ApplicationDTO> response = new PaginableList<>(pageProperties, pageProperties.getContent());
return ResponseEntity.ok(response);
}
use of py.org.fundacionparaguaya.pspserver.common.pagination.PspPageRequest in project FP-PSP-SERVER by FundacionParaguaya.
the class OrganizationServiceImpl method listOrganizations.
@Override
public PaginableList<OrganizationDTO> listOrganizations(Long applicationId, Long organizationId, int page, int perPage, String orderBy, String sortBy) {
PaginableList<OrganizationDTO> response;
PageRequest pageRequest = new PspPageRequest(page, perPage, orderBy, sortBy);
Page<OrganizationEntity> pageResponse = organizationRepository.findAll(where(byFilter(applicationId, organizationId)), pageRequest);
if (pageResponse == null) {
return new PaginableList<>(Collections.emptyList());
} else {
Page<OrganizationDTO> organizationPage = pageResponse.map(new Converter<OrganizationEntity, OrganizationDTO>() {
@Override
public OrganizationDTO convert(OrganizationEntity source) {
return organizationMapper.entityToDto(source);
}
});
response = new PaginableList<OrganizationDTO>(organizationPage, organizationPage.getContent());
}
return response;
}
use of py.org.fundacionparaguaya.pspserver.common.pagination.PspPageRequest in project FP-PSP-SERVER by FundacionParaguaya.
the class OrganizationController method getAllOrganizations.
@GetMapping()
public ResponseEntity<PaginableList<OrganizationDTO>> getAllOrganizations(@RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "per_page", required = false, defaultValue = "12") int perPage, @RequestParam(value = "sort_by", required = false, defaultValue = "name") String sortBy, @RequestParam(value = "order", required = false, defaultValue = "asc") String orderBy, @RequestParam(value = "filter", required = false, defaultValue = "") String filter, @AuthenticationPrincipal UserDetailsDTO userDetails) {
PageRequest pageRequest = new PspPageRequest(page, perPage, orderBy, sortBy);
Page<OrganizationDTO> pageProperties = organizationService.listOrganizations(userDetails, filter, pageRequest);
PaginableList<OrganizationDTO> response = new PaginableList<>(pageProperties, pageProperties.getContent());
return ResponseEntity.ok(response);
}
use of py.org.fundacionparaguaya.pspserver.common.pagination.PspPageRequest in project FP-PSP-SERVER by FundacionParaguaya.
the class ApplicationServiceImpl method listApplicationsHubs.
@Override
public PaginableList<ApplicationDTO> listApplicationsHubs(int page, int perPage, String orderBy, String sortBy) {
PageRequest pageRequest = new PspPageRequest(page, perPage, orderBy, sortBy);
Page<ApplicationEntity> pageResponse = applicationRepository.findAllByIsHub(true, pageRequest);
if (pageResponse == null) {
return new PaginableList<ApplicationDTO>(Collections.emptyList());
}
Page<ApplicationDTO> applicationPage = pageResponse.map(new Converter<ApplicationEntity, ApplicationDTO>() {
public ApplicationDTO convert(ApplicationEntity source) {
return applicationMapper.entityToDto(source);
}
});
return new PaginableList<ApplicationDTO>(applicationPage, applicationPage.getContent());
}
Aggregations