Merge pull request #182 from Kitzanos/feature/GEPAFINBE-151
GEPAFINBE-151(Updated endpoint for get all amendment for instructor manager)
This commit is contained in:
@@ -592,7 +592,7 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId) {
|
public List<GetAllAmendmentResponseBean> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId) {
|
||||||
if (validator.checkIsPreInstructor() && userId == null) {
|
if (validator.checkIsPreInstructor() && userId == null) {
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
|
||||||
}
|
}
|
||||||
@@ -604,7 +604,7 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
applicationAmendmentRequestRepository.findAll(spec);
|
applicationAmendmentRequestRepository.findAll(spec);
|
||||||
|
|
||||||
return applicationAmendmentRequestEntities.stream()
|
return applicationAmendmentRequestEntities.stream()
|
||||||
.map(entity -> convertEntityToResponse(entity, false))
|
.map(this::initializeGetAllBasicResponse)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1178,6 +1178,37 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
return applicationEvaluation;
|
return applicationEvaluation;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private GetAllAmendmentResponseBean initializeGetAllBasicResponse(ApplicationAmendmentRequestEntity entity) {
|
||||||
|
GetAllAmendmentResponseBean response = new GetAllAmendmentResponseBean();
|
||||||
|
ApplicationEntity applicationEntity = entity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication();
|
||||||
|
response.setId(entity.getId());
|
||||||
|
response.setApplicationId(entity.getApplicationId());
|
||||||
|
response.setApplicationEvaluationId(entity.getApplicationEvaluationEntity().getId());
|
||||||
|
response.setNote(entity.getNote());
|
||||||
|
response.setStatus(ApplicationAmendmentRequestEnum.valueOf(entity.getStatus()));
|
||||||
|
response.setResponseDays(entity.getResponseDays());
|
||||||
|
response.setInternalNote(entity.getInternalNote());
|
||||||
|
|
||||||
|
LocalDateTime startDate = entity.getStartDate();
|
||||||
|
response.setStartDate(startDate);
|
||||||
|
response.setExpirationDate(entity.getEndDate());
|
||||||
|
response.setEvaluationEndDate(entity.getApplicationEvaluationEntity().getEndDate());
|
||||||
|
response.setIsSendEmail(entity.getIsEmail());
|
||||||
|
response.setIsSendNotification(entity.getIsNotification());
|
||||||
|
|
||||||
|
ApplicationEntity application = applicationService.validateApplication(entity.getApplicationId());
|
||||||
|
response.setCallEmail(application.getCall().getEmail());
|
||||||
|
response.setCallName(application.getCall().getName());
|
||||||
|
|
||||||
|
UserEntity userEntity = userService.validateUser(application.getUserId());
|
||||||
|
response.setBeneficiaryName(buildBeneficiaryName(userEntity));
|
||||||
|
CompanyEntity company = companyService.validateCompany(application.getCompanyId());
|
||||||
|
response.setCompanyName(company.getCompanyName());
|
||||||
|
Long protocolNumber = entity.getProtocol() != null ? entity.getProtocol().getProtocolNumber() : null;
|
||||||
|
response.setProtocolNumber(protocolNumber);
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
private void softDeleteDocument(Long documentId) {
|
private void softDeleteDocument(Long documentId) {
|
||||||
documentService.deleteFile(documentId);
|
documentService.deleteFile(documentId);
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GetAllAmendmentResponseBean {
|
||||||
|
private Long id;
|
||||||
|
private String callEmail;
|
||||||
|
private String note;
|
||||||
|
private Long responseDays;
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
private Boolean isSendNotification;
|
||||||
|
private Boolean isSendEmail;
|
||||||
|
private Long protocolNumber;
|
||||||
|
private String callName;
|
||||||
|
private String beneficiaryName;
|
||||||
|
private String companyName;
|
||||||
|
private String amendmentNotes;
|
||||||
|
private Long applicationId;
|
||||||
|
private Long applicationEvaluationId;
|
||||||
|
private LocalDateTime evaluationEndDate;
|
||||||
|
private LocalDateTime expirationDate;
|
||||||
|
private String internalNote;
|
||||||
|
private ApplicationAmendmentRequestEnum status;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -8,6 +8,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.GetAllAmendmentResponseBean;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ public interface ApplicationAmendmentRequestService {
|
|||||||
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest);
|
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest);
|
||||||
void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id);
|
void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id);
|
||||||
ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id);
|
ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id);
|
||||||
List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request,Long userId);
|
List<GetAllAmendmentResponseBean> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId);
|
||||||
ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean);
|
ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean);
|
||||||
ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long applicationAmendmentId);
|
ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long applicationAmendmentId);
|
||||||
List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request,Long beneficiaryId);
|
List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request,Long beneficiaryId);
|
||||||
|
|||||||
@@ -12,6 +12,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.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;
|
||||||
@@ -83,8 +84,7 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request,Long userId) {
|
public List<GetAllAmendmentResponseBean> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId) {
|
||||||
UserEntity user = validator.validatePreInstructor(request, userId);
|
|
||||||
return applicationAmendmentRequestDao.getAllApplicationAmendmentRequest(request,userId);
|
return applicationAmendmentRequestDao.getAllApplicationAmendmentRequest(request,userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBea
|
|||||||
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.ApplicationResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
|
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;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -85,9 +87,10 @@ public interface ApplicationAmendmentRequestApi {
|
|||||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||||
@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) })) })
|
||||||
@GetMapping(value = "/user/{id}", produces = "application/json")
|
@GetMapping(value = "/user", produces = "application/json")
|
||||||
ResponseEntity<Response<List<ApplicationAmendmentRequestResponse>>> getAllApplicationAmendmentRequest(HttpServletRequest request,
|
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN') || hasRole('ROLE_INSTRUCTOR_MANAGER')|| hasRole('ROLE_PRE_INSTRUCTOR')")
|
||||||
@Parameter(description = "The User ID", required = false) @PathVariable(value = "id",required = false) Long userId);
|
ResponseEntity<Response<List<GetAllAmendmentResponseBean>>> getAllApplicationAmendmentRequest(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The User ID", required = false) @RequestParam(value = "userId",required = false) Long userId);
|
||||||
|
|
||||||
@Operation(summary = "Api to update application amendment",
|
@Operation(summary = "Api to update application amendment",
|
||||||
responses = {
|
responses = {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBea
|
|||||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||||
|
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.service.ApplicationAmendmentRequestService;
|
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
||||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||||
@@ -85,14 +86,14 @@ public class ApplicationAmendmentRequestController implements ApplicationAmendme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<List<ApplicationAmendmentRequestResponse>>> getAllApplicationAmendmentRequest(HttpServletRequest request,Long userId) {
|
public ResponseEntity<Response<List<GetAllAmendmentResponseBean>>> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId) {
|
||||||
log.info("Get All Applications Amendment Request");
|
log.info("Get All Applications Amendment Request");
|
||||||
|
|
||||||
/** This code is responsible for creating user action logs for the "get all application amendment by preInstructor user id" operation. **/
|
/** This code is responsible for creating user action logs for the "get all application amendment by preInstructor user id" operation. **/
|
||||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||||
.actionContext(UserActionContextEnum.GET_ALL_AMENDMENT_BY_PREINSTRUCTOR_USER_ID).build());
|
.actionContext(UserActionContextEnum.GET_ALL_AMENDMENT_BY_PREINSTRUCTOR_USER_ID).build());
|
||||||
|
|
||||||
List<ApplicationAmendmentRequestResponse> applicationAmendmentRequestResponses = applicationAmendmentRequestService.getAllApplicationAmendmentRequest(request,userId);
|
List<GetAllAmendmentResponseBean> applicationAmendmentRequestResponses = applicationAmendmentRequestService.getAllApplicationAmendmentRequest(request,userId);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(applicationAmendmentRequestResponses, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_AMENDMENT_SUCCESS_MSG)));
|
.body(new Response<>(applicationAmendmentRequestResponses, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_AMENDMENT_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user