Search in sources :

Example 21 with Action

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

the class Document_delete method $$.

@Action(semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE, domainEvent = ActionDomainEvent.class)
@ActionLayout(cssClassFa = "trash")
public Object $$() {
    List<Object> attachedToList = Lists.newArrayList();
    // links from this document to other objects
    List<Paperclip> paperclips = paperclipRepository.findByDocument(document);
    for (Paperclip paperclip : paperclips) {
        final Object attachedTo = paperclip.getAttachedTo();
        attachedToList.add(attachedTo);
        paperclipRepository.delete(paperclip);
    }
    // links from other documents to this document
    paperclips = paperclipRepository.findByAttachedTo(document);
    for (Paperclip paperclip : paperclips) {
        paperclipRepository.delete(paperclip);
    }
    documentRepository.delete(document);
    // if was only attached to a single object, then return; otherwise return null.
    return attachedToList.size() == 1 ? attachedToList.get(0) : null;
}
Also used : Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 22 with Action

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

the class FakeScheduler method runBackgroundCommands.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
public void runBackgroundCommands(@ParameterLayout(named = "Wait for (ms)") final Integer waitFor) throws InterruptedException {
    List<CommandJdo> commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted();
    if (commands.isEmpty()) {
        throw new IllegalStateException("There are no commands not yet started");
    }
    transactionService.nextTransaction();
    BackgroundCommandExecutionFromBackgroundCommandServiceJdo backgroundExec = new BackgroundCommandExecutionFromBackgroundCommandServiceJdo();
    final SimpleSession session = new SimpleSession("scheduler_user", new String[] { "admin_role" });
    final Thread thread = new Thread(() -> backgroundExec.execute(session, null));
    thread.start();
    thread.join(waitFor);
    commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted();
    if (!commands.isEmpty()) {
        throw new IllegalStateException("There are still " + commands.size() + " not yet started");
    }
}
Also used : CommandJdo(org.isisaddons.module.command.dom.CommandJdo) BackgroundCommandExecutionFromBackgroundCommandServiceJdo(org.isisaddons.module.command.dom.BackgroundCommandExecutionFromBackgroundCommandServiceJdo) SimpleSession(org.apache.isis.core.runtime.authentication.standard.SimpleSession) Action(org.apache.isis.applib.annotation.Action)

Example 23 with Action

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

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

the class Order_recategorize method act.

@Action(semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(cssClassFa = "mail-reply", cssClass = "btn-danger")
public Document act(@Nullable final String comment) {
    Document document = lookupPdf();
    document.setType(DocumentTypeData.INCOMING.findUsing(documentTypeRepository));
    stateTransitionService.trigger(document, IncomingDocumentCategorisationStateTransition.class, IncomingDocumentCategorisationStateTransitionType.RESET, comment, null);
    // use events to cascade delete, eg paperclips and state transitions/tasks
    orderRepository.delete(order);
    return document;
}
Also used : Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 25 with Action

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

the class Occupancy method remove.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE, domainEvent = Occupancy.RemoveEvent.class)
public Object remove() {
    Lease lease = getLease();
    remove(this);
    return lease;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) 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