The pre-instructor user must be able to request integration for a specific application

This commit is contained in:
harish
2024-10-27 12:36:29 +05:30
parent c4c43ead95
commit d9baed5aff
17 changed files with 726 additions and 7 deletions

View File

@@ -251,5 +251,13 @@ public class GepafinConstant {
public static final String APPLICATION_NOT_IN_DRAFT_STATUS="application.not.in.draft.status";
public static final String GET_ERROR_S3 = "get.error.s3";
public static final String INVALID_APPLICATION_STATUS = "invalid.application.status";
public static final String APPLICATION_DATA_FOR_AMENDMENT_SUCCESS_MSG = "application.data.amendment.success";
public static final String DELETE_APPLICATION_AMENDMENT_SUCCESS_MSG = "delete.application.amendment.success";
public static final String CREATE_APPLICATION_DATA_FOR_AMENDMENT_MSG = "create.application.data.amendment.msg";
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";
}

View File

@@ -0,0 +1,314 @@
package net.gepafin.tendermanagement.dao;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.entities.*;
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
import net.gepafin.tendermanagement.model.request.ApplicationFormFieldRequestBean;
import net.gepafin.tendermanagement.model.response.AmendmentFormFieldResponse;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
import net.gepafin.tendermanagement.repositories.*;
import net.gepafin.tendermanagement.service.ApplicationService;
import net.gepafin.tendermanagement.service.UserService;
import net.gepafin.tendermanagement.util.DateTimeUtil;
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static net.gepafin.tendermanagement.util.Utils.log;
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
@Component
public class ApplicationAmendmentRequestDao {
@Autowired
private ApplicationService applicationService;
@Autowired
private FormRepository formRepository;
@Autowired
private UserService userService;
@Autowired
private ApplicationFormRepository applicationFormRepository;
@Autowired
private ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
@Autowired
private ApplicationFormFieldRepository applicationFormFieldRepository;
@Autowired
private DocumentRepository documentRepository;
public List<ApplicationAmendmentRequestResponse> getApplicationDataForAmendment(HttpServletRequest request,Long applicationId){
log.info("Fetching the application data for the Amendment process {}", applicationId);
ApplicationEntity application = applicationService.validateApplication(applicationId);
String callName = application.getCall().getName();
Long protocolNumber = (application.getProtocol() != null && application.getProtocol().getProtocolNumber() != null)
? application.getProtocol().getProtocolNumber()
: null;
UserEntity userEntity = userService.validateUser(application.getUserId());
String firstName = userEntity.getBeneficiary() != null ? userEntity.getBeneficiary().getFirstName() : "";
String lastName = userEntity.getBeneficiary() != null ? userEntity.getBeneficiary().getLastName() : "";
String beneficiaryName = (!firstName.isBlank() ? firstName : "") +
(!lastName.isBlank() ? " " + lastName : "");
beneficiaryName = beneficiaryName.isBlank() ? "" : beneficiaryName;
List<ApplicationFormEntity> forms = applicationFormRepository.findByApplicationId(applicationId);
List<ApplicationAmendmentRequestResponse> responses = new ArrayList<>();
for (ApplicationFormEntity form : forms) {
String content = form.getForm().getContent();
List<Map<String, Object>> result = filterByName(content, "fileupload");
List<AmendmentFormFieldResponse> formFields = getIdAndLabelFromResult(result);
ApplicationAmendmentRequestResponse response = convertEntityToResponse(
protocolNumber, callName, formFields, beneficiaryName);
responses.add(response);
}
return responses;
}
public List<AmendmentFormFieldResponse> getIdAndLabelFromResult(List<Map<String, Object>> result) {
List<AmendmentFormFieldResponse> formFieldResponses = new ArrayList<>();
for (Map<String, Object> item : result) {
AmendmentFormFieldResponse formFieldResponse = new AmendmentFormFieldResponse();
formFieldResponse.setFieldId((String) item.get("id"));
// Extract "label" value from the "settings" array
List<Map<String, Object>> settings = (List<Map<String, Object>>) item.get("settings");
String label = settings.stream()
.filter(setting -> "label".equals(setting.get("name")))
.map(setting -> (String) setting.get("value"))
.findFirst()
.orElse(""); // Default to empty string if not found
if (label == null || label.trim().isEmpty()) {
continue;
}
formFieldResponse.setLabel(label); // Set the label as fieldValue
formFieldResponses.add(formFieldResponse);
}
return formFieldResponses;
}
private ApplicationAmendmentRequestResponse convertEntityToResponse(
Long protocolNumber, String callName,
List<AmendmentFormFieldResponse> formFields,String beneficiaryName) {
ApplicationAmendmentRequestResponse response = new ApplicationAmendmentRequestResponse();
response.setProtocolNumber(protocolNumber);
response.setCallName(callName);
response.setBeneficiaryName(beneficiaryName);
response.setFormFields(formFields);
response.setResponseDays(null);
response.setSendEmail(false);
response.setSendNotification(false);
response.setNote(null);
response.setStartDate(null);
return response;
}
public static List<Map<String, Object>> filterByName(String content, String target) {
ObjectMapper objectMapper = new ObjectMapper();
List<Map<String, Object>> filteredList = new ArrayList<>();
try {
List<Map<String, Object>> dataList = objectMapper.readValue(
content, new TypeReference<List<Map<String, Object>>>() {});
for (Map<String, Object> data : dataList) {
if (target.equals(data.get("name"))) {
filteredList.add(data);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return filteredList;
}
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(Long applicationId, ApplicationAmendmentRequest applicationAmendmentRequest){
log.info("Submiting application data for amendment Process with details: {}", applicationId);
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = createApplicationAmendmentRequestEntity(applicationAmendmentRequest);
ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = convertEntityToResponse(applicationAmendmentRequestEntity);
log.info("Application submitted successfully for amendment", applicationAmendmentRequestResponse);
return applicationAmendmentRequestResponse;
}
public ApplicationAmendmentRequestEntity createApplicationAmendmentRequestEntity(ApplicationAmendmentRequest applicationAmendmentRequest){
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = new ApplicationAmendmentRequestEntity();
applicationAmendmentRequestEntity.setNote(applicationAmendmentRequest.getNote());
applicationAmendmentRequestEntity.setResponseDays(applicationAmendmentRequest.getResponseDays());
if (applicationAmendmentRequest.getFormFields() != null) {
String fieldIdsString = applicationAmendmentRequest.getFormFields().stream()
.filter(AmendmentFormFieldResponse::isSelected)
.map(AmendmentFormFieldResponse::getFieldId)
.collect(Collectors.joining(","));
applicationAmendmentRequestEntity.setFormFields(fieldIdsString);
}
applicationAmendmentRequestEntity.setIsEmail(false);
applicationAmendmentRequestEntity.setIsNotification(false);
ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity);
return applicationAmendment;
}
public ApplicationAmendmentRequestEntity saveApplicationAmendmentRequestEntity(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity){
ApplicationAmendmentRequestEntity applicationAmendmentRequest= applicationAmendmentRequestRepository.save(applicationAmendmentRequestEntity);
return applicationAmendmentRequest;
}
public ApplicationAmendmentRequestResponse convertEntityToResponse(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity){
ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = new ApplicationAmendmentRequestResponse();
applicationAmendmentRequestResponse.setId(applicationAmendmentRequestEntity.getId());
Long applicationId = 1L;
ApplicationEntity application = applicationService.validateApplication(applicationId);
applicationAmendmentRequestResponse.setNote(applicationAmendmentRequestEntity.getNote());
applicationAmendmentRequestResponse.setResponseDays(applicationAmendmentRequestEntity.getResponseDays());
applicationAmendmentRequestResponse.setStartDate(applicationAmendmentRequestEntity.getCreatedDate());
applicationAmendmentRequestResponse.setSendEmail(applicationAmendmentRequestEntity.getIsEmail());
applicationAmendmentRequestResponse.setSendNotification(applicationAmendmentRequestEntity.getIsNotification());
String callName = application.getCall().getName();
Long protocolNumber = (application.getProtocol() != null && application.getProtocol().getProtocolNumber() != null)
? application.getProtocol().getProtocolNumber()
: null;
UserEntity userEntity = userService.validateUser(application.getUserId());
String firstName = userEntity.getBeneficiary() != null ? userEntity.getBeneficiary().getFirstName() : "";
String lastName = userEntity.getBeneficiary() != null ? userEntity.getBeneficiary().getLastName() : "";
String beneficiaryName = (!firstName.isBlank() ? firstName : "") +
(!lastName.isBlank() ? " " + lastName : "");
beneficiaryName = beneficiaryName.isBlank() ? "" : beneficiaryName;
applicationAmendmentRequestResponse.setCallName(callName);
applicationAmendmentRequestResponse.setProtocolNumber(protocolNumber);
applicationAmendmentRequestResponse.setBeneficiaryName(beneficiaryName);
String formFieldsString = applicationAmendmentRequestEntity.getFormFields();
List<String> storedFieldIds = (formFieldsString != null) ? Arrays.asList(formFieldsString.split(",")) : Collections.emptyList();
List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(application.getId());
List<AmendmentFormFieldResponse> formFields = new ArrayList<>();
for (ApplicationFormEntity formEntity : applicationForms) {
String content = formEntity.getForm().getContent();
List<Map<String, Object>> result = filterByName(content, "fileupload");
List<AmendmentFormFieldResponse> matchingFields = getIdAndLabelFromResult(result).stream()
.filter(field -> storedFieldIds.contains(field.getFieldId()))
.collect(Collectors.toList());
formFields.addAll(matchingFields);
}
applicationAmendmentRequestResponse.setFormFields(formFields);
List<AmendmentFormFieldResponse> formField = formFields.stream()
.map(field -> {
AmendmentFormFieldResponse responseField = new AmendmentFormFieldResponse();
responseField.setFieldId(field.getFieldId());
responseField.setLabel(field.getLabel());
responseField.setSelected(true);
return responseField;
})
.collect(Collectors.toList());
applicationAmendmentRequestResponse.setFormFields(formFields);
return applicationAmendmentRequestResponse;
}
public ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long id){
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id).orElseThrow(()->
new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
return applicationAmendmentRequestEntity;
}
public void deleteById(Long id) {
log.info("Deleting assigned application with ID: {}", id);
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity= validateApplicationAmendmentRequest(id);
applicationAmendmentRequestEntity.setIsDeleted(true);
applicationAmendmentRequestEntity= saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity);
log.info(" Application amendment deleted with ID: {}", id);
}
public ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(Long id) {
log.info("Fetching application amendment with ID: {}", id);
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = validateApplicationAmendmentRequest(id);
ApplicationAmendmentRequestResponse response = convertEntityToResponse(applicationAmendmentRequestEntity);
log.info("Application Amendment fetched successfully by ID: {}", response);
return response;
}
public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest() {
List<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntities =
applicationAmendmentRequestRepository.findAll();
return applicationAmendmentRequestEntities.stream()
.map(this::convertEntityToResponse)
.collect(Collectors.toList());
}
public ApplicationAmendmentRequestResponse updateApplicationAmendment(
Long id, ApplicationAmendmentRequestBean updateRequest) {
log.info("Updating application amendement with ID: {}", id);
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
setIfUpdated(existingApplicationAmendment::getNote, existingApplicationAmendment::setNote, updateRequest.getNote());
if (updateRequest.getUpdatedFormFields() != null) {
updateApplicationFormFields(existingApplicationAmendment, updateRequest.getUpdatedFormFields());
}
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
ApplicationAmendmentRequestEntity updatedApplicationAmendment = saveApplicationAmendmentRequestEntity(existingApplicationAmendment);
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment);
log.info("Application Amendment updated successfully: {}", response);
return response;
}
private boolean documentExists(String documentId) {
Long documentIdLong = Long.parseLong(documentId); // Convert to Long
return documentRepository.existsById(documentIdLong);
}
private void updateApplicationFormFields(ApplicationAmendmentRequestEntity applicationAmendment, ApplicationFormFieldRequestBean updatedFormField) {
List<String> documentIds = Arrays.asList(updatedFormField.getFieldValue().toString().split(","));
for (String documentId : documentIds) {
if (!documentExists(documentId)) {
log.warn("Document with ID {} does not exist. Skipping update.", documentId);
continue;
}
ApplicationFormFieldEntity formEntity = applicationFormFieldRepository.findByFieldId(updatedFormField.getFieldId());
if (formEntity != null) {
formEntity.setFieldValue(updatedFormField.getFieldValue().toString());
applicationFormFieldRepository.save(formEntity);
log.info("Updated field value for field ID {} with document IDs {}", updatedFormField.getFieldId(), updatedFormField.getFieldValue());
} else {
log.warn("No ApplicationFormEntity found with field ID {}. Skipping update.", updatedFormField.getFieldId());
}
}
}
}

View File

@@ -47,12 +47,6 @@ public class AssignedApplicationsDao {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_ASSIGNED));
}
ApplicationEntity application = applicationService.validateApplication(applicationId);
if (Boolean.FALSE.equals(ApplicationStatusTypeEnum.SUBMIT.equals(application.getStatus()))) {
throw new CustomValidationException(
Status.BAD_REQUEST,
Translator.toLocale(GepafinConstant.INVALID_APPLICATION_STATUS)
);
}
UserEntity user = userService.validateUser(userId);
AssignedApplicationsEntity assignment = createAssignmentEntity(application, user.getId(), assignedByUser, assignedApplicationsRequest);
AssignedApplicationsResponse assignApplicationToInstructorResponse = convertEntityToResponse(assignment, assignedApplicationsRequest);

View File

@@ -0,0 +1,31 @@
package net.gepafin.tendermanagement.entities;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
@Entity
@Table(name="application_amendment_request")
@Data
public class ApplicationAmendmentRequestEntity extends BaseEntity {
@Column(name = "NOTE")
private String note;
@Column(name ="RESPONSE_DAYS")
private Long responseDays;
@Column(name = "IS_NOTIFICATION")
private Boolean isNotification = false;
@Column(name = "IS_EMAIL")
private Boolean isEmail=false;
@Column(name = "FORM_FIELDS")
private String formFields;
@Column(name="IS_DELETED")
private Boolean isDeleted=false;
}

View File

@@ -0,0 +1,12 @@
package net.gepafin.tendermanagement.model.request;
import lombok.Data;
import net.gepafin.tendermanagement.model.response.AmendmentFormFieldResponse;
import java.util.List;
@Data
public class ApplicationAmendmentRequest {
private String note;
private List<AmendmentFormFieldResponse> formFields;
private Long responseDays;
}

View File

@@ -0,0 +1,9 @@
package net.gepafin.tendermanagement.model.request;
import lombok.Data;
@Data
public class ApplicationAmendmentRequestBean {
private String note;
private ApplicationFormFieldRequestBean updatedFormFields;
}

View File

@@ -0,0 +1,10 @@
package net.gepafin.tendermanagement.model.response;
import lombok.Data;
@Data
public class AmendmentFormFieldResponse {
private String fieldId;
private String label;
private boolean isSelected = false;
}

View File

@@ -0,0 +1,22 @@
package net.gepafin.tendermanagement.model.response;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class ApplicationAmendmentRequestResponse {
private Long id;
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 List<AmendmentFormFieldResponse> formFields;
private List<ApplicationFormFieldResponseBean> updatedFormFields;
}

View File

@@ -0,0 +1,10 @@
package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
public interface ApplicationAmendmentRequestRepository extends JpaRepository<ApplicationAmendmentRequestEntity,Long> {
Optional<ApplicationAmendmentRequestEntity> findByIdAndIsDeletedFalse(Long id);
}

View File

@@ -24,4 +24,6 @@ public interface ApplicationFormFieldRepository extends JpaRepository<Applicatio
public List<ApplicationFormFieldEntity> findByFieldValueInAndApplicationFormApplicationId(
List<String> fieldValue, Long applicationId);
public ApplicationFormFieldEntity findByFieldId(String FieldId);
}

View File

@@ -0,0 +1,18 @@
package net.gepafin.tendermanagement.service;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
import java.util.List;
public interface ApplicationAmendmentRequestService {
public List<ApplicationAmendmentRequestResponse> getApplicationDataForAmendment(HttpServletRequest request,Long applicationId);
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest);
void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id);
ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id);
List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request);
ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean);
}

View File

@@ -0,0 +1,61 @@
package net.gepafin.tendermanagement.service.impl;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.dao.ApplicationAmendmentRequestDao;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
import net.gepafin.tendermanagement.util.Validator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendmentRequestService {
@Autowired
private Validator validator;
@Autowired
private ApplicationAmendmentRequestDao applicationAmendmentRequestDao;
@Override
public List<ApplicationAmendmentRequestResponse> getApplicationDataForAmendment(HttpServletRequest request, Long applicationId) {
UserEntity user= validator.validateUser(request);
return applicationAmendmentRequestDao.getApplicationDataForAmendment(request,applicationId);
}
@Override
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest) {
UserEntity user= validator.validateUser(request);
return applicationAmendmentRequestDao.createApplicationAmendmentRequest(applicationEvaluationId,applicationAmendmentRequest);
}
@Override
public void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id) {
applicationAmendmentRequestDao.deleteById(id);
}
@Override
public ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id) {
return applicationAmendmentRequestDao.getApplicationAmendmentRequestById(id);
}
@Override
public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request) {
return applicationAmendmentRequestDao.getAllApplicationAmendmentRequest();
}
@Override
public ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean) {
UserEntity updatedByUser= validator.validateUser(request);
return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean);
}
}

View File

@@ -0,0 +1,102 @@
package net.gepafin.tendermanagement.web.rest.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
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.model.request.ApplicationAmendmentRequest;
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Validated
public interface ApplicationAmendmentRequestApi {
@Operation(summary = "Api to get application data for the Amendment process",
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 = "/{applicationId}", produces = "application/json")
ResponseEntity<Response<List<ApplicationAmendmentRequestResponse>>> getApplicationDataForAmendment(HttpServletRequest request, @Parameter(description = "The application id", required = true) @PathVariable(value = "applicationId", required = true) Long applicationId);
@Operation(summary = "Api to submit the application data for the Amendment",
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) })) })
@PostMapping(value = "", produces = "application/json")
ResponseEntity<Response<ApplicationAmendmentRequestResponse>> createApplicationAmendmentRequest(HttpServletRequest request,
@Parameter(description = "Application Evaluation Id", required = true) @RequestParam Long applicationEvaluationId,
@Valid @RequestBody ApplicationAmendmentRequest applicationAmendmentRequest);
@Operation(summary = "Api to delete application 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) })) })
@DeleteMapping(value = "/{id}")
ResponseEntity<Response<Void>> deleteApplicationAmendmentRequest(HttpServletRequest request,
@Parameter(description = "The application Amendment id", required = true) @PathVariable("id") Long id);
@Operation(summary = "Api to get an application amendment by id",
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<ApplicationAmendmentRequestResponse>> getApplicationAmendmentRequestById(HttpServletRequest request,@Parameter(description = "The application amendment id", required = true) @RequestParam(value = "id", required = true) Long id);
@Operation(summary = "Api to get all applications 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) })) })
@GetMapping(value = "/getAll", produces = "application/json")
ResponseEntity<Response<List<ApplicationAmendmentRequestResponse>>> getAllApplicationAmendmentRequest(HttpServletRequest request);
@Operation(summary = "Api to update application amendment",
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}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Response<ApplicationAmendmentRequestResponse>> updateApplicationAmendment(HttpServletRequest request,
@Parameter(description = "The Application Amendment id", required = true) @PathVariable("id") Long id,
@Parameter(description = "Assigned Application request object", required = true) @Valid @RequestBody ApplicationAmendmentRequestBean applicationAmendmentRequestBean);
}

View File

@@ -0,0 +1,74 @@
package net.gepafin.tendermanagement.web.rest.api.impl;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.log4j.Log4j2;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
import net.gepafin.tendermanagement.web.rest.api.ApplicationAmendmentRequestApi;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/amendments}")
@Log4j2
public class ApplicationAmendmentRequestController implements ApplicationAmendmentRequestApi {
@Autowired
ApplicationAmendmentRequestService applicationAmendmentRequestService;
@Override
public ResponseEntity<Response<List<ApplicationAmendmentRequestResponse>>> getApplicationDataForAmendment(HttpServletRequest request, Long applicationId) {
List<ApplicationAmendmentRequestResponse> applicationAmendmentBean = applicationAmendmentRequestService.getApplicationDataForAmendment(request,applicationId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(applicationAmendmentBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_DATA_FOR_AMENDMENT_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<ApplicationAmendmentRequestResponse>> createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId, ApplicationAmendmentRequest applicationAmendmentRequest) {
ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = applicationAmendmentRequestService.createApplicationAmendmentRequest(request,applicationEvaluationId,applicationAmendmentRequest);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(applicationAmendmentRequestResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.CREATE_APPLICATION_DATA_FOR_AMENDMENT_MSG)));
}
@Override
public ResponseEntity<Response<Void>> deleteApplicationAmendmentRequest(HttpServletRequest request, Long id) {
log.info("Delete Application Amendment Request- Application Amendment ID: {}", id);
applicationAmendmentRequestService.deleteApplicationAmendmentRequest(request,id);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_APPLICATION_AMENDMENT_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<ApplicationAmendmentRequestResponse>> getApplicationAmendmentRequestById(HttpServletRequest request,Long id) {
log.info("Get Application Amendment Request By Id");
ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = applicationAmendmentRequestService.getApplicationAmendmentRequestById(request,id);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(applicationAmendmentRequestResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_AMENDMENT_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<List<ApplicationAmendmentRequestResponse>>> getAllApplicationAmendmentRequest(HttpServletRequest request) {
log.info("Get All Applications Amendment Request");
List<ApplicationAmendmentRequestResponse> applicationAmendmentRequestResponses = applicationAmendmentRequestService.getAllApplicationAmendmentRequest(request);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(applicationAmendmentRequestResponses, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_AMENDMENT_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<ApplicationAmendmentRequestResponse>> updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean) {
log.info("Update Application Amendment");
ApplicationAmendmentRequestResponse updateApplicationAmendment = applicationAmendmentRequestService.updateApplicationAmendment(request, id, applicationAmendmentRequestBean);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(updateApplicationAmendment, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_UPDATE_SUCCESSFULLY_MSG)));
}
}