use of py.org.fundacionparaguaya.pspserver.families.dtos.FamilyFilterDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotServiceImpl method countSnapshotTaken.
@Override
public SnapshotTaken countSnapshotTaken(FamilyFilterDTO filter) {
List<SnapshotEconomicEntity> snapshots = getSnapshotsLess2MonthsByFamilies(filter);
Map<String, Long> result = snapshots.stream().collect(Collectors.groupingBy(item -> item.getCreatedAt().toLocalDate().with(TemporalAdjusters.firstDayOfMonth()).format(DateTimeFormatter.ISO_DATE), Collectors.counting()));
SnapshotTaken t = new SnapshotTaken();
t.setByMonth(result);
return t;
}
use of py.org.fundacionparaguaya.pspserver.families.dtos.FamilyFilterDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class FamilyController method getAllFamilies.
@GetMapping()
public ResponseEntity<List<FamilyDTO>> getAllFamilies(@RequestParam(value = "organization_id", required = false) Long organizationId, @RequestParam(value = "country_id", required = false) Long countryId, @RequestParam(value = "city_id", required = false) Long cityId, @RequestParam(value = "free_text", required = false) String name, @RequestParam(value = "application_id", required = false) Long applicationId, @RequestParam(value = "last_modified_gt", required = false) String lastModifiedGt, @AuthenticationPrincipal UserDetailsDTO user) {
FamilyFilterDTO filter = FamilyFilterDTO.builder().applicationId(applicationId).organizationId(organizationId).countryId(countryId).cityId(cityId).name(name).isActive(true).lastModifiedGt(lastModifiedGt).build();
List<FamilyDTO> families = familyService.listFamilies(filter, user);
return ResponseEntity.ok(families);
}
use of py.org.fundacionparaguaya.pspserver.families.dtos.FamilyFilterDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class ApplicationServiceImpl method getApplicationDashboard.
@Override
public ApplicationDTO getApplicationDashboard(Long applicationId, UserDetailsDTO details) {
ApplicationDTO dto = getUserApplication(details, applicationId);
Long organizationId = Optional.ofNullable(details.getOrganization()).orElse(new OrganizationDTO()).getId();
FamilyFilterDTO filter = FamilyFilterDTO.builder().applicationId(dto.getId()).organizationId(organizationId).build();
DashboardDTO dashboard = DashboardDTO.of(familyService.countFamiliesByFilter(filter), null, null, null, snapshotService.countSnapshotTaken(filter));
dto.setDashboard(dashboard);
return dto;
}
use of py.org.fundacionparaguaya.pspserver.families.dtos.FamilyFilterDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class FamilyServiceImpl method listFamilies.
@Override
public List<FamilyDTO> listFamilies(FamilyFilterDTO filter, UserDetailsDTO userDetails) {
FamilyFilterDTO newFilter = buildFilterFromFilterAndUser(filter, userDetails);
List<FamilyEntity> entityList = familyRepository.findAll(where(byFilter(newFilter)));
return familyMapper.entityListToDtoList(entityList);
}
use of py.org.fundacionparaguaya.pspserver.families.dtos.FamilyFilterDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class OrganizationServiceImpl method getOrganizationDashboard.
@Override
public OrganizationDTO getOrganizationDashboard(Long organizationId, UserDetailsDTO details) {
OrganizationDTO dto = new OrganizationDTO();
if (details.getOrganization() != null && details.getOrganization().getId() != null) {
dto = getOrganizationById(details.getOrganization().getId());
} else if (organizationId != null) {
dto = getOrganizationById(organizationId);
}
Long applicationId = Optional.ofNullable(details.getApplication()).orElse(new ApplicationDTO()).getId();
FamilyFilterDTO filter = FamilyFilterDTO.builder().applicationId(applicationId).organizationId(dto.getId()).build();
DashboardDTO dashboard = DashboardDTO.of(familyService.countFamiliesByFilter(filter), null, snapshotServiceImpl.getTopOfIndicators(organizationId), countSnapshotIndicators(organizationId), null);
dto.setDashboard(dashboard);
return dto;
}
Aggregations