Search in sources :

Example 6 with Document

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

the class DemoInvoice_simulateRenderAsDoc method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
@ActionLayout(contributed = Contributed.AS_ACTION)
@MemberOrder(name = "documents", sequence = "1")
public Document $$(@Parameter(fileAccept = "application/pdf") final Blob document, @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "File name") final String fileName) throws IOException {
    String name = determineName(document, fileName);
    final DocumentType documentType = findDocumentType(DocumentType_and_DocumentTemplates_createSome.DOC_TYPE_REF_INVOICE);
    final Document receiptDoc = documentRepository.create(documentType, AT_PATH, name, document.getMimeType().getBaseType());
    // unlike documents that are generated from a template (where we call documentTemplate#render), in this case
    // we have the actual bytes; so we just set up the remaining state of the document manually.
    receiptDoc.setRenderedAt(clockService.nowAsDateTime());
    receiptDoc.setState(DocumentState.RENDERED);
    receiptDoc.setSort(DocumentSort.BLOB);
    receiptDoc.setBlobBytes(document.getBytes());
    paperclipRepository.attach(receiptDoc, ROLE_NAME, invoice);
    return receiptDoc;
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType) Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 7 with Document

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

the class Order_recategorize method act.

@Action(semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(cssClassFa = "mail-reply", cssClass = "btn-danger")
public Document act(@Nullable final String comment) {
    Document document = lookupPdf();
    document.setType(DocumentTypeData.INCOMING.findUsing(documentTypeRepository));
    stateTransitionService.trigger(document, IncomingDocumentCategorisationStateTransition.class, IncomingDocumentCategorisationStateTransitionType.RESET, comment, null);
    // use events to cascade delete, eg paperclips and state transitions/tasks
    orderRepository.delete(order);
    return document;
}
Also used : Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 8 with Document

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

the class InvoiceSummaryForPropertyDueDateStatus_sendAbstract method appendTuplesToSend.

private void appendTuplesToSend(final Invoice invoice, final Predicate<InvoiceAndDocument> filter, final List<InvoiceAndDocument> invoiceAndDocuments) {
    final CommunicationChannel sendTo = invoice.getSendTo();
    if (sendTo == null) {
        return;
    }
    final CommunicationChannelType channelType = sendTo.getType();
    if (channelType != communicationChannelType) {
        return;
    }
    final Document document = findMostRecentAttachedTo(invoice, getDocumentType());
    if (document == null) {
        return;
    }
    if (document.getState() == DocumentState.NOT_RENDERED) {
        return;
    }
    if (invoiceDocAndCommService.findFirstCommunication(document) != null) {
        return;
    }
    final InvoiceAndDocument invoiceAndDocument = new InvoiceAndDocument(invoice, document);
    if (!filter.apply(invoiceAndDocument)) {
        return;
    }
    invoiceAndDocuments.add(invoiceAndDocument);
}
Also used : CommunicationChannelType(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType) Document(org.incode.module.document.dom.impl.docs.Document) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

Example 9 with Document

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

the class InvoiceSummaryForPropertyDueDateStatus_sendByPostAbstract method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public Blob $$(final String fileName) throws IOException {
    final List<byte[]> pdfBytes = Lists.newArrayList();
    for (final InvoiceAndDocument invoiceAndDocument : invoiceAndDocumentsToSend()) {
        final Invoice invoice = invoiceAndDocument.getInvoice();
        final Document prelimLetterOrInvoiceNote = invoiceAndDocument.getDocument();
        final InvoiceForLease_sendByPost invoice_sendByPost = invoice_sendByPost(invoice);
        final PostalAddress postalAddress = invoice_sendByPost.default1$$(prelimLetterOrInvoiceNote);
        invoice_sendByPost.createPostalCommunicationAsSent(prelimLetterOrInvoiceNote, postalAddress);
        invoice_sendByPost.appendPdfBytes(prelimLetterOrInvoiceNote, pdfBytes);
    }
    final byte[] mergedBytes = pdfBoxService.merge(pdfBytes.toArray(new byte[][] {}));
    return new Blob(fileName, DocumentConstants.MIME_TYPE_APPLICATION_PDF, mergedBytes);
}
Also used : PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) Blob(org.apache.isis.applib.value.Blob) Invoice(org.estatio.module.invoice.dom.Invoice) Document(org.incode.module.document.dom.impl.docs.Document) InvoiceForLease_sendByPost(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByPost) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 10 with Document

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

the class DocAndCommAbstract_download method act.

@Action(semantics = SemanticsOf.SAFE, invokeOn = InvokeOn.OBJECT_ONLY)
@ActionLayout(contributed = Contributed.AS_ACTION)
public Blob act() throws IOException {
    final List<byte[]> pdfBytes = Lists.newArrayList();
    final Document document = getDocument();
    appendBytes(document, pdfBytes);
    final List<Document> supportingDocs = attachmentsProvider.attachmentsFor(document);
    for (Document supportingDoc : supportingDocs) {
        appendBytes(supportingDoc, pdfBytes);
    }
    final byte[] mergedBytes = pdfBoxService.merge(pdfBytes.toArray(new byte[][] {}));
    return new Blob(fileName, MIME_TYPE_APPLICATION_PDF, mergedBytes);
}
Also used : Blob(org.apache.isis.applib.value.Blob) Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

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