Search in sources :

Example 1 with Paperclip

use of org.incode.module.document.dom.impl.paperclips.Paperclip in project estatio by estatio.

the class Document_delete method $$.

@Action(semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE, domainEvent = ActionDomainEvent.class)
@ActionLayout(cssClassFa = "trash")
public Object $$() {
    List<Object> attachedToList = Lists.newArrayList();
    // links from this document to other objects
    List<Paperclip> paperclips = paperclipRepository.findByDocument(document);
    for (Paperclip paperclip : paperclips) {
        final Object attachedTo = paperclip.getAttachedTo();
        attachedToList.add(attachedTo);
        paperclipRepository.delete(paperclip);
    }
    // links from other documents to this document
    paperclips = paperclipRepository.findByAttachedTo(document);
    for (Paperclip paperclip : paperclips) {
        paperclipRepository.delete(paperclip);
    }
    documentRepository.delete(document);
    // if was only attached to a single object, then return; otherwise return null.
    return attachedToList.size() == 1 ? attachedToList.get(0) : null;
}
Also used : Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 2 with Paperclip

use of org.incode.module.document.dom.impl.paperclips.Paperclip in project estatio by estatio.

the class RenderModelFactoryOfDocumentAttachedToDemoInvoice method doNewRendererModel.

@Override
protected Object doNewRendererModel(final DocumentTemplate documentTemplate, final Document document) {
    final List<Paperclip> paperclips = paperclipRepository.findByDocument(document);
    final DemoInvoice demoInvoice = paperclips.stream().map(Paperclip::getAttachedTo).filter(DemoInvoice.class::isInstance).map(DemoInvoice.class::cast).findFirst().get();
    return new DataModel(demoInvoice.getCustomer(), demoInvoice);
}
Also used : Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) DemoInvoice(org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice)

Example 3 with Paperclip

use of org.incode.module.document.dom.impl.paperclips.Paperclip in project estatio by estatio.

the class InvoiceForLease_sendAbstract method appendPdfBytes.

@Programmatic
public void appendPdfBytes(final Document prelimLetterOrInvoiceDoc, final List<byte[]> pdfBytes) {
    // this one should be a PDF
    appendBytesIfPdf(prelimLetterOrInvoiceDoc, pdfBytes);
    // and any attachments that are PDFs are also merged in
    final List<Paperclip> paperclips = paperclipRepository.findByDocument(prelimLetterOrInvoiceDoc);
    for (Paperclip paperclip : paperclips) {
        final Object objAttachedToDocument = paperclip.getAttachedTo();
        if (objAttachedToDocument instanceof Document) {
            final Document docAttachedToDocument = (Document) objAttachedToDocument;
            appendBytesIfPdf(docAttachedToDocument, pdfBytes);
        }
    }
}
Also used : Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) Document(org.incode.module.document.dom.impl.docs.Document) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with Paperclip

use of org.incode.module.document.dom.impl.paperclips.Paperclip in project estatio by estatio.

the class InvoiceForLease_sendByEmail method choices0$$.

public List<Document> choices0$$() {
    final List<Paperclip> paperclips = paperclipRepository.findByAttachedTo(invoice);
    final List<Document> documents = Lists.newArrayList();
    for (Paperclip paperclip : paperclips) {
        final DocumentAbstract documentAbs = paperclip.getDocument();
        if (!(documentAbs instanceof Document)) {
            continue;
        }
        final Document document = (Document) documentAbs;
        if (document.getState() != DocumentState.RENDERED) {
            continue;
        }
        if (!DocumentTypeData.isPrimaryType(document)) {
            continue;
        }
        final Document_sendByEmail document_email = document_sendByEmail(document);
        if (document_email.disableAct() != null) {
            continue;
        }
        documents.add(document);
    }
    return documents;
}
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) Document_sendByEmail(org.incode.module.communications.dom.mixins.Document_sendByEmail)

Example 5 with Paperclip

use of org.incode.module.document.dom.impl.paperclips.Paperclip in project estatio by estatio.

the class DocumentCommunicationSupportForDocumentsAttachedToDemoInvoice method inferToHeader.

private <T extends CommunicationChannel> void inferToHeader(final Document document, final CommHeaderAbstract<T> header, final CommunicationChannelType channelType) {
    final List<Paperclip> paperclips = paperclipRepository.findByDocument(document);
    for (final Paperclip paperclip : paperclips) {
        final Object attachedTo = paperclip.getAttachedTo();
        if (attachedTo instanceof DemoInvoice) {
            final DemoInvoice invoice = (DemoInvoice) attachedTo;
            addTo(invoice, header, channelType);
        }
    }
}
Also used : Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) DemoInvoice(org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice)

Aggregations

Paperclip (org.incode.module.document.dom.impl.paperclips.Paperclip)15 DocumentAbstract (org.incode.module.document.dom.impl.docs.DocumentAbstract)7 Document (org.incode.module.document.dom.impl.docs.Document)5 DemoInvoice (org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice)4 Action (org.apache.isis.applib.annotation.Action)2 DocumentTypeData (org.estatio.module.invoice.dom.DocumentTypeData)2 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)2 CommChannelRole (org.incode.module.communications.dom.impl.comms.CommChannelRole)2 Communication (org.incode.module.communications.dom.impl.comms.Communication)2 Document_sendByEmail (org.incode.module.communications.dom.mixins.Document_sendByEmail)2 Document_sendByPost (org.incode.module.communications.dom.mixins.Document_sendByPost)2 DocumentType (org.incode.module.document.dom.impl.types.DocumentType)2 DemoObjectWithNotes (org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes)2 Test (org.junit.Test)2 List (java.util.List)1 Objects (java.util.Objects)1 Predicate (java.util.function.Predicate)1 Inject (javax.inject.Inject)1 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)1 Mixin (org.apache.isis.applib.annotation.Mixin)1