Search in sources :

Example 1 with TermCondPolEntity

use of py.org.fundacionparaguaya.pspserver.security.entities.TermCondPolEntity in project FP-PSP-SERVER by FundacionParaguaya.

the class SnapshotEconomicMapper method newSnapshotToEconomicEntity.

public SnapshotEconomicEntity newSnapshotToEconomicEntity(NewSnapshot snapshot, SnapshotIndicatorEntity indicator) {
    UserEntity user = null;
    TermCondPolEntity termCond = null;
    TermCondPolEntity privPol = null;
    if (snapshot.getUserName() != null) {
        user = userRepository.findOneByUsername(snapshot.getUserName()).get();
    }
    if (snapshot.getTermCondId() != null) {
        termCond = termCondPolRepository.findOne(snapshot.getTermCondId());
    }
    if (snapshot.getPrivPolId() != null) {
        privPol = termCondPolRepository.findOne(snapshot.getPrivPolId());
    }
    return new SnapshotEconomicEntity().surveyDefinition(new SurveyEntity(snapshot.getSurveyId())).surveyIndicator(indicator).staticProperties(snapshot.getMappedEconomicSurveyData(propertyAttributeSupport.staticEconomic(), propertyAttributeSupport::propertySchemaToSystemName)).additionalProperties(snapshot.getEconomicSurveyData(propertyAttributeSupport.additional())).user(user).termCond(termCond).privPol(privPol);
}
Also used : SnapshotEconomicEntity(py.org.fundacionparaguaya.pspserver.surveys.entities.SnapshotEconomicEntity) SurveyEntity(py.org.fundacionparaguaya.pspserver.surveys.entities.SurveyEntity) UserEntity(py.org.fundacionparaguaya.pspserver.security.entities.UserEntity) TermCondPolEntity(py.org.fundacionparaguaya.pspserver.security.entities.TermCondPolEntity)

Example 2 with TermCondPolEntity

use of py.org.fundacionparaguaya.pspserver.security.entities.TermCondPolEntity in project FP-PSP-SERVER by FundacionParaguaya.

the class TermCondPolServiceImpl method saveTerms.

@Override
public TermCondPolDTO saveTerms(MultipartFile htmlFile, TermCondPolDTO termCondPolDTO) {
    try {
        String htmlContent = new String(htmlFile.getBytes(), "UTF-8");
        TermCondPolEntity entity = mapper.dtoToEntity(termCondPolDTO);
        entity.setHtml(htmlContent);
        return mapper.entityToDto(repository.save(entity));
    } catch (IOException e) {
        throw new InternalServerErrorException(e);
    }
}
Also used : InternalServerErrorException(py.org.fundacionparaguaya.pspserver.common.exceptions.InternalServerErrorException) IOException(java.io.IOException) TermCondPolEntity(py.org.fundacionparaguaya.pspserver.security.entities.TermCondPolEntity)

Aggregations

TermCondPolEntity (py.org.fundacionparaguaya.pspserver.security.entities.TermCondPolEntity)2 IOException (java.io.IOException)1 InternalServerErrorException (py.org.fundacionparaguaya.pspserver.common.exceptions.InternalServerErrorException)1 UserEntity (py.org.fundacionparaguaya.pspserver.security.entities.UserEntity)1 SnapshotEconomicEntity (py.org.fundacionparaguaya.pspserver.surveys.entities.SnapshotEconomicEntity)1 SurveyEntity (py.org.fundacionparaguaya.pspserver.surveys.entities.SurveyEntity)1