Search in sources :

Example 1 with SnapshotIndicatorPriority

use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicatorPriority 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 SnapshotIndicatorPriority

use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicatorPriority in project FP-PSP-SERVER by FundacionParaguaya.

the class SnapshotServiceImpl method getSnapshotIndicators.

@Override
public SnapshotIndicators getSnapshotIndicators(Long snapshotId) {
    SnapshotIndicators toRet = new SnapshotIndicators();
    SnapshotEconomicEntity originalSnapshot = economicRepository.findOne(snapshotId);
    if (originalSnapshot == null) {
        return toRet;
    }
    List<SnapshotIndicatorPriority> priorities = priorityService.getSnapshotIndicatorPriorityList(originalSnapshot.getSnapshotIndicator().getId());
    toRet.setIndicatorsPriorities(priorities);
    toRet.setIndicatorsSurveyData(getIndicatorsValue(originalSnapshot, toRet));
    toRet.setCreatedAt(originalSnapshot.getCreatedAtAsISOString());
    toRet.setSnapshotIndicatorId(originalSnapshot.getSnapshotIndicator().getId());
    toRet.setSnapshotEconomicId(originalSnapshot.getId());
    toRet.setSurveyId(originalSnapshot.getSurveyDefinition().getId());
    // set family for information purpose
    Long familyId = originalSnapshot.getFamily().getFamilyId();
    toRet.setFamilyId(familyId);
    toRet.setFamily(familyService.getFamilyById(familyId));
    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)

Example 3 with SnapshotIndicatorPriority

use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicatorPriority in project FP-PSP-SERVER by FundacionParaguaya.

the class SnapshotIndicatorPriorityMapper method entityToDto.

@Override
public SnapshotIndicatorPriority entityToDto(SnapshotIndicatorPriorityEntity entity) {
    SnapshotIndicatorPriority dto = modelMapper.map(entity, SnapshotIndicatorPriority.class);
    dto = dto.estimatedDate(entity.getEstimatedDateAsISOString());
    return dto;
}
Also used : SnapshotIndicatorPriority(py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicatorPriority)

Example 4 with SnapshotIndicatorPriority

use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicatorPriority in project FP-PSP-SERVER by FundacionParaguaya.

the class SnapshotIndicatorPriorityController method addSnapshotIndicatorPriority.

@PostMapping(consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
@io.swagger.annotations.ApiOperation(value = "Create Snapshot Indicator Priority", notes = "A `POST` request will create new priority for a particular indicator of a snapshot indicator.", response = SnapshotIndicatorPriority.class, tags = {})
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 201, message = "The created snapshot indicator priority", response = SnapshotIndicatorPriority.class) })
public ResponseEntity<SnapshotIndicatorPriority> addSnapshotIndicatorPriority(@ApiParam(value = "The snapshot indicator priority", required = true) @RequestBody SnapshotIndicatorPriority priority) throws NotFoundException, URISyntaxException {
    SnapshotIndicatorPriority data = snapshotPriorityService.addSnapshotIndicatorPriority(priority);
    URI surveyLocation = new URI("/snapshots/priority/" + data.getId());
    return ResponseEntity.created(surveyLocation).body(data);
}
Also used : SnapshotIndicatorPriority(py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicatorPriority) URI(java.net.URI)

Example 5 with SnapshotIndicatorPriority

use of py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicatorPriority in project FP-PSP-SERVER by FundacionParaguaya.

the class SnapshotIndicatorPriorityController method updateSnapshotIndicatorPriority.

@PutMapping(consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
@io.swagger.annotations.ApiOperation(value = "Update Snapshot Indicator Priority", notes = "A `PUT` request will update priority for a particular indicator of a snapshot indicator.", response = SnapshotIndicatorPriority.class, tags = {})
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 201, message = "The updated snapshot indicator priority", response = SnapshotIndicatorPriority.class) })
public ResponseEntity updateSnapshotIndicatorPriority(@ApiParam(value = "The snapshot indicator priority", required = true) @RequestBody SnapshotIndicatorPriority priority) throws NotFoundException, URISyntaxException {
    SnapshotIndicatorPriority data = snapshotPriorityService.updateSnapshotIndicatorPriority(priority);
    URI surveyLocation = new URI("/snapshots/priority/" + data.getId());
    return ResponseEntity.created(surveyLocation).body(data);
}
Also used : SnapshotIndicatorPriority(py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicatorPriority) URI(java.net.URI)

Aggregations

SnapshotIndicatorPriority (py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicatorPriority)5 URI (java.net.URI)2 SnapshotIndicators (py.org.fundacionparaguaya.pspserver.surveys.dtos.SnapshotIndicators)2 SnapshotEconomicEntity (py.org.fundacionparaguaya.pspserver.surveys.entities.SnapshotEconomicEntity)2 ArrayList (java.util.ArrayList)1 FamilyDTO (py.org.fundacionparaguaya.pspserver.families.dtos.FamilyDTO)1