Search in sources :

Example 1 with OrderApprovalStateTransition

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;
}
Also used : Order(org.estatio.module.capex.dom.order.Order) IncomingInvoiceApprovalStateTransition(org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransition) IncomingDocumentCategorisationStateTransition(org.estatio.module.capex.dom.documents.categorisation.IncomingDocumentCategorisationStateTransition) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) Document(org.incode.module.document.dom.impl.docs.Document) OrderApprovalStateTransition(org.estatio.module.capex.dom.order.approval.OrderApprovalStateTransition) BankAccountVerificationStateTransition(org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationStateTransition)

Aggregations

BankAccountVerificationStateTransition (org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationStateTransition)1 IncomingDocumentCategorisationStateTransition (org.estatio.module.capex.dom.documents.categorisation.IncomingDocumentCategorisationStateTransition)1 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)1 IncomingInvoiceApprovalStateTransition (org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransition)1 Order (org.estatio.module.capex.dom.order.Order)1 OrderApprovalStateTransition (org.estatio.module.capex.dom.order.approval.OrderApprovalStateTransition)1 BankAccount (org.estatio.module.financial.dom.BankAccount)1 Document (org.incode.module.document.dom.impl.docs.Document)1