use of org.estatio.module.capex.dom.order.approval.OrderApprovalStateTransition in project estatio by estatio.
the class TaskIncomingDocumentPdfService method doLookupPdfFor.
private Blob doLookupPdfFor(final Task task) {
StateTransition<?, ?, ?, ?> stateTransition = stateTransitionService.findFor(task);
if (stateTransition == null) {
return null;
}
if (stateTransition instanceof IncomingDocumentCategorisationStateTransition) {
IncomingDocumentCategorisationStateTransition idcst = (IncomingDocumentCategorisationStateTransition) stateTransition;
final Document document = idcst.getDocument();
if (document == null) {
return null;
}
if (!Objects.equals(document.getMimeType(), "application/pdf")) {
return null;
}
return document.getBlob();
}
if (stateTransition instanceof OrderApprovalStateTransition) {
final OrderApprovalStateTransition oast = (OrderApprovalStateTransition) stateTransition;
final Order order = oast.getOrdr();
final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupOrderPdfFrom(order);
return documentIfAny.map(DocumentAbstract::getBlob).orElse(null);
}
if (stateTransition instanceof IncomingInvoiceApprovalStateTransition) {
final IncomingInvoiceApprovalStateTransition iiast = (IncomingInvoiceApprovalStateTransition) stateTransition;
final IncomingInvoice invoice = iiast.getInvoice();
final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(invoice);
return documentIfAny.map(DocumentAbstract::getBlob).orElse(null);
}
if (stateTransition instanceof BankAccountVerificationStateTransition) {
final BankAccountVerificationStateTransition bavst = (BankAccountVerificationStateTransition) stateTransition;
final BankAccount bankAccount = bavst.getBankAccount();
final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIbanProofPdfFrom(bankAccount);
return documentIfAny.map(DocumentAbstract::getBlob).orElse(null);
}
return null;
}
Aggregations