updated code
This commit is contained in:
@@ -174,10 +174,9 @@ public class ApplicationDao {
|
||||
}
|
||||
|
||||
public List<ApplicationResponse> getAllApplications(UserEntity userEntity, Long callId) {
|
||||
RoleStatusEnum roleStatus = RoleStatusEnum.valueOf(userEntity.getRoleEntity().getRoleType());
|
||||
boolean isBeneficiary = RoleStatusEnum.ROLE_BENEFICIARY.equals(roleStatus);
|
||||
boolean isBeneficiary = isBeneficiary(userEntity);
|
||||
|
||||
log.info("Fetching applications for RoleType: {}", roleStatus);
|
||||
log.info("Fetching applications for RoleType: {}", userEntity.getRoleEntity().getRoleType());
|
||||
List<ApplicationResponse> applicationResponses = new ArrayList<>();
|
||||
|
||||
if (callId != null) {
|
||||
@@ -351,7 +350,12 @@ public class ApplicationDao {
|
||||
public ApplicationGetResponseBean getApplicationByFormId( Long applicationId,Long formId, UserEntity userEntity) {
|
||||
List<FormApplicationResponse> formApplicationResponses = new ArrayList<>();
|
||||
List<FormEntity> formEntities = new ArrayList<>();
|
||||
ApplicationEntity applicationEntity = applicationRepository.findById(applicationId)
|
||||
boolean isBeneficiary = isBeneficiary(userEntity);
|
||||
ApplicationEntity applicationEntity = isBeneficiary
|
||||
? applicationRepository.findByIdAndUserIdAndIsDeletedFalse(applicationId,userEntity.getId())
|
||||
.orElseThrow(() -> new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG)))
|
||||
: applicationRepository.findById(applicationId)
|
||||
.stream().findFirst()
|
||||
.orElseThrow(() -> new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG)));
|
||||
|
||||
if (formId != null) {
|
||||
@@ -374,6 +378,12 @@ public class ApplicationDao {
|
||||
return createApplicationGetResponseBean(applicationEntity, formEntities, formApplicationResponses);
|
||||
}
|
||||
|
||||
private boolean isBeneficiary(UserEntity userEntity) {
|
||||
RoleStatusEnum roleStatus = RoleStatusEnum.valueOf(userEntity.getRoleEntity().getRoleType());
|
||||
boolean isBeneficiary = RoleStatusEnum.ROLE_BENEFICIARY.equals(roleStatus);
|
||||
return isBeneficiary;
|
||||
}
|
||||
|
||||
private void addFormApplication(FormEntity formEntity, ApplicationEntity applicationEntity,
|
||||
List<FormApplicationResponse> formApplicationResponses) {
|
||||
FormApplicationResponse formApplicationResponse = processForm(formEntity, applicationEntity);
|
||||
|
||||
Reference in New Issue
Block a user