Done ticket GEPAFINBE-195
This commit is contained in:
@@ -504,6 +504,10 @@ public class GepafinConstant {
|
|||||||
public static final String APPLICATION="application";
|
public static final String APPLICATION="application";
|
||||||
public static final String APPLICATION_ID="applicationId";
|
public static final String APPLICATION_ID="applicationId";
|
||||||
public static final String USER_WITH_COMPANY_ID="userWithCompanyId";
|
public static final String USER_WITH_COMPANY_ID="userWithCompanyId";
|
||||||
|
public static final String ASSIGNED_USER_ID="assignedUserId";
|
||||||
|
public static final String APPLICATION_USER_ID="applicationUserId";
|
||||||
|
public static final String INVALID_USER_ID="invalid.user";
|
||||||
|
public static final String COMPANY_NAME="companyName";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,12 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEvaluationFormRepository applicationEvaluationFormRepository;
|
private ApplicationEvaluationFormRepository applicationEvaluationFormRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationAmendmentRequestViewRepository applicationAmendmentRequestViewRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationDao applicationDao;
|
||||||
|
|
||||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
|
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
|
||||||
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
|
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
|
||||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
||||||
@@ -1268,7 +1274,122 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
documentService.deleteFile(documentId);
|
documentService.deleteFile(documentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(Long userId, ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
// public PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(Long userId, ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||||
|
// Integer pageNo = null;
|
||||||
|
// Integer pageLimit = null;
|
||||||
|
// if (applicationAmendmentPaginationRequestBean.getGlobalFilters() != null) {
|
||||||
|
// pageNo = applicationAmendmentPaginationRequestBean.getGlobalFilters().getPage();
|
||||||
|
// pageLimit = applicationAmendmentPaginationRequestBean.getGlobalFilters().getLimit();
|
||||||
|
// }
|
||||||
|
// if (pageLimit == null || pageLimit <= 0) {
|
||||||
|
// pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||||
|
// }
|
||||||
|
// if (pageNo == null || pageNo <= 0) {
|
||||||
|
// pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||||
|
// }
|
||||||
|
// Specification<ApplicationAmendmentRequestEntity> spec = searchPagination(userId,applicationAmendmentPaginationRequestBean);
|
||||||
|
// Page<ApplicationAmendmentRequestEntity> entityPage = applicationAmendmentRequestRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// List<ApplicationAmendmentRequestResponse> applicationResponses = entityPage.getContent().stream()
|
||||||
|
// .map(application -> {
|
||||||
|
// ApplicationAmendmentRequestResponse response = convertEntityToResponse(application,false);
|
||||||
|
// return response;
|
||||||
|
// })
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// PageableResponseBean<List<ApplicationAmendmentRequestResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||||
|
// pageableResponseBean.setBody(applicationResponses);
|
||||||
|
// pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||||
|
// pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||||
|
// pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||||
|
// pageableResponseBean.setPageSize(entityPage.getSize());
|
||||||
|
//
|
||||||
|
// return pageableResponseBean;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public Specification<ApplicationAmendmentRequestEntity> searchPagination(Long userId,ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||||
|
// return (root, query, criteriaBuilder) -> {
|
||||||
|
//
|
||||||
|
// List<Predicate> predicates = getPredicates(applicationAmendmentPaginationRequestBean, criteriaBuilder, root,userId);
|
||||||
|
// SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||||
|
//
|
||||||
|
// if (applicationAmendmentPaginationRequestBean .getGlobalFilters() != null
|
||||||
|
// && applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy() != null &&
|
||||||
|
// applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName() != null && Boolean.FALSE.equals(
|
||||||
|
// isEmpty(applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName()))) {
|
||||||
|
// sortBy.setColumnName(applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName());
|
||||||
|
// sortBy.setSortDesc(true);
|
||||||
|
// if (applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getSortDesc() != null) {
|
||||||
|
// sortBy.setSortDesc(applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// query.orderBy(criteriaBuilder.desc(root.get(sortBy.getColumnName())));
|
||||||
|
// if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||||
|
// query.orderBy(criteriaBuilder.asc(root.get(sortBy.getColumnName())));
|
||||||
|
// }
|
||||||
|
// return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private List<Predicate> getPredicates(ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean,
|
||||||
|
// CriteriaBuilder criteriaBuilder, Root<ApplicationAmendmentRequestEntity> root,Long userId) {
|
||||||
|
//
|
||||||
|
// Integer year = null;
|
||||||
|
// String search = null;
|
||||||
|
// if (amendmentPaginationRequestBean.getGlobalFilters() != null) {
|
||||||
|
// year = amendmentPaginationRequestBean.getGlobalFilters().getYear();
|
||||||
|
// search = amendmentPaginationRequestBean.getGlobalFilters().getSearch();
|
||||||
|
// }
|
||||||
|
// List<Predicate> predicates = new ArrayList<>();
|
||||||
|
//
|
||||||
|
// if (year != null && year > 0) {
|
||||||
|
// int filterYear = amendmentPaginationRequestBean.getGlobalFilters().getYear();
|
||||||
|
//
|
||||||
|
//// Create LocalDateTime boundaries for the start and end of the year
|
||||||
|
// LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
|
||||||
|
// LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
|
||||||
|
//
|
||||||
|
//// Add the range comparison to filter records within the year
|
||||||
|
// predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// // Search in `title` and `message` (if search term is provided)
|
||||||
|
// if (search != null && !search.isEmpty()) {
|
||||||
|
// Predicate notePredicate = criteriaBuilder.like(
|
||||||
|
// criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
||||||
|
// "%" + search.toUpperCase() + "%"
|
||||||
|
// );
|
||||||
|
// predicates.add(criteriaBuilder.or(notePredicate));
|
||||||
|
// Predicate internalNotePredicate = criteriaBuilder.like(
|
||||||
|
// criteriaBuilder.upper(root.get(GepafinConstant.INTERNAL_NOTE)),
|
||||||
|
// "%" + search.toUpperCase() + "%"
|
||||||
|
// );
|
||||||
|
// predicates.add(criteriaBuilder.or(internalNotePredicate));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Filter by `status` (if status list is provided)
|
||||||
|
// if (amendmentPaginationRequestBean.getStatus() != null && !amendmentPaginationRequestBean.getStatus().isEmpty()) {
|
||||||
|
// List<String> statusValues = amendmentPaginationRequestBean.getStatus().stream()
|
||||||
|
// .map(ApplicationAmendmentRequestEnum::name) // Convert enum to string
|
||||||
|
// .toList();
|
||||||
|
// predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||||
|
// }
|
||||||
|
// if(Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
||||||
|
// predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("application").get("userId").in(userId));
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("userId").in(userId));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return predicates;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
public PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> getApplicationAmendmentByPaginationByView(Long userId, ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||||
Integer pageNo = null;
|
Integer pageNo = null;
|
||||||
Integer pageLimit = null;
|
Integer pageLimit = null;
|
||||||
if (applicationAmendmentPaginationRequestBean.getGlobalFilters() != null) {
|
if (applicationAmendmentPaginationRequestBean.getGlobalFilters() != null) {
|
||||||
@@ -1281,20 +1402,20 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
if (pageNo == null || pageNo <= 0) {
|
if (pageNo == null || pageNo <= 0) {
|
||||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||||
}
|
}
|
||||||
Specification<ApplicationAmendmentRequestEntity> spec = searchPagination(userId,applicationAmendmentPaginationRequestBean);
|
Specification<ApplicationAmendmentRequestView> spec = searchPaginationByView(userId,applicationAmendmentPaginationRequestBean);
|
||||||
Page<ApplicationAmendmentRequestEntity> entityPage = applicationAmendmentRequestRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
Page<ApplicationAmendmentRequestView> entityPage = applicationAmendmentRequestViewRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||||
|
|
||||||
|
|
||||||
List<ApplicationAmendmentRequestResponse> applicationResponses = entityPage.getContent().stream()
|
List<ApplicationAmendmentRequestViewResponse> applicationAmendmentRequestViewResponses = entityPage.getContent().stream()
|
||||||
.map(application -> {
|
.map(amendmentRequestView -> {
|
||||||
ApplicationAmendmentRequestResponse response = convertEntityToResponse(application,false);
|
ApplicationAmendmentRequestViewResponse response = convertAmendmentEntityToApplicationAmendmentRequestViewResponse(amendmentRequestView);
|
||||||
return response;
|
return response;
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
PageableResponseBean<List<ApplicationAmendmentRequestResponse>> pageableResponseBean = new PageableResponseBean<>();
|
PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||||
pageableResponseBean.setBody(applicationResponses);
|
pageableResponseBean.setBody(applicationAmendmentRequestViewResponses);
|
||||||
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||||
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||||
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||||
@@ -1302,11 +1423,10 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
|
|
||||||
return pageableResponseBean;
|
return pageableResponseBean;
|
||||||
}
|
}
|
||||||
|
public Specification<ApplicationAmendmentRequestView> searchPaginationByView(Long userId,ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||||
public Specification<ApplicationAmendmentRequestEntity> searchPagination(Long userId,ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
|
||||||
return (root, query, criteriaBuilder) -> {
|
return (root, query, criteriaBuilder) -> {
|
||||||
|
|
||||||
List<Predicate> predicates = getPredicates(applicationAmendmentPaginationRequestBean, criteriaBuilder, root,userId);
|
List<Predicate> predicates = getPredicatesByView(applicationAmendmentPaginationRequestBean, criteriaBuilder, root,userId);
|
||||||
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||||
|
|
||||||
if (applicationAmendmentPaginationRequestBean .getGlobalFilters() != null
|
if (applicationAmendmentPaginationRequestBean .getGlobalFilters() != null
|
||||||
@@ -1329,15 +1449,19 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<Predicate> getPredicates(ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean,
|
private List<Predicate> getPredicatesByView(ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean,
|
||||||
CriteriaBuilder criteriaBuilder, Root<ApplicationAmendmentRequestEntity> root,Long userId) {
|
CriteriaBuilder criteriaBuilder, Root<ApplicationAmendmentRequestView> root,Long userId) {
|
||||||
|
|
||||||
Integer year = null;
|
Integer year = null;
|
||||||
String search = null;
|
String search = null;
|
||||||
|
Map<String, FilterCriteria> filters = new HashMap<>();
|
||||||
if (amendmentPaginationRequestBean.getGlobalFilters() != null) {
|
if (amendmentPaginationRequestBean.getGlobalFilters() != null) {
|
||||||
year = amendmentPaginationRequestBean.getGlobalFilters().getYear();
|
year = amendmentPaginationRequestBean.getGlobalFilters().getYear();
|
||||||
search = amendmentPaginationRequestBean.getGlobalFilters().getSearch();
|
search = amendmentPaginationRequestBean.getGlobalFilters().getSearch();
|
||||||
}
|
}
|
||||||
|
if (amendmentPaginationRequestBean.getFilters() != null) {
|
||||||
|
filters = amendmentPaginationRequestBean.getFilters();
|
||||||
|
}
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
|
||||||
if (year != null && year > 0) {
|
if (year != null && year > 0) {
|
||||||
@@ -1351,19 +1475,37 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||||
|
|
||||||
}
|
}
|
||||||
// Search in `title` and `message` (if search term is provided)
|
|
||||||
if (search != null && !search.isEmpty()) {
|
if (search != null && !search.isEmpty()) {
|
||||||
Predicate notePredicate = criteriaBuilder.like(
|
List<Predicate> searchPredicates = new ArrayList<>();
|
||||||
criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
|
||||||
|
searchPredicates.add(criteriaBuilder.like(
|
||||||
|
criteriaBuilder.upper(root.get(GepafinConstant.CALL_NAME)),
|
||||||
"%" + search.toUpperCase() + "%"
|
"%" + search.toUpperCase() + "%"
|
||||||
);
|
));
|
||||||
predicates.add(criteriaBuilder.or(notePredicate));
|
|
||||||
Predicate internalNotePredicate = criteriaBuilder.like(
|
searchPredicates.add(criteriaBuilder.like(
|
||||||
criteriaBuilder.upper(root.get(GepafinConstant.INTERNAL_NOTE)),
|
criteriaBuilder.upper(root.get(GepafinConstant.COMPANY_NAME)),
|
||||||
"%" + search.toUpperCase() + "%"
|
"%" + search.toUpperCase() + "%"
|
||||||
);
|
));
|
||||||
predicates.add(criteriaBuilder.or(internalNotePredicate));
|
|
||||||
|
// Uncomment these if needed
|
||||||
|
// searchPredicates.add(criteriaBuilder.like(
|
||||||
|
// criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
||||||
|
// "%" + search.toUpperCase() + "%"
|
||||||
|
// ));
|
||||||
|
//
|
||||||
|
// searchPredicates.add(criteriaBuilder.like(
|
||||||
|
// criteriaBuilder.upper(root.get(GepafinConstant.INTERNAL_NOTE)),
|
||||||
|
// "%" + search.toUpperCase() + "%"
|
||||||
|
// ));
|
||||||
|
|
||||||
|
Predicate finalPredicate = criteriaBuilder.or(searchPredicates.toArray(new Predicate[0]));
|
||||||
|
|
||||||
|
predicates.add(finalPredicate);
|
||||||
}
|
}
|
||||||
|
Utils.applyFiltersByPagination(root, criteriaBuilder, predicates, filters);
|
||||||
|
|
||||||
|
|
||||||
// Filter by `status` (if status list is provided)
|
// Filter by `status` (if status list is provided)
|
||||||
if (amendmentPaginationRequestBean.getStatus() != null && !amendmentPaginationRequestBean.getStatus().isEmpty()) {
|
if (amendmentPaginationRequestBean.getStatus() != null && !amendmentPaginationRequestBean.getStatus().isEmpty()) {
|
||||||
@@ -1372,14 +1514,33 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
.toList();
|
.toList();
|
||||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||||
}
|
}
|
||||||
if(Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
boolean isBeneficiaryOrConfidi = validator.checkIsBeneficiary() || validator.checkIsConfidi();
|
||||||
predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("application").get("userId").in(userId));
|
boolean isPreInstructor = validator.checkIsPreInstructor();
|
||||||
}
|
boolean isInstructorManagerWithPersonalRecords = validator.checkIsInstructorManager() &&
|
||||||
else {
|
Boolean.TRUE.equals(amendmentPaginationRequestBean.getPersonalRecords());
|
||||||
predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("userId").in(userId));
|
|
||||||
|
if (isBeneficiaryOrConfidi) {
|
||||||
|
predicates.add(root.get(GepafinConstant.APPLICATION_USER_ID).in(userId));
|
||||||
|
} else if (isPreInstructor || isInstructorManagerWithPersonalRecords) {
|
||||||
|
predicates.add(root.get(GepafinConstant.ASSIGNED_USER_ID).in(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return predicates;
|
return predicates;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public ApplicationAmendmentRequestViewResponse convertAmendmentEntityToApplicationAmendmentRequestViewResponse(ApplicationAmendmentRequestView applicationAmendmentRequestView){
|
||||||
|
ApplicationAmendmentRequestViewResponse applicationAmendmentRequestViewResponse=new ApplicationAmendmentRequestViewResponse();
|
||||||
|
applicationAmendmentRequestViewResponse.setId(applicationAmendmentRequestView.getId());
|
||||||
|
applicationAmendmentRequestViewResponse.setApplicationId(applicationAmendmentRequestView.getApplicationId());
|
||||||
|
applicationAmendmentRequestViewResponse.setProtocolNumber(applicationAmendmentRequestView.getProtocolNumber());
|
||||||
|
applicationAmendmentRequestViewResponse.setCallName(applicationAmendmentRequestView.getCallName());
|
||||||
|
applicationAmendmentRequestViewResponse.setCompanyName(applicationAmendmentRequestView.getCompanyName());
|
||||||
|
applicationAmendmentRequestViewResponse.setStartDate(applicationAmendmentRequestView.getStartDate());
|
||||||
|
applicationAmendmentRequestViewResponse.setExpirationDate(applicationAmendmentRequestView.getExpirationDate());
|
||||||
|
applicationAmendmentRequestViewResponse.setAssigendUserName(applicationAmendmentRequestView.getAssigendUserName());
|
||||||
|
applicationAmendmentRequestViewResponse.setStatus(applicationAmendmentRequestView.getStatus());
|
||||||
|
return applicationAmendmentRequestViewResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1467,185 +1467,6 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageableResponseBean<List<ApplicationResponse>> getAllApplicationByPagination(UserEntity userEntity, Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean) {
|
|
||||||
Integer pageNo = null;
|
|
||||||
Integer pageLimit = null;
|
|
||||||
|
|
||||||
UserWithCompanyEntity userWithCompany= userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), companyId).orElse(null);
|
|
||||||
Long userWithCompanyId = userWithCompany!=null?userWithCompany.getId():null;
|
|
||||||
if (applicationPageableRequestBean.getGlobalFilters() != null) {
|
|
||||||
pageNo = applicationPageableRequestBean.getGlobalFilters().getPage();
|
|
||||||
pageLimit = applicationPageableRequestBean.getGlobalFilters().getLimit();
|
|
||||||
}
|
|
||||||
if (pageLimit == null || pageLimit <= 0) {
|
|
||||||
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
|
||||||
}
|
|
||||||
if (pageNo == null || pageNo <= 0) {
|
|
||||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
|
||||||
}
|
|
||||||
Specification<ApplicationEntity> spec = search(callId,companyId, userWithCompanyId, applicationPageableRequestBean, userEntity);
|
|
||||||
Page<ApplicationEntity> entityPage = applicationRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
|
||||||
// Prepare the response
|
|
||||||
|
|
||||||
|
|
||||||
List<ApplicationResponse> applicationResponses = entityPage.getContent().stream()
|
|
||||||
.map(application -> {
|
|
||||||
ApplicationResponse response = getApplicationResponse(application);
|
|
||||||
return response;
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
|
|
||||||
PageableResponseBean<List<ApplicationResponse>> pageableResponseBean = new PageableResponseBean<>();
|
|
||||||
pageableResponseBean.setBody(applicationResponses);
|
|
||||||
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
|
||||||
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
|
||||||
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
|
||||||
pageableResponseBean.setPageSize(entityPage.getSize());
|
|
||||||
|
|
||||||
return pageableResponseBean;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Specification<ApplicationEntity> search(Long callId, Long companyId, Long userWithCompanyId, ApplicationPageableRequestBean applicationPageableRequestBean, UserEntity userEntity) {
|
|
||||||
return (root, query, criteriaBuilder) -> {
|
|
||||||
|
|
||||||
List<Predicate> predicates = getPredicates(applicationPageableRequestBean, criteriaBuilder, root, callId,companyId, userWithCompanyId, userEntity);
|
|
||||||
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
|
||||||
|
|
||||||
if (applicationPageableRequestBean.getGlobalFilters() != null
|
|
||||||
&& applicationPageableRequestBean.getGlobalFilters().getSortBy() != null &&
|
|
||||||
applicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName() != null && Boolean.FALSE.equals(
|
|
||||||
isEmpty(applicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName()))) {
|
|
||||||
sortBy.setColumnName(applicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName());
|
|
||||||
sortBy.setSortDesc(true);
|
|
||||||
if (applicationPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc() != null) {
|
|
||||||
sortBy.setSortDesc(applicationPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query.orderBy(criteriaBuilder.desc(root.get(sortBy.getColumnName())));
|
|
||||||
if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
|
||||||
query.orderBy(criteriaBuilder.asc(root.get(sortBy.getColumnName())));
|
|
||||||
}
|
|
||||||
return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private List<Predicate> getPredicates(ApplicationPageableRequestBean applicationPageableRequestBean,
|
|
||||||
CriteriaBuilder criteriaBuilder, Root<ApplicationEntity> root, Long callId,Long companyId, Long userWithCompanyId, UserEntity userEntity) {
|
|
||||||
|
|
||||||
Integer year = null;
|
|
||||||
String search = null;
|
|
||||||
Integer daysRange = null;
|
|
||||||
Map<String, FilterCriteria> filters = new HashMap<>();
|
|
||||||
if (applicationPageableRequestBean.getGlobalFilters() != null) {
|
|
||||||
year = applicationPageableRequestBean.getGlobalFilters().getYear();
|
|
||||||
search = applicationPageableRequestBean.getGlobalFilters().getSearch();
|
|
||||||
daysRange = applicationPageableRequestBean.getDaysRange();
|
|
||||||
}
|
|
||||||
if (applicationPageableRequestBean.getFilters() != null) {
|
|
||||||
filters = applicationPageableRequestBean.getFilters();
|
|
||||||
}
|
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
int filterYear = applicationPageableRequestBean.getGlobalFilters().getYear();
|
|
||||||
|
|
||||||
// Create LocalDateTime boundaries for the start and end of the year
|
|
||||||
LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
|
|
||||||
LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
|
|
||||||
|
|
||||||
// Add the range comparison to filter records within the year
|
|
||||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
|
||||||
|
|
||||||
}
|
|
||||||
// Search in `title` and `message` (if search term is provided)
|
|
||||||
if (search != null && !search.isEmpty()) {
|
|
||||||
Predicate titlePredicate = criteriaBuilder.like(
|
|
||||||
criteriaBuilder.upper(root.get(GepafinConstant.COMMENTS)),
|
|
||||||
"%" + search.toUpperCase() + "%"
|
|
||||||
);
|
|
||||||
// Predicate protocolPredicate = criteriaBuilder.like(
|
|
||||||
// criteriaBuilder.function(
|
|
||||||
// "TO_CHAR",
|
|
||||||
// String.class,
|
|
||||||
// criteriaBuilder.function("CAST", String.class, root.get(GepafinConstant.PROTOCOL).get(GepafinConstant.PROTOCOL_NUMBER))
|
|
||||||
// ),
|
|
||||||
// "%" + search + "%"
|
|
||||||
// );
|
|
||||||
|
|
||||||
Predicate callNamePredicate =criteriaBuilder.like(
|
|
||||||
criteriaBuilder.upper(root.get(GepafinConstant.CALL).get(GepafinConstant.NAME)), // Adjust field name
|
|
||||||
"%" + search.toUpperCase() + "%"
|
|
||||||
);
|
|
||||||
|
|
||||||
// predicates.add(criteriaBuilder.or(protocolPredicate));
|
|
||||||
predicates.add(criteriaBuilder.or(callNamePredicate));
|
|
||||||
predicates.add(criteriaBuilder.or(titlePredicate));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter by `status` (if status list is provided)
|
|
||||||
if (applicationPageableRequestBean.getStatus() != null && !applicationPageableRequestBean.getStatus().isEmpty()) {
|
|
||||||
List<String> statusValues = applicationPageableRequestBean.getStatus().stream()
|
|
||||||
.map(ApplicationStatusTypeEnum::name) // Convert enum to string
|
|
||||||
.toList();
|
|
||||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (callId != null) {
|
|
||||||
CallEntity call = callService.validateCall(callId);
|
|
||||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.CALL).get(GepafinConstant.ID), callId));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Optional companyId filter
|
|
||||||
if (userWithCompanyId != null) {
|
|
||||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_WITH_COMPANY).get(GepafinConstant.ID), userWithCompanyId));
|
|
||||||
}
|
|
||||||
if (companyId != null) {
|
|
||||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.COMPANY_ID), companyId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (daysRange != null && daysRange >= 0) {
|
|
||||||
LocalDateTime today = LocalDateTime.now();
|
|
||||||
LocalDateTime pastDate = today.minusDays(daysRange);
|
|
||||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), pastDate, today));
|
|
||||||
}
|
|
||||||
applyFilters(root, criteriaBuilder, predicates, filters);
|
|
||||||
|
|
||||||
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
|
||||||
|
|
||||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB_ID), userEntity.getHub().getId()));
|
|
||||||
|
|
||||||
|
|
||||||
return predicates;
|
|
||||||
}
|
|
||||||
private void applyFilters(Root<?> root, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Map<String, FilterCriteria> filters) {
|
|
||||||
if (Boolean.FALSE.equals(filters.isEmpty())) {
|
|
||||||
for (Map.Entry<String, FilterCriteria> entry : filters.entrySet()) {
|
|
||||||
String fieldName = entry.getKey();
|
|
||||||
FilterCriteria filterCriteria = entry.getValue();
|
|
||||||
Object value = filterCriteria.getValue();
|
|
||||||
MatchModeEnum matchMode = filterCriteria.getMatchMode();
|
|
||||||
|
|
||||||
if (value != null && matchMode != null) {
|
|
||||||
Path<?> fieldPath = root.get(fieldName);
|
|
||||||
if (fieldPath != null) {
|
|
||||||
Utils.applyStringFilter(fieldPath, criteriaBuilder, predicates, value, matchMode);
|
|
||||||
Utils.applyNumberFilter(fieldPath, criteriaBuilder, predicates, value, matchMode);
|
|
||||||
Utils.applyDateFilter(fieldPath, criteriaBuilder, predicates, value, matchMode,root);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// private Path<?> getFieldPath(Root<?> root, String fieldName) {
|
// private Path<?> getFieldPath(Root<?> root, String fieldName) {
|
||||||
// try {
|
// try {
|
||||||
@@ -1918,27 +1739,29 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
// Search in `title` and `message` (if search term is provided)
|
// Search in `title` and `message` (if search term is provided)
|
||||||
if (search != null && !search.isEmpty()) {
|
if (search != null && !search.isEmpty()) {
|
||||||
|
String searchPattern = "%" + search.toUpperCase() + "%";
|
||||||
|
|
||||||
Predicate titlePredicate = criteriaBuilder.like(
|
Predicate titlePredicate = criteriaBuilder.like(
|
||||||
criteriaBuilder.upper(root.get(GepafinConstant.COMMENTS)),
|
criteriaBuilder.upper(root.get(GepafinConstant.COMMENTS)),
|
||||||
"%" + search.toUpperCase() + "%"
|
searchPattern
|
||||||
);
|
|
||||||
// Predicate protocolPredicate = criteriaBuilder.like(
|
|
||||||
// criteriaBuilder.function(
|
|
||||||
// "TO_CHAR",
|
|
||||||
// String.class,
|
|
||||||
// criteriaBuilder.function("CAST", String.class, root.get(GepafinConstant.PROTOCOL).get(GepafinConstant.PROTOCOL_NUMBER))
|
|
||||||
// ),
|
|
||||||
// "%" + search + "%"
|
|
||||||
// );
|
|
||||||
|
|
||||||
Predicate callNamePredicate =criteriaBuilder.like(
|
|
||||||
criteriaBuilder.upper(root.get(GepafinConstant.CALL_TITLE)), // Adjust field name
|
|
||||||
"%" + search.toUpperCase() + "%"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// predicates.add(criteriaBuilder.or(protocolPredicate));
|
Predicate callTitlePredicate = criteriaBuilder.like(
|
||||||
predicates.add(criteriaBuilder.or(callNamePredicate));
|
criteriaBuilder.upper(root.get(GepafinConstant.CALL_TITLE)),
|
||||||
predicates.add(criteriaBuilder.or(titlePredicate));
|
searchPattern
|
||||||
|
);
|
||||||
|
Predicate callNamePredicate = criteriaBuilder.like(
|
||||||
|
criteriaBuilder.upper(root.get(GepafinConstant.CALL_NAME)),
|
||||||
|
searchPattern
|
||||||
|
);
|
||||||
|
Predicate companyName = criteriaBuilder.like(
|
||||||
|
criteriaBuilder.upper(root.get(GepafinConstant.COMPANY_NAME)),
|
||||||
|
searchPattern
|
||||||
|
);
|
||||||
|
|
||||||
|
// Combine them using a single `or()`
|
||||||
|
Predicate finalPredicate = criteriaBuilder.or(titlePredicate, callTitlePredicate,callNamePredicate,companyName);
|
||||||
|
predicates.add(finalPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by `status` (if status list is provided)
|
// Filter by `status` (if status list is provided)
|
||||||
@@ -1967,7 +1790,7 @@ public class ApplicationDao {
|
|||||||
LocalDateTime pastDate = today.minusDays(daysRange);
|
LocalDateTime pastDate = today.minusDays(daysRange);
|
||||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), pastDate, today));
|
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), pastDate, today));
|
||||||
}
|
}
|
||||||
applyFilters(root, criteriaBuilder, predicates, filters);
|
Utils.applyFiltersByPagination(root, criteriaBuilder, predicates, filters);
|
||||||
|
|
||||||
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
||||||
|
|
||||||
@@ -1981,7 +1804,7 @@ public class ApplicationDao {
|
|||||||
ApplicationResponse responseBean = new ApplicationResponse();
|
ApplicationResponse responseBean = new ApplicationResponse();
|
||||||
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationView.getCallId());
|
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationView.getCallId());
|
||||||
Long totalFormSteps = flowFormDao.calculateTotalSteps(flowEdgesList);
|
Long totalFormSteps = flowFormDao.calculateTotalSteps(flowEdgesList);
|
||||||
Long completedSteps= Long.valueOf(flowFormDao.getCompletedStepsByView(applicationView.getId(), false));
|
Long completedSteps = Long.valueOf(flowFormDao.getCompletedStepsByView(applicationView.getId(), false));
|
||||||
Integer progress = calculateProgress(totalFormSteps, completedSteps);
|
Integer progress = calculateProgress(totalFormSteps, completedSteps);
|
||||||
responseBean.setId(applicationView.getId());
|
responseBean.setId(applicationView.getId());
|
||||||
responseBean.setProgress(progress);
|
responseBean.setProgress(progress);
|
||||||
@@ -1995,18 +1818,9 @@ public class ApplicationDao {
|
|||||||
responseBean.setEvaluationVersion(EvaluationVersionEnum.valueOf(applicationView.getEvaluationVersion()));
|
responseBean.setEvaluationVersion(EvaluationVersionEnum.valueOf(applicationView.getEvaluationVersion()));
|
||||||
responseBean.setComments(applicationView.getComments());
|
responseBean.setComments(applicationView.getComments());
|
||||||
responseBean.setCompanyId(applicationView.getCompanyId());
|
responseBean.setCompanyId(applicationView.getCompanyId());
|
||||||
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
|
responseBean.setAssignedUserId(applicationView.getAssignedUserId());
|
||||||
assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationView.getId());
|
responseBean.setAssignedUserName(applicationView.getAssignedUserName());
|
||||||
if(assignedApplicationsOptional.isPresent()){
|
responseBean.setCompanyName(applicationView.getCompanyName());
|
||||||
responseBean.setAssignedUserId(assignedApplicationsOptional.get().getUserId());
|
|
||||||
UserEntity user = userService.validateUser(assignedApplicationsOptional.get().getUserId());
|
|
||||||
String firstName = user.getFirstName() != null ? user.getFirstName() : "";
|
|
||||||
String lastName = user.getLastName() != null ? user.getLastName() : "";
|
|
||||||
String userName = String.join(" ", firstName, lastName).trim();
|
|
||||||
responseBean.setAssignedUserName(userName);
|
|
||||||
}
|
|
||||||
CompanyEntity company=companyService.validateCompany(applicationView.getCompanyId());
|
|
||||||
responseBean.setCompanyName(company.getCompanyName());
|
|
||||||
responseBean.setProtocolNumber(applicationView.getProtocolNumber());
|
responseBean.setProtocolNumber(applicationView.getProtocolNumber());
|
||||||
responseBean.setAmountAccepted(applicationView.getAmountAccepted());
|
responseBean.setAmountAccepted(applicationView.getAmountAccepted());
|
||||||
responseBean.setAmountRequested(applicationView.getAmountRequested());
|
responseBean.setAmountRequested(applicationView.getAmountRequested());
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.hibernate.annotations.Immutable;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Immutable
|
||||||
|
@Table(name = "application_amendment_request_view")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@IdClass(ApplicationAmendmentRequestViewId.class)
|
||||||
|
public class ApplicationAmendmentRequestView {
|
||||||
|
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "APPLICATION_ID")
|
||||||
|
private Long applicationId;
|
||||||
|
|
||||||
|
@Column(name = "PROTOCOL_NUMBER")
|
||||||
|
private Long protocolNumber;
|
||||||
|
|
||||||
|
@Column(name = "CALL_NAME")
|
||||||
|
private String callName;
|
||||||
|
|
||||||
|
@Column(name = "COMPANY_NAME")
|
||||||
|
private String companyName;
|
||||||
|
|
||||||
|
@Column(name = "START_DATE")
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
|
||||||
|
@Column(name = "EXPIRATION_DATE")
|
||||||
|
private LocalDateTime expirationDate;
|
||||||
|
|
||||||
|
@Column(name = "ASSIGNED_USER_NAME")
|
||||||
|
private String assigendUserName;
|
||||||
|
|
||||||
|
@Column(name = "ASSIGNED_USER_ID")
|
||||||
|
private Long assignedUserId;
|
||||||
|
|
||||||
|
@Column(name = "STATUS")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Column(name = "NOTE")
|
||||||
|
private String note;
|
||||||
|
|
||||||
|
@Column(name = "INTERNAL_NOTE")
|
||||||
|
private String internalNote;
|
||||||
|
|
||||||
|
@Column(name = "APPLICATION_USER_ID")
|
||||||
|
private Long applicationUserId;
|
||||||
|
|
||||||
|
@Column(name = "CREATED_DATE")
|
||||||
|
private String createdDate;
|
||||||
|
|
||||||
|
@Column(name = "UPDATED_DATE")
|
||||||
|
private String updatedDate;
|
||||||
|
|
||||||
|
@Column(name = "IS_DELETED")
|
||||||
|
private Boolean isDeleted;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
public class ApplicationAmendmentRequestViewId {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
public ApplicationAmendmentRequestViewId() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationAmendmentRequestViewId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -80,7 +80,7 @@ public class ApplicationView implements Serializable {
|
|||||||
private Long protocolNumber;
|
private Long protocolNumber;
|
||||||
|
|
||||||
@Column(name = "ASSIGNED_USER_ID")
|
@Column(name = "ASSIGNED_USER_ID")
|
||||||
private Long assigned_user_id;
|
private Long assignedUserId;
|
||||||
|
|
||||||
@Column(name = "ASSIGNED_USER_NAME")
|
@Column(name = "ASSIGNED_USER_NAME")
|
||||||
private String assignedUserName;
|
private String assignedUserName;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import lombok.Data;
|
|||||||
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ApplicationAmendmentPaginationRequestBean {
|
public class ApplicationAmendmentPaginationRequestBean {
|
||||||
@@ -11,4 +12,9 @@ public class ApplicationAmendmentPaginationRequestBean {
|
|||||||
private GlobalFilters globalFilters;
|
private GlobalFilters globalFilters;
|
||||||
|
|
||||||
private List<ApplicationAmendmentRequestEnum> status;
|
private List<ApplicationAmendmentRequestEnum> status;
|
||||||
|
|
||||||
|
private Map<String, FilterCriteria> filters;
|
||||||
|
|
||||||
|
private Boolean personalRecords;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApplicationAmendmentRequestViewResponse {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long applicationId;
|
||||||
|
|
||||||
|
private Long protocolNumber;
|
||||||
|
|
||||||
|
private String callName;
|
||||||
|
|
||||||
|
private String companyName;
|
||||||
|
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
|
||||||
|
private LocalDateTime expirationDate;
|
||||||
|
|
||||||
|
private String assigendUserName;
|
||||||
|
|
||||||
|
private String status;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestView;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
|
public interface ApplicationAmendmentRequestViewRepository extends JpaRepository<ApplicationAmendmentRequestView,Long> , JpaSpecificationExecutor<ApplicationAmendmentRequestView> {
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
|||||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestViewResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||||
|
|
||||||
@@ -29,5 +30,5 @@ public interface ApplicationAmendmentRequestService {
|
|||||||
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(HttpServletRequest request, Long applicationAmendmentId, ApplicationAmendmentRequestEnum status);
|
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(HttpServletRequest request, Long applicationAmendmentId, ApplicationAmendmentRequestEnum status);
|
||||||
|
|
||||||
void sendReminderEmail(HttpServletRequest request,Long amendmentId);
|
void sendReminderEmail(HttpServletRequest request,Long amendmentId);
|
||||||
PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean);
|
PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,15 @@ import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
|||||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestViewResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
||||||
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -41,6 +44,9 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(HttpServletRequest request, Long applicationEvaluationId) {
|
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(HttpServletRequest request, Long applicationEvaluationId) {
|
||||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(applicationEvaluationId);
|
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(applicationEvaluationId);
|
||||||
@@ -153,8 +159,16 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean) {
|
public PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean) {
|
||||||
UserEntity user=validator.validateUser(request);
|
boolean isSpecialUser = validator.checkIsBeneficiary() ||
|
||||||
return applicationAmendmentRequestDao.getApplicationAmendmentByPaginnation(userId,amendmentPaginationRequestBean);
|
validator.checkIsConfidi() ||
|
||||||
|
validator.checkIsPreInstructor() ||
|
||||||
|
validator.checkIsInstructorManager();
|
||||||
|
|
||||||
|
if (isSpecialUser && Boolean.TRUE.equals(validator.checkRequestedUserWithUserId(request,userId))) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_USER_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
return applicationAmendmentRequestDao.getApplicationAmendmentByPaginationByView(userId,amendmentPaginationRequestBean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.enums.MatchModeEnum;
|
import net.gepafin.tendermanagement.enums.MatchModeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.FilterCriteria;
|
||||||
import net.gepafin.tendermanagement.model.request.GlobalFilters;
|
import net.gepafin.tendermanagement.model.request.GlobalFilters;
|
||||||
import net.objecthunter.exp4j.Expression;
|
import net.objecthunter.exp4j.Expression;
|
||||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||||
@@ -932,4 +933,25 @@ public class Utils {
|
|||||||
Object obj = parentMap.get(key);
|
Object obj = parentMap.get(key);
|
||||||
return (obj instanceof String str) ? str : null;
|
return (obj instanceof String str) ? str : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void applyFiltersByPagination(Root<?> root, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Map<String, FilterCriteria> filters) {
|
||||||
|
if (Boolean.FALSE.equals(filters.isEmpty())) {
|
||||||
|
for (Map.Entry<String, FilterCriteria> entry : filters.entrySet()) {
|
||||||
|
String fieldName = entry.getKey();
|
||||||
|
FilterCriteria filterCriteria = entry.getValue();
|
||||||
|
Object value = filterCriteria.getValue();
|
||||||
|
MatchModeEnum matchMode = filterCriteria.getMatchMode();
|
||||||
|
|
||||||
|
if (value != null && matchMode != null) {
|
||||||
|
Path<?> fieldPath = root.get(fieldName);
|
||||||
|
if (fieldPath != null) {
|
||||||
|
Utils.applyStringFilter(fieldPath, criteriaBuilder, predicates, value, matchMode);
|
||||||
|
Utils.applyNumberFilter(fieldPath, criteriaBuilder, predicates, value, matchMode);
|
||||||
|
Utils.applyDateFilter(fieldPath, criteriaBuilder, predicates, value, matchMode,root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -206,4 +206,12 @@ public class Validator {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
public Boolean checkRequestedUserWithUserId(HttpServletRequest request,Long userId){
|
||||||
|
UserEntity user=validateUser(request);
|
||||||
|
UserEntity requestedUser=userService.validateUser(userId);
|
||||||
|
if( Boolean.FALSE.equals(user.getId().equals(requestedUser.getId()))){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,7 @@ import jakarta.validation.Valid;
|
|||||||
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.*;
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
|
||||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
|
||||||
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
|
||||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
|
||||||
import net.gepafin.tendermanagement.model.util.Response;
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@@ -201,7 +197,7 @@ public interface ApplicationAmendmentRequestApi {
|
|||||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
@PostMapping(value = "/user/{userId}/pagination", produces = { "application/json" })
|
@PostMapping(value = "/user/{userId}/pagination", produces = { "application/json" })
|
||||||
ResponseEntity<Response<PageableResponseBean<List<ApplicationAmendmentRequestResponse>>>> getApplicationAmendmentByPaginnation(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
|
ResponseEntity<Response<PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>>>> getApplicationAmendmentByPaginnation(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
|
||||||
@RequestBody ApplicationAmendmentPaginationRequestBean userActionPaginationRequest);
|
@RequestBody ApplicationAmendmentPaginationRequestBean userActionPaginationRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
|||||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.*;
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestViewResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.util.Response;
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
@@ -187,11 +188,11 @@ public class ApplicationAmendmentRequestController implements ApplicationAmendme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<PageableResponseBean<List<ApplicationAmendmentRequestResponse>>>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean) {
|
public ResponseEntity<Response<PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>>>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean) {
|
||||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||||
.actionContext(UserActionContextEnum.GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION).build());
|
.actionContext(UserActionContextEnum.GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION).build());
|
||||||
|
|
||||||
PageableResponseBean<List<ApplicationAmendmentRequestResponse>> listPageableResponseBean=applicationAmendmentRequestService.getApplicationAmendmentByPaginnation(request,userId,amendmentPaginationRequestBean);
|
PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> listPageableResponseBean=applicationAmendmentRequestService.getApplicationAmendmentByPaginnation(request,userId,amendmentPaginationRequestBean);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(listPageableResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_DATA_FOR_AMENDMENT_SUCCESS_MSG)));
|
.body(new Response<>(listPageableResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_DATA_FOR_AMENDMENT_SUCCESS_MSG)));
|
||||||
|
|
||||||
|
|||||||
@@ -2690,4 +2690,9 @@
|
|||||||
</insert>
|
</insert>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="01-04-2025_PK_185849" author="Piyush Kag">
|
||||||
|
<sqlFile dbms="postgresql"
|
||||||
|
path="db/dump/create_application_amendment_request_view.sql"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
CREATE OR REPLACE VIEW application_amendment_request_view AS
|
||||||
|
|
||||||
|
SELECT a.id,
|
||||||
|
a.application_id,
|
||||||
|
p.protocol_number,
|
||||||
|
cl.name AS call_name,
|
||||||
|
c.company_name,
|
||||||
|
a.start_date,
|
||||||
|
a.end_date AS expiration_date,
|
||||||
|
COALESCE(NULLIF(TRIM(BOTH FROM concat(COALESCE(u.first_name, ''), ' ', COALESCE(u.last_name, ''))), ''), '') AS assigned_user_name,
|
||||||
|
aa.user_id AS assigned_user_id,
|
||||||
|
a.status,
|
||||||
|
a.note,
|
||||||
|
a.internal_note,
|
||||||
|
app.user_id AS application_user_id,
|
||||||
|
a.created_date,
|
||||||
|
a.updated_date,
|
||||||
|
a.is_deleted
|
||||||
|
FROM gepafin_schema.application_amendment_request a
|
||||||
|
LEFT JOIN gepafin_schema.application app ON a.application_id = app.id AND (app.is_deleted IS FALSE OR app.is_deleted IS NULL)
|
||||||
|
LEFT JOIN gepafin_schema.call cl ON app.call_id = cl.id
|
||||||
|
LEFT JOIN gepafin_schema.company c ON app.company_id = c.id
|
||||||
|
LEFT JOIN gepafin_schema.protocol p ON a.protocol_id = p.id
|
||||||
|
LEFT JOIN gepafin_schema.assigned_applications aa ON app.id = aa.application_id AND (aa.is_deleted IS FALSE OR aa.is_deleted IS NULL)
|
||||||
|
LEFT JOIN gepafin_schema.gepafin_user u ON aa.user_id = u.id
|
||||||
|
WHERE a.is_deleted IS FALSE OR a.is_deleted IS NULL ORDER BY id;
|
||||||
@@ -398,3 +398,4 @@ error.invalid.limit=Limit should be between 1 and 3000.
|
|||||||
insufficient.score.msg = Insufficient score to pass to the technical and economic-financial evaluation
|
insufficient.score.msg = Insufficient score to pass to the technical and economic-financial evaluation
|
||||||
|
|
||||||
password.expired.for.login.to.odessa = Odessa login password has been expired.
|
password.expired.for.login.to.odessa = Odessa login password has been expired.
|
||||||
|
invalid.user=Invalid user.
|
||||||
|
|||||||
@@ -390,3 +390,4 @@ insufficient.score.msg = Punteggio non sufficiente per passaggio alla valutazion
|
|||||||
validation.table.message=I dati per il campo {0} non sono presenti.
|
validation.table.message=I dati per il campo {0} non sono presenti.
|
||||||
|
|
||||||
password.expired.for.login.to.odessa = La password di accesso a Odessa è scaduta
|
password.expired.for.login.to.odessa = La password di accesso a Odessa è scaduta
|
||||||
|
invalid.user=Utente non valido.
|
||||||
Reference in New Issue
Block a user