use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotServiceImpl method getIndicatorsValue.
private List<SurveyData> getIndicatorsValue(SnapshotEconomicEntity snapshotEconomic, SnapshotIndicators toRet) {
SurveyDefinition survey = surveyService.getSurveyDefinition(snapshotEconomic.getSurveyDefinition().getId());
List<String> indicatorGroup = survey.getSurveyUISchema().getGroupIndicators();
List<String> order = survey.getSurveyUISchema().getUiOrder().stream().filter(field -> indicatorGroup.contains(field)).collect(Collectors.toList());
SurveyData indicators = indicatorMapper.entityToDto(snapshotEconomic.getSnapshotIndicator());
List<SurveyData> indicatorsToRet = new ArrayList<>();
if (indicatorGroup != null && !indicatorGroup.isEmpty() && order != null && !order.isEmpty()) {
order.forEach(indicator -> {
if (indicators.containsKey(indicator)) {
SurveyData sd = new SurveyData();
sd.put(INDICATOR_NAME, getDescriptionOpt(survey, indicator).map(e -> e.get("es")).orElse(getNameFromCamelCase(indicator)));
sd.put(INDICATOR_VALUE, indicators.get(indicator));
countIndicators(toRet, sd.get(INDICATOR_VALUE));
indicatorsToRet.add(sd);
}
});
}
return indicatorsToRet;
}
use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotServiceImpl method getTopOfIndicators.
@Override
public List<TopOfIndicators> getTopOfIndicators(Long organizationId) {
List<FamilyEntity> families = familyService.findByOrganizationId(organizationId);
List<SurveyData> propertiesList = indicatorMapper.entityListToDtoList(economicRepository.findByFamilyIn(families).stream().map(economic -> economic.getSnapshotIndicator()).collect(Collectors.toList()));
Map<String, TopOfIndicators> topOfIndicatorMap = new HashMap<String, TopOfIndicators>();
for (SurveyData surveyData : propertiesList) {
surveyData.forEach((key, value) -> {
countTopIndicators(topOfIndicatorMap, key, value);
});
}
List<TopOfIndicators> list = topOfIndicatorMap.entrySet().stream().map(e -> new TopOfIndicators(e.getValue())).collect(Collectors.toList());
return list;
}
use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotEconomicMapper method getAllProperties.
public SurveyData getAllProperties(StoreableSnapshot bean, List<PropertyAttributeEntity> attributes) {
SurveyData data = new SurveyData();
attributes.stream().forEach(makeSurveyDataWriter(bean, data));
bean.getAdditionalProperties().entrySet().stream().forEach(a -> data.put(a.getKey(), a.getValue()));
return data;
}
use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotReportManagerImpl method generateRows.
private List<List<String>> generateRows(List<SurveyData> rowsValue, List<String> headers) {
List<List<String>> rows = new ArrayList<>();
for (SurveyData data : rowsValue) {
List<String> row = new ArrayList<>();
for (String header : headers) {
String key = StringConverter.getCamelCaseFromName(header);
if (data.containsKey(key)) {
if (data.getAsString(key) == null) {
row.add("");
} else {
row.add(data.getAsString(key));
}
} else {
row.add("");
}
}
rows.add(row);
}
return rows;
}
use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData 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;
}
Aggregations