use of org.incode.module.document.dom.impl.paperclips.Paperclip in project estatio by estatio.
the class Document_delete method $$.
@Action(semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE, domainEvent = ActionDomainEvent.class)
@ActionLayout(cssClassFa = "trash")
public Object $$() {
List<Object> attachedToList = Lists.newArrayList();
// links from this document to other objects
List<Paperclip> paperclips = paperclipRepository.findByDocument(document);
for (Paperclip paperclip : paperclips) {
final Object attachedTo = paperclip.getAttachedTo();
attachedToList.add(attachedTo);
paperclipRepository.delete(paperclip);
}
// links from other documents to this document
paperclips = paperclipRepository.findByAttachedTo(document);
for (Paperclip paperclip : paperclips) {
paperclipRepository.delete(paperclip);
}
documentRepository.delete(document);
// if was only attached to a single object, then return; otherwise return null.
return attachedToList.size() == 1 ? attachedToList.get(0) : null;
}
use of org.incode.module.document.dom.impl.paperclips.Paperclip in project estatio by estatio.
the class RenderModelFactoryOfDocumentAttachedToDemoInvoice method doNewRendererModel.
@Override
protected Object doNewRendererModel(final DocumentTemplate documentTemplate, final Document document) {
final List<Paperclip> paperclips = paperclipRepository.findByDocument(document);
final DemoInvoice demoInvoice = paperclips.stream().map(Paperclip::getAttachedTo).filter(DemoInvoice.class::isInstance).map(DemoInvoice.class::cast).findFirst().get();
return new DataModel(demoInvoice.getCustomer(), demoInvoice);
}
use of org.incode.module.document.dom.impl.paperclips.Paperclip in project estatio by estatio.
the class InvoiceForLease_sendAbstract method appendPdfBytes.
@Programmatic
public void appendPdfBytes(final Document prelimLetterOrInvoiceDoc, final List<byte[]> pdfBytes) {
// this one should be a PDF
appendBytesIfPdf(prelimLetterOrInvoiceDoc, pdfBytes);
// and any attachments that are PDFs are also merged in
final List<Paperclip> paperclips = paperclipRepository.findByDocument(prelimLetterOrInvoiceDoc);
for (Paperclip paperclip : paperclips) {
final Object objAttachedToDocument = paperclip.getAttachedTo();
if (objAttachedToDocument instanceof Document) {
final Document docAttachedToDocument = (Document) objAttachedToDocument;
appendBytesIfPdf(docAttachedToDocument, pdfBytes);
}
}
}
use of org.incode.module.document.dom.impl.paperclips.Paperclip in project estatio by estatio.
the class InvoiceForLease_sendByEmail method choices0$$.
public List<Document> choices0$$() {
final List<Paperclip> paperclips = paperclipRepository.findByAttachedTo(invoice);
final List<Document> documents = Lists.newArrayList();
for (Paperclip paperclip : paperclips) {
final DocumentAbstract documentAbs = paperclip.getDocument();
if (!(documentAbs instanceof Document)) {
continue;
}
final Document document = (Document) documentAbs;
if (document.getState() != DocumentState.RENDERED) {
continue;
}
if (!DocumentTypeData.isPrimaryType(document)) {
continue;
}
final Document_sendByEmail document_email = document_sendByEmail(document);
if (document_email.disableAct() != null) {
continue;
}
documents.add(document);
}
return documents;
}
use of org.incode.module.document.dom.impl.paperclips.Paperclip in project estatio by estatio.
the class DocumentCommunicationSupportForDocumentsAttachedToDemoInvoice method inferToHeader.
private <T extends CommunicationChannel> void inferToHeader(final Document document, final CommHeaderAbstract<T> header, final CommunicationChannelType channelType) {
final List<Paperclip> paperclips = paperclipRepository.findByDocument(document);
for (final Paperclip paperclip : paperclips) {
final Object attachedTo = paperclip.getAttachedTo();
if (attachedTo instanceof DemoInvoice) {
final DemoInvoice invoice = (DemoInvoice) attachedTo;
addTo(invoice, header, channelType);
}
}
}
Aggregations