use of py.org.fundacionparaguaya.pspserver.families.entities.FamilyEntity 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.FamilyEntity in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotServiceImpl method getTopOfIndicators.
@Override
public List<TopOfIndicators> getTopOfIndicators(Long organizationId) {
List<FamilyEntity> families = familyService.findByOrganizationId(organizationId);
List<SurveyData> propertiesList = indicatorMapper.entityListToDtoList(economicRepository.findByFamilyIn(families).stream().map(economic -> economic.getSnapshotIndicator()).collect(Collectors.toList()));
Map<String, TopOfIndicators> topOfIndicatorMap = new HashMap<String, TopOfIndicators>();
for (SurveyData surveyData : propertiesList) {
surveyData.forEach((key, value) -> {
countTopIndicators(topOfIndicatorMap, key, value);
});
}
List<TopOfIndicators> list = topOfIndicatorMap.entrySet().stream().map(e -> new TopOfIndicators(e.getValue())).collect(Collectors.toList());
return list;
}
use of py.org.fundacionparaguaya.pspserver.families.entities.FamilyEntity in project FP-PSP-SERVER by FundacionParaguaya.
the class FamilyServiceImpl method addFamily.
@Override
public FamilyDTO addFamily(FamilyDTO familyDTO) {
FamilyEntity family = new FamilyEntity();
BeanUtils.copyProperties(familyDTO, family);
FamilyEntity newFamily = familyRepository.save(family);
return familyMapper.entityToDto(newFamily);
}
use of py.org.fundacionparaguaya.pspserver.families.entities.FamilyEntity in project FP-PSP-SERVER by FundacionParaguaya.
the class FamilyServiceImpl method listFamilies.
@Override
public List<FamilyDTO> listFamilies(FamilyFilterDTO filter, UserDetailsDTO userDetails) {
FamilyFilterDTO newFilter = buildFilterFromFilterAndUser(filter, userDetails);
List<FamilyEntity> entityList = familyRepository.findAll(where(byFilter(newFilter)));
return familyMapper.entityListToDtoList(entityList);
}
use of py.org.fundacionparaguaya.pspserver.families.entities.FamilyEntity 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;
}
Aggregations