use of org.incode.module.document.dom.impl.docs.Document 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;
}
use of org.incode.module.document.dom.impl.docs.Document 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;
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class InvoiceSummaryForPropertyDueDateStatus_sendAbstract method appendTuplesToSend.
private void appendTuplesToSend(final Invoice invoice, final Predicate<InvoiceAndDocument> filter, final List<InvoiceAndDocument> invoiceAndDocuments) {
final CommunicationChannel sendTo = invoice.getSendTo();
if (sendTo == null) {
return;
}
final CommunicationChannelType channelType = sendTo.getType();
if (channelType != communicationChannelType) {
return;
}
final Document document = findMostRecentAttachedTo(invoice, getDocumentType());
if (document == null) {
return;
}
if (document.getState() == DocumentState.NOT_RENDERED) {
return;
}
if (invoiceDocAndCommService.findFirstCommunication(document) != null) {
return;
}
final InvoiceAndDocument invoiceAndDocument = new InvoiceAndDocument(invoice, document);
if (!filter.apply(invoiceAndDocument)) {
return;
}
invoiceAndDocuments.add(invoiceAndDocument);
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class InvoiceSummaryForPropertyDueDateStatus_sendByPostAbstract method $$.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public Blob $$(final String fileName) throws IOException {
final List<byte[]> pdfBytes = Lists.newArrayList();
for (final InvoiceAndDocument invoiceAndDocument : invoiceAndDocumentsToSend()) {
final Invoice invoice = invoiceAndDocument.getInvoice();
final Document prelimLetterOrInvoiceNote = invoiceAndDocument.getDocument();
final InvoiceForLease_sendByPost invoice_sendByPost = invoice_sendByPost(invoice);
final PostalAddress postalAddress = invoice_sendByPost.default1$$(prelimLetterOrInvoiceNote);
invoice_sendByPost.createPostalCommunicationAsSent(prelimLetterOrInvoiceNote, postalAddress);
invoice_sendByPost.appendPdfBytes(prelimLetterOrInvoiceNote, pdfBytes);
}
final byte[] mergedBytes = pdfBoxService.merge(pdfBytes.toArray(new byte[][] {}));
return new Blob(fileName, DocumentConstants.MIME_TYPE_APPLICATION_PDF, mergedBytes);
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class DocAndCommAbstract_download method act.
@Action(semantics = SemanticsOf.SAFE, invokeOn = InvokeOn.OBJECT_ONLY)
@ActionLayout(contributed = Contributed.AS_ACTION)
public Blob act() throws IOException {
final List<byte[]> pdfBytes = Lists.newArrayList();
final Document document = getDocument();
appendBytes(document, pdfBytes);
final List<Document> supportingDocs = attachmentsProvider.attachmentsFor(document);
for (Document supportingDoc : supportingDocs) {
appendBytes(supportingDoc, pdfBytes);
}
final byte[] mergedBytes = pdfBoxService.merge(pdfBytes.toArray(new byte[][] {}));
return new Blob(fileName, MIME_TYPE_APPLICATION_PDF, mergedBytes);
}
Aggregations