Search in sources :

Example 1 with CaseData

use of uk.gov.hmcts.probate.model.ccd.raw.request.CaseData in project probate-back-office by hmcts.

the class DocumentController method generateGrantDraftReissue.

@PostMapping(path = "/generate-grant-draft-reissue", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<CallbackResponse> generateGrantDraftReissue(@RequestBody CallbackRequest callbackRequest) {
    Document document;
    final CaseDetails caseDetails = callbackRequest.getCaseDetails();
    final CaseData caseData = caseDetails.getData();
    registryDetailsService.getRegistryDetails(caseDetails);
    // so we use html/pdf template instead.
    if (useHtmlPdfGeneratorForReissue(caseData)) {
        document = documentGeneratorService.getDocument(callbackRequest, DocumentStatus.PREVIEW, DocumentIssueType.REISSUE);
    } else {
        document = documentGeneratorService.generateGrantReissue(callbackRequest, DocumentStatus.PREVIEW, Optional.of(DocumentIssueType.REISSUE));
    }
    return ResponseEntity.ok(callbackResponseTransformer.addDocuments(callbackRequest, Arrays.asList(document), null, null));
}
Also used : CaseData(uk.gov.hmcts.probate.model.ccd.raw.request.CaseData) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with CaseData

use of uk.gov.hmcts.probate.model.ccd.raw.request.CaseData in project probate-back-office by hmcts.

the class DocumentController method generateGrantReissue.

@PostMapping(path = "/generate-grant-reissue", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<CallbackResponse> generateGrantReissue(@RequestBody CallbackRequest callbackRequest) throws NotificationClientException {
    final List<Document> documents = new ArrayList<>();
    Document grantDocument;
    Document coversheet;
    final CaseDetails caseDetails = callbackRequest.getCaseDetails();
    final CaseData caseData = caseDetails.getData();
    registryDetailsService.getRegistryDetails(caseDetails);
    // so we use html/pdf template instead.
    if (useHtmlPdfGeneratorForReissue(caseData)) {
        grantDocument = documentGeneratorService.getDocument(callbackRequest, DocumentStatus.FINAL, DocumentIssueType.REISSUE);
        coversheet = pdfManagementService.generateAndUpload(callbackRequest, DocumentType.GRANT_COVER);
    } else {
        grantDocument = documentGeneratorService.generateGrantReissue(callbackRequest, DocumentStatus.FINAL, Optional.of(DocumentIssueType.REISSUE));
        coversheet = documentGeneratorService.generateCoversheet(callbackRequest);
    }
    documents.add(grantDocument);
    documents.add(coversheet);
    String letterId = null;
    if (caseData.isSendForBulkPrintingRequested() && !EDGE_CASE_NAME.equals(caseData.getCaseType())) {
        letterId = bulkPrintService.optionallySendToBulkPrint(callbackRequest, coversheet, grantDocument, true);
    }
    String pdfSize = getPdfSize(caseData);
    if (caseData.isGrantReissuedEmailNotificationRequested()) {
        documents.add(notificationService.generateGrantReissue(callbackRequest));
    }
    log.info("{} documents generated: {}", documents.size(), documents);
    return ResponseEntity.ok(callbackResponseTransformer.addDocuments(callbackRequest, documents, letterId, pdfSize));
}
Also used : CaseData(uk.gov.hmcts.probate.model.ccd.raw.request.CaseData) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) ArrayList(java.util.ArrayList) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 3 with CaseData

use of uk.gov.hmcts.probate.model.ccd.raw.request.CaseData in project probate-back-office by hmcts.

the class NotificationController method sendCaseStoppedNotification.

@PostMapping(path = "/case-stopped")
public ResponseEntity<CallbackResponse> sendCaseStoppedNotification(@Validated({ EmailAddressNotifyValidationRule.class }) @RequestBody CallbackRequest callbackRequest) throws NotificationClientException {
    CaseDetails caseDetails = callbackRequest.getCaseDetails();
    CaseData caseData = caseDetails.getData();
    CallbackResponse response = CallbackResponse.builder().errors(new ArrayList<>()).build();
    Document document;
    List<Document> documents = new ArrayList<>();
    String letterId = null;
    if (caseData.isCaveatStopNotificationRequested() && caseData.isCaveatStopEmailNotificationRequested()) {
        response = eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
        if (response.getErrors().isEmpty()) {
            log.info("Initiate call to send caveat email for case id {} ", callbackRequest.getCaseDetails().getId());
            document = notificationService.sendEmail(CASE_STOPPED_CAVEAT, caseDetails);
            documents.add(document);
            log.info("Successful response for caveat email for case id {} ", callbackRequest.getCaseDetails().getId());
        }
    } else if (caseData.isCaveatStopNotificationRequested() && !caseData.isCaveatStopEmailNotificationRequested()) {
        Document coversheet = documentGeneratorService.generateCoversheet(callbackRequest);
        documents.add(coversheet);
        log.info("Initiate call to generate Caveat stopped document for case id {} ", callbackRequest.getCaseDetails().getId());
        Map<String, Object> placeholders = gorDocmosisService.caseDataForStoppedMatchedCaveat(callbackRequest.getCaseDetails());
        Document caveatRaisedDoc = pdfManagementService.generateDocmosisDocumentAndUpload(placeholders, DocumentType.CAVEAT_STOPPED);
        documents.add(caveatRaisedDoc);
        log.info("Successful response for caveat stopped document for case id {} ", callbackRequest.getCaseDetails().getId());
        if (caseData.isCaveatStopSendToBulkPrintRequested()) {
            log.info("Initiate call to bulk print for Caveat stopped document and coversheet for case id {} ", callbackRequest.getCaseDetails().getId());
            SendLetterResponse sendLetterResponse = bulkPrintService.sendToBulkPrintForGrant(callbackRequest, caveatRaisedDoc, coversheet);
            letterId = sendLetterResponse != null ? sendLetterResponse.letterId.toString() : null;
            response = eventValidationService.validateBulkPrintResponse(letterId, bulkPrintValidationRules);
        }
    } else {
        response = eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
        if (response.getErrors().isEmpty()) {
            log.info("Initiate call to notify applicant for case id {} ", callbackRequest.getCaseDetails().getId());
            document = notificationService.sendEmail(CASE_STOPPED, caseDetails);
            documents.add(document);
            log.info("Successful response from notify for case id {} ", callbackRequest.getCaseDetails().getId());
        }
    }
    if (response.getErrors().isEmpty()) {
        response = callbackResponseTransformer.caseStopped(callbackRequest, documents, letterId);
    }
    return ResponseEntity.ok(response);
}
Also used : CaseData(uk.gov.hmcts.probate.model.ccd.raw.request.CaseData) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) ArrayList(java.util.ArrayList) ProbateDocument(uk.gov.hmcts.reform.probate.model.ProbateDocument) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) Map(java.util.Map) SendLetterResponse(uk.gov.hmcts.reform.sendletter.api.SendLetterResponse) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 4 with CaseData

