From 03fbae86d63af99329bf68642c0696a881bf7024 Mon Sep 17 00:00:00 2001 From: rajesh Date: Mon, 3 Feb 2025 16:36:11 +0530 Subject: [PATCH] Create an endpoint to get application evaluation version --- .../constants/GepafinConstant.java | 1 + .../dao/ApplicationEvaluationDao.java | 18 ++++++++++++++++++ .../enums/UserActionContextEnum.java | 1 + .../ApplicationEvaluationVersionResponse.java | 13 +++++++++++++ .../service/ApplicationEvaluationService.java | 2 ++ .../impl/ApplicationEvaluationServiceImpl.java | 9 +++++++++ .../web/rest/api/ApplicationEvaluationApi.java | 14 ++++++++++++++ .../ApplicationEvaluationApiController.java | 12 ++++++++++++ src/main/resources/message_en.properties | 1 + src/main/resources/message_it.properties | 1 + 10 files changed, 72 insertions(+) create mode 100644 src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationVersionResponse.java diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index 85bceee3..3c2a0942 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -112,6 +112,7 @@ public class GepafinConstant { public static final String APPLICATION_UPDATED_SUCCESS_MSG = "application.updated.success"; public static final String DELETE_APPLICATION_SUCCESS_MSG = "application.deleted.success"; public static final String GET_APPLICATION_SUCCESS_MSG = "application.get.success"; + public static final String GET_APPLICATION_EVALUATION_VERSION_SUCCESS_MSG = "application.evaluation.version.get.success"; public static final String APPLICATION_NOT_FOUND_MSG = "application.not.found"; public static final String APPLICATION_FORM_FIELD_NOT_FOUND = "application.form.field.not.found"; public static final String FORM_ID_DOES_NOT_MACTHES = "Form.not.matches.to.call.initial.form"; diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java index 3579b90c..f84e7b3f 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java @@ -2201,5 +2201,23 @@ public class ApplicationEvaluationDao { return evaluationFormResponseBean; } + public ApplicationEvaluationVersionResponse getApplicationEvaluationVersion(HttpServletRequest request, Long applicationId){ + + log.info("Fetching application evaluation version with ID: {}", applicationId); + + ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId); + return buildApplicationEvaluationVersionResponse(applicationEntity); + + } + private ApplicationEvaluationVersionResponse buildApplicationEvaluationVersionResponse(ApplicationEntity applicationEntity) { + ApplicationEvaluationVersionResponse response = new ApplicationEvaluationVersionResponse(); + response.setApplicationId(applicationEntity.getId()); + response.setCallId(applicationEntity.getCall().getId()); + response.setCompanyId(applicationEntity.getCompanyId()); + response.setEvaluationVersion(EvaluationVersionEnum.valueOf(applicationEntity.getEvaluationVersion())); + response.setEvaluationId(applicationEntity.getApplicationEvaluationId()); + return response; + } + } diff --git a/src/main/java/net/gepafin/tendermanagement/enums/UserActionContextEnum.java b/src/main/java/net/gepafin/tendermanagement/enums/UserActionContextEnum.java index d0839370..847ee9b8 100644 --- a/src/main/java/net/gepafin/tendermanagement/enums/UserActionContextEnum.java +++ b/src/main/java/net/gepafin/tendermanagement/enums/UserActionContextEnum.java @@ -35,6 +35,7 @@ public enum UserActionContextEnum { /** application action context **/ GET_APPLICATION("GET_APPLICATION"), CREATE_UPDATE_APPLICATION_FORM("CREATE_UPDATE_APPLICATION_FORM"), + GET_APPLICATION_EVALUATION_VERSION("GET_APPLICATION_EVALUATION_VERSION"), CREATE_APPLICATION("CREATE_APPLICATION"), DELETE_APPLICATION("DELETE_APPLICATION"), GET_ALL_APPLICATION("GET_ALL_APPLICATION"), diff --git a/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationVersionResponse.java b/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationVersionResponse.java new file mode 100644 index 00000000..99f1ae75 --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationVersionResponse.java @@ -0,0 +1,13 @@ +package net.gepafin.tendermanagement.model.response; + +import lombok.Data; +import net.gepafin.tendermanagement.enums.EvaluationVersionEnum; + +@Data +public class ApplicationEvaluationVersionResponse { + private Long callId; + private Long companyId; + private Long applicationId; + private Long evaluationId; + private EvaluationVersionEnum evaluationVersion; +} diff --git a/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java b/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java index 51f0b52c..50b4f299 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java @@ -27,4 +27,6 @@ public interface ApplicationEvaluationService { ApplicationEvaluationFormResponse getApplicationEvaluationForm(HttpServletRequest request, Long applicationId, Long assignedApplicationId); + ApplicationEvaluationVersionResponse getApplicationEvaluationVersion(HttpServletRequest request, Long applicationId); + } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java index 55da1766..c1f5d0f2 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java @@ -14,6 +14,7 @@ import net.gepafin.tendermanagement.model.response.ApplicationEvaluationFormResp import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse; import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponseBean; +import net.gepafin.tendermanagement.model.response.ApplicationEvaluationVersionResponse; import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository; import net.gepafin.tendermanagement.service.ApplicationEvaluationService; import net.gepafin.tendermanagement.service.ApplicationService; @@ -100,4 +101,12 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe return applicationEvaluationDao.getApplicationEvaluationForm(request,applicationId,assignedApplicationId); } + @Override + public ApplicationEvaluationVersionResponse getApplicationEvaluationVersion(HttpServletRequest request, Long applicationId) { + validator.validateUser(request); + return applicationEvaluationDao.getApplicationEvaluationVersion(request,applicationId); + } + + + } diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java index 0e59e6ac..f1769b92 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java @@ -89,5 +89,19 @@ public interface ApplicationEvaluationApi { @Parameter(required = false) @RequestParam(value = "applicationId", required = false) Long applicationId, @Parameter( required = false) @RequestParam(value = "assignedApplicationId", required = false) Long assignedApplicationId); + @Operation(summary = "Api to get application evaluation version", + 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) })) }) + @GetMapping(value = "/application/{id}/version", produces = { "application/json" }) + ResponseEntity> getApplicationEvaluationVersion(HttpServletRequest request, + @Parameter(description = "The application id", required = true) @PathVariable("id") Long id); + + } diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java index 3a5df202..f7b9b8c1 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java @@ -109,4 +109,16 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation } + @Override + public ResponseEntity> getApplicationEvaluationVersion(HttpServletRequest request, Long applicationId) { + + /** This code is responsible for creating user action logs for the "get application evaluation version" operation. **/ + loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_APPLICATION_EVALUATION_VERSION).build()); + + ApplicationEvaluationVersionResponse applicationEvaluationVersionResponse = applicationEvaluationService.getApplicationEvaluationVersion(request,applicationId); + + return ResponseEntity.status(HttpStatus.OK) + .body(new Response<>(applicationEvaluationVersionResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_EVALUATION_VERSION_SUCCESS_MSG))); + } + } diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index 6e058a9f..ef54674d 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -152,6 +152,7 @@ application.created.success=Application successfully created. application.updated.success=Application successfully updated. application.deleted.success=Application successfully deleted. application.get.success=Application details fetched successfully. +application.evaluation.version.get.success = Application evaluation version fetched successfully. application.not.found=Application not found with the given ID. application.form.field.not.found=Application form field not found. Form.not.matches.to.call.initial.form=Form id does not matches to initial form id of call. diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index 624c7dfe..e14120cd 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -146,6 +146,7 @@ application.created.success=Applicazione creata con successo. application.updated.success=Applicazione aggiornata con successo. application.deleted.success=Applicazione eliminata con successo. application.get.success=Dettagli dell'applicazione recuperati con successo. +application.evaluation.version.get.success = Versione di valutazione dell'applicazione recuperata correttamente. application.not.found=Applicazione non trovata con l'ID fornito. application.form.field.not.found=Campo del modulo di domanda non trovato. Form.not.matches.to.call.initial.form=L'ID del modulo non corrisponde all'ID del modulo iniziale della chiamata.