Search in sources :

Example 26 with Programmatic

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

the class PaperclipRepository method attach.

// endregion
// region > attach (programmatic)
/**
 * This is an idempotent operation.
 */
@Programmatic
public Paperclip attach(final DocumentAbstract documentAbstract, final String roleName, final Object attachTo) {
    Paperclip paperclip = findByDocumentAndAttachedToAndRoleName(documentAbstract, attachTo, roleName);
    if (paperclip != null) {
        return paperclip;
    }
    final Class<? extends Paperclip> subtype = subtypeClassFor(attachTo);
    paperclip = repositoryService.instantiate(subtype);
    paperclip.setDocument(documentAbstract);
    paperclip.setRoleName(roleName);
    if (documentAbstract instanceof Document) {
        final Document document = (Document) documentAbstract;
        paperclip.setDocumentCreatedAt(document.getCreatedAt());
    }
    if (!repositoryService.isPersistent(attachTo)) {
        transactionService.flushTransaction();
    }
    final Bookmark bookmark = bookmarkService.bookmarkFor(attachTo);
    paperclip.setAttachedTo(attachTo);
    paperclip.setAttachedToStr(bookmark.toString());
    repositoryService.persistAndFlush(paperclip);
    return paperclip;
}
Also used : Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) Document(org.incode.module.document.dom.impl.docs.Document) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 27 with Programmatic

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

the class PaperclipRepository method findByDocumentAndAttachedTo.

// endregion
// region > findByDocumentAndAttachedTo (programmatic)
@Programmatic
public List<Paperclip> findByDocumentAndAttachedTo(final DocumentAbstract<?> document, final Object attachedTo) {
    if (document == null) {
        return null;
    }
    if (attachedTo == null) {
        return null;
    }
    final Bookmark bookmark = bookmarkService.bookmarkFor(attachedTo);
    if (bookmark == null) {
        return null;
    }
    final String attachedToStr = bookmark.toString();
    return repositoryService.allMatches(new QueryDefault<>(Paperclip.class, "findByDocumentAndAttachedTo", "document", document, "attachedToStr", attachedToStr));
}
Also used : Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 28 with Programmatic

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

the class DocumentCreatorService method createDocumentAndAttachPaperclips.

/**
 * Replaced by {@link org.incode.module.document.dom.api.DocumentService#createDocumentAndAttachPaperclips(Object, DocumentTemplate)} as formal API.
 *
 * @param domainObject
 * @param template
 * @return
 */
@Deprecated
@Programmatic
public Document createDocumentAndAttachPaperclips(final Object domainObject, final DocumentTemplate template) {
    final Document createdDocument = template.create(domainObject);
    final List<AttachmentAdvisor.PaperclipSpec> paperclipSpecs = template.newAttachmentAdvice(createdDocument, domainObject);
    for (AttachmentAdvisor.PaperclipSpec paperclipSpec : paperclipSpecs) {
        final String roleName = paperclipSpec.getRoleName();
        final Object attachTo = paperclipSpec.getAttachTo();
        final Document paperclipSpecCreatedDocument = paperclipSpec.getCreatedDocument();
        if (paperclipRepository.canAttach(attachTo)) {
            paperclipRepository.attach(paperclipSpecCreatedDocument, roleName, attachTo);
        }
    }
    return createdDocument;
}
Also used : AttachmentAdvisor(org.incode.module.document.dom.impl.applicability.AttachmentAdvisor) Document(org.incode.module.document.dom.impl.docs.Document) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 29 with Programmatic

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

the class OrderRepository method create.

@Programmatic
public Order create(final Property property, final String orderNumber, final String sellerOrderReference, final LocalDate entryDate, final LocalDate orderDate, final Party seller, final Party buyer, final String atPath, final OrderApprovalState approvalStateIfAny) {
    final Numerator numerator = numeratorRepository.findOrCreateNumerator("Order number", null, "%05d", BigInteger.ZERO, applicationTenancyRepository.findByPath(atPath));
    final Order order = new Order(property, orderNumber == null ? numerator.nextIncrementStr() : orderNumber, sellerOrderReference, entryDate, orderDate, seller, buyer, atPath, approvalStateIfAny);
    serviceRegistry2.injectServicesInto(order);
    repositoryService.persistAndFlush(order);
    return order;
}
Also used : Numerator(org.estatio.module.numerator.dom.Numerator) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 30 with Programmatic

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

the class OrderApprovalStateSubscriber method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(Order.ObjectPersistedEvent ev) {
    // nb: note that the order at this stage has no items attached to it,
    // so there is a limit as to what we can safely do.
    // however, it *is* ok to just create the state chart for the domain object.
    final Order order = ev.getSource();
    OrderApprovalState approvalState = order.getApprovalState();
    if (approvalState == OrderApprovalStateTransitionType.INSTANTIATE.getToState()) {
        // ie was set in the persisting callback
        stateTransitionService.trigger(order, OrderApprovalStateTransitionType.INSTANTIATE, null, null);
    }
}
Also used : Order(org.estatio.module.capex.dom.order.Order) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Programmatic (org.apache.isis.applib.annotation.Programmatic)162 Party (org.estatio.module.party.dom.Party)21 Lease (org.estatio.module.lease.dom.Lease)16 DomainObject (org.apache.isis.applib.annotation.DomainObject)11 BankAccount (org.estatio.module.financial.dom.BankAccount)11 Charge (org.estatio.module.charge.dom.Charge)10 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)10 LocalDate (org.joda.time.LocalDate)10 BigDecimal (java.math.BigDecimal)9 Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)9 ApplicationException (org.apache.isis.applib.ApplicationException)8 Property (org.estatio.module.asset.dom.Property)8 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)8 ArrayList (java.util.ArrayList)7 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)7 InvoiceItem (org.estatio.module.invoice.dom.InvoiceItem)7 LeaseItem (org.estatio.module.lease.dom.LeaseItem)7 Inject (javax.inject.Inject)6 Unit (org.estatio.module.asset.dom.Unit)6 Document (org.incode.module.document.dom.impl.docs.Document)6