use of py.org.fundacionparaguaya.pspserver.reports.dtos.ReportDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotReportManagerImpl method getSnasphots.
private ReportDTO getSnasphots(List<SnapshotEconomicEntity> snapshots) {
ReportDTO report = new ReportDTO();
report.getHeaders().add("Created At");
List<SurveyData> rows = new ArrayList<>();
report.getHeaders().addAll(snapshotMapper.getStaticPropertiesNames());
for (SnapshotEconomicEntity s : snapshots) {
s.getSnapshotIndicator().getAdditionalProperties().forEach((k, v) -> {
if (!report.getHeaders().contains(StringConverter.getNameFromCamelCase(k))) {
report.getHeaders().add(StringConverter.getNameFromCamelCase(k));
}
});
SurveyData data = snapshotMapper.entityToDto(s.getSnapshotIndicator());
data.put("createdAt", s.getCreatedAtLocalDateString());
rows.add(data);
}
report.setRows(generateRows(rows, report.getHeaders()));
return report;
}
use of py.org.fundacionparaguaya.pspserver.reports.dtos.ReportDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotReportManagerImpl method generateCSVSnapshotByOrganizationAndCreatedDate.
@Override
public String generateCSVSnapshotByOrganizationAndCreatedDate(SnapshotFilterDTO filters) {
List<SnapshotEconomicEntity> snapshots = new ArrayList<>();
Sort sort = new Sort(new Sort.Order(Direction.ASC, "family.organization.name"), new Sort.Order(Direction.ASC, "family.name"), new Sort.Order(Direction.ASC, "createdAt"));
if (filters.getDateFrom() != null && filters.getDateTo() != null) {
Specification<SnapshotEconomicEntity> dateRange = SnapshotEconomicSpecification.createdAtBetween2Dates(filters.getDateFrom(), filters.getDateTo());
snapshots = snapshotRepository.findAll(where(SnapshotEconomicSpecification.byApplication(filters.getApplicationId())).and(dateRange).and(SnapshotEconomicSpecification.byOrganization(filters.getOrganizationId())), sort);
}
ReportDTO report = getOrganizationAndFamilyData(snapshots);
return reportToCsv(report);
}
use of py.org.fundacionparaguaya.pspserver.reports.dtos.ReportDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotReportManagerImpl method getOrganizationAndFamilyData.
private ReportDTO getOrganizationAndFamilyData(List<SnapshotEconomicEntity> snapshots) {
ReportDTO report = new ReportDTO();
report.getHeaders().addAll(DEFAULT_HEADRES);
List<SurveyData> rows = new ArrayList<>();
report.getHeaders().addAll(snapshotMapper.getStaticPropertiesNames());
for (SnapshotEconomicEntity s : snapshots) {
s.getSnapshotIndicator().getAdditionalProperties().forEach((k, v) -> {
if (!report.getHeaders().contains(k)) {
report.getHeaders().add(StringConverter.getNameFromCamelCase(k));
}
});
SurveyData data = snapshotMapper.entityToDto(s.getSnapshotIndicator());
data.put("organizationCode", s.getFamily().getOrganization().getCode());
data.put("organizationName", s.getFamily().getOrganization().getName());
data.put("organizationStatus", s.getFamily().getOrganization().getStatus().toString());
data.put("familyCode", s.getFamily().getCode());
data.put("familyName", s.getFamily().getName());
data.put("familyStatus", s.getFamily().getStatus().toString());
data.put("snapshotCreatedAt", s.getCreatedAtLocalDateString());
rows.add(data);
}
report.setRows(generateRows(rows, report.getHeaders()));
return report;
}
Aggregations