Added an get API for application evaluation form
This commit is contained in:
@@ -237,6 +237,7 @@ public class GepafinConstant {
|
||||
public static final String EVALUATION_UPDATED_SUCCESSFULLY = "evaluation.updated.successfully";
|
||||
public static final String EVALUATION_FETCHED_SUCCESSFULLY = "evaluation.fetched.successfully";
|
||||
public static final String EVALUATION_DELETED_SUCCESSFULLY = "evaluation.deleted.successfully";
|
||||
public static final String GET_APPLICATION_EVALUATION_FORM_SUCCESS_MSG = "application.evaluation.form.get.success";
|
||||
public static final String EVALUATIONS_FETCHED_SUCCESSFULLY = "evaluations.fetched.successfully";
|
||||
public static final String APPLICATION_EVALUATION_NOT_FOUND = "application.evaluation.not.found";
|
||||
public static final String APPLICATION_EVALUATION_STATUS_UPDATED_SUCCESSFULLY = "application.evaluation.status.updated.successfully";
|
||||
@@ -401,5 +402,7 @@ public class GepafinConstant {
|
||||
public static final String EVALUATION_FORM_NOT_FOUND = "evaluation.form.not.found";
|
||||
|
||||
public static final String EVALUATION_V2_STEP_2 = "EVALUATION_V2_STEP_2";
|
||||
|
||||
public static final String EITHER_APPLICATION_ID_OR_ASSIGNED_APPLICATION_ID_MUST_BE_PROVIDED = "either.applicationId.or.assignedApplicationId.must.be.provided";
|
||||
}
|
||||
|
||||
|
||||
@@ -136,6 +136,9 @@ public class ApplicationEvaluationDao {
|
||||
@Autowired
|
||||
private CallDao callDao;
|
||||
|
||||
@Autowired
|
||||
private EvaluationFormRepository evaluationFormRepository;
|
||||
|
||||
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
|
||||
|
||||
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
||||
@@ -2132,5 +2135,57 @@ public class ApplicationEvaluationDao {
|
||||
response.setUpdatedDate(entity.getUpdatedDate());
|
||||
return response;
|
||||
}
|
||||
|
||||
public ApplicationEvaluationFormResponse getApplicationEvaluationForm(HttpServletRequest request, Long applicationId, Long assignedApplicationId ){
|
||||
|
||||
if (applicationId == null && assignedApplicationId == null) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.EITHER_APPLICATION_ID_OR_ASSIGNED_APPLICATION_ID_MUST_BE_PROVIDED));
|
||||
}
|
||||
|
||||
ApplicationEvaluationEntity evaluationEntity = applicationEvaluationRepository.findByApplicationIdAndAssignedApplicationId(applicationId, assignedApplicationId);
|
||||
|
||||
return (evaluationEntity != null) ? processEvaluationForm(evaluationEntity) : null;
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormResponse processEvaluationForm(ApplicationEvaluationEntity evaluationEntity){
|
||||
ApplicationEvaluationFormResponse response = new ApplicationEvaluationFormResponse();
|
||||
response.setApplicationId(evaluationEntity.getApplicationId());
|
||||
response.setNote(evaluationEntity.getNote());
|
||||
response.setStatus(evaluationEntity.getStatus());
|
||||
response.setAssignedApplicationId(evaluationEntity.getAssignedApplicationsEntity().getId());
|
||||
|
||||
EvaluationFormEntity evaluationFormEntity = evaluationFormRepository.findByCallIdAndIsDeletedFalse(evaluationEntity.getAssignedApplicationsEntity().getApplication().getCall().getId());
|
||||
|
||||
if (evaluationFormEntity != null) {
|
||||
response.setEvaluationFormId(evaluationFormEntity.getId());
|
||||
response.setApplicationEvaluationFormResponse(convertEvaluationFormToResponse(evaluationFormEntity, evaluationEntity));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormResponseBean convertEvaluationFormToResponse(EvaluationFormEntity evaluationForm, ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||
ApplicationEvaluationFormResponseBean applicationEvaluationFormResponseBean = createEvaluationFormResponse(evaluationForm);
|
||||
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = applicationEvaluationFormRepository.findByEvaluationIdAndEvaluationFormId(applicationEvaluationEntity.getId(), evaluationForm.getId());
|
||||
|
||||
if(applicationEvaluationFormEntity!=null) {
|
||||
List<ApplicationEvaluationFormFieldEntity> applicationEvaluationFormFieldEntities = applicationEvaluationFormFieldRepository.findByApplicationEvaluationFormId(applicationEvaluationFormEntity.getId());
|
||||
List<ApplicationEvaluationFormFieldReponseBean> evaluationFormFieldResponseBeans = createEvaluationFormFieldResponse(applicationEvaluationFormFieldEntities, applicationEvaluationFormEntity);
|
||||
applicationEvaluationFormResponseBean.setFormFields(evaluationFormFieldResponseBeans);
|
||||
}
|
||||
|
||||
return applicationEvaluationFormResponseBean;
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormResponseBean createEvaluationFormResponse(EvaluationFormEntity evaluationFormEntity) {
|
||||
ApplicationEvaluationFormResponseBean evaluationFormResponseBean = new ApplicationEvaluationFormResponseBean();
|
||||
evaluationFormResponseBean.setId(evaluationFormEntity.getId());
|
||||
evaluationFormResponseBean.setLabel(evaluationFormEntity.getLabel());
|
||||
evaluationFormResponseBean.setCallId(evaluationFormEntity.getCall().getId());
|
||||
evaluationFormResponseBean.setContent(evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent());
|
||||
return evaluationFormResponseBean;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,17 +21,13 @@ package net.gepafin.tendermanagement.dao;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class EvaluationFormDao {
|
||||
|
||||
@Autowired
|
||||
private EvalualtionFormRepository evaluationFormRepository;
|
||||
private EvaluationFormRepository evaluationFormRepository;
|
||||
|
||||
@Autowired
|
||||
private CallDao callDao;
|
||||
|
||||
@@ -98,6 +98,7 @@ public enum UserActionContextEnum {
|
||||
GET_APPLICATION_EVALUATION("GET_APPLICATION_EVALUATION"),
|
||||
DELETE_APPLICATION_EVALUATION("DELETE_APPLICATION_EVALUATION"),
|
||||
CREATE_UPDATE_APPLICATION_EVALUATION_FORM("CREATE_UPDATE_APPLICATION_EVALUATION_FORM"),
|
||||
GET_APPLICATION_EVALUATION_FORM("GET_APPLICATION_EVALUATION_FORM"),
|
||||
|
||||
/** Beneficiary Preferred Call action context **/
|
||||
CREATE_BENEFICIARY_PREFERRED_CALL("CREATE_BENEFICIARY_PREFERRED_CALL"),
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApplicationEvaluationFormResponse {
|
||||
|
||||
private Long evaluationFormId;
|
||||
private Long applicationId;
|
||||
private Long assignedApplicationId;
|
||||
private String note;
|
||||
private String status;
|
||||
private ApplicationEvaluationFormResponseBean applicationEvaluationFormResponse;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApplicationEvaluationFormResponseBean {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String label;
|
||||
|
||||
private Long callId;
|
||||
|
||||
private List<ContentResponseBean> content;
|
||||
|
||||
private List<ApplicationEvaluationFormFieldReponseBean> formFields;
|
||||
}
|
||||
@@ -16,4 +16,6 @@ public interface ApplicationEvaluationFormRepository extends JpaRepository<Appli
|
||||
ApplicationEvaluationFormEntity findByEvaluationIdAndEvaluationFormId(
|
||||
@Param("evaluationId") Long evaluationId,
|
||||
@Param("evaluationFormId") Long evaluationFormId);
|
||||
|
||||
ApplicationEvaluationFormEntity findByApplicationEvaluation_IdAndIsDeletedFalse(Long evaluationId);
|
||||
}
|
||||
|
||||
@@ -62,5 +62,14 @@ public interface ApplicationEvaluationRepository extends JpaRepository<Applicati
|
||||
@Param("endDate") LocalDate endDate
|
||||
);
|
||||
|
||||
@Query("SELECT ae FROM ApplicationEvaluationEntity ae " +
|
||||
"WHERE ae.isDeleted = false " +
|
||||
"AND (:applicationId IS NULL OR ae.applicationId = :applicationId) " +
|
||||
"AND (:assignedApplicationId IS NULL OR ae.assignedApplicationsEntity.id = :assignedApplicationId)")
|
||||
ApplicationEvaluationEntity findByApplicationIdAndAssignedApplicationId(
|
||||
@Param("applicationId") Long applicationId,
|
||||
@Param("assignedApplicationId") Long assignedApplicationId
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.EvaluationFormEntity;
|
||||
import net.gepafin.tendermanagement.entities.FormEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@Repository
|
||||
public interface EvalualtionFormRepository extends JpaRepository<EvaluationFormEntity,Long> {
|
||||
public interface EvaluationFormRepository extends JpaRepository<EvaluationFormEntity,Long> {
|
||||
|
||||
EvaluationFormEntity findByCallIdAndIsDeletedFalse(Long callId);
|
||||
EvaluationFormEntity findByIdAndIsDeletedFalse(Long formId);
|
||||
@@ -2,12 +2,11 @@ package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,4 +25,6 @@ public interface ApplicationEvaluationService {
|
||||
|
||||
ApplicationEvaluationResponseBean createApplicationEvaluation(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long evaluationId, Long evaluationFormId);
|
||||
|
||||
ApplicationEvaluationFormResponse getApplicationEvaluationForm(HttpServletRequest request, Long applicationId, Long assignedApplicationId);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,17 +3,20 @@ package net.gepafin.tendermanagement.service.impl;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.ApplicationEvaluationDao;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationFormResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -36,6 +39,9 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
||||
@Autowired
|
||||
private ApplicationEvaluationService applicationEvaluationService;
|
||||
|
||||
@Autowired
|
||||
private ApplicationService applicationService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
|
||||
@@ -87,4 +93,11 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
||||
return applicationEvaluationDao.createApplicationEvaluation(request,applicationRequestBean,evaluationFormId,evaluationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ApplicationEvaluationFormResponse getApplicationEvaluationForm(HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
|
||||
validator.validateUser(request);
|
||||
return applicationEvaluationDao.getApplicationEvaluationForm(request,applicationId,assignedApplicationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,12 +7,11 @@ import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -48,6 +47,7 @@ public interface ApplicationEvaluationApi {
|
||||
HttpServletRequest request,
|
||||
@Parameter(required = false) @RequestParam(value = "applicationId", required = false) Long applicationId,
|
||||
@Parameter( required = false) @RequestParam(value = "assignedApplicationId", required = false) Long assignedApplicationId);
|
||||
|
||||
@Operation(summary = "API to delete ApplicationEvaluation",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@@ -75,4 +75,19 @@ public interface ApplicationEvaluationApi {
|
||||
@Parameter(description = "The evaluation id", required = true) @PathVariable(value = "id", required = true) Long id,
|
||||
@Parameter(description = "The evaluation form ID", required = true) @RequestParam("evaluationFormId") Long evaluationFormId);
|
||||
|
||||
@Operation(summary = "Api to get an application evaluation form",
|
||||
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 = "", produces = "application/json")
|
||||
ResponseEntity<Response<ApplicationEvaluationFormResponse>> getApplicationEvaluationForm(HttpServletRequest request,
|
||||
@Parameter(required = false) @RequestParam(value = "applicationId", required = false) Long applicationId,
|
||||
@Parameter( required = false) @RequestParam(value = "assignedApplicationId", required = false) Long assignedApplicationId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,16 +3,14 @@ package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.EvaluationDocumentResponse;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
@@ -99,4 +97,16 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
|
||||
.body(new Response<>(applicationEvaluationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_CREATED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<ApplicationEvaluationFormResponse>> getApplicationEvaluationForm(HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "get application evaluation form" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_APPLICATION_EVALUATION_FORM).build());
|
||||
|
||||
ApplicationEvaluationFormResponse applicationEvaluationFormResponse = applicationEvaluationService.getApplicationEvaluationForm(request,applicationId,assignedApplicationId);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(applicationEvaluationFormResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_EVALUATION_FORM_SUCCESS_MSG)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user