Search in sources :

Example 1 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class IncomingInvoice_switchView method act.

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(contributed = Contributed.AS_ACTION, // not sure why this isn't being picked up from isis-non-changing.properties
cssClassFa = "fa-exchange")
@MemberOrder(sequence = "1")
public IncomingDocAsInvoiceViewModel act() {
    Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(incomingInvoice);
    // guaranteed to return, hidden if none
    Document document = documentIfAny.get();
    final IncomingDocAsInvoiceViewModel viewModel = new IncomingDocAsInvoiceViewModel(incomingInvoice, document);
    serviceRegistry2.injectServicesInto(viewModel);
    viewModel.init();
    return viewModel;
}
Also used : 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 2 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class T_createAndAttachDocumentAndScheduleRender method $$.

/**
 * Create a {@link Document} and attach using a {@link Paperclip}.
 */
@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.NON_IDEMPOTENT)
@ActionLayout(contributed = Contributed.AS_ACTION)
@MemberOrder(name = "documents", sequence = "3.2")
public Object $$(final DocumentTemplate template) throws IOException {
    final Document document = documentCreatorService.createDocumentAndAttachPaperclips(domainObject, template);
    render(template, document);
    return document;
}
Also used : 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 3 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class Paperclip method getDocumentDate.

/**
 * Either the {@link Document#getCreatedAt()} or {@link Document#getRenderedAt()}, depending upon the
 * {@link Document#getState()} of the {@link Document}.  Returns <tt>null</tt> for {@link DocumentTemplate}s.
 */
@NotPersistent
@Property(domainEvent = DocumentDateDomainEvent.class, editing = Editing.DISABLED)
public DateTime getDocumentDate() {
    final DocumentAbstract documentAbstract = getDocument();
    if (documentAbstract instanceof Document) {
        final Document document = (Document) documentAbstract;
        DocumentState state = document.getState();
        return state.dateOf(document);
    }
    return null;
}
Also used : DocumentAbstract(org.incode.module.document.dom.impl.docs.DocumentAbstract) DocumentState(org.incode.module.document.dom.impl.docs.DocumentState) Document(org.incode.module.document.dom.impl.docs.Document) NotPersistent(javax.jdo.annotations.NotPersistent) Property(org.apache.isis.applib.annotation.Property)

Example 4 with Document

use of org.incode.module.document.dom.impl.docs.Document 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 5 with Document

use of org.incode.module.document.dom.impl.docs.Document 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)

Aggregations

Document (org.incode.module.document.dom.impl.docs.Document)57 Action (org.apache.isis.applib.annotation.Action)23 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)22 Programmatic (org.apache.isis.applib.annotation.Programmatic)8 Blob (org.apache.isis.applib.value.Blob)7 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)7 DocumentAbstract (org.incode.module.document.dom.impl.docs.DocumentAbstract)7 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)5 Paperclip (org.incode.module.document.dom.impl.paperclips.Paperclip)5 IncomingDocumentCategorisationStateTransition (org.estatio.module.capex.dom.documents.categorisation.IncomingDocumentCategorisationStateTransition)4 Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)3 BuyerFinder (org.estatio.module.capex.dom.documents.BuyerFinder)3 Communication (org.incode.module.communications.dom.impl.comms.Communication)3 DocumentTemplate (org.incode.module.document.dom.impl.docs.DocumentTemplate)3 Expectations (org.jmock.Expectations)3 TitleBuffer (org.apache.isis.applib.util.TitleBuffer)2 IncomingDocAsOrderViewModel (org.estatio.module.capex.app.order.IncomingDocAsOrderViewModel)2 Order (org.estatio.module.capex.dom.order.Order)2 BankAccount (org.estatio.module.financial.dom.BankAccount)2 DocumentTypeData (org.estatio.module.invoice.dom.DocumentTypeData)2