Resolved Conflicts
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,19 +1818,10 @@ 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());
|
responseBean.setProtocolNumber(applicationView.getProtocolNumber());
|
||||||
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.setAmountAccepted(applicationView.getAmountAccepted());
|
responseBean.setAmountAccepted(applicationView.getAmountAccepted());
|
||||||
responseBean.setAmountRequested(applicationView.getAmountRequested());
|
responseBean.setAmountRequested(applicationView.getAmountRequested());
|
||||||
responseBean.setDateAccepted(applicationView.getDateAccepted());
|
responseBean.setDateAccepted(applicationView.getDateAccepted());
|
||||||
|
|||||||
@@ -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.gepafin.tendermanagement.web.rest.api.errors.*;
|
import net.gepafin.tendermanagement.web.rest.api.errors.*;
|
||||||
import net.objecthunter.exp4j.Expression;
|
import net.objecthunter.exp4j.Expression;
|
||||||
@@ -111,6 +112,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String extractFileName(String filePath) {
|
public static String extractFileName(String filePath) {
|
||||||
if (filePath == null || filePath.isEmpty()) {
|
if (filePath == null || filePath.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
@@ -123,6 +125,7 @@ public class Utils {
|
|||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String decodeBase64String(String decodedString) {
|
public static String decodeBase64String(String decodedString) {
|
||||||
if (StringUtils.isBlank(decodedString)) {
|
if (StringUtils.isBlank(decodedString)) {
|
||||||
return decodedString;
|
return decodedString;
|
||||||
@@ -131,17 +134,19 @@ public class Utils {
|
|||||||
return new String(decode, StandardCharsets.UTF_8);
|
return new String(decode, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void setIfNotNull(Consumer<T> setter, T value) {
|
public static <T> void setIfNotNull(Consumer<T> setter, T value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
setter.accept(value);
|
setter.accept(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static <T> void setIfUpdated(Supplier<T> getter, Consumer<T> setter, T newValue) {
|
|
||||||
T currentValue = getter.get();
|
public static <T> void setIfUpdated(Supplier<T> getter, Consumer<T> setter, T newValue) {
|
||||||
if (newValue != null && !newValue.equals(currentValue)) {
|
T currentValue = getter.get();
|
||||||
setter.accept(newValue);
|
if (newValue != null && !newValue.equals(currentValue)) {
|
||||||
}
|
setter.accept(newValue);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> String convertListToJsonString(List<T> list) {
|
public static <T> String convertListToJsonString(List<T> list) {
|
||||||
try {
|
try {
|
||||||
return mapper.writeValueAsString(list);
|
return mapper.writeValueAsString(list);
|
||||||
@@ -151,6 +156,7 @@ public class Utils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> List<T> convertJsonStringToList(String jsonString, Class<T> clazz) {
|
public static <T> List<T> convertJsonStringToList(String jsonString, Class<T> clazz) {
|
||||||
try {
|
try {
|
||||||
TypeReference<List<T>> typeRef = new TypeReference<List<T>>() {
|
TypeReference<List<T>> typeRef = new TypeReference<List<T>>() {
|
||||||
@@ -166,6 +172,7 @@ public class Utils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String convertMapIntoJsonString(Map<String, Object> map) {
|
public static String convertMapIntoJsonString(Map<String, Object> map) {
|
||||||
try {
|
try {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
@@ -180,6 +187,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> convertIntoJson(String jsonString) {
|
public static Map<String, Object> convertIntoJson(String jsonString) {
|
||||||
if (jsonString != null && !jsonString.isEmpty()) {
|
if (jsonString != null && !jsonString.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
@@ -192,6 +200,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, U> U convertSourceObjectToDestinationObject(T source, Class<U> destinationClass) {
|
public static <T, U> U convertSourceObjectToDestinationObject(T source, Class<U> destinationClass) {
|
||||||
try {
|
try {
|
||||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
@@ -202,6 +211,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void retainOnlySpecificFields(T requestObject, List<T> retainFields) throws IllegalAccessException {
|
public static <T> void retainOnlySpecificFields(T requestObject, List<T> retainFields) throws IllegalAccessException {
|
||||||
// Get all declared fields of the request object's class
|
// Get all declared fields of the request object's class
|
||||||
Field[] fields = requestObject.getClass().getDeclaredFields();
|
Field[] fields = requestObject.getClass().getDeclaredFields();
|
||||||
@@ -217,22 +227,23 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String encodeData(String data) {
|
public static String encodeData(String data) {
|
||||||
return Base64.getEncoder().encodeToString(data.getBytes(StandardCharsets.UTF_8));
|
return Base64.getEncoder().encodeToString(data.getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String decodeData(String token) {
|
public static String decodeData(String token) {
|
||||||
byte[] decodedBytes = Base64.getDecoder().decode(token);
|
byte[] decodedBytes = Base64.getDecoder().decode(token);
|
||||||
return new String(decodedBytes, StandardCharsets.UTF_8);
|
return new String(decodedBytes, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String generateSecureSamlToken() {
|
public static String generateSecureSamlToken() {
|
||||||
SecureRandom secureRandom = new SecureRandom();
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
byte[] tokenBytes = new byte[24];
|
byte[] tokenBytes = new byte[24];
|
||||||
secureRandom.nextBytes(tokenBytes);
|
secureRandom.nextBytes(tokenBytes);
|
||||||
String token = Base64.getUrlEncoder().withoutPadding().encodeToString(tokenBytes);
|
String token = Base64.getUrlEncoder().withoutPadding().encodeToString(tokenBytes);
|
||||||
log.debug("Generated secure token: {}", token);
|
log.debug("Generated secure token: {}", token);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String generateSecureToken() {
|
public static String generateSecureToken() {
|
||||||
SecureRandom secureRandom = new SecureRandom();
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
byte[] tokenBytes = new byte[5];
|
byte[] tokenBytes = new byte[5];
|
||||||
@@ -241,6 +252,7 @@ public class Utils {
|
|||||||
log.debug("Generated secure token: {}", token);
|
log.debug("Generated secure token: {}", token);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, List<Object>> convertStringIntoMap(String jsonString) {
|
public static Map<String, List<Object>> convertStringIntoMap(String jsonString) {
|
||||||
try {
|
try {
|
||||||
return mapper.readValue(jsonString, new TypeReference<Map<String, List<Object>>>() {
|
return mapper.readValue(jsonString, new TypeReference<Map<String, List<Object>>>() {
|
||||||
@@ -253,20 +265,20 @@ public class Utils {
|
|||||||
|
|
||||||
public static void callException(Integer staus, FeignException ex) {
|
public static void callException(Integer staus, FeignException ex) {
|
||||||
switch (staus) {
|
switch (staus) {
|
||||||
case 400:
|
case 400:
|
||||||
throw new FeignClientValidationException(HttpStatus.valueOf(staus), ex.getMessage());
|
throw new FeignClientValidationException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||||
|
|
||||||
case 401:
|
case 401:
|
||||||
throw new FeignClientUnauthorizedException(HttpStatus.valueOf(staus), ex.getMessage());
|
throw new FeignClientUnauthorizedException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||||
|
|
||||||
case 403:
|
case 403:
|
||||||
throw new FeignClientForbiddenException(HttpStatus.valueOf(staus), ex.getMessage());
|
throw new FeignClientForbiddenException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||||
|
|
||||||
case 404:
|
case 404:
|
||||||
throw new FeignClientNotFoundException(HttpStatus.valueOf(staus), ex.getMessage());
|
throw new FeignClientNotFoundException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||||
default:
|
default:
|
||||||
log.error("Exception occured :- {0}", ex);
|
log.error("Exception occured :- {0}", ex);
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +339,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Map<String, String>> parseJsonContent(String jsonContent) {
|
public static Map<String, Map<String, String>> parseJsonContent(String jsonContent) {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
try {
|
try {
|
||||||
return mapper.readValue(jsonContent, HashMap.class);
|
return mapper.readValue(jsonContent, HashMap.class);
|
||||||
@@ -339,19 +351,20 @@ public class Utils {
|
|||||||
|
|
||||||
// Utility method to replace placeholders with their values, handling nulls
|
// Utility method to replace placeholders with their values, handling nulls
|
||||||
public static String replacePlaceholders(String text, Map<String, String> placeholders) {
|
public static String replacePlaceholders(String text, Map<String, String> placeholders) {
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, String> entry : placeholders.entrySet()) {
|
for (Map.Entry<String, String> entry : placeholders.entrySet()) {
|
||||||
text = replaceNull(text, entry.getKey(), entry.getValue());
|
text = replaceNull(text, entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to safely replace nulls with an empty string or a default value
|
// Method to safely replace nulls with an empty string or a default value
|
||||||
private static String replaceNull(String text, String target, String replacement) {
|
private static String replaceNull(String text, String target, String replacement) {
|
||||||
return text.replace(target, replacement != null ? replacement : "");
|
return text.replace(target, replacement != null ? replacement : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getClientIpAddress(HttpServletRequest request) {
|
public static String getClientIpAddress(HttpServletRequest request) {
|
||||||
String header = request.getHeader("X-Forwarded-For");
|
String header = request.getHeader("X-Forwarded-For");
|
||||||
if (org.apache.commons.lang3.StringUtils.isBlank(header)) {
|
if (org.apache.commons.lang3.StringUtils.isBlank(header)) {
|
||||||
@@ -360,6 +373,7 @@ public class Utils {
|
|||||||
|
|
||||||
return new StringTokenizer(header, ",").nextToken().trim();
|
return new StringTokenizer(header, ",").nextToken().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> List<T> convertJsonToList(String json, TypeReference<List<T>> typeRef) {
|
public static <T> List<T> convertJsonToList(String json, TypeReference<List<T>> typeRef) {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
try {
|
try {
|
||||||
@@ -372,11 +386,15 @@ public class Utils {
|
|||||||
|
|
||||||
public static String convertObjectToJson(Object obj) {
|
public static String convertObjectToJson(Object obj) {
|
||||||
try {
|
try {
|
||||||
if(obj == null){return null;}
|
if (obj == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new ObjectMapper().writeValueAsString(obj);
|
return new ObjectMapper().writeValueAsString(obj);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
log.error("Failed to convert object to JSON: {}", e.getMessage(), e);
|
log.error("Failed to convert object to JSON: {}", e.getMessage(), e);
|
||||||
throw new RuntimeException("Failed to convert object to JSON", e);}}
|
throw new RuntimeException("Failed to convert object to JSON", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String replaceSpacesWithUnderscores(String content) {
|
public static String replaceSpacesWithUnderscores(String content) {
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
@@ -384,10 +402,10 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return content.trim().replace(" ", "_");
|
return content.trim().replace(" ", "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Map<String, Object>> convertJsonStringIntoJsonList(String jsonString) {
|
public static List<Map<String, Object>> convertJsonStringIntoJsonList(String jsonString) {
|
||||||
try {
|
try {
|
||||||
if(isEmpty(jsonString))
|
if (isEmpty(jsonString)) {
|
||||||
{
|
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
@@ -398,6 +416,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String convertToString(Object input) {
|
public static String convertToString(Object input) {
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
return "null"; // Return string "null" for null input
|
return "null"; // Return string "null" for null input
|
||||||
@@ -459,6 +478,7 @@ public class Utils {
|
|||||||
throw new RuntimeException("Error converting map to string", e);
|
throw new RuntimeException("Error converting map to string", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidDateString(String dateStr) {
|
public static boolean isValidDateString(String dateStr) {
|
||||||
Pattern datePattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}");
|
Pattern datePattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}");
|
||||||
return datePattern.matcher(dateStr).matches();
|
return datePattern.matcher(dateStr).matches();
|
||||||
@@ -476,7 +496,7 @@ public class Utils {
|
|||||||
|
|
||||||
return targetFormat.format(date);
|
return targetFormat.format(date);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
log.error("error while prcoessing date formate");
|
log.error("error while prcoessing date formate");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -522,6 +542,7 @@ public class Utils {
|
|||||||
return "Invalid amount format";
|
return "Invalid amount format";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isItalianFormattedAmount(String input) {
|
public static boolean isItalianFormattedAmount(String input) {
|
||||||
// Regular expression to match Italian-style amounts (e.g., 41.003,00 or 123,45)
|
// Regular expression to match Italian-style amounts (e.g., 41.003,00 or 123,45)
|
||||||
String sanitizedInput = input.replace(",", "");
|
String sanitizedInput = input.replace(",", "");
|
||||||
@@ -534,7 +555,7 @@ public class Utils {
|
|||||||
|
|
||||||
public static String encryptCredential(String value) {
|
public static String encryptCredential(String value) {
|
||||||
try {
|
try {
|
||||||
if(Boolean.FALSE.equals(isEmpty(value))) {
|
if (Boolean.FALSE.equals(isEmpty(value))) {
|
||||||
|
|
||||||
IvParameterSpec iv = new IvParameterSpec(GepafinConstant.ENCRYPT_INIT_VECTOR.getBytes("UTF-8"));
|
IvParameterSpec iv = new IvParameterSpec(GepafinConstant.ENCRYPT_INIT_VECTOR.getBytes("UTF-8"));
|
||||||
SecretKeySpec skeySpec = new SecretKeySpec(Base64.getDecoder().decode(GepafinConstant.ENCRYPT_KEY), "AES");
|
SecretKeySpec skeySpec = new SecretKeySpec(Base64.getDecoder().decode(GepafinConstant.ENCRYPT_KEY), "AES");
|
||||||
@@ -555,7 +576,7 @@ public class Utils {
|
|||||||
|
|
||||||
public static String decryptCredential(String encrypted) {
|
public static String decryptCredential(String encrypted) {
|
||||||
try {
|
try {
|
||||||
if(Boolean.FALSE.equals(isEmpty(encrypted))) {
|
if (Boolean.FALSE.equals(isEmpty(encrypted))) {
|
||||||
|
|
||||||
IvParameterSpec iv = new IvParameterSpec(GepafinConstant.ENCRYPT_INIT_VECTOR.getBytes("UTF-8"));
|
IvParameterSpec iv = new IvParameterSpec(GepafinConstant.ENCRYPT_INIT_VECTOR.getBytes("UTF-8"));
|
||||||
SecretKeySpec skeySpec = new SecretKeySpec(Base64.getDecoder().decode(GepafinConstant.ENCRYPT_KEY), "AES");
|
SecretKeySpec skeySpec = new SecretKeySpec(Base64.getDecoder().decode(GepafinConstant.ENCRYPT_KEY), "AES");
|
||||||
@@ -620,17 +641,17 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setHttpServletRequestForScheduler() {
|
public static void setHttpServletRequestForScheduler() {
|
||||||
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
|
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
|
||||||
mockRequest.setRequestURI("/scheduled");
|
mockRequest.setRequestURI("/scheduled");
|
||||||
mockRequest.setMethod("POST");
|
mockRequest.setMethod("POST");
|
||||||
ServletRequestAttributes attributes = new ServletRequestAttributes(mockRequest);
|
ServletRequestAttributes attributes = new ServletRequestAttributes(mockRequest);
|
||||||
RequestContextHolder.setRequestAttributes(attributes);
|
RequestContextHolder.setRequestAttributes(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearHttpServletRequest() {
|
public static void clearHttpServletRequest() {
|
||||||
// Clear the RequestContextHolder after task execution
|
// Clear the RequestContextHolder after task execution
|
||||||
RequestContextHolder.resetRequestAttributes();
|
RequestContextHolder.resetRequestAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String generateAuthTokenForLoginToOdessa() {
|
public static String generateAuthTokenForLoginToOdessa() {
|
||||||
|
|
||||||
@@ -739,7 +760,8 @@ public class Utils {
|
|||||||
public static String createChannelForUserAndCompany(Long userId, Long companyId) {
|
public static String createChannelForUserAndCompany(Long userId, Long companyId) {
|
||||||
return GepafinConstant.COMMON_SINGLE_CHANNEL_PREFIX + userId + GepafinConstant.COMPANY_PREFIX + companyId;
|
return GepafinConstant.COMMON_SINGLE_CHANNEL_PREFIX + userId + GepafinConstant.COMPANY_PREFIX + companyId;
|
||||||
}
|
}
|
||||||
public static GlobalFilters setPageNumberAndLimit(GlobalFilters globalFilters){
|
|
||||||
|
public static GlobalFilters setPageNumberAndLimit(GlobalFilters globalFilters) {
|
||||||
if (globalFilters == null) {
|
if (globalFilters == null) {
|
||||||
if (globalFilters.getLimit() == null || globalFilters.getLimit() <= 0) {
|
if (globalFilters.getLimit() == null || globalFilters.getLimit() <= 0) {
|
||||||
globalFilters.setLimit(GepafinConstant.DEFAULT_PAGE_LIMIT);
|
globalFilters.setLimit(GepafinConstant.DEFAULT_PAGE_LIMIT);
|
||||||
@@ -767,6 +789,7 @@ public class Utils {
|
|||||||
private static Map<String, Object> defaultErrorResponse() {
|
private static Map<String, Object> defaultErrorResponse() {
|
||||||
return Collections.singletonMap("message", Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
return Collections.singletonMap("message", Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> extractValues(String input) {
|
public static List<String> extractValues(String input) {
|
||||||
List<String> extractedValues = new ArrayList<>();
|
List<String> extractedValues = new ArrayList<>();
|
||||||
Pattern pattern = Pattern.compile("\\{(.*?)\\}"); // Regex to match {value}
|
Pattern pattern = Pattern.compile("\\{(.*?)\\}"); // Regex to match {value}
|
||||||
@@ -777,6 +800,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return extractedValues;
|
return extractedValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double evaluateExpression(String expression) {
|
public static double evaluateExpression(String expression) {
|
||||||
try {
|
try {
|
||||||
Expression exp = new ExpressionBuilder(expression).build();
|
Expression exp = new ExpressionBuilder(expression).build();
|
||||||
@@ -786,6 +810,7 @@ public class Utils {
|
|||||||
return Double.NaN; // Return NaN if the expression is invalid
|
return Double.NaN; // Return NaN if the expression is invalid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNumeric(String input) {
|
public static boolean isNumeric(String input) {
|
||||||
if (input == null || input.trim().isEmpty()) {
|
if (input == null || input.trim().isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -793,9 +818,11 @@ public class Utils {
|
|||||||
|
|
||||||
return input.matches("-?\\d+(\\.\\d+)?");
|
return input.matches("-?\\d+(\\.\\d+)?");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidBoolean(String value) {
|
public static boolean isValidBoolean(String value) {
|
||||||
return "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
|
return "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> convertJsonStringToMap(String jsonString) {
|
public static Map<String, Object> convertJsonStringToMap(String jsonString) {
|
||||||
try {
|
try {
|
||||||
return mapper.readValue(jsonString, Map.class);
|
return mapper.readValue(jsonString, Map.class);
|
||||||
@@ -905,8 +932,10 @@ public class Utils {
|
|||||||
switch (mode) {
|
switch (mode) {
|
||||||
case DATEIS -> predicates.add(criteriaBuilder.equal(dateField, dateValue));
|
case DATEIS -> predicates.add(criteriaBuilder.equal(dateField, dateValue));
|
||||||
case DATEISNOT -> predicates.add(criteriaBuilder.notEqual(dateField, dateValue));
|
case DATEISNOT -> predicates.add(criteriaBuilder.notEqual(dateField, dateValue));
|
||||||
case BEFORE -> predicates.add(criteriaBuilder.lessThan(fieldPath.as(Timestamp.class), Timestamp.valueOf(dateTimeValue)));
|
case BEFORE ->
|
||||||
case AFTER -> predicates.add(criteriaBuilder.greaterThan(fieldPath.as(Timestamp.class), Timestamp.valueOf(dateTimeValue)));
|
predicates.add(criteriaBuilder.lessThan(fieldPath.as(Timestamp.class), Timestamp.valueOf(dateTimeValue)));
|
||||||
|
case AFTER ->
|
||||||
|
predicates.add(criteriaBuilder.greaterThan(fieldPath.as(Timestamp.class), Timestamp.valueOf(dateTimeValue)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -937,4 +966,25 @@ public class Utils {
|
|||||||
Translator.toLocale(GepafinConstant.VALIDATION_ERROR_FILE_EMPTY));
|
Translator.toLocale(GepafinConstant.VALIDATION_ERROR_FILE_EMPTY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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