Updated status filter in get all application api

This commit is contained in:
rajesh
2024-11-07 16:06:50 +05:30
parent d550f97ea8
commit 647b41b231
5 changed files with 14 additions and 11 deletions

View File

@@ -294,11 +294,11 @@ public class ApplicationDao {
// return applicationResponses;
// }
public List<ApplicationResponse> getAllApplications(UserEntity userEntity, Long callId, Long companyId,String status) {
public List<ApplicationResponse> getAllApplications(UserEntity userEntity, Long callId, Long companyId,List<ApplicationStatusTypeEnum> statusList) {
log.info("Fetching applications for RoleType: {}", userEntity.getRoleEntity().getRoleType());
Specification<ApplicationEntity> spec = search(userEntity, callId, companyId,status);
Specification<ApplicationEntity> spec = search(userEntity, callId, companyId,statusList);
List<ApplicationEntity> applicationEntities = applicationRepository.findAll(spec);
@@ -308,7 +308,7 @@ public class ApplicationDao {
}
private Specification<ApplicationEntity> search(UserEntity userEntity, Long callId, Long companyId,String status) {
private Specification<ApplicationEntity> search(UserEntity userEntity, Long callId, Long companyId,List<ApplicationStatusTypeEnum> statusList) {
return (root, query, builder) -> {
Boolean isBeneficiary = validator.checkIsBeneficiary();
Predicate predicate = builder.isFalse(root.get("isDeleted"));
@@ -321,8 +321,11 @@ public class ApplicationDao {
if (companyId != null) {
predicate = builder.and(predicate, builder.equal(root.get("company").get("id"), companyId));
}
if (status != null) {
predicate = builder.and(predicate, builder.equal(root.get("status"), status));
if (statusList != null && !statusList.isEmpty()) {
List<String> statusNames = statusList.stream()
.map(Enum::name)
.collect(Collectors.toList());
predicate = builder.and(predicate, root.get("status").in(statusNames));
}
predicate = builder.and(predicate, builder.equal(root.get("hubId"), userEntity.getHub().getId()));
return predicate;