use of py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException in project FP-PSP-SERVER by FundacionParaguaya.
the class FamilyServiceImpl method updateFamily.
@Override
public FamilyDTO updateFamily(Long familyId) {
checkArgument(familyId > 0, i18n.translate("argument.nonNegative", familyId));
LOG.debug("Updating family with id: {}", familyId);
return Optional.ofNullable(familyRepository.findOne(familyId)).map(family -> {
family.setLastModifiedAt(LocalDateTime.now());
return familyRepository.save(family);
}).map(familyMapper::entityToDto).orElseThrow(() -> new UnknownResourceException(i18n.translate("family.notExist")));
}
use of py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException in project FP-PSP-SERVER by FundacionParaguaya.
the class PersonServiceImpl method updatePerson.
@Override
public PersonDTO updatePerson(Long personId, PersonDTO personDTO) {
checkArgument(personId > 0, "Argument was %s but expected nonnegative", personId);
return Optional.ofNullable(personRepository.findOne(personId)).map(person -> {
BeanUtils.copyProperties(personDTO, person);
LOG.debug("Changed Information for Person: {}", person);
return person;
}).map(personMapper::entityToDto).orElseThrow(() -> new UnknownResourceException("Person does not exist"));
}
use of py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException in project FP-PSP-SERVER by FundacionParaguaya.
the class SurveyServiceImpl method updateSurvey.
@Override
@Transactional
public SurveyDefinition updateSurvey(UserDetailsDTO details, Long surveyId, SurveyDefinition surveyDefinition) {
checkArgument(surveyId > 0, "Argument was %s but expected nonnegative", surveyId);
return Optional.ofNullable(repo.findOne(surveyId)).map(survey -> {
survey.setDescription(surveyDefinition.getDescription());
survey.setTitle(surveyDefinition.getTitle());
survey.setSurveyDefinition(surveyDefinition);
survey.setLastModifiedAt(LocalDateTime.now());
surveyOrganizationService.crudSurveyOrganization(details, surveyId, surveyDefinition, survey);
repo.save(survey);
return survey;
}).map(mapper::entityToDto).orElseThrow(() -> new UnknownResourceException("Survey does not exist"));
}
use of py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException in project FP-PSP-SERVER by FundacionParaguaya.
the class ParameterServiceImpl method updateParameter.
@Override
public ParameterDTO updateParameter(Long parameterId, ParameterDTO parameterDTO) {
checkArgument(parameterId > 0, "Argument was %s but expected nonnegative", parameterId);
return Optional.ofNullable(parameterRepository.findOne(parameterId)).map(parameter -> {
BeanUtils.copyProperties(parameterDTO, parameter);
LOG.debug("Changed Information for Parameter: {}", parameter);
return parameter;
}).map(parameterMapper::entityToDto).orElseThrow(() -> new UnknownResourceException("Parameter does not exist"));
}
use of py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException 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;
}
Aggregations