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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations