Search in sources :

Example 41 with Document

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

the class PdfAdvisorForEstatio method bookmarkFor.

private String bookmarkFor(final InstanceKey instanceKey) {
    Document document = determineDocument(instanceKey);
    InstanceKey.TypeKey typeKey = instanceKey.getTypeKey();
    String objectType = typeKey.getObjectType();
    if (Objects.equals(objectType, IncomingDocAsInvoiceViewModel.class.getName())) {
        String identifier = instanceKey.getIdentifier();
        final String xmlStr = urlEncodingService.decode(identifier);
        IncomingDocAsInvoiceViewModel viewModel = jaxbService.fromXml(IncomingDocAsInvoiceViewModel.class, xmlStr);
        final Bookmark bookmark = bookmarkService2.bookmarkFor(viewModel.getDocument());
        if (bookmark != null)
            return "incomingInvoiceViewModel:" + bookmark.getIdentifier();
        else {
            // object presumably deleted
            return null;
        }
    } else if (Objects.equals(objectType, IncomingDocAsOrderViewModel.class.getName())) {
        String identifier = instanceKey.getIdentifier();
        final String xmlStr = urlEncodingService.decode(identifier);
        IncomingDocAsOrderViewModel viewModel = jaxbService.fromXml(IncomingDocAsOrderViewModel.class, xmlStr);
        final Bookmark bookmark = bookmarkService2.bookmarkFor(viewModel.getDocument());
        if (bookmark != null)
            return "incomingOrderViewModel:" + bookmark.getIdentifier();
        else {
            // object presumably deleted
            return null;
        }
    } else {
        return instanceKey.asBookmark().toString();
    }
}
Also used : Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) IncomingDocAsInvoiceViewModel(org.estatio.module.capex.app.invoice.IncomingDocAsInvoiceViewModel) Document(org.incode.module.document.dom.impl.docs.Document) IncomingDocAsOrderViewModel(org.estatio.module.capex.app.order.IncomingDocAsOrderViewModel)

Example 42 with Document

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

the class InvoiceSummaryForPropertyDueDateStatus_actionAbstract method findMostRecentAttachedTo.

Document findMostRecentAttachedTo(final Invoice invoice, final DocumentType documentType) {
    final List<Paperclip> paperclips = paperclipRepository.findByAttachedTo(invoice);
    for (Paperclip paperclip : paperclips) {
        final DocumentAbstract documentAbstract = paperclip.getDocument();
        if (!(documentAbstract instanceof Document)) {
            continue;
        }
        final Document document = (Document) documentAbstract;
        if (document.getType() == documentType) {
            return document;
        }
    }
    return null;
}
Also used : Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) DocumentAbstract(org.incode.module.document.dom.impl.docs.DocumentAbstract) Document(org.incode.module.document.dom.impl.docs.Document)

Example 43 with Document

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

the class InvoiceSummaryForPropertyDueDateStatus_sendByEmailAbstract method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public InvoiceSummaryForPropertyDueDateStatus $$() throws IOException {
    final List<InvoiceAndDocument> invoiceAndDocuments = invoiceAndDocumentsToSend();
    for (InvoiceAndDocument invoiceAndDocument : invoiceAndDocuments) {
        final Invoice invoice = invoiceAndDocument.getInvoice();
        final Document document = invoiceAndDocument.getDocument();
        final InvoiceForLease_sendByEmail invoice_sendByEmail = invoice_email(invoice);
        final EmailAddress emailAddress = invoice_sendByEmail.default1$$(document);
        final String cc = invoice_sendByEmail.default2$$(document);
        final String bcc = invoice_sendByEmail.default5$$(document);
        invoice_sendByEmail.$$(document, emailAddress, cc, null, null, bcc, null);
    }
    return this.invoiceSummary;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceForLease_sendByEmail(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByEmail) Document(org.incode.module.document.dom.impl.docs.Document) EmailAddress(org.incode.module.communications.dom.impl.commchannel.EmailAddress) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 44 with Document

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

the class ForPrimaryDocOfInvoiceAttachToInvoiceAndAnyRelevantSupportingDocuments method doAdvise.

@Override
protected List<AttachmentAdvisor.PaperclipSpec> doAdvise(final DocumentTemplate documentTemplate, final Invoice invoice, final Document createdDocument) {
    final List<PaperclipSpec> paperclipSpecs = Lists.newArrayList();
    paperclipSpecs.add(new PaperclipSpec(null, invoice, createdDocument));
    // not every supporting doc type supports each type of primary document
    // for example, TAX_REGISTER supports invoices (but not PLs), whereas CALCULATION is other way around.
    // we therefore need to filter the supporting documents that we find attached to the invoice.
    // 
    // to start with, we get hold of the set of doc type (data)s that _do_ support the primary doc just created
    DocumentTypeData primaryDocTypeData = DocumentTypeData.docTypeDataFor(createdDocument);
    List<DocumentTypeData> supportingDocTypeDatasForThisPrimaryDoc = DocumentTypeData.supports(primaryDocTypeData);
    // copy over all relevant supporting attached to this primary document (invoice or prelim letter)
    final List<Paperclip> paperclips = paperclipRepository.findByAttachedTo(invoice);
    for (Paperclip paperclip : paperclips) {
        if (PaperclipRoleNames.SUPPORTING_DOCUMENT.equals(paperclip.getRoleName())) {
            final DocumentAbstract supportingDocAbs = paperclip.getDocument();
            if (supportingDocAbs instanceof Document) {
                final Document supportingDoc = (Document) supportingDocAbs;
                final DocumentTypeData supportingDocTypeData = DocumentTypeData.docTypeDataFor(supportingDoc);
                // (and here is where filter out to only attach those that are relevant)
                if (supportingDocTypeDatasForThisPrimaryDoc.contains(supportingDocTypeData)) {
                    // note that the supporting documents point to the primary doc, rather than the other way around
                    paperclipSpecs.add(new PaperclipSpec(PaperclipRoleNames.INVOICE_DOCUMENT_SUPPORTED_BY, createdDocument, supportingDoc));
                }
            }
        }
    }
    return paperclipSpecs;
}
Also used : Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) DocumentAbstract(org.incode.module.document.dom.impl.docs.DocumentAbstract) DocumentTypeData(org.estatio.module.invoice.dom.DocumentTypeData) Document(org.incode.module.document.dom.impl.docs.Document)

Example 45 with Document

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

the class InvoiceForLease_sendByPostPrelimLetterOrInvoiceDocAbstract method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT, domainEvent = DomainEvent.class)
@ActionLayout(contributed = Contributed.AS_ACTION)
public Blob $$(@ParameterLayout(named = "to:") final PostalAddress toChannel) throws IOException {
    final Document document = findDocument();
    createPostalCommunicationAsSent(document, toChannel);
    final byte[] mergedBytes = mergePdfBytes(document);
    final String fileName = document.getName();
    return new Blob(fileName, DocumentConstants.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