Search in sources :

Example 1 with FamilyDTO

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

Example 2 with FamilyDTO

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);
}
Also used : FamilyFilterDTO(py.org.fundacionparaguaya.pspserver.families.dtos.FamilyFilterDTO) FamilyDTO(py.org.fundacionparaguaya.pspserver.families.dtos.FamilyDTO) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with FamilyDTO

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;
}
Also used : FamilyDTO(py.org.fundacionparaguaya.pspserver.families.dtos.FamilyDTO)

Example 4 with FamilyDTO

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;
}
Also used : FamilyMapDTO(py.org.fundacionparaguaya.pspserver.families.dtos.FamilyMapDTO) UnknownResourceException(py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException) FamilyDTO(py.org.fundacionparaguaya.pspserver.families.dtos.FamilyDTO)

Aggregations

FamilyDTO (py.org.fundacionparaguaya.pspserver.families.dtos.FamilyDTO)4 ArrayList (java.util.ArrayList)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 UnknownResourceException (py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException)1 FamilyFilterDTO (py.org.fundacionparaguaya.pspserver.families.dtos.FamilyFilterDTO)1 FamilyMapDTO (py.org.fundacionparaguaya.pspserver.families.dtos.FamilyMapDTO)1 SnapshotIndicatorPriority (py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicatorPriority)1 SnapshotIndicators (py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicators)1 SnapshotEconomicEntity (py.org.fundacionparaguaya.pspserver.surveys.entities.SnapshotEconomicEntity)1