use of py.org.fundacionparaguaya.pspserver.families.entities.PersonEntity in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotServiceImpl method addSurveySnapshot.
@Override
@Transactional
public Snapshot addSurveySnapshot(UserDetailsDTO details, NewSnapshot snapshot) {
checkNotNull(snapshot);
ValidationResults results = surveyService.checkSchemaCompliance(snapshot);
if (!results.isValid()) {
throw new CustomParameterizedException(i18n.translate("snapshot.invalid"), results.asMap());
}
SnapshotIndicatorEntity indicatorEntity = economicMapper.newSnapshotToIndicatorEntity(snapshot);
PersonEntity personEntity = personMapper.snapshotPersonalToEntity(snapshot);
FamilyEntity family = familyService.getOrCreateFamilyFromSnapshot(details, snapshot, personEntity);
SnapshotEconomicEntity snapshotEconomicEntity = saveEconomic(snapshot, indicatorEntity, family);
familyService.updateFamily(family.getFamilyId());
return economicMapper.entityToDto(snapshotEconomicEntity);
}
use of py.org.fundacionparaguaya.pspserver.families.entities.PersonEntity in project FP-PSP-SERVER by FundacionParaguaya.
the class PersonServiceImpl method addPerson.
@Override
public PersonDTO addPerson(PersonDTO personDTO) {
PersonEntity person = new PersonEntity();
BeanUtils.copyProperties(personDTO, person);
PersonEntity newPerson = personRepository.save(person);
return personMapper.entityToDto(newPerson);
}
use of py.org.fundacionparaguaya.pspserver.families.entities.PersonEntity 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;
}
Aggregations