Merge branch 'develop' of https://github.com/Kitzanos/GEPAFIN-BE into develop
This commit is contained in:
@@ -682,7 +682,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
log.info("Updating application amendement with ID: {}", id);
|
||||
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
||||
Boolean isBeneficiary=false;
|
||||
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||
if (Boolean.FALSE.equals(validator.checkIsBeneficiary()) && Boolean.FALSE.equals(validator.checkIsConfidi()) ) {
|
||||
validator.validatePreInstructor(request, existingApplicationAmendment.getApplicationEvaluationEntity().getUserId());
|
||||
isBeneficiary=false;
|
||||
} else {
|
||||
@@ -1372,10 +1372,10 @@ public class ApplicationAmendmentRequestDao {
|
||||
.toList();
|
||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||
}
|
||||
if(Boolean.TRUE.equals(validator.checkIsBeneficiary())) {
|
||||
if(Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
||||
predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("application").get("userId").in(userId));
|
||||
}
|
||||
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||
else {
|
||||
predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("userId").in(userId));
|
||||
}
|
||||
|
||||
|
||||
@@ -389,7 +389,7 @@ public class ApplicationDao {
|
||||
return (root, query, builder) -> {
|
||||
Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
||||
if (isBeneficiary) {
|
||||
if (Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
||||
predicate = builder.and(predicate, builder.equal(root.get("userId"), userEntity.getId()));
|
||||
}
|
||||
if (callId != null) {
|
||||
@@ -742,7 +742,7 @@ public class ApplicationDao {
|
||||
List<FormApplicationResponse> formApplicationResponses = new ArrayList<>();
|
||||
List<FormEntity> formEntities = new ArrayList<>();
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
boolean isBeneficiary = isBeneficiary(userEntity);
|
||||
boolean isBeneficiary = Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi());
|
||||
ApplicationEntity applicationEntity = isBeneficiary
|
||||
? applicationRepository.findByIdAndUserIdAndIsDeletedFalse(applicationId, userEntity.getId())
|
||||
.orElseThrow(() -> new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG)))
|
||||
@@ -1530,8 +1530,8 @@ public class ApplicationDao {
|
||||
}
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||
if (isBeneficiary) {
|
||||
// Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||
if (Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_ID), userEntity.getId()));
|
||||
}
|
||||
if (year != null && year > 0) {
|
||||
|
||||
@@ -785,17 +785,20 @@ public class CallDao {
|
||||
return createCallResponseBean;
|
||||
}
|
||||
|
||||
public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,UserEntity user, Long companyId,Boolean onlyPreferredCall) {
|
||||
public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,UserEntity user, Long companyId,Boolean onlyPreferredCall,Boolean onlyConfidiCall) {
|
||||
String type = user.getRoleEntity().getRoleType();
|
||||
List<String> callStatusList = CallStatusEnum.getStatusValues();
|
||||
if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) {
|
||||
callStatusList = List.of(CallStatusEnum.PUBLISH.getValue());
|
||||
}
|
||||
List<CallEntity> calls;
|
||||
// List<CallEntity> calls = List.of();
|
||||
if (Boolean.TRUE.equals(onlyPreferredCall) && companyId == null) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL));
|
||||
}
|
||||
Specification<CallEntity> spec = buildCallSpecification(request, user, companyId, onlyPreferredCall, onlyConfidiCall, callStatusList);
|
||||
|
||||
List<CallEntity> calls = callRepository.findAll(spec);
|
||||
|
||||
if (Boolean.TRUE.equals(onlyPreferredCall)) {
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
@@ -853,7 +856,7 @@ public class CallDao {
|
||||
public Map<String, BeneficiaryPreferredCallEntity> getBeneficiaryPreferredCallsForUser(HttpServletRequest request, UserEntity user, List<Long> callIds, Long companyId) {
|
||||
List<BeneficiaryPreferredCallEntity> beneficiaryPreferredCalls;
|
||||
|
||||
if (companyId != null && Boolean.TRUE.equals(validator.checkIsBeneficiary())) {
|
||||
if (companyId != null && (Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi()))) {
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(),companyId);
|
||||
beneficiaryPreferredCalls = beneficiaryPreferredCallRepository
|
||||
@@ -1022,7 +1025,10 @@ public class CallDao {
|
||||
|
||||
// Add preferredCallIds filtering to the specification
|
||||
spec = spec.and((root, query, criteriaBuilder) ->
|
||||
root.get(GepafinConstant.ID).in(preferredCallIds)
|
||||
criteriaBuilder.and(
|
||||
root.get(GepafinConstant.ID).in(preferredCallIds),
|
||||
criteriaBuilder.isTrue(root.get("confidi"))
|
||||
)
|
||||
);
|
||||
}
|
||||
entityPage = callRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
@@ -1138,6 +1144,28 @@ public class CallDao {
|
||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||
}
|
||||
applyFilters(root, criteriaBuilder, predicates, filters);
|
||||
Boolean isConfidi = callPageableRequestBean.getConfidi();
|
||||
|
||||
if (validator.checkIsConfidi()) {
|
||||
|
||||
if (isConfidi == null || isConfidi.equals(Boolean.FALSE)) {
|
||||
// Ensure no records are returned
|
||||
return List.of(criteriaBuilder.disjunction());
|
||||
}
|
||||
|
||||
if (isConfidi.equals(Boolean.TRUE)) {
|
||||
predicates.add(criteriaBuilder.isTrue(root.get("confidi")));
|
||||
}
|
||||
}
|
||||
else if( Boolean.FALSE.equals(validator.checkIsConfidi()) && isConfidi!=null){
|
||||
if (isConfidi.equals(Boolean.TRUE)) {
|
||||
predicates.add(criteriaBuilder.isTrue(root.get("confidi")));
|
||||
}
|
||||
if (isConfidi.equals(Boolean.FALSE)) {
|
||||
predicates.add(criteriaBuilder.isFalse(root.get("confidi")));
|
||||
}
|
||||
}
|
||||
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB).get(GepafinConstant.ID), userEntity.getHub().getId()));
|
||||
|
||||
return predicates;
|
||||
@@ -1327,4 +1355,45 @@ public class CallDao {
|
||||
createCallResponseBean.setCurrentStep(GepafinConstant.EVALUATION_V2_STEP_2);
|
||||
return createCallResponseBean;
|
||||
}
|
||||
private Specification<CallEntity> buildCallSpecification(HttpServletRequest request, UserEntity user, Long companyId, Boolean onlyPreferredCall, Boolean onlyConfidiCall, List<String> callStatusList) {
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(root.get("status").in(callStatusList));
|
||||
|
||||
if (Boolean.TRUE.equals(onlyPreferredCall)) {
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
UserWithCompanyEntity userWithCompanyEntity = companyService.getUserWithCompany(user.getId(), companyId);
|
||||
List<BeneficiaryPreferredCallEntity> preferredCalls = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndUserWithCompanyIdAndIsDeletedFalse(user.getId(), userWithCompanyEntity.getId());
|
||||
List<Long> preferredCallIds = preferredCalls.stream()
|
||||
.map(BeneficiaryPreferredCallEntity::getCallId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
predicates.add(root.get("id").in(preferredCallIds));
|
||||
} else {
|
||||
predicates.add(criteriaBuilder.equal(root.get("hub").get("id"), user.getHub().getId()));
|
||||
}
|
||||
|
||||
if (validator.checkIsConfidi()) {
|
||||
if (onlyConfidiCall==null || Boolean.FALSE.equals(onlyConfidiCall)) {
|
||||
return criteriaBuilder.conjunction();
|
||||
}
|
||||
|
||||
if (onlyConfidiCall!=null && Boolean.TRUE.equals(onlyConfidiCall)) {
|
||||
predicates.add(criteriaBuilder.isTrue(root.get("confidi")));
|
||||
}
|
||||
}else {
|
||||
if(onlyConfidiCall!=null) {
|
||||
if (Boolean.TRUE.equals(onlyConfidiCall)) {
|
||||
predicates.add(criteriaBuilder.isTrue(root.get("confidi")));
|
||||
}
|
||||
if (Boolean.FALSE.equals(onlyConfidiCall)) {
|
||||
predicates.add(criteriaBuilder.isFalse(root.get("confidi")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return criteriaBuilder.and(predicates.toArray(new Predicate[0]));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class CommunicationDao {
|
||||
if(validator.checkIsPreInstructor()){
|
||||
communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId());
|
||||
communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||
} else if(validator.checkIsBeneficiary()) {
|
||||
} else if(Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
||||
communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||
communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId());
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ public class DashboardDao {
|
||||
}
|
||||
|
||||
private void setRegisteredUsers(Widget1 widget1, UserEntity requestedUserEntity) {
|
||||
Long activeUsers = userRepository.countByStatusAndRoleEntityRoleTypeAndHubId(UserStatusEnum.ACTIVE.getValue(),
|
||||
RoleStatusEnum.ROLE_BENEFICIARY.getValue(), requestedUserEntity.getHub().getId());
|
||||
Long activeUsers = userRepository.countByStatusAndRoleEntityRoleTypeInAndHubId(UserStatusEnum.ACTIVE.getValue(),
|
||||
List.of(RoleStatusEnum.ROLE_BENEFICIARY.getValue(),RoleStatusEnum.ROLE_CONFIDI.getValue()), requestedUserEntity.getHub().getId());
|
||||
if (activeUsers != null) {
|
||||
widget1.setNumberOfResgisteredUsers(activeUsers);
|
||||
}
|
||||
@@ -183,10 +183,21 @@ public class DashboardDao {
|
||||
.map(BeneficiaryPreferredCallEntity::getCallId)
|
||||
.collect(Collectors.toList());
|
||||
List<CallEntity> callEntities = callRepository.findByIdIn(callIds);
|
||||
long activeCallsCount = callEntities.stream()
|
||||
.filter(call -> CallStatusEnum.PUBLISH.getValue().equals(call.getStatus())
|
||||
&& userEntity.getHub().getId().equals(call.getHub().getId()))
|
||||
.count();
|
||||
long activeCallsCount=0;
|
||||
if(Boolean.TRUE.equals(validator.checkIsBeneficiary())) {
|
||||
activeCallsCount = callEntities.stream()
|
||||
.filter(call -> CallStatusEnum.PUBLISH.getValue().equals(call.getStatus())
|
||||
&& userEntity.getHub().getId().equals(call.getHub().getId()))
|
||||
.count();
|
||||
}
|
||||
if(Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
||||
activeCallsCount = callEntities.stream()
|
||||
.filter(call -> CallStatusEnum.PUBLISH.getValue().equals(call.getStatus())
|
||||
&& userEntity.getHub().getId().equals(call.getHub().getId())
|
||||
&& call.getConfidi()) // Add this condition for confidi
|
||||
.count();
|
||||
|
||||
}
|
||||
|
||||
beneficiaryWidgetResponseBean.setNumberOfCalls(activeCallsCount);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,12 @@ public class DelegationDao {
|
||||
CompanyEntity companyEntity = companyDao.validateCompany(companyId);
|
||||
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||
updatePlaceholdersForDelegation(user, companyEntity, placeholders, companyDelegationRequest);
|
||||
DocumentEntity documentEntity = documentRepository.findBySource(GepafinConstant.DELEGATION_TEMPLATE).get(0);
|
||||
DocumentEntity documentEntity =null;
|
||||
if(Boolean.TRUE.equals(validator.checkIsConfidi())){
|
||||
documentEntity = documentRepository.findBySource(GepafinConstant.DELEGATION_TEMPLATE_CONFIDI).get(0);
|
||||
}else {
|
||||
documentEntity = documentRepository.findBySource(GepafinConstant.DELEGATION_TEMPLATE).get(0);
|
||||
}
|
||||
return generateDocument(placeholders, documentEntity.getFilePath());
|
||||
}
|
||||
|
||||
@@ -293,7 +298,7 @@ public class DelegationDao {
|
||||
if (validator.checkIsPreInstructor()) {
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluationByApplicationId(applicationId);
|
||||
validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId());
|
||||
} else if (validator.checkIsBeneficiary()) {
|
||||
} else if (Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
||||
userId = validator.validateUser(request).getId();
|
||||
}
|
||||
return companyService.getUserWithCompany(userId, companyId);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class FaqDao {
|
||||
CallEntity callEntity = callService.validateCall(callId);
|
||||
FaqEntity entity = createOrUpdateFaqEntity(faqRequest, callEntity, userEntity, LookUpDataTypeEnum.FAQ);
|
||||
FaqEntity oldFaqEntity = Utils.getClonedEntityForData(entity);
|
||||
if (validator.checkIsBeneficiary() && companyId == null) {
|
||||
if ((Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) && companyId == null) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.COMPANY_ID_MANDATORY));
|
||||
}
|
||||
UserWithCompanyEntity userWithCompanyEntity=null;
|
||||
@@ -132,7 +132,7 @@ public class FaqDao {
|
||||
oldFaqEntity = Utils.getClonedEntityForData(faqEntity);
|
||||
actionType = VersionActionTypeEnum.UPDATE;
|
||||
} else {
|
||||
if (Boolean.FALSE.equals(userEntity.getRoleEntity().getRoleType().equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue()))) {
|
||||
if (Boolean.FALSE.equals(userEntity.getRoleEntity().getRoleType().equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue())) && Boolean.FALSE.equals(userEntity.getRoleEntity().getRoleType().equals(RoleStatusEnum.ROLE_CONFIDI.getValue()))) {
|
||||
lookUpDataService.getOrCreateLookUpDataEntity(faqReq, type);
|
||||
}
|
||||
faqEntity = new FaqEntity();
|
||||
|
||||
@@ -169,7 +169,7 @@ public class UserDao {
|
||||
}
|
||||
private BeneficiaryEntity createBeneficiary(RoleEntity roleEntity, UserReq userReq, HubEntity hub) {
|
||||
BeneficiaryEntity beneficiaryEntity = null;
|
||||
if (RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleEntity.getRoleType())) {
|
||||
if (RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleEntity.getRoleType()) || RoleStatusEnum.ROLE_CONFIDI.getValue().equals(roleEntity.getRoleType())) {
|
||||
beneficiaryEntity = new BeneficiaryEntity();
|
||||
beneficiaryEntity.setAddress(userReq.getAddress());
|
||||
beneficiaryEntity.setCity(userReq.getCity());
|
||||
@@ -765,7 +765,7 @@ public class UserDao {
|
||||
HubEntity hubEntity = hubService.valdateHub(userEntity.getHub().getId());
|
||||
String beneficiaryRoleType = RoleStatusEnum.ROLE_BENEFICIARY.getValue();
|
||||
|
||||
if (validator.checkIsBeneficiary()) {
|
||||
if (Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
||||
// Validate if the new email already exists for another beneficiary in the same hub
|
||||
boolean emailExistsForBeneficiary = userRepository.existsByEmailIgnoreCaseForBeneficiaries(
|
||||
userReq.getEmail(), hubEntity.getUniqueUuid(), beneficiaryRoleType);
|
||||
|
||||
Reference in New Issue
Block a user