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));
}
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));
}
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);
}
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);
}
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);
}
Aggregations