use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData in project FP-PSP-SERVER by FundacionParaguaya.
the class PersonMapper method snapshotPersonalToEntity.
public PersonEntity snapshotPersonalToEntity(NewSnapshot snapshot) {
SurveyData personalInformation = snapshot.getMappedPersonalSurveyData(propertyAttributeSupport.staticPersonal(), propertyAttributeSupport::propertySchemaToSystemName);
if (personalInformation.get("birthdate") != null) {
personalInformation.put("birthdate", LocalDate.parse(personalInformation.getAsString("birthdate"), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
}
if (personalInformation.get("gender") != null) {
personalInformation.put("gender", Gender.valueOf(personalInformation.getAsString("gender")));
}
if (personalInformation.get("countryOfBirth") != null) {
Optional<CountryEntity> country = countryRepository.findByAlfa2Code(personalInformation.getAsString("countryOfBirth"));
personalInformation.put("countryOfBirth", country.orElse(null));
}
PersonEntity pe = new PersonEntity().staticProperties(personalInformation);
return pe;
}
use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotServiceImpl method countSnapshotIndicators.
private SnapshotIndicators countSnapshotIndicators(SnapshotEconomicEntity snapshot) {
SnapshotIndicators indicators = new SnapshotIndicators();
try {
SurveyData properties = indicatorMapper.entityToDto(snapshot.getSnapshotIndicator());
properties.forEach((k, v) -> {
countIndicators(indicators, v);
});
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new UnknownResourceException(i18n.translate("snapshot.invalid", snapshot.getId()));
}
return indicators;
}
use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotServiceImpl method getIndicatorsValue.
@Override
public List<SurveyData> getIndicatorsValue(SurveyData indicators) {
List<SurveyData> toRet = new ArrayList<>();
indicators.forEach((k, v) -> {
SurveyData indicator = new SurveyData();
indicator.put(INDICATOR_NAME, getNameFromCamelCase(k));
indicator.put(INDICATOR_VALUE, v != null ? StringUtils.lowerCase(v.toString()) : "none");
toRet.add(indicator);
});
return toRet;
}
use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData in project FP-PSP-SERVER by FundacionParaguaya.
the class OrganizationServiceImpl method countSnapshotIndicators.
private SnapshotIndicators countSnapshotIndicators(Long organizationId) {
List<FamilyEntity> families = familyService.findByOrganizationId(organizationId);
List<SnapshotEconomicEntity> snapshotEconomics = snapshotEconomicRepo.findByFamilyIn(families);
List<SnapshotIndicatorEntity> entityList = new ArrayList<SnapshotIndicatorEntity>();
for (SnapshotEconomicEntity economics : snapshotEconomics) {
entityList.add(economics.getSnapshotIndicator());
}
SnapshotIndicators indicators = new SnapshotIndicators();
List<SurveyData> listProperties = indicatorMapper.entityListToDtoList(entityList);
for (SurveyData properties : listProperties) {
properties.forEach((k, v) -> {
countIndicators(indicators, v);
});
}
return indicators;
}
use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData 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