use of py.org.fundacionparaguaya.pspserver.families.dtos.FamilyDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotServiceImpl method getSnapshotIndicatorsByFamily.
@Override
public List<SnapshotIndicators> getSnapshotIndicatorsByFamily(Long familyId) {
List<SnapshotIndicators> toRet = new ArrayList<>();
List<SnapshotEconomicEntity> originalSnapshots = economicRepository.findByFamilyFamilyId(familyId).stream().collect(Collectors.toList());
for (SnapshotEconomicEntity os : originalSnapshots) {
SnapshotIndicators snapshotIndicators = countSnapshotIndicators(os);
List<SnapshotIndicatorPriority> priorities = priorityService.getSnapshotIndicatorPriorityList(os.getSnapshotIndicator().getId());
snapshotIndicators.setIndicatorsPriorities(priorities);
snapshotIndicators.setCreatedAt(os.getCreatedAtAsISOString());
snapshotIndicators.setSnapshotIndicatorId(os.getSnapshotIndicator().getId());
snapshotIndicators.setFamilyId(os.getFamily().getFamilyId());
snapshotIndicators.setSnapshotEconomicId(os.getId());
snapshotIndicators.setSurveyId(os.getSurveyDefinition().getId());
FamilyDTO familyDto = familyService.getFamilyById(familyId);
familyDto.setOrganizationId(organizationMapper.entityToDto(organizationRepository.findOne(familyDto.getOrganization().getId())));
snapshotIndicators.setFamily(familyDto);
if (os.getUser() != null) {
snapshotIndicators.setUser(UserDTO.builder().userId(os.getUser().getId()).username(os.getUser().getUsername()).build());
}
snapshotIndicators.setIndicatorsSurveyData(getIndicatorsValue(os, snapshotIndicators));
toRet.add(snapshotIndicators);
}
return toRet;
}
use of py.org.fundacionparaguaya.pspserver.families.dtos.FamilyDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class FamilyController method getAllFamilies.
@GetMapping()
public ResponseEntity<List<FamilyDTO>> getAllFamilies(@RequestParam(value = "organization_id", required = false) Long organizationId, @RequestParam(value = "country_id", required = false) Long countryId, @RequestParam(value = "city_id", required = false) Long cityId, @RequestParam(value = "free_text", required = false) String name, @RequestParam(value = "application_id", required = false) Long applicationId, @RequestParam(value = "last_modified_gt", required = false) String lastModifiedGt, @AuthenticationPrincipal UserDetailsDTO user) {
FamilyFilterDTO filter = FamilyFilterDTO.builder().applicationId(applicationId).organizationId(organizationId).countryId(countryId).cityId(cityId).name(name).isActive(true).lastModifiedGt(lastModifiedGt).build();
List<FamilyDTO> families = familyService.listFamilies(filter, user);
return ResponseEntity.ok(families);
}
use of py.org.fundacionparaguaya.pspserver.families.dtos.FamilyDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class PersonControllerTest method getFamilynTest.
private FamilyDTO getFamilynTest() {
FamilyDTO dto = new FamilyDTO();
dto.setFamilyId(new Long(1));
dto.setName("foo.FAMILY");
return dto;
}
use of py.org.fundacionparaguaya.pspserver.families.dtos.FamilyDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class FamilySnapshotsManagerImpl method getFamilyMapById.
@Override
public FamilyMapDTO getFamilyMapById(Long familyId) {
checkArgument(familyId > 0, i18n.translate("argument.nonNegative", familyId));
FamilyMapDTO familyFile = new FamilyMapDTO();
FamilyDTO family = Optional.ofNullable(familyRepository.findOne(familyId)).map(familyMapper::entityToDto).orElseThrow(() -> new UnknownResourceException(i18n.translate("family.notExist")));
BeanUtils.copyProperties(family, familyFile);
familyFile.setSnapshotIndicators(snapshotService.getLastSnapshotIndicatorsByFamily(familyId));
return familyFile;
}
Aggregations