Search in sources :

Example 1 with DocumentTemplate

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

the class DocumentTemplateFSAbstract method upsertDocumentTextTemplate.

protected DocumentTemplate upsertDocumentTextTemplate(final DocumentType documentType, final LocalDate date, final String atPath, final String fileSuffix, final boolean previewOnly, final String name, final String mimeType, final String contentText, final RenderingStrategy contentRenderingStrategy, final String nameText, final RenderingStrategy nameRenderingStrategy, final ExecutionContext executionContext) {
    DocumentTemplate documentTemplate = documentTemplateRepository.findByTypeAndAtPathAndDate(documentType, atPath, date);
    if (documentTemplate != null) {
        documentTemplate.setFileSuffix(fileSuffix);
        documentTemplate.setPreviewOnly(previewOnly);
        documentTemplate.setName(name);
        documentTemplate.setMimeType(mimeType);
        documentTemplate.setText(contentText);
        documentTemplate.setContentRenderingStrategy(contentRenderingStrategy);
        documentTemplate.setNameText(nameText);
        documentTemplate.setNameRenderingStrategy(nameRenderingStrategy);
    } else {
        documentTemplate = documentTemplateRepository.createText(documentType, date, atPath, fileSuffix, previewOnly, name, mimeType, contentText, contentRenderingStrategy, nameText, nameRenderingStrategy);
    }
    return executionContext.addResult(this, documentTemplate);
}
Also used : DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate)

Example 2 with DocumentTemplate

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

the class DocumentTemplateFSAbstract method upsertDocumentBlobTemplate.

protected DocumentTemplate upsertDocumentBlobTemplate(final DocumentType documentType, final LocalDate date, final String atPath, final String fileSuffix, final boolean previewOnly, final Blob blob, 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.modifyBlob(blob);
        documentTemplate.setContentRenderingStrategy(contentRenderingStrategy);
        documentTemplate.setNameText(nameText);
        documentTemplate.setNameRenderingStrategy(nameRenderingStrategy);
    } else {
        documentTemplate = documentTemplateRepository.createBlob(documentType, date, atPath, fileSuffix, previewOnly, blob, contentRenderingStrategy, nameText, nameRenderingStrategy);
    }
    return executionContext.addResult(this, documentTemplate);
}
Also used : DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate)

Example 3 with DocumentTemplate

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

the class InvoiceSummaryForPropertyDueDateStatus_backgroundPrepareAbstract method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public InvoiceSummaryForPropertyDueDateStatus $$() throws IOException {
    final List<InvoiceForLease> invoices = invoicesToPrepare();
    for (Invoice invoice : invoices) {
        final DocumentTemplate documentTemplate = documentTemplateFor(invoice);
        factoryService.mixin(InvoiceForLease_backgroundPrepare.class, invoice).$$(documentTemplate);
    }
    return this.invoiceSummary;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) InvoiceForLease_backgroundPrepare(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_backgroundPrepare) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 4 with DocumentTemplate

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

the class DocumentTypeAndTemplatesFSForInvoicesUsingSsrs method upsertDocumentTemplateForTextHtmlWithApplicability.

private void upsertDocumentTemplateForTextHtmlWithApplicability(final DocumentType docType, final LocalDate templateDate, final String atPath, final String nameSuffixIfAny, final String contentText, final RenderingStrategy contentRenderingStrategy, final String nameText, final RenderingStrategy nameRenderingStrategy, final Class<?> domainClass, final Class<? extends RendererModelFactory> rendererModelFactoryClass, final Class<? extends AttachmentAdvisor> attachmentAdvisorClass, final ExecutionContext executionContext) {
    final Clob clob = new Clob(buildTemplateName(docType, nameSuffixIfAny, ".html"), "text/html", contentText);
    final DocumentTemplate documentTemplate = upsertDocumentClobTemplate(docType, templateDate, atPath, ".html", false, clob, contentRenderingStrategy, nameText, nameRenderingStrategy, executionContext);
    mixin(DocumentTemplate._applicable.class, documentTemplate).applicable(domainClass, rendererModelFactoryClass, attachmentAdvisorClass);
    // TODO: push down to incode document; for now this is a work-around that the 'DocumentTemplate#applicable' mixin isn't a full 'upsert'
    final Applicability applicability = existingApplicability(documentTemplate, domainClass.getName());
    applicability.setRendererModelFactoryClassName(rendererModelFactoryClass.getName());
    applicability.setAttachmentAdvisorClassName(attachmentAdvisorClass.getName());
    executionContext.addResult(this, documentTemplate);
}
Also used : DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) Applicability(org.incode.module.document.dom.impl.applicability.Applicability) Clob(org.apache.isis.applib.value.Clob)

Example 5 with DocumentTemplate

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

the class DocumentTemplate_cloneWhenText method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
@ActionLayout(named = "Clone", contributed = Contributed.AS_ACTION)
public DocumentTemplate $$(@Parameter(maxLength = NameType.Meta.MAX_LEN) @ParameterLayout(named = "Name") final String name, final ApplicationTenancy applicationTenancy, @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "Date") final LocalDate date, @ParameterLayout(named = "Text", multiLine = DocumentModule.Constants.TEXT_MULTILINE) final String templateText, @ParameterLayout(named = "Content rendering strategy") final RenderingStrategy contentRenderingStrategy, @Parameter(maxLength = DocumentTemplate.NameTextType.Meta.MAX_LEN) final String nameText, @ParameterLayout(named = "Name rendering strategy") final RenderingStrategy nameRenderingStrategy, @ParameterLayout(named = "Preview only?") final boolean previewOnly) {
    final DocumentType type = documentTemplate.getType();
    final String mimeType = documentTemplate.getMimeType();
    final String fileSuffix = documentTemplate.getFileSuffix();
    final DocumentTemplate template = documentTemplateRepository.createText(type, date, applicationTenancy.getPath(), fileSuffix, previewOnly, name, mimeType, templateText, contentRenderingStrategy, nameText, nameRenderingStrategy);
    final DocumentTemplate._applicable template_applicable = factoryService.mixin(DocumentTemplate._applicable.class, template);
    for (Applicability applicability : documentTemplate.getAppliesTo()) {
        template_applicable.applicable(applicability.getDomainClassName(), applicability.getRendererModelFactoryClassName(), applicability.getAttachmentAdvisorClassName());
    }
    return template;
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType) DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) TranslatableString(org.apache.isis.applib.services.i18n.TranslatableString) Applicability(org.incode.module.document.dom.impl.applicability.Applicability) 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