use of py.org.fundacionparaguaya.pspserver.reports.dtos.OrganizationFamilyDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotReportController method getFamiliesByOrganization.
@GetMapping(path = "/family/organizations", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<List<OrganizationFamilyDTO>> getFamiliesByOrganization(@RequestParam(value = "application_id", required = false) Long applicationId, @RequestParam(value = "organization_id", required = false) Long organizationId, @RequestParam(value = "family_id", required = false) Long familyId, @RequestParam(value = "date_from", required = true) String dateFrom, @RequestParam(value = "date_to", required = true) String dateTo) {
SnapshotFilterDTO filters = new SnapshotFilterDTO(applicationId, organizationId, familyId, dateFrom, dateTo);
List<OrganizationFamilyDTO> families = familyReportService.listFamilyByOrganizationAndCreatedDate(filters);
return ResponseEntity.ok(families);
}
use of py.org.fundacionparaguaya.pspserver.reports.dtos.OrganizationFamilyDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotReportManagerImpl method listFamilyByOrganizationAndCreatedDate.
@Override
public List<OrganizationFamilyDTO> listFamilyByOrganizationAndCreatedDate(SnapshotFilterDTO filters) {
List<FamilyEntity> families = new ArrayList<>();
Sort sort = new Sort(new Sort.Order(Direction.ASC, "organization.name"), new Sort.Order(Direction.ASC, "name"));
Specification<FamilyEntity> dateRange = FamilySpecification.createdAtBetween2Dates(filters.getDateFrom(), filters.getDateTo());
families = familyRepository.findAll(where(byOrganization(filters.getOrganizationId())).and(dateRange).and(byApplication(filters.getApplicationId())).and(dateRange), sort);
Map<OrganizationEntity, List<FamilyEntity>> groupByOrganization = families.stream().collect(Collectors.groupingBy(f -> f.getOrganization()));
List<OrganizationFamilyDTO> toRet = new ArrayList<>();
groupByOrganization.forEach((k, v) -> {
OrganizationFamilyDTO fa = new OrganizationFamilyDTO(k.getName(), k.getCode(), k.getDescription(), k.isActive());
fa.setFamilies(familyReportMapper.entityListToDtoList(v));
toRet.add(fa);
});
return toRet;
}
Aggregations