Resolved conflicts
This commit is contained in:
@@ -14,12 +14,14 @@ import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationViewResponse;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.SortBy;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsViewRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
@@ -77,6 +79,9 @@ public class AssignedApplicationsDao {
|
||||
@Autowired
|
||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||
|
||||
@Autowired
|
||||
private AssignedApplicationsViewRepository assignedApplicationsViewRepository;
|
||||
|
||||
public AssignedApplicationsResponse createAssignedApplications(Long applicationId, Long userId, UserEntity assignedByUser, AssignedApplicationsRequest assignedApplicationsRequest) {
|
||||
log.info("Assigning application to pre-Instructor with details: {}", applicationId, userId);
|
||||
|
||||
@@ -297,7 +302,7 @@ public class AssignedApplicationsDao {
|
||||
log.info("Assigned application fetched successfully: {}", response);
|
||||
return response;
|
||||
}
|
||||
public PageableResponseBean<List<AssignedApplicationsResponse>> getAllAssignedApplicationsByPagination(UserEntity user, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean,Long userId) {
|
||||
public PageableResponseBean<List<AssignedApplicationViewResponse>> getAllAssignedApplicationsByPagination(UserEntity user, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean,Long userId) {
|
||||
Integer pageNo = null;
|
||||
Integer pageLimit = null;
|
||||
if (assignedApplicationPageableRequestBean.getGlobalFilters() != null) {
|
||||
@@ -310,21 +315,15 @@ public class AssignedApplicationsDao {
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
}
|
||||
Specification<AssignedApplicationsEntity> spec = searchByPagination( assignedApplicationPageableRequestBean, user,userId);
|
||||
Page<AssignedApplicationsEntity> entityPage = assignedApplicationsRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
Specification<AssignedApplicationsView> spec = searchByPagination( assignedApplicationPageableRequestBean, user,userId);
|
||||
Page<AssignedApplicationsView> entityPage = assignedApplicationsViewRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
// Prepare the response
|
||||
|
||||
|
||||
List<AssignedApplicationsResponse> assignedApplicationsResponses = entityPage.getContent().stream()
|
||||
.map(application -> {
|
||||
AssignedApplicationsResponse response = convertEntityToResponse(application);
|
||||
return response;
|
||||
})
|
||||
List<AssignedApplicationViewResponse> assignedApplicationsResponses = entityPage.getContent().stream()
|
||||
.map(this::getAssignedApplicationResponseByView)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
|
||||
PageableResponseBean<List<AssignedApplicationsResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||
PageableResponseBean<List<AssignedApplicationViewResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||
pageableResponseBean.setBody(assignedApplicationsResponses);
|
||||
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1);
|
||||
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||
@@ -334,7 +333,7 @@ public class AssignedApplicationsDao {
|
||||
return pageableResponseBean;
|
||||
}
|
||||
|
||||
public Specification<AssignedApplicationsEntity> searchByPagination(AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean, UserEntity userEntity,Long userId) {
|
||||
public Specification<AssignedApplicationsView> searchByPagination(AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean, UserEntity userEntity,Long userId) {
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
|
||||
List<Predicate> predicates = getPredicates(assignedApplicationPageableRequestBean, criteriaBuilder, root, userEntity,userId);
|
||||
@@ -350,30 +349,35 @@ public class AssignedApplicationsDao {
|
||||
sortBy.setSortDesc(assignedApplicationPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
||||
}
|
||||
}
|
||||
Path<?> sortPath;
|
||||
Join<AssignedApplicationsEntity, ApplicationEntity> applicationJoin = root.join(GepafinConstant.APPLICATION, JoinType.LEFT);
|
||||
// Path<?> sortPath;
|
||||
// Join<AssignedApplicationsEntity, ApplicationEntity> applicationJoin = root.join(GepafinConstant.APPLICATION, JoinType.LEFT);
|
||||
//
|
||||
// if (GepafinConstant.APPLICATION_ID.equals(sortBy.getColumnName())) {
|
||||
// sortPath = root.join(GepafinConstant.APPLICATION, JoinType.LEFT).get(GepafinConstant.ID); // Join ApplicationEntity and sort by application.id
|
||||
// }
|
||||
// else if (GepafinConstant.PROTOCOL_NUMBER.equals(sortBy.getColumnName())) {
|
||||
// Join<ApplicationEntity, ProtocolEntity> protocolJoin = applicationJoin.join(GepafinConstant.PROTOCOL, JoinType.LEFT);
|
||||
// sortPath = protocolJoin.get(GepafinConstant.PROTOCOL_NUMBER);
|
||||
// }
|
||||
// else {
|
||||
// sortPath = root.get(sortBy.getColumnName()); // Sorting by a field in AmendmentEntity
|
||||
// }
|
||||
// query.orderBy(criteriaBuilder.desc(sortPath));
|
||||
// if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||
// query.orderBy(criteriaBuilder.asc(sortPath));
|
||||
// }
|
||||
// return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||
|
||||
Path<?> sortPath = root.get(sortBy.getColumnName()); // All fields are accessible directly in the view
|
||||
query.orderBy(sortBy.getSortDesc() ? criteriaBuilder.desc(sortPath) : criteriaBuilder.asc(sortPath));
|
||||
|
||||
if (GepafinConstant.APPLICATION_ID.equals(sortBy.getColumnName())) {
|
||||
sortPath = root.join(GepafinConstant.APPLICATION, JoinType.LEFT).get(GepafinConstant.ID); // Join ApplicationEntity and sort by application.id
|
||||
}
|
||||
else if (GepafinConstant.PROTOCOL_NUMBER.equals(sortBy.getColumnName())) {
|
||||
Join<ApplicationEntity, ProtocolEntity> protocolJoin = applicationJoin.join(GepafinConstant.PROTOCOL, JoinType.LEFT);
|
||||
sortPath = protocolJoin.get(GepafinConstant.PROTOCOL_NUMBER);
|
||||
}
|
||||
else {
|
||||
sortPath = root.get(sortBy.getColumnName()); // Sorting by a field in AmendmentEntity
|
||||
}
|
||||
query.orderBy(criteriaBuilder.desc(sortPath));
|
||||
if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||
query.orderBy(criteriaBuilder.asc(sortPath));
|
||||
}
|
||||
return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private List<Predicate> getPredicates(AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean,
|
||||
CriteriaBuilder criteriaBuilder, Root<AssignedApplicationsEntity> root, UserEntity userEntity,Long userId) {
|
||||
CriteriaBuilder criteriaBuilder, Root<AssignedApplicationsView> root, UserEntity userEntity,Long userId) {
|
||||
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
@@ -404,12 +408,35 @@ public class AssignedApplicationsDao {
|
||||
|
||||
}
|
||||
// Search in `title` and `message` (if search term is provided)
|
||||
if (search != null && !search.isEmpty()) {
|
||||
Predicate titlePredicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(titlePredicate));
|
||||
// if (search != null && !search.isEmpty()) {
|
||||
// Predicate titlePredicate = criteriaBuilder.like(
|
||||
// criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
||||
// "%" + search.toUpperCase() + "%"
|
||||
// );
|
||||
// predicates.add(criteriaBuilder.or(titlePredicate));
|
||||
// }
|
||||
|
||||
if (search != null && !search.trim().isEmpty()) {
|
||||
String pattern = "%" + search.toUpperCase() + "%";
|
||||
List<Predicate> searchPredicates = new ArrayList<>();
|
||||
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.CALL_NAME)), pattern));
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.COMPANY_NAME)), pattern));
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.STATUS)), pattern));
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.NDG_STRING)), pattern));
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.APPOINTMENT_ID)), pattern));
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.APPLICATION_STATUS)), pattern));
|
||||
|
||||
// Convert numeric fields to string for search (optional and DB-specific; otherwise exact match)
|
||||
try {
|
||||
Long searchLong = Long.parseLong(search);
|
||||
searchPredicates.add(criteriaBuilder.equal(root.get(GepafinConstant.APPLICATION_ID), searchLong));
|
||||
searchPredicates.add(criteriaBuilder.equal(root.get(GepafinConstant.PROTOCOL_NUMBER), searchLong));
|
||||
} catch (NumberFormatException ignored) {
|
||||
// Ignore if search is not a number
|
||||
}
|
||||
|
||||
predicates.add(criteriaBuilder.or(searchPredicates.toArray(new Predicate[0])));
|
||||
}
|
||||
|
||||
// Filter by `status` (if status list is provided)
|
||||
@@ -421,12 +448,31 @@ public class AssignedApplicationsDao {
|
||||
}
|
||||
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
||||
|
||||
applyFilters(root, criteriaBuilder, predicates, filters);
|
||||
|
||||
Utils.applyFiltersByPagination(root, criteriaBuilder, predicates, filters);
|
||||
|
||||
return predicates;
|
||||
|
||||
}
|
||||
|
||||
private AssignedApplicationViewResponse getAssignedApplicationResponseByView(AssignedApplicationsView view) {
|
||||
AssignedApplicationViewResponse response = new AssignedApplicationViewResponse();
|
||||
response.setId(view.getId());
|
||||
response.setUserId(view.getUserId());
|
||||
response.setStatus(AssignedApplicationEnum.valueOf(view.getStatus()));
|
||||
response.setApplicationId(view.getApplicationId());
|
||||
response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(view.getApplicationStatus()));
|
||||
response.setSubmissionDate(view.getSubmissionDate());
|
||||
response.setEvaluationEndDate(view.getEvaluationEndDate());
|
||||
response.setNdg(view.getNdg());
|
||||
response.setAppointmentId(view.getAppointmentId());
|
||||
response.setProtocolNumber(view.getProtocolNumber());
|
||||
response.setCallName(view.getCallName());
|
||||
response.setCompanyName(view.getCompanyName());
|
||||
response.setCreatedDate(view.getCreatedDate());
|
||||
response.setUpdatedDate(view.getUpdatedDate());
|
||||
return response;
|
||||
}
|
||||
|
||||
public AssignedApplicationsResponse updateAssignedApplicationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedApplicationEnum status) {
|
||||
|
||||
AssignedApplicationsEntity assignedApplication = validateAssignedApplication(assignedApplicationId);
|
||||
|
||||
@@ -124,6 +124,9 @@ public class CallDao {
|
||||
@Autowired
|
||||
private EvaluationFormDao evalualtionFormDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationRepository applicationRepository;
|
||||
|
||||
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
|
||||
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
|
||||
CallEntity callEntity = convertToCallEntity(createCallRequest, userEntity);
|
||||
@@ -598,8 +601,8 @@ public class CallDao {
|
||||
if (!requestEndDate.equals(storedEndDate)) { // Check if dates are different
|
||||
|
||||
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
|
||||
callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
callRepository.save(callEntity);
|
||||
// callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
// callRepository.save(callEntity);
|
||||
isEndDateUpdated = true;
|
||||
}
|
||||
}
|
||||
@@ -611,13 +614,13 @@ public class CallDao {
|
||||
|
||||
if (!requestEndTime.equals(storedEndTime)) {
|
||||
setIfUpdated(callEntity::getEndTime, callEntity::setEndTime, DateTimeUtil.parseTime(updateCallRequest.getEndTime()));
|
||||
callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
callRepository.save(callEntity);
|
||||
// callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
// callRepository.save(callEntity);
|
||||
isEndTimeUpdated = true;
|
||||
}
|
||||
}
|
||||
if (isEndDateUpdated || isEndTimeUpdated) {
|
||||
|
||||
callRepository.save(callEntity);
|
||||
loggingUtil.logUserAction(UserActionRequest.builder()
|
||||
.request(request)
|
||||
.actionType(UserActionLogsEnum.UPDATE)
|
||||
@@ -902,7 +905,7 @@ public class CallDao {
|
||||
public CallResponse updateCallStatus(CallEntity callEntity, CallStatusEnum statusReq) {
|
||||
CallEntity oldCallEntity = Utils.getClonedEntityForData(callEntity);
|
||||
CallStatusEnum currentStatus = CallStatusEnum.valueOf(callEntity.getStatus());
|
||||
validateStatusChange(currentStatus, statusReq);
|
||||
validateStatusChange(currentStatus, statusReq, callEntity.getId());
|
||||
callEntity.setStatus(statusReq.getValue());
|
||||
callEntity = callRepository.save(callEntity);
|
||||
|
||||
@@ -922,36 +925,37 @@ public class CallDao {
|
||||
return convertToCallResponseBean(callEntity);
|
||||
}
|
||||
|
||||
private void validateStatusChange(CallStatusEnum currentStatus, CallStatusEnum newStatus) {
|
||||
private void validateStatusChange(CallStatusEnum currentStatus, CallStatusEnum newStatus, Long callId) {
|
||||
|
||||
if (currentStatus == newStatus) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.STATUS_SAME_ERROR));
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.STATUS_SAME_ERROR));
|
||||
}
|
||||
|
||||
switch (currentStatus) {
|
||||
case DRAFT:
|
||||
if (newStatus == CallStatusEnum.READY_TO_PUBLISH || newStatus == CallStatusEnum.PUBLISH) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.INVALID_STATUS_CHANGE_FROM_DRAFT));
|
||||
}
|
||||
break;
|
||||
case PUBLISH:
|
||||
if (newStatus == CallStatusEnum.READY_TO_PUBLISH || newStatus == CallStatusEnum.DRAFT) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.INVALID_STATUS_CHANGE_FROM_PUBLISH));
|
||||
}
|
||||
break;
|
||||
case DRAFT:
|
||||
if (newStatus == CallStatusEnum.READY_TO_PUBLISH || newStatus == CallStatusEnum.PUBLISH) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_STATUS_CHANGE_FROM_DRAFT));
|
||||
}
|
||||
break;
|
||||
|
||||
case EXPIRED:
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.STATUS_CANNOT_BE_CHANGED));
|
||||
case READY_TO_PUBLISH:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case PUBLISH:
|
||||
if (newStatus == CallStatusEnum.READY_TO_PUBLISH) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_STATUS_CHANGE_FROM_PUBLISH));
|
||||
}
|
||||
if (newStatus == CallStatusEnum.DRAFT && Boolean.TRUE.equals(applicationRepository.existsByCallId(callId))) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_STATUS_CHANGE_FROM_PUBLISH_TO_DRAFT));
|
||||
}
|
||||
break;
|
||||
|
||||
case EXPIRED:
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.STATUS_CANNOT_BE_CHANGED));
|
||||
|
||||
case READY_TO_PUBLISH:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public CallEntity validatePublishedCall(Long callId, Long hubId) {
|
||||
CallEntity callEntity= callRepository
|
||||
.findByIdAndStatusAndHubId(callId, CallStatusEnum.PUBLISH.getValue(), hubId);
|
||||
|
||||
Reference in New Issue
Block a user