Search in sources :

Example 11 with DocumentTemplate

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

the class DocumentTemplateForAtPathService method documentTemplatesForCreateAndAttach.

@Programmatic
public List<DocumentTemplate> documentTemplatesForCreateAndAttach(final Object domainObject) {
    final List<DocumentTemplate> templates = Lists.newArrayList();
    final String atPath = atPathFor(domainObject);
    if (atPath == null) {
        return templates;
    }
    final List<DocumentTemplate> templatesForPath = documentTemplateRepository.findByApplicableToAtPath(atPath);
    return Lists.newArrayList(templatesForPath.stream().filter(template -> {
        final AttachmentAdvisor advisor = template.newAttachmentAdvisor(domainObject);
        if (advisor == null) {
            return false;
        }
        // at this stage we are asking the advisor if it would be able to attach a document
        // if created.  We don't yet have that document, so it is null.
        final Document document = null;
        final List<AttachmentAdvisor.PaperclipSpec> paperclipSpecs = advisor.advise(template, domainObject, document);
        return canCreate(template, paperclipSpecs);
    }).collect(Collectors.toList()));
}
Also used : AttachmentAdvisor(org.incode.module.document.dom.impl.applicability.AttachmentAdvisor) DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) Document(org.incode.module.document.dom.impl.docs.Document) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

DocumentTemplate (org.incode.module.document.dom.impl.docs.DocumentTemplate)11 Action (org.apache.isis.applib.annotation.Action)4 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)4 Document (org.incode.module.document.dom.impl.docs.Document)3 Applicability (org.incode.module.document.dom.impl.applicability.Applicability)2 DocumentType (org.incode.module.document.dom.impl.types.DocumentType)2 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)1 Clob (org.apache.isis.applib.value.Clob)1 Invoice (org.estatio.module.invoice.dom.Invoice)1 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)1 InvoiceForLease_backgroundPrepare (org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_backgroundPrepare)1 Communication (org.incode.module.communications.dom.impl.comms.Communication)1 AttachmentAdvisor (org.incode.module.document.dom.impl.applicability.AttachmentAdvisor)1