Search in sources :

Example 1 with CaseDetails

use of uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails 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 CaseDetails

use of uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails 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 CaseDetails

use of uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails 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 CaseDetails

use of uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails 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 CaseDetails

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

the class DocumentGeneratorService method generateLetter.

public Document generateLetter(CallbackRequest callbackRequest, boolean forFinal) {
    CaseDetails caseDetails = callbackRequest.getCaseDetails();
    Map<String, Object> placeholders = previewLetterService.addLetterData(caseDetails);
    if (!forFinal) {
        Map<String, Object> images = new HashMap<>();
        images.put(WATERMARK, WATERMARK_FILE_PATH);
        Map<String, Object> mappedImages = genericMapperService.mappedBase64Images(images);
        placeholders.putAll(mappedImages);
    }
    return pdfManagementService.generateDocmosisDocumentAndUpload(placeholders, DocumentType.ASSEMBLED_LETTER);
}
Also used : HashMap(java.util.HashMap) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails)

Aggregations

CaseDetails (uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails)207 Test (org.junit.Test)167 CallbackRequest (uk.gov.hmcts.probate.model.ccd.raw.request.CallbackRequest)98 CaseData (uk.gov.hmcts.probate.model.ccd.raw.request.CaseData)63 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)56 Document (uk.gov.hmcts.probate.model.ccd.raw.Document)36 Matchers.containsString (org.hamcrest.Matchers.containsString)28 ResponseCaseData (uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData)27 ArrayList (java.util.ArrayList)25 CollectionMember (uk.gov.hmcts.probate.model.ccd.raw.CollectionMember)25 BusinessValidationException (uk.gov.hmcts.probate.exception.BusinessValidationException)24 CallbackResponse (uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse)20 Before (org.junit.Before)14 CaveatCallbackRequest (uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatCallbackRequest)14 SolsAddress (uk.gov.hmcts.probate.model.ccd.raw.SolsAddress)14 ReturnedCaseDetails (uk.gov.hmcts.probate.model.ccd.raw.request.ReturnedCaseDetails)14 DocumentLink (uk.gov.hmcts.probate.model.ccd.raw.DocumentLink)13 SendLetterResponse (uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)13 ScannedDocument (uk.gov.hmcts.probate.model.ccd.raw.ScannedDocument)12 LetterV3 (uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3)12