Search in sources :

Example 16 with Document

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

the class IncomingDocumentRepository method upsertAndArchive.

@Programmatic
public Document upsertAndArchive(final DocumentType type, final String atPath, final String name, final Blob blob) {
    synchronized (this) {
        Document document = null;
        final List<Document> incomingDocumentsWithSameName = findAllIncomingDocumentsByName(name);
        if (incomingDocumentsWithSameName.size() > 0) {
            document = incomingDocumentsWithSameName.get(0);
        }
        if (document != null) {
            if (Arrays.equals(document.getBlobBytes(), blob.getBytes())) {
                return document;
            }
            // else...
            String prefix = "arch-".concat(clockService.nowAsLocalDateTime().toString("yyyy-MM-dd-HH-mm-ss")).concat("-");
            String archivedName = prefix.concat(document.getName());
            Document archivedDocument = documentService.createForBlob(document.getType(), document.getAtPath(), archivedName, document.getBlob());
            // update blobbytes of document
            document.setBlobBytes(blob.getBytes());
            // attach document to archived document
            paperclipRepository.attach(document, "", archivedDocument);
        } else {
            document = documentService.createForBlob(type, atPath, name, blob);
        }
        return document;
    }
}
Also used : Document(org.incode.module.document.dom.impl.docs.Document) QDocument(org.incode.module.document.dom.impl.docs.QDocument) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 17 with Document

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

the class IncomingDocumentCategorisationStateSubscriber method toInstantiateWhen.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void toInstantiateWhen(IncomingDocumentRepository.UploadDomainEvent ev) {
    switch(ev.getEventPhase()) {
        case EXECUTED:
            final Document document = (Document) ev.getReturnValue();
            stateTransitionService.trigger(document, IncomingDocumentCategorisationStateTransitionType.INSTANTIATE, null, null);
            break;
    }
}
Also used : Document(org.incode.module.document.dom.impl.docs.Document) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 18 with Document

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

the class BankAccount_attachInvoiceAsIbanProof method choices0Act.

public List<Document> choices0Act() {
    final List<Document> documents = Lists.newArrayList();
    final List<IncomingInvoice> invoices = incomingInvoiceRepository.findByBankAccount(bankAccount);
    for (IncomingInvoice invoice : invoices) {
        final List<Document> attachedDocuments = lookupAttachedPdfService.lookupIncomingInvoicePdfsFrom(invoice);
        documents.addAll(attachedDocuments);
    }
    final List<Document> documentsCurrentlyAttachedAsIbanProof = paperclipRepository.findByAttachedToAndRoleName(bankAccount, ROLE_NAME_FOR_IBAN_PROOF).stream().map(Paperclip::getDocument).filter(Document.class::isInstance).map(Document.class::cast).collect(Collectors.toList());
    documents.removeAll(documentsCurrentlyAttachedAsIbanProof);
    return documents;
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Document(org.incode.module.document.dom.impl.docs.Document)

Example 19 with Document

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

the class Task_discardDocument method act.

@Action(domainEvent = Task_categoriseDocumentAsOrder.ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION, cssClassFa = "trash-o")
public Object act(@Nullable final String comment, final boolean goToNext) {
    final Object nextTaskIfAny = nextTaskOrWarnIfRequired(goToNext);
    Document mixinResult = mixin().act(comment);
    return coalesce(nextTaskIfAny, mixinResult);
}
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 20 with Document

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

the class PdfAdvisorForEstatio method determineDocument.

private Document determineDocument(final InstanceKey instanceKey) {
    Document document = determineDocument(instanceKey, IncomingDocAsInvoiceViewModel.class);
    if (document != null) {
        return document;
    }
    document = determineDocument(instanceKey, IncomingDocAsOrderViewModel.class);
    if (document != null) {
        return document;
    }
    return null;
}
Also used : Document(org.incode.module.document.dom.impl.docs.Document) IncomingDocAsOrderViewModel(org.estatio.module.capex.app.order.IncomingDocAsOrderViewModel)

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