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;
}
}
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;
}
}
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;
}
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);
}
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;
}
Aggregations