Search in sources :

Example 6 with SnapshotIndicators

use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicators 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;
}
Also used : SnapshotIndicators(py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicators) SurveyData(py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData) UnknownResourceException(py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException) CustomParameterizedException(py.org.fundacionparaguaya.pspserver.common.exceptions.CustomParameterizedException) UnknownResourceException(py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException)

Example 7 with SnapshotIndicators

use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicators 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;
}
Also used : FamilyEntity(py.org.fundacionparaguaya.pspserver.families.entities.FamilyEntity) SnapshotIndicators(py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicators) SnapshotEconomicEntity(py.org.fundacionparaguaya.pspserver.surveys.entities.SnapshotEconomicEntity) ArrayList(java.util.ArrayList) SnapshotIndicatorEntity(py.org.fundacionparaguaya.pspserver.surveys.entities.SnapshotIndicatorEntity) SurveyData(py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData)

Aggregations

SnapshotIndicators (py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicators)7 SnapshotEconomicEntity (py.org.fundacionparaguaya.pspserver.surveys.entities.SnapshotEconomicEntity)5 ArrayList (java.util.ArrayList)3 SnapshotIndicatorPriority (py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicatorPriority)3 SurveyData (py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyData)3 CustomParameterizedException (py.org.fundacionparaguaya.pspserver.common.exceptions.CustomParameterizedException)2 UnknownResourceException (py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException)2 FamilyDTO (py.org.fundacionparaguaya.pspserver.families.dtos.FamilyDTO)2 FamilyEntity (py.org.fundacionparaguaya.pspserver.families.entities.FamilyEntity)2 SnapshotTaken (py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotTaken)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 TemporalAdjusters (java.time.temporal.TemporalAdjusters)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Logger (org.slf4j.Logger)1