use of uk.gov.hmcts.probate.model.ccd.raw.request.CaseData in project probate-back-office by hmcts.

the class NotificationController method sendApplicationReceivedNotification.

@PostMapping(path = "/application-received")
public ResponseEntity<ProbateDocument> sendApplicationReceivedNotification(@RequestBody CallbackRequest callbackRequest) throws NotificationClientException {
    CaseDetails caseDetails = callbackRequest.getCaseDetails();
    CaseData caseData = callbackRequest.getCaseDetails().getData();
    if (isDigitalApplication(caseData) && isAnEmailAddressPresent(caseData)) {
        CallbackResponse response = eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
        if (response.getErrors().isEmpty()) {
            Document sentEmailAsDocument = notificationService.sendEmail(APPLICATION_RECEIVED, caseDetails);
            return ResponseEntity.ok(buildProbateDocument(sentEmailAsDocument));
        }
    }
    log.info("No email sent or document returned to case: {}", caseDetails.getId());
    return ResponseEntity.ok(null);
}
Also used : CaseData(uk.gov.hmcts.probate.model.ccd.raw.request.CaseData) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) ProbateDocument(uk.gov.hmcts.reform.probate.model.ProbateDocument) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 5 with CaseData

use of uk.gov.hmcts.probate.model.ccd.raw.request.CaseData in project probate-back-office by hmcts.

the class DocumentGenerationTests method verifySuccessForWillLodgementForCardiff.

@Test
public void verifySuccessForWillLodgementForCardiff() throws IOException {
    final CaseData caseData = CaseData.builder().build();
    final String response = generateNonProbateDocument(DEFAULT_WILL_NO_DOCS_PAYLOAD, GENERATE_DEPOSIT_RECEIPT);
    String expectedText = removeCrLfs(utils.getJsonFromFile("willLodgementDepositReceiptResponse.txt"));
    expectedText = expectedText.replaceAll("19th November 2020", caseData.convertDate(LocalDate.now()));
    assertTrue(response.contains(expectedText));
}
Also used : CaseData(uk.gov.hmcts.probate.model.ccd.raw.request.CaseData) Test(org.junit.Test)

Aggregations

CaseData (uk.gov.hmcts.probate.model.ccd.raw.request.CaseData)203 Test (org.junit.Test)154 CaseDetails (uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails)59 ResponseCaseData (uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData)57 ArrayList (java.util.ArrayList)55 CollectionMember (uk.gov.hmcts.probate.model.ccd.raw.CollectionMember)45 ParagraphDetail (uk.gov.hmcts.probate.model.ccd.raw.ParagraphDetail)30 Document (uk.gov.hmcts.probate.model.ccd.raw.Document)25 CallbackResponse (uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse)21 CallbackRequest (uk.gov.hmcts.probate.model.ccd.raw.request.CallbackRequest)20 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)19 AdditionalExecutorApplying (uk.gov.hmcts.probate.model.ccd.raw.AdditionalExecutorApplying)17 CaveatCallbackRequest (uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatCallbackRequest)14 SolsAddress (uk.gov.hmcts.probate.model.ccd.raw.SolsAddress)14 DocumentLink (uk.gov.hmcts.probate.model.ccd.raw.DocumentLink)13 SendLetterResponse (uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)13 LetterV3 (uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3)12 BusinessValidationException (uk.gov.hmcts.probate.exception.BusinessValidationException)10 LocalDate (java.time.LocalDate)9 UUID (java.util.UUID)9