Search in sources :

Example 26 with ActionLayout

use of org.apache.isis.applib.annotation.ActionLayout 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)

Example 27 with ActionLayout

use of org.apache.isis.applib.annotation.ActionLayout in project estatio by estatio.

the class Communication_downloadPdfForPosting method act.

@Action(semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(named = "Download PDF for posting", cssClassFa = "download")
public Blob act(@ParameterLayout(named = "File name") final String fileName) throws IOException {
    // the act of downloading implicitly sends the communication
    if (communication.getState() == CommunicationState.PENDING) {
        communication.sent();
    }
    final List<byte[]> pdfBytes = Lists.newArrayList();
    final Document primaryDoc = communication.getPrimaryDocument();
    appendBytes(primaryDoc, pdfBytes);
    // merge any and all attachments
    final List<Document> attachedDocuments = findAttachedPdfDocuments();
    attachedDocuments.sort(Ordering.natural().onResultOf(Document::getCreatedAt));
    for (final Document attachedDoc : attachedDocuments) {
        appendBytes(attachedDoc, pdfBytes);
    }
    final byte[] mergedBytes = pdfBoxService.merge(pdfBytes.toArray(new byte[][] {}));
    return new Blob(fileName, DocumentConstants.MIME_TYPE_APPLICATION_PDF, mergedBytes);
}
Also used : Document_downloadExternalUrlAsBlob(org.incode.module.document.dom.impl.docs.Document_downloadExternalUrlAsBlob) Blob(org.apache.isis.applib.value.Blob) Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 28 with ActionLayout

use of org.apache.isis.applib.annotation.ActionLayout in project estatio by estatio.

the class Document_sendByPost method act.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT, domainEvent = ActionDomainEvent.class)
@ActionLayout(cssClassFa = "envelope-o", contributed = Contributed.AS_ACTION)
public Communication act(@ParameterLayout(named = "to:") final PostalAddress toChannel) 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 comm and correspondents
    final String atPath = document.getAtPath();
    final String subject = document.getName();
    final Communication communication = communicationRepository.createPostal(subject, atPath, toChannel);
    transactionService.flushTransaction();
    // 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 original document
    final List<Document> communicationAttachments = attachmentProvider.attachmentsFor(document);
    for (Document communicationAttachment : communicationAttachments) {
        paperclipRepository.attach(communicationAttachment, DocumentConstants.PAPERCLIP_ROLE_ATTACHMENT, communication);
    }
    transactionService.flushTransaction();
    return communication;
}
Also used : 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)

Example 29 with ActionLayout

use of org.apache.isis.applib.annotation.ActionLayout in project estatio by estatio.

the class EstatioSecurityModuleFixturesMenu method installFixturesAndReturnFirstRole.

// //////////////////////////////////////
@Action(semantics = SemanticsOf.NON_IDEMPOTENT, restrictTo = RestrictTo.PROTOTYPING)
@ActionLayout(cssClassFa = "fa-bolt")
@MemberOrder(sequence = "20")
public Object installFixturesAndReturnFirstRole() {
    final List<FixtureResult> fixtureResultList = fixtureScripts.findFixtureScriptFor(EstatioSecurityModuleSeedFixture.class).run(null);
    for (FixtureResult fixtureResult : fixtureResultList) {
        final Object object = fixtureResult.getObject();
        if (object instanceof ApplicationRole) {
            return object;
        }
    }
    container.warnUser("No rules found in fixture; returning all results");
    return fixtureResultList;
}
Also used : FixtureResult(org.apache.isis.applib.fixturescripts.FixtureResult) ApplicationRole(org.isisaddons.module.security.dom.role.ApplicationRole) EstatioSecurityModuleSeedFixture(org.estatio.module.base.seed.EstatioSecurityModuleSeedFixture) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 30 with ActionLayout

use of org.apache.isis.applib.annotation.ActionLayout 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)

Aggregations

ActionLayout (org.apache.isis.applib.annotation.ActionLayout)62 Action (org.apache.isis.applib.annotation.Action)61 Document (org.incode.module.document.dom.impl.docs.Document)22 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)14 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)9 WorksheetSpec (org.isisaddons.module.excel.dom.WorksheetSpec)7 Blob (org.apache.isis.applib.value.Blob)6 ArrayList (java.util.ArrayList)5 WorksheetContent (org.isisaddons.module.excel.dom.WorksheetContent)5 DocumentTemplate (org.incode.module.document.dom.impl.docs.DocumentTemplate)3 DomainObject (org.apache.isis.applib.annotation.DomainObject)2 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)2 PartitionItem (org.estatio.module.budget.dom.partioning.PartitionItem)2 IncomingDocViewModel (org.estatio.module.capex.app.document.IncomingDocViewModel)2 Invoice (org.estatio.module.invoice.dom.Invoice)2 Lease (org.estatio.module.lease.dom.Lease)2 Organisation (org.estatio.module.party.dom.Organisation)2 DocumentType (org.incode.module.document.dom.impl.types.DocumentType)2 LocalDate (org.joda.time.LocalDate)2 LocalDateTime (org.joda.time.LocalDateTime)2