Search in sources :

Example 31 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class IncomingDocumentPresentationSubscriber_IntegTest method setupData.

@Before
public void setupData() throws IOException {
    runFixtureScript(new FixtureScript() {

        @Override
        protected void execute(final ExecutionContext executionContext) {
            executionContext.executeChild(this, new DocumentTypesAndTemplatesForCapexFixture());
        }
    });
    List<Document> incomingDocumentsBefore = repository.findIncomingDocuments();
    assertThat(incomingDocumentsBefore).isEmpty();
    // given
    final String fileName = "1020100123.pdf";
    final byte[] pdfBytes = Resources.toByteArray(Resources.getResource(IncomingDocumentPresentationSubscriber_IntegTest.class, fileName));
    final Blob blob = new Blob(fileName, "application/pdf", pdfBytes);
    wrap(documentMenu).upload(blob);
    transactionService.nextTransaction();
}
Also used : Blob(org.apache.isis.applib.value.Blob) DocumentTypesAndTemplatesForCapexFixture(org.estatio.module.capex.seed.DocumentTypesAndTemplatesForCapexFixture) FixtureScript(org.apache.isis.applib.fixturescripts.FixtureScript) Document(org.incode.module.document.dom.impl.docs.Document) Before(org.junit.Before)

Example 32 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class DeriveBlobFromReturnedDocumentAbstract method process.

@Override
public CommandDto process(final Command command, final CommandDto commandDto) {
    final Bookmark result = command.getResult();
    if (result == null) {
        return commandDto;
    }
    try {
        final Document document = bookmarkService.lookup(result, Document.class);
        if (document != null) {
            ParamDto paramDto = getParamDto(commandDto, paramNum);
            CommonDtoUtils.setValueOn(paramDto, ValueType.BLOB, document.getBlob(), bookmarkService);
        }
    } catch (Exception ex) {
        return commandDto;
    }
    return commandDto;
}
Also used : Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) Document(org.incode.module.document.dom.impl.docs.Document) ParamDto(org.apache.isis.schema.cmd.v1.ParamDto)

Example 33 with Document

use of org.incode.module.document.dom.impl.docs.Document 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)

Example 34 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class BuyerFinder_Test method testerWhenNullOrTooShort.

private void testerWhenNullOrTooShort(final String documentName) {
    // given
    IncomingInvoice invoice = new IncomingInvoice();
    BuyerFinder finder = new BuyerFinder();
    finder.partyRepository = mockPartyRepository;
    finder.lookupAttachedPdfService = mockLookupAttachedPdfService;
    Optional<Document> optional = Optional.of(new Document(null, null, documentName, null, null));
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockLookupAttachedPdfService).lookupIncomingInvoicePdfFrom(invoice);
            will(returnValue(optional));
        }
    });
    // when
    finder.buyerDerivedFromDocumentName(invoice);
}
Also used : Expectations(org.jmock.Expectations) BuyerFinder(org.estatio.module.capex.dom.documents.BuyerFinder) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Document(org.incode.module.document.dom.impl.docs.Document)

Example 35 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class BuyerFinder_Test method testWhenParamIsInvoice.

private void testWhenParamIsInvoice(final String documentName, final String derivedPartyReference) {
    // given
    IncomingInvoice invoice = new IncomingInvoice();
    BuyerFinder finder = new BuyerFinder();
    finder.partyRepository = mockPartyRepository;
    finder.lookupAttachedPdfService = mockLookupAttachedPdfService;
    Optional<Document> optional = Optional.of(new Document(null, null, documentName, null, null));
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockLookupAttachedPdfService).lookupIncomingInvoicePdfFrom(invoice);
            will(returnValue(optional));
            oneOf(mockPartyRepository).findPartyByReference(derivedPartyReference);
        }
    });
    // when
    finder.buyerDerivedFromDocumentName(invoice);
}
Also used : Expectations(org.jmock.Expectations) BuyerFinder(org.estatio.module.capex.dom.documents.BuyerFinder) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Document(org.incode.module.document.dom.impl.docs.Document)

Aggregations

Document (org.incode.module.document.dom.impl.docs.Document)57 Action (org.apache.isis.applib.annotation.Action)23 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)22 Programmatic (org.apache.isis.applib.annotation.Programmatic)8 Blob (org.apache.isis.applib.value.Blob)7 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)7 DocumentAbstract (org.incode.module.document.dom.impl.docs.DocumentAbstract)7 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)5 Paperclip (org.incode.module.document.dom.impl.paperclips.Paperclip)5 IncomingDocumentCategorisationStateTransition (org.estatio.module.capex.dom.documents.categorisation.IncomingDocumentCategorisationStateTransition)4 Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)3 BuyerFinder (org.estatio.module.capex.dom.documents.BuyerFinder)3 Communication (org.incode.module.communications.dom.impl.comms.Communication)3 DocumentTemplate (org.incode.module.document.dom.impl.docs.DocumentTemplate)3 Expectations (org.jmock.Expectations)3 TitleBuffer (org.apache.isis.applib.util.TitleBuffer)2 IncomingDocAsOrderViewModel (org.estatio.module.capex.app.order.IncomingDocAsOrderViewModel)2 Order (org.estatio.module.capex.dom.order.Order)2 BankAccount (org.estatio.module.financial.dom.BankAccount)2 DocumentTypeData (org.estatio.module.invoice.dom.DocumentTypeData)2