Updated evaluation endpoint and created an endpoint for extending response days for amendment

This commit is contained in:
harish
2024-10-29 16:59:13 +05:30
parent a3e027876e
commit 6e5e148e05
13 changed files with 117 additions and 66 deletions

View File

@@ -276,7 +276,7 @@ public class GepafinConstant {
public static final String APPLICATION_AMENDMENT_NOT_FOUND_MSG = "application.amendment.not.found";
public static final String GET_APPLICATION_AMENDMENT_SUCCESS_MSG = "application.amendment.get.success";
public static final String APPLICATION_AMENDMENT_UPDATE_SUCCESSFULLY_MSG = "application.amendment.update.successfully";
public static final String RESPONSE_DAYS_EXTENDED_SUCCESS_MSG = "response.days.extended.success";
public static final String COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS = "added.comment.to.amendment.request.success";
public static final String COMMENT_NOT_FOUND = "comment.not.found";
public static final String COMMENT_UPDATED_SUCCESS_MSG = "comment.updated.successfully";

View File

@@ -63,10 +63,10 @@ public class ApplicationAmendmentRequestDao {
@Autowired
private ApplicationEvaluationService applicationEvaluationService;
@Autowired
private ProtocolDao protocolDao;
@Autowired
private AssignedApplicationsService assignedApplicationsService;
@@ -200,11 +200,11 @@ public class ApplicationAmendmentRequestDao {
.collect(Collectors.joining(","));
applicationAmendmentRequestEntity.setFormFields(fieldIdsString);
}
UserEntity userEntity = userService.validateUser(applicationEvaluationId);
UserEntity userEntity = userService.validateUser(applicationEvaluationEntity.getUserId());
Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub());
ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(
applicationEvaluationEntity.getAssignedApplicationsEntity().getApplication(), protocolNumber,
userEntity.getHub().getId());
ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(
applicationEvaluationEntity.getAssignedApplicationsEntity().getApplication(), protocolNumber,
userEntity.getHub().getId());
applicationAmendmentRequestEntity.setProtocol(protocolEntity);
applicationAmendmentRequestEntity.setIsEmail(false);
applicationAmendmentRequestEntity.setIsNotification(false);
@@ -294,11 +294,11 @@ public class ApplicationAmendmentRequestDao {
return applicationAmendmentRequestResponse;
}
public ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long id) {
return applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
}
public ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long id) {
return applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
}
public void deleteById(Long id) {
log.info("Deleting assigned application with ID: {}", id);
@@ -422,4 +422,16 @@ public class ApplicationAmendmentRequestDao {
.collect(Collectors.toList());
}
}
public ApplicationAmendmentRequestResponse extendResponseDays(Long id, Long newResponseDays) {
ApplicationAmendmentRequestEntity request = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
if (newResponseDays != null && newResponseDays > 0) {
Long currentResponseDays = request.getResponseDays() != null ? request.getResponseDays() : 0L;
request.setResponseDays(currentResponseDays + newResponseDays);
applicationAmendmentRequestRepository.save(request);
}
return convertEntityToResponse(request);
}
}

View File

@@ -333,10 +333,18 @@ public class ApplicationEvaluationDao {
}
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
Optional<ApplicationEvaluationEntity> existingEntityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplciationId);
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
UserEntity user,
ApplicationEvaluationRequest req,
Long assignedApplicationId,
AssignedEvaluationStatus status) {
Optional<ApplicationEvaluationEntity> existingEntityOptional =
applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId);
ApplicationEvaluationEntity entity;
Optional<AssignedApplicationsEntity> assignedApplications=assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplciationId);
Optional<AssignedApplicationsEntity> assignedApplications =
assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationId);
if (existingEntityOptional.isPresent()) {
entity = existingEntityOptional.get();
entity.setCriteria(Utils.convertObjectToJson(filterNonNullCriteria(processCriteria(entity, req))));
@@ -345,13 +353,19 @@ public class ApplicationEvaluationDao {
entity.setIsDeleted(false);
setIfUpdated(entity::getNote, entity::setNote, req.getNote());
} else {
entity = convertToEntity(user, req, assignedApplciationId);
entity = convertToEntity(user, req, assignedApplicationId);
}
if (status != null) {
ApplicationEntity application = applicationService.validateApplication(assignedApplications.get().getApplication().getId());
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplications.get();
return updateApplicationEvaluationStatus(application, assignedApplicationsEntity, status);
} else {
ApplicationEvaluationEntity savedEntity = applicationEvaluationRepository.save(entity);
return convertToResponse(savedEntity);
}
ApplicationEvaluationEntity savedEntity = applicationEvaluationRepository.save(entity);
return convertToResponse(savedEntity);
}
private List<ChecklistRequest> filterNonNullChecklist(List<ChecklistRequest> checklistRequests) {
return checklistRequests.stream()
.filter(request -> request.getValid() != null)

View File

@@ -17,5 +17,5 @@ public interface ApplicationAmendmentRequestService {
ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean);
ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long applicationAmendmentId);
List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request,Long beneficiaryId);
ApplicationAmendmentRequestResponse extendResponseDays(HttpServletRequest request, Long id, Long addedDays);
}

View File

@@ -11,12 +11,14 @@ import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse
import java.util.List;
public interface ApplicationEvaluationService {
ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationRequest applicationEvaluationRequest,Long assignedApplicationsId);
ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
HttpServletRequest request,
ApplicationEvaluationRequest applicationEvaluationRequest,
Long assignedApplicationsId,
AssignedEvaluationStatus status);
void deleteApplicationEvaluation(HttpServletRequest request,Long id);
ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId,Long assignedApplicationId);
ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedEvaluationStatus status);
ApplicationEvaluationEntity validateApplicationEvaluation(Long applicationEvaluationId);
}

View File

@@ -66,6 +66,11 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
return applicationAmendmentRequestDao.getAllAmendmentRequestByBeneficiaryId(beneficiaryId);
}
@Override
public ApplicationAmendmentRequestResponse extendResponseDays(HttpServletRequest request, Long id, Long addedDays) {
return applicationAmendmentRequestDao.extendResponseDays(id, addedDays);
}
}

View File

@@ -39,11 +39,21 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationRequest req,Long assignedApplicationsId) {
AssignedApplicationsEntity assignedApplication = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationsId).orElseThrow(()->
new ResourceNotFoundException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_MSG)));
UserEntity user=validator.validatePreInstructor(request,assignedApplication.getUserId());
return applicationEvaluationDao.createOrUpdateApplicationEvaluation(user,req,assignedApplication.getId());
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
HttpServletRequest request,
ApplicationEvaluationRequest req,
Long assignedApplicationsId,
AssignedEvaluationStatus status) {
AssignedApplicationsEntity assignedApplication = assignedApplicationsRepository
.findByIdAndIsDeletedFalse(assignedApplicationsId)
.orElseThrow(() -> new ResourceNotFoundException(
Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_MSG)));
UserEntity user = validator.validatePreInstructor(request, assignedApplication.getUserId());
return applicationEvaluationDao.createOrUpdateApplicationEvaluation(user, req, assignedApplication.getId(), status);
}
@Override
@@ -78,8 +88,6 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteApplicationEvaluation(HttpServletRequest request,Long id) {
@@ -87,16 +95,6 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
applicationEvaluationDao.deleteById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedEvaluationStatus status) {
AssignedApplicationsEntity assignedApplication = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationId).orElseThrow(()->
new ResourceNotFoundException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_MSG)));
validator.validatePreInstructor(request,assignedApplication.getUserId());
return applicationEvaluationDao.updateApplicationEvaluationStatus(assignedApplication.getApplication(),assignedApplication,status);
}
@Override
public ApplicationEvaluationEntity validateApplicationEvaluation(Long applicationEvaluationId) {
return applicationEvaluationDao.validateApplicationEvaluation(applicationEvaluationId);

View File

@@ -112,5 +112,20 @@ public interface ApplicationAmendmentRequestApi {
@GetMapping(value = "/beneficiary/{id}", produces = "application/json")
ResponseEntity<Response<List<ApplicationAmendmentRequestResponse>>> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request,
@Parameter(description = "Id", required = false) @PathVariable(value = "id",required = false) Long beneficiaryId);
@Operation(summary = "Api to extend response days for an amendment request",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PutMapping(value = "/{id}/extendExpiration", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<ApplicationAmendmentRequestResponse>> extendResponseDays(
HttpServletRequest request,
@Parameter( required = true) @PathVariable("id") Long id,
@Parameter( required = true) @RequestParam("extendedDays") Long extendedDays);
}

View File

@@ -36,8 +36,9 @@ public interface ApplicationEvaluationApi {
@PutMapping(value = "/{assignedApplicationsId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<ApplicationEvaluationResponse>> createOrUpdateApplicationEvaluation(
HttpServletRequest request,
@Parameter(required = true) @PathVariable("assignedApplicationsId") Long assignedApplicationsId,
@Parameter( required = true) @Valid @RequestBody ApplicationEvaluationRequest evaluationRequest);
@Parameter(description = "Assigned Application ID", required = true) @PathVariable("assignedApplicationsId") Long assignedApplicationsId,
@Parameter(description = "Application Evaluation Request Body", required = true) @Valid @RequestBody ApplicationEvaluationRequest evaluationRequest,
@Parameter( required = false) @RequestParam(value = "status", required = false) AssignedEvaluationStatus status);
@Operation(summary = "API to get ApplicationEvaluation data for evaluation process",
responses = {
@@ -60,18 +61,5 @@ public interface ApplicationEvaluationApi {
ResponseEntity<Response<Void>> deleteApplicationEvaluation(HttpServletRequest request,
@Parameter( required = true) @PathVariable("id") Long id);
@Operation(summary = "Api to update application evaluation status",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@PutMapping(value = "/{assignedApplicationId}/status", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<ApplicationEvaluationResponse>> updateApplicationEvaluationStatus(HttpServletRequest request,
@Parameter( required = true) @PathVariable("assignedApplicationId") Long assignedApplicationId,
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) AssignedEvaluationStatus status);
}

View File

@@ -79,4 +79,17 @@ public class ApplicationAmendmentRequestController implements ApplicationAmendme
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(applicationAmendmentRequestResponseList, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_AMENDMENT_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<ApplicationAmendmentRequestResponse>> extendResponseDays(
HttpServletRequest request,
Long id,
Long addedDays) {
log.info("Extending response days for Amendment Request ID: {}", id);
ApplicationAmendmentRequestResponse response = applicationAmendmentRequestService.extendResponseDays(request, id, addedDays);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.RESPONSE_DAYS_EXTENDED_SUCCESS_MSG)));
}
}

View File

@@ -30,13 +30,20 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
private ApplicationEvaluationService applicationEvaluationService;
@Override
public ResponseEntity<Response<ApplicationEvaluationResponse>> createOrUpdateApplicationEvaluation(HttpServletRequest request,
Long assignedApplicationsId,ApplicationEvaluationRequest evaluationRequest) {
ApplicationEvaluationResponse response = applicationEvaluationService.createOrUpdateApplicationEvaluation(request,evaluationRequest,assignedApplicationsId);
public ResponseEntity<Response<ApplicationEvaluationResponse>> createOrUpdateApplicationEvaluation(
HttpServletRequest request,
Long assignedApplicationsId,
ApplicationEvaluationRequest evaluationRequest,
AssignedEvaluationStatus status) {
ApplicationEvaluationResponse response = applicationEvaluationService.createOrUpdateApplicationEvaluation(
request, evaluationRequest, assignedApplicationsId, status);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_CREATED_SUCCESSFULLY)));
}
@Override
public ResponseEntity<Response<ApplicationEvaluationResponse>> getApplicationEvaluationByApplicationId(
HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
@@ -56,10 +63,4 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_DELETED_SUCCESSFULLY)));
}
@Override
public ResponseEntity<Response<ApplicationEvaluationResponse>> updateApplicationEvaluationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedEvaluationStatus status) {
ApplicationEvaluationResponse applicationEvaluationResponse = applicationEvaluationService.updateApplicationEvaluationStatus(request, assignedApplicationId,status);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(applicationEvaluationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_EVALUATION_STATUS_UPDATED_SUCCESSFULLY)));
}
}