use of py.org.fundacionparaguaya.pspserver.surveys.dtos.TopOfIndicators 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.surveys.dtos.TopOfIndicators in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotServiceImpl method countTopIndicators.
private void countTopIndicators(Map<String, TopOfIndicators> topOfIndicatorMap, String key, Object value) {
String light = (String) value;
TopOfIndicators topOfIndicators = topOfIndicatorMap.get(key);
if (topOfIndicators == null) {
topOfIndicators = new TopOfIndicators();
topOfIndicators.setIndicatorName(getNameFromCamelCase(key));
topOfIndicatorMap.put(key, topOfIndicators);
}
if (light != null) {
switch(light) {
case "RED":
topOfIndicators.incrementRed();
break;
case "YELLOW":
topOfIndicators.incrementYellow();
break;
case "GREEN":
topOfIndicators.incrementGreen();
break;
default:
break;
}
}
}
Aggregations