Search in sources :

Example 16 with UnknownResourceException

use of py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException in project FP-PSP-SERVER by FundacionParaguaya.

the class UserRoleServiceImpl method updateUserRole.

@Override
public UserRoleDTO updateUserRole(Long userRoleId, UserRoleDTO userRoleDTO) {
    checkArgument(userRoleId > 0, "Argument was %s but expected nonnegative", userRoleId);
    return Optional.ofNullable(userRoleRepository.findOne(userRoleId)).map(userRole -> {
        BeanUtils.copyProperties(userRoleDTO, userRole);
        LOG.debug("Changed Information for User role: {}", userRole);
        return userRole;
    }).map(userRoleMapper::entityToDto).orElseThrow(() -> new UnknownResourceException("User role does not exist"));
}
Also used : UnknownResourceException(py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException)

Example 17 with UnknownResourceException

use of py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException 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

UnknownResourceException (py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException)17 CustomParameterizedException (py.org.fundacionparaguaya.pspserver.common.exceptions.CustomParameterizedException)3 Transactional (org.springframework.transaction.annotation.Transactional)2 ImageDTO (py.org.fundacionparaguaya.pspserver.system.dtos.ImageDTO)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Specifications.where (org.springframework.data.jpa.domain.Specifications.where)1 Service (org.springframework.stereotype.Service)1 FamilyDTO (py.org.fundacionparaguaya.pspserver.families.dtos.FamilyDTO)1 FamilyMapDTO (py.org.fundacionparaguaya.pspserver.families.dtos.FamilyMapDTO)1 FamilyEntity (py.org.fundacionparaguaya.pspserver.families.entities.FamilyEntity)1 ApplicationDTO (py.org.fundacionparaguaya.pspserver.network.dtos.ApplicationDTO)1 OrganizationDTO (py.org.fundacionparaguaya.pspserver.network.dtos.OrganizationDTO)1 SurveyOrganizationEntity (py.org.fundacionparaguaya.pspserver.network.entities.SurveyOrganizationEntity)1