Search in sources :

Example 1 with DocumentType

use of org.incode.module.document.dom.impl.types.DocumentType in project estatio by estatio.

the class DocumentTypeAndTemplatesApplicableForDemoObjectFixture method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    // prereqs
    executionContext.executeChild(this, new RenderingStrategy_create6());
    // these document types have no associated templates (for attachPdf mixin)
    final DocumentType invoiceType = upsertType(DOC_TYPE_REF_TAX_RECEIPT, "Tax receipt", executionContext);
    final DocumentType docType = upsertType(DOC_TYPE_REF_SUPPLIER_RECEIPT, "Supplier receipt", executionContext);
    final DocumentType docTypeForFreemarkerHtml = upsertType(DOC_TYPE_REF_FREEMARKER_HTML, "Demo Freemarker HTML (eg email Cover Note)", executionContext);
    final RenderingStrategy fmkRenderingStrategy = renderingStrategyRepository.findByReference(RenderingStrategy_create6.REF_FMK);
    final RenderingStrategy sipcRenderingStrategy = renderingStrategyRepository.findByReference(RenderingStrategy_create6.REF_SIPC);
    final RenderingStrategy siRenderingStrategy = renderingStrategyRepository.findByReference(RenderingStrategy_create6.REF_SI);
    final RenderingStrategy xdpRenderingStrategy = renderingStrategyRepository.findByReference(RenderingStrategy_create6.REF_XDP);
    final RenderingStrategy xddRenderingStrategy = renderingStrategyRepository.findByReference(RenderingStrategy_create6.REF_XDD);
    final String atPath = "/";
    // 
    // freemarker template, with html
    // 
    final LocalDate now = clockService.now();
    final Clob clob = new Clob(docTypeForFreemarkerHtml.getName(), "text/html", loadResource("FreemarkerHtmlCoverNote.html"));
    fmkTemplate = upsertDocumentClobTemplate(docTypeForFreemarkerHtml, now, atPath, ".html", false, clob, fmkRenderingStrategy, "Freemarker-html-cover-note-for-${demoObject.name}", fmkRenderingStrategy, executionContext);
    mixin(DocumentTemplate._applicable.class, fmkTemplate).applicable(DemoObjectWithUrl.class, FreemarkerModelOfDemoObject.class, ForDemoObjectAttachToSame.class);
    executionContext.addResult(this, fmkTemplate);
    // 
    // template for string interpolator URL
    // 
    final DocumentType docTypeForStringInterpolatorUrl = upsertType(DOC_TYPE_REF_STRINGINTERPOLATOR_URL, "Demo String Interpolator to retrieve URL", executionContext);
    siTemplate = upsertDocumentTextTemplate(docTypeForStringInterpolatorUrl, now, atPath, ".pdf", false, docTypeForStringInterpolatorUrl.getName(), "application/pdf", "${demoObject.url}", sipcRenderingStrategy, "pdf-of-url-held-in-${demoObject.name}", siRenderingStrategy, executionContext);
    mixin(DocumentTemplate._applicable.class, siTemplate).applicable(DemoObjectWithUrl.class, StringInterpolatorRootOfDemoObject.class, ForDemoObjectAttachToSame.class);
    // 
    // template for xdocreport (PDF)
    // 
    final DocumentType docTypeForXDocReportPdf = upsertType(DOC_TYPE_REF_XDOCREPORT_PDF, "Demo XDocReport for PDF", executionContext);
    xdpTemplate = upsertDocumentBlobTemplate(docTypeForXDocReportPdf, now, atPath, ".pdf", false, new Blob(docTypeForXDocReportPdf.getName() + ".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", loadResourceBytes("demoObject-template.docx")), xdpRenderingStrategy, "${demoObject.name}", fmkRenderingStrategy, executionContext);
    mixin(DocumentTemplate._applicable.class, xdpTemplate).applicable(DemoObjectWithUrl.class, XDocReportModelOfDemoObject.class, ForDemoObjectAttachToSame.class);
    // 
    // template for xdocreport (DOCX)
    // 
    final DocumentType docTypeForXDocReportDocx = upsertType(DOC_TYPE_REF_XDOCREPORT_DOC, "Demo XDocReport for DOCX", executionContext);
    xddTemplate = upsertDocumentBlobTemplate(docTypeForXDocReportDocx, now, atPath, ".docx", false, new Blob(docTypeForXDocReportDocx.getName() + ".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", loadResourceBytes("demoObject-template.docx")), xddRenderingStrategy, "${demoObject.name}", fmkRenderingStrategy, executionContext);
    mixin(DocumentTemplate._applicable.class, xddTemplate).applicable(DemoObjectWithUrl.class, XDocReportModelOfDemoObject.class, ForDemoObjectAlsoAttachToFirstOtherObject.class);
}
Also used : Blob(org.apache.isis.applib.value.Blob) RenderingStrategy(org.incode.module.document.dom.impl.rendering.RenderingStrategy) DocumentType(org.incode.module.document.dom.impl.types.DocumentType) Clob(org.apache.isis.applib.value.Clob) LocalDate(org.joda.time.LocalDate)

Example 2 with DocumentType

use of org.incode.module.document.dom.impl.types.DocumentType in project estatio by estatio.

the class DocumentCommunicationSupportForDocumentsAttachedToDemoInvoice method emailCoverNoteDocumentTypeFor.

@Override
public DocumentType emailCoverNoteDocumentTypeFor(final Document document) {
    final DemoInvoice invoice = paperclipRepository.paperclipAttaches(document, DemoInvoice.class);
    if (invoice == null) {
        return null;
    }
    final DocumentType documentType = documentTypeRepository.findByReference(DocumentType_and_DocumentTemplates_createSome.DOC_TYPE_REF_FREEMARKER_HTML);
    return documentType;
}
Also used : DemoInvoice(org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice) DocumentType(org.incode.module.document.dom.impl.types.DocumentType)

Example 3 with DocumentType

use of org.incode.module.document.dom.impl.types.DocumentType in project estatio by estatio.

the class DemoInvoice_simulateRenderAsDoc method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
@ActionLayout(contributed = Contributed.AS_ACTION)
@MemberOrder(name = "documents", sequence = "1")
public Document $$(@Parameter(fileAccept = "application/pdf") final Blob document, @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "File name") final String fileName) throws IOException {
    String name = determineName(document, fileName);
    final DocumentType documentType = findDocumentType(DocumentType_and_DocumentTemplates_createSome.DOC_TYPE_REF_INVOICE);
    final Document receiptDoc = documentRepository.create(documentType, AT_PATH, name, document.getMimeType().getBaseType());
    // unlike documents that are generated from a template (where we call documentTemplate#render), in this case
    // we have the actual bytes; so we just set up the remaining state of the document manually.
    receiptDoc.setRenderedAt(clockService.nowAsDateTime());
    receiptDoc.setState(DocumentState.RENDERED);
    receiptDoc.setSort(DocumentSort.BLOB);
    receiptDoc.setBlobBytes(document.getBytes());
    paperclipRepository.attach(receiptDoc, ROLE_NAME, invoice);
    return receiptDoc;
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType) Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 4 with DocumentType

use of org.incode.module.document.dom.impl.types.DocumentType in project estatio by estatio.

the class DocumentType_and_DocumentTemplates_createSome method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    // these document types have no associated templates
    final DocumentType invoiceType = upsertType(DOC_TYPE_REF_INVOICE, "Demo invoice document type", executionContext);
    final DocumentType docType = upsertType(DOC_TYPE_REF_RECEIPT, "Receipt document type", executionContext);
    // doc type for rendering cover notes.
    final DocumentType docTypeForFreemarkerHtml = upsertType(DOC_TYPE_REF_FREEMARKER_HTML, "Demo Freemarker HTML (eg email Cover Note)", executionContext);
    final RenderingStrategy fmkRenderingStrategy = renderingStrategyRepository.findByReference(RenderingStrategy_create1.REF_FMK);
    final String atPath = "/";
    // 
    // freemarker template, with html
    // 
    final LocalDate now = clockService.now();
    final Clob clob = new Clob(docTypeForFreemarkerHtml.getName(), "text/html", loadResource("FreemarkerHtmlCoverNote.html"));
    fmkTemplate = upsertDocumentClobTemplate(docTypeForFreemarkerHtml, now, atPath, ".html", false, clob, fmkRenderingStrategy, "Freemarker-html-cover-note-for-${demoInvoice.num}", fmkRenderingStrategy, executionContext);
    mixin(DocumentTemplate._applicable.class, fmkTemplate).applicable(Document.class, RenderModelFactoryOfDocumentAttachedToDemoInvoice.class, null);
    executionContext.addResult(this, fmkTemplate);
}
Also used : RenderingStrategy(org.incode.module.document.dom.impl.rendering.RenderingStrategy) DocumentType(org.incode.module.document.dom.impl.types.DocumentType) Clob(org.apache.isis.applib.value.Clob) LocalDate(org.joda.time.LocalDate)

Example 5 with DocumentType

use of org.incode.module.document.dom.impl.types.DocumentType in project estatio by estatio.

the class DocumentTypeAndTemplatesFSForInvoicesUsingSsrs method upsertTemplatesForInvoice.

private void upsertTemplatesForInvoice(final LocalDate templateDate, final ExecutionContext executionContext) {
    final String url = "${reportServerBaseUrl}";
    final RenderingStrategy fmkRenderingStrategy = renderingStrategyRepository.findByReference(RenderingStrategies.REF_FMK);
    final RenderingStrategy sipcRenderingStrategy = renderingStrategyRepository.findByReference(RenderingStrategies.REF_SIPC);
    final RenderingStrategy siRenderingStrategy = renderingStrategyRepository.findByReference(RenderingStrategies.REF_SI);
    // 
    // prelim letter
    // 
    // template for PL cover note
    final DocumentType docTypeForPrelimCoverNote = upsertType(DocumentTypeData.COVER_NOTE_PRELIM_LETTER, executionContext);
    String contentText = loadResource("PrelimLetterEmailCoverNote.html.ftl");
    String subjLneText = loadResource("PrelimLetterEmailCoverNoteSubjectLine.ftl");
    upsertDocumentTemplateForTextHtmlWithApplicability(docTypeForPrelimCoverNote, templateDate, ApplicationTenancy_enum.Global.getPath(), null, contentText, fmkRenderingStrategy, subjLneText, fmkRenderingStrategy, Document.class, FreemarkerModelOfPrelimLetterOrInvoiceDocForEmailCover.class, AttachToNone.class, executionContext);
    contentText = loadResource("PrelimLetterEmailCoverNote-ITA.html.ftl");
    subjLneText = loadResource("PrelimLetterEmailCoverNoteSubjectLine-ITA.ftl");
    upsertDocumentTemplateForTextHtmlWithApplicability(docTypeForPrelimCoverNote, templateDate, ApplicationTenancy_enum.It.getPath(), " (Italy)", contentText, fmkRenderingStrategy, subjLneText, fmkRenderingStrategy, Document.class, FreemarkerModelOfPrelimLetterOrInvoiceDocForEmailCover.class, AttachToNone.class, executionContext);
    // template for PL itself
    final DocumentType docTypeForPrelim = upsertType(DocumentTypeData.PRELIM_LETTER, executionContext);
    String titleText = loadResource("PrelimLetterTitle.ftl");
    upsertTemplateForPdfWithApplicability(docTypeForPrelim, templateDate, ApplicationTenancy_enum.Global.getPath(), null, false, url + "PreliminaryLetterV2" + "&id=${this.id}" + "&rs:Command=Render&rs:Format=PDF", sipcRenderingStrategy, titleText, siRenderingStrategy, Invoice.class, StringInterpolatorToSsrsUrlOfInvoice.class, ForPrimaryDocOfInvoiceAttachToInvoiceAndAnyRelevantSupportingDocuments.class, executionContext);
    // (currently) this is identical to global
    titleText = loadResource("PrelimLetterTitle-ITA.ftl");
    upsertTemplateForPdfWithApplicability(docTypeForPrelim, templateDate, ApplicationTenancy_enum.It.getPath(), " (Italy)", false, url + "PreliminaryLetterV2" + "&id=${this.id}" + "&rs:Command=Render&rs:Format=PDF", sipcRenderingStrategy, titleText, siRenderingStrategy, Invoice.class, StringInterpolatorToSsrsUrlOfInvoice.class, ForPrimaryDocOfInvoiceAttachToInvoiceAndAnyRelevantSupportingDocuments.class, executionContext);
    // 
    // invoice
    // 
    // template for invoice cover note
    final DocumentType docTypeForInvoiceCoverNote = upsertType(DocumentTypeData.COVER_NOTE_INVOICE, executionContext);
    contentText = loadResource("InvoiceEmailCoverNote.html.ftl");
    subjLneText = loadResource("InvoiceEmailCoverNoteSubjectLine.ftl");
    upsertDocumentTemplateForTextHtmlWithApplicability(docTypeForInvoiceCoverNote, templateDate, ApplicationTenancy_enum.Global.getPath(), null, contentText, fmkRenderingStrategy, subjLneText, fmkRenderingStrategy, Document.class, FreemarkerModelOfPrelimLetterOrInvoiceDocForEmailCover.class, AttachToNone.class, executionContext);
    contentText = loadResource("InvoiceEmailCoverNote-ITA.html.ftl");
    subjLneText = loadResource("InvoiceEmailCoverNoteSubjectLine-ITA.ftl");
    upsertDocumentTemplateForTextHtmlWithApplicability(docTypeForInvoiceCoverNote, templateDate, ApplicationTenancy_enum.It.getPath(), " (Italy)", contentText, fmkRenderingStrategy, subjLneText, fmkRenderingStrategy, Document.class, FreemarkerModelOfPrelimLetterOrInvoiceDocForEmailCover.class, AttachToNone.class, executionContext);
    // template for invoice itself
    final DocumentType docTypeForInvoice = upsertType(DocumentTypeData.INVOICE, executionContext);
    titleText = loadResource("InvoiceTitle.ftl");
    upsertTemplateForPdfWithApplicability(docTypeForInvoice, templateDate, ApplicationTenancy_enum.Global.getPath(), null, false, url + "InvoiceItaly" + "&id=${this.id}" + "&rs:Command=Render&rs:Format=PDF", sipcRenderingStrategy, titleText, siRenderingStrategy, Invoice.class, StringInterpolatorToSsrsUrlOfInvoice.class, ForPrimaryDocOfInvoiceAttachToInvoiceAndAnyRelevantSupportingDocuments.class, executionContext);
    // (currently) this is identical to global
    titleText = loadResource("InvoiceTitle-ITA.ftl");
    upsertTemplateForPdfWithApplicability(docTypeForInvoice, templateDate, ApplicationTenancy_enum.It.getPath(), "( Italy)", false, url + "InvoiceItaly" + "&id=${this.id}" + "&rs:Command=Render&rs:Format=PDF", sipcRenderingStrategy, titleText, siRenderingStrategy, Invoice.class, StringInterpolatorToSsrsUrlOfInvoice.class, ForPrimaryDocOfInvoiceAttachToInvoiceAndAnyRelevantSupportingDocuments.class, executionContext);
    // 
    // document types without any templates
    // (used to attach supporting documents to invoice)
    // 
    upsertType(DocumentTypeData.SUPPLIER_RECEIPT, executionContext);
    upsertType(DocumentTypeData.TAX_REGISTER, executionContext);
    upsertType(DocumentTypeData.SPECIAL_COMMUNICATION, executionContext);
    upsertType(DocumentTypeData.CALCULATION, executionContext);
}
Also used : RenderingStrategy(org.incode.module.document.dom.impl.rendering.RenderingStrategy) DocumentType(org.incode.module.document.dom.impl.types.DocumentType)

Aggregations

DocumentType (org.incode.module.document.dom.impl.types.DocumentType)13 Action (org.apache.isis.applib.annotation.Action)4 Blob (org.apache.isis.applib.value.Blob)3 RenderingStrategy (org.incode.module.document.dom.impl.rendering.RenderingStrategy)3 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)2 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)2 Clob (org.apache.isis.applib.value.Clob)2 DocumentTemplate (org.incode.module.document.dom.impl.docs.DocumentTemplate)2 Paperclip (org.incode.module.document.dom.impl.paperclips.Paperclip)2 LocalDate (org.joda.time.LocalDate)2 List (java.util.List)1 Objects (java.util.Objects)1 Predicate (java.util.function.Predicate)1 Inject (javax.inject.Inject)1 Mixin (org.apache.isis.applib.annotation.Mixin)1 Parameter (org.apache.isis.applib.annotation.Parameter)1 SemanticsOf (org.apache.isis.applib.annotation.SemanticsOf)1 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)1 BankAccount (org.estatio.module.financial.dom.BankAccount)1 DocumentTypeData (org.estatio.module.invoice.dom.DocumentTypeData)1