Search in sources :

Example 51 with Action

use of org.apache.isis.applib.annotation.Action 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 52 with Action

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

the class CommunicationChannelOwner_findCommunications method act.

@Action(semantics = SemanticsOf.SAFE, domainEvent = ActionDomainEvent.class)
public List<Communication> act(final LocalDate from, final LocalDate to) {
    final DateTime fromDateTime = toDateTime(from);
    final DateTime toDateTime = toDateTime(to).plusDays(1);
    final List<CommunicationChannelOwnerLink> channelLinks = communicationChannelRepository.findByOwner(communicationChannelOwner);
    final List<Communication> communications = Lists.newArrayList();
    for (final CommunicationChannelOwnerLink link : channelLinks) {
        final List<Communication> comms = communicationRepository.findByCommunicationChannelAndPendingOrCreatedAtBetween(link.getCommunicationChannel(), fromDateTime, toDateTime);
        communications.addAll(comms);
    }
    communications.sort(Communication.Orderings.createdAtDescending);
    return communications;
}
Also used : DateTime(org.joda.time.DateTime) Communication(org.incode.module.communications.dom.impl.comms.Communication) Action(org.apache.isis.applib.annotation.Action)

Example 53 with Action

use of org.apache.isis.applib.annotation.Action 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 54 with Action

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

the class KeyTable method generateItems.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
public KeyTable generateItems() {
    // delete old items
    for (Iterator<KeyItem> it = this.getItems().iterator(); it.hasNext(); ) {
        it.next().deleteBudgetKeyItem();
    }
    /*
        create list of input pairs: identifier - sourcevalue
        sourcevalue is determined by FoundationValueType
        */
    List<Distributable> input = new ArrayList<>();
    for (Unit unit : unitRepository.findByProperty(this.getBudget().getProperty())) {
        if (unitIntervalValidForThisKeyTable(unit)) {
            BigDecimal sourceValue;
            if (getFoundationValueType().valueOf(unit) != null) {
                sourceValue = getFoundationValueType().valueOf(unit);
            } else {
                sourceValue = BigDecimal.ZERO;
            }
            KeyItem newItem = new KeyItem();
            newItem.setSourceValue(sourceValue);
            newItem.setValue(BigDecimal.ZERO);
            newItem.setUnit(unit);
            newItem.setKeyTable(this);
            persistIfNotAlready(newItem);
            input.add(newItem);
        }
    }
    /*
        call distribute method
         */
    DistributionService distributionService = new DistributionService();
    distributionService.distribute(input, getKeyValueMethod().divider(this), getPrecision());
    return this;
}
Also used : Distributable(org.estatio.module.budget.dom.Distributable) ArrayList(java.util.ArrayList) KeyItem(org.estatio.module.budget.dom.keyitem.KeyItem) Unit(org.estatio.module.asset.dom.Unit) BigDecimal(java.math.BigDecimal) DistributionService(org.estatio.module.budget.dom.DistributionService) Action(org.apache.isis.applib.annotation.Action)

Example 55 with Action

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

the class KeyTable method remove.

@Action(semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE)
public Budget remove() {
    Budget budgetToReturn = getBudget();
    repositoryService.removeAndFlush(this);
    return budgetToReturn;
}
Also used : Budget(org.estatio.module.budget.dom.budget.Budget) Action(org.apache.isis.applib.annotation.Action)

Aggregations

Action (org.apache.isis.applib.annotation.Action)117 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)63 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)31 Document (org.incode.module.document.dom.impl.docs.Document)23 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)12 ArrayList (java.util.ArrayList)11 Blob (org.apache.isis.applib.value.Blob)10 WorksheetSpec (org.isisaddons.module.excel.dom.WorksheetSpec)10 LocalDate (org.joda.time.LocalDate)9 WorksheetContent (org.isisaddons.module.excel.dom.WorksheetContent)8 DomainObject (org.apache.isis.applib.annotation.DomainObject)6 DateTime (org.joda.time.DateTime)6 List (java.util.List)5 SemanticsOf (org.apache.isis.applib.annotation.SemanticsOf)5 PaymentBatch (org.estatio.module.capex.dom.payment.PaymentBatch)5 BankAccount (org.estatio.module.financial.dom.BankAccount)5 Lease (org.estatio.module.lease.dom.Lease)5 Organisation (org.estatio.module.party.dom.Organisation)5 BigDecimal (java.math.BigDecimal)4 Collectors (java.util.stream.Collectors)4