Done ticket GEPAFINBE-38

This commit is contained in:
nisha
2024-10-22 15:17:24 +05:30
parent fc51fb2200
commit b1f9841557
10 changed files with 85 additions and 78 deletions

View File

@@ -241,5 +241,7 @@ public class GepafinConstant {
public static final String HUB_DELETE_SUCCESS = "hub_delete_success";
public static final String HUB_NOT_FOUND = "hub_not_found";
public static final String EVALUATIONCRITERIA_INVALID = "evaluationCriteria.invalid";
public static final String APPLICATION_NOT_IN_DRAFT_STATUS="application.not.in.draft.status";
public static final String APPLICATION_ALREADY_ASSIGNED="application.already.assigned";
}

View File

@@ -595,25 +595,8 @@ public class ApplicationDao {
if(Boolean.TRUE.equals(applicationEntity.getStatus().equals(status.getValue()))){
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_IN_PREVIOUS_STATUS));
}
if (status.equals(ApplicationStatusTypeEnum.SUBMIT)) {
if (status.equals(ApplicationStatusTypeEnum.SUBMIT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.READY.getValue()))) {
callService.validatePublishedCall(applicationEntity.getCall().getId());
// CallEntity callEntity = applicationEntity.getCall();
// Long initialFormId = callEntity.getInitialForm();
// Long finalFormId = callEntity.getFinalForm();
//// if (initialFormId == null || finalFormId == null) {
//// throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
//// }
// ApplicationFormEntity initialApplicationForm = applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(), initialFormId);
// ApplicationFormEntity finalApplicationForm = applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(), finalFormId);
// if (initialApplicationForm == null || finalApplicationForm == null) {
// throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
// }
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
Long totalSteps=flowFormDao.calculateTotalSteps(flowEdgesList);
Integer completedSteps=flowFormDao.getCompletedSteps(applicationEntity);
if (totalSteps.intValue() != completedSteps) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
}
Long protocolNumber = getProtocolNumber(userEntity.getHub());
ProtocolEntity protocolEntity = createProtocolEntity(applicationEntity,protocolNumber, userEntity.getHub().getId());
applicationEntity.setProtocol(protocolEntity);
@@ -622,11 +605,10 @@ public class ApplicationDao {
applicationEntity = saveApplicationEntity(applicationEntity);
sendMailToUserAndCompany(userEntity, applicationEntity);
sendMailTodefaultSystemAndGepafin(userEntity, applicationEntity);
} else {
applicationEntity.setStatus(status.getValue());
applicationEntity = saveApplicationEntity(applicationEntity);
}
return getApplicationResponse(applicationEntity);
}
@@ -798,8 +780,9 @@ public class ApplicationDao {
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
if (applicationSignedDocument != null) {
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue());
applicationSignedDocumentRepository.save(applicationSignedDocument);
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_ASSIGNED));
// applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue());
// applicationSignedDocumentRepository.save(applicationSignedDocument);
}
UploadFileOnAmazonS3Response uploadFileOnAmazonS3 = amazonS3Service.uploadFileOnAmazonS3(signedDocumentS3Folder,
file);
@@ -809,6 +792,8 @@ public class ApplicationDao {
applicationSignedDocument.setFilePath(uploadFileOnAmazonS3.getFilePath());
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
applicationSignedDocumentRepository.save(applicationSignedDocument);
applicationEntity.setStatus(ApplicationStatusTypeEnum.READY.getValue());
applicationRepository.save(applicationEntity);
return convertApplicationSignedDocumentToApplicationSignedDocumentResponse(applicationSignedDocument);
}
@@ -865,4 +850,24 @@ public class ApplicationDao {
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue());
applicationSignedDocumentRepository.save(applicationSignedDocument);
}
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId) {
ApplicationEntity applicationEntity = validateApplication(applicationId);
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
if (Boolean.FALSE.equals(ApplicationStatusTypeEnum.DRAFT.getValue().equals(applicationEntity.getStatus()))) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_NOT_IN_DRAFT_STATUS));
}
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
Long totalSteps=flowFormDao.calculateTotalSteps(flowEdgesList);
Integer completedSteps=flowFormDao.getCompletedSteps(applicationEntity);
if (totalSteps.intValue() != completedSteps) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
}
applicationEntity.setStatus(ApplicationStatusTypeEnum.AWAIT.getValue());
applicationEntity = saveApplicationEntity(applicationEntity);
return getApplicationResponse(applicationEntity);
}
}

View File

@@ -75,42 +75,6 @@ public class PdfDao {
addColoredLines(writer,document,greyColor);
document.add(new Paragraph(" "));
// Application ID section (Centered)
// pageEvent.setTotalPages(writer.getPageNumber());
String protocolNumber="XX00";
if(applicationEntity.getProtocol()!=null) {
protocolNumber= String.valueOf(applicationEntity.getProtocol().getProtocolNumber());
}
Paragraph appId = new Paragraph("ID domanda :" +protocolNumber);
appId.setAlignment(Element.ALIGN_RIGHT);
document.add(appId);
document.add(new Paragraph(" "));
addColoredLines(writer,document,greenColor);
document.add(new Paragraph(" "));
document.add(new Paragraph("\n")); // Add line break
// String companyName= companyEntity.getCompanyName();
// String vatNumber=companyEntity.getVatNumber();
// String address=companyEntity.getAddress();
// // Section: Dati Anagrafici Azienda
// document.add(new Paragraph("Dati Anagrafici Azienda", sectionFont));
// addLabelValuePair(document, "Codice ATECO", "SEZIONE C “ATTIVITÀ MANUFATTURIERE”", regularFont);
// addLabelValuePair(document, "Ragione Sociale", companyName, regularFont);
// addLabelValuePair(document, "Partita IVA", vatNumber, regularFont);
// addLabelValuePair(document, "Indirizzo sede Legale", address, regularFont);
//
// document.add(new Paragraph("\n")); // Add line break
//
// // Section: Domanda presentata da
// document.add(new Paragraph("Domanda presentata da:", sectionFont));
// addLabelValuePair(document, "Nome e cognome", userEntity.getBeneficiary().getFirstName()+" "+userEntity.getBeneficiary().getLastName(), regularFont);
// addLabelValuePair(document, "Codice fiscale", userEntity.getBeneficiary().getCodiceFiscale(), regularFont);
// addLabelValuePair(document, "Telefono", userEntity.getBeneficiary().getPhoneNumber(), regularFont);
// addLabelValuePair(document, "Email", userEntity.getBeneficiary().getEmail(), regularFont);
// addLabelValuePair(document, "Con il titolo di", "Rappresentante legale", regularFont);
document.add(new Paragraph(" "));
ApplicationGetResponseBean applicationGetResponseBean=applicationDao.getApplicationByFormId(request, applicationId, null);
for(FormApplicationResponse formApplicationResponse: applicationGetResponseBean.getForm()) {
document.add(new Paragraph(formApplicationResponse.getLabel(),sectionFont));

View File

@@ -6,6 +6,8 @@ public enum ApplicationStatusTypeEnum {
DRAFT("DRAFT"),
SUBMIT("SUBMIT"),
AWAIT("AWAIT"),
READY("READY"),
DISCARD("DISCARD");
private String value;

View File

@@ -40,4 +40,6 @@ public interface ApplicationService {
public void deleteSignedDocument(HttpServletRequest request, Long applicationId);
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId);
}

View File

@@ -109,5 +109,11 @@ public class ApplicationServiceImpl implements ApplicationService {
public void deleteSignedDocument(HttpServletRequest request, Long applicationId) {
applicationDao.deleteSignedDocument(request, applicationId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId) {
return applicationDao.validateApplication(request, applicationId);
}
}

View File

@@ -175,17 +175,30 @@ public interface ApplicationApi {
ResponseEntity<Response<ApplicationSignedDocumentResponse>> getSignedDocument(HttpServletRequest request,
@Parameter(description = "The applicationId id", required = true) @PathVariable("applicationId") Long applicationId);
@Operation(summary = "Api to delete signed document", 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 = "{applicationId}/signedDocument", produces = "application/json")
ResponseEntity<Response<Void>> deleteSignedDocument(HttpServletRequest request,
@Parameter(description = "The applicationId id", required = true) @PathVariable("applicationId") Long applicationId);
// @Operation(summary = "Api to delete signed document", 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 = "{applicationId}/signedDocument", produces = "application/json")
// ResponseEntity<Response<Void>> deleteSignedDocument(HttpServletRequest request,
// @Parameter(description = "The applicationId id", required = true) @PathVariable("applicationId") Long applicationId);
@Operation(summary = "Api to validate application",
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 = "/{applicationId}/validate", produces = { "application/json" })
ResponseEntity<Response<ApplicationResponse>> validateApplication(HttpServletRequest request,
@Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId);
}

View File

@@ -133,13 +133,20 @@ public class ApplicationApiController implements ApplicationApi {
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_SIGNED_DOCUMENT_FILE_SUCCESS)));
}
// @Override
// public ResponseEntity<Response<Void>> deleteSignedDocument(HttpServletRequest request,
// Long applicationId) {
// applicationService.deleteSignedDocument(request, applicationId);
// log.info("delete signed document applicationId: {}", applicationId);
// return ResponseEntity.status(HttpStatus.OK)
// .body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_SIGNED_DOCUMENT_FILE_SUCCESS)));
// }
@Override
public ResponseEntity<Response<Void>> deleteSignedDocument(HttpServletRequest request,
Long applicationId) {
applicationService.deleteSignedDocument(request, applicationId);
log.info("delete signed document applicationId: {}", applicationId);
public ResponseEntity<Response<ApplicationResponse>> validateApplication(HttpServletRequest request, Long applicationId) {
ApplicationResponse applicationResponse = applicationService.validateApplication(request, applicationId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_SIGNED_DOCUMENT_FILE_SUCCESS)));
.body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_STATUS_UPDATED_SUCCESSFULLY)));
}
}

View File

@@ -264,5 +264,8 @@ hub_get_all_success=Hubs retrieved successfully
hub_delete_success=Hub deleted successfully
hub_not_found=Hub not found
application.not.in.draft.status=Application is not in DRAFT status.
application.already.assigned=Application is already assigned.

View File

@@ -259,4 +259,7 @@ hub_update_success=Hub aggiornato con successo
hub_get_success=Hub recuperato con successo
hub_get_all_success=Hub recuperati con successo
hub_delete_success=Hub eliminato con successo
hub_not_found=Hub non trovato
hub_not_found=Hub non trovato
application.not.in.draft.status=La domanda non è in stato DRAFT.
application.already.assigned=L'applicazione è già assegnata.