Search in sources :

Example 6 with DocumentTemplate

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

the class InvoiceForLease_prepareAbstract method $$.

@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public Invoice $$() throws IOException {
    final DocumentTemplate template = documentTemplateFor(invoiceForLease);
    final Document document = documentCreatorService.createDocumentAndAttachPaperclips(invoiceForLease, template);
    document.render(template, invoiceForLease);
    return invoiceForLease;
}
Also used : DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 7 with DocumentTemplate

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

the class DocumentTemplateFSAbstract method upsertDocumentClobTemplate.

protected DocumentTemplate upsertDocumentClobTemplate(final DocumentType documentType, final LocalDate date, final String atPath, final String fileSuffix, final boolean previewOnly, final Clob clob, final RenderingStrategy contentRenderingStrategy, final String nameText, final RenderingStrategy nameRenderingStrategy, ExecutionContext executionContext) {
    DocumentTemplate documentTemplate = documentTemplateRepository.findByTypeAndAtPathAndDate(documentType, atPath, date);
    if (documentTemplate != null) {
        documentTemplate.setFileSuffix(fileSuffix);
        documentTemplate.setPreviewOnly(previewOnly);
        documentTemplate.modifyClob(clob);
        documentTemplate.setContentRenderingStrategy(contentRenderingStrategy);
        documentTemplate.setNameText(nameText);
        documentTemplate.setNameRenderingStrategy(nameRenderingStrategy);
    } else {
        documentTemplate = documentTemplateRepository.createClob(documentType, date, atPath, fileSuffix, previewOnly, clob, contentRenderingStrategy, nameText, nameRenderingStrategy);
    }
    return executionContext.addResult(this, documentTemplate);
}
Also used : DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate)

Example 8 with DocumentTemplate

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

the class Invoice_DocumentManagement_IntegTest method findDocumentTemplateFor.

DocumentTemplate findDocumentTemplateFor(final DocumentTypeData documentTypeData, final Invoice invoice) {
    final DocumentType documentType = documentTypeData.findUsing(documentTypeRepository);
    assertThat(documentType).isNotNull();
    DocumentTemplate documentTemplate = documentTemplateRepository.findFirstByTypeAndApplicableToAtPath(documentType, invoice.getApplicationTenancyPath());
    assertThat(documentType).isNotNull();
    return documentTemplate;
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType) DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate)

Example 9 with DocumentTemplate

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

the class DocumentTypeAndTemplatesFSForInvoicesUsingSsrs method upsertTemplateForPdfWithApplicability.

private DocumentTemplate upsertTemplateForPdfWithApplicability(final DocumentType documentType, final LocalDate templateDate, final String atPath, final String templateNameSuffixIfAny, final boolean previewOnly, final String contentText, final RenderingStrategy contentRenderingStrategy, final String nameText, final RenderingStrategy nameRenderingStrategy, final Class<?> applicableToClass, final Class<? extends RendererModelFactory> rendererModelFactoryClass, final Class<? extends AttachmentAdvisor> attachmentAdvisorClass, final ExecutionContext executionContext) {
    final DocumentTemplate template = upsertTemplateForPdf(documentType, templateDate, atPath, templateNameSuffixIfAny, previewOnly, contentText, contentRenderingStrategy, nameText, nameRenderingStrategy, executionContext);
    mixin(DocumentTemplate._applicable.class, template).applicable(applicableToClass, rendererModelFactoryClass, attachmentAdvisorClass);
    return template;
}
Also used : DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate)

Example 10 with DocumentTemplate

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

the class Document_sendByEmail method act.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT, domainEvent = ActionDomainEvent.class)
@ActionLayout(cssClassFa = "at", contributed = Contributed.AS_ACTION)
public Communication act(@ParameterLayout(named = "to:") final EmailAddress toChannel, @Parameter(optionality = Optionality.OPTIONAL, maxLength = CommunicationChannel.EmailType.Meta.MAX_LEN, regexPattern = CommunicationChannel.EmailType.Meta.REGEX, regexPatternReplacement = CommunicationChannel.EmailType.Meta.REGEX_DESC) @ParameterLayout(named = "cc:") final String cc, @Parameter(optionality = Optionality.OPTIONAL, maxLength = CommunicationChannel.EmailType.Meta.MAX_LEN, regexPattern = CommunicationChannel.EmailType.Meta.REGEX, regexPatternReplacement = CommunicationChannel.EmailType.Meta.REGEX_DESC) @ParameterLayout(named = "cc (2):") final String cc2, @Parameter(optionality = Optionality.OPTIONAL, maxLength = CommunicationChannel.EmailType.Meta.MAX_LEN, regexPattern = CommunicationChannel.EmailType.Meta.REGEX, regexPatternReplacement = CommunicationChannel.EmailType.Meta.REGEX_DESC) @ParameterLayout(named = "cc (3):") final String cc3, @Parameter(optionality = Optionality.OPTIONAL, maxLength = CommunicationChannel.EmailType.Meta.MAX_LEN, regexPattern = CommunicationChannel.EmailType.Meta.REGEX, regexPatternReplacement = CommunicationChannel.EmailType.Meta.REGEX_DESC) @ParameterLayout(named = "bcc:") final String bcc, @Parameter(optionality = Optionality.OPTIONAL, maxLength = CommunicationChannel.EmailType.Meta.MAX_LEN, regexPattern = CommunicationChannel.EmailType.Meta.REGEX, regexPatternReplacement = CommunicationChannel.EmailType.Meta.REGEX_DESC) @ParameterLayout(named = "bcc (2):") final String bcc2) throws IOException {
    if (this.document.getState() == DocumentState.NOT_RENDERED) {
        // this shouldn't happen, but want to fail-fast in case a future programmer calls this directly
        throw new IllegalArgumentException("Document is not yet rendered");
    }
    // create cover note
    // 
    // nb: there is a presumption is that the cover note will not be automatically attached to any other objects,
    // ie its AttachmentAdvisor should be AttachToNone.
    final DocumentTemplate coverNoteTemplate = determineEmailCoverNoteTemplate();
    final Document coverNoteDoc = documentCreatorService.createDocumentAndAttachPaperclips(this.document, coverNoteTemplate);
    coverNoteDoc.render(coverNoteTemplate, this.document);
    // create comm and correspondents
    final String atPath = document.getAtPath();
    final String subject = stripFileExtensionIfAny(coverNoteDoc.getName());
    final Communication communication = communicationRepository.createEmail(subject, atPath, toChannel, cc, cc2, cc3, bcc, bcc2);
    transactionService.flushTransaction();
    // manually attach the cover note to the comm
    paperclipRepository.attach(coverNoteDoc, DocumentConstants.PAPERCLIP_ROLE_COVER, communication);
    // also attach this "primary" document to the comm
    paperclipRepository.attach(this.document, DocumentConstants.PAPERCLIP_ROLE_PRIMARY, communication);
    // also copy over as attachments to the comm anything else also attached to primary document
    final List<Document> communicationAttachments = attachmentProvider.attachmentsFor(document);
    for (Document communicationAttachment : communicationAttachments) {
        paperclipRepository.attach(communicationAttachment, DocumentConstants.PAPERCLIP_ROLE_ATTACHMENT, communication);
    }
    transactionService.flushTransaction();
    // finally, schedule the email to be sent
    communication.scheduleSend();
    return communication;
}
Also used : DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) Document(org.incode.module.document.dom.impl.docs.Document) Communication(org.incode.module.communications.dom.impl.comms.Communication) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

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