use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class PdfAdvisorForEstatio method bookmarkFor.
private String bookmarkFor(final InstanceKey instanceKey) {
Document document = determineDocument(instanceKey);
InstanceKey.TypeKey typeKey = instanceKey.getTypeKey();
String objectType = typeKey.getObjectType();
if (Objects.equals(objectType, IncomingDocAsInvoiceViewModel.class.getName())) {
String identifier = instanceKey.getIdentifier();
final String xmlStr = urlEncodingService.decode(identifier);
IncomingDocAsInvoiceViewModel viewModel = jaxbService.fromXml(IncomingDocAsInvoiceViewModel.class, xmlStr);
final Bookmark bookmark = bookmarkService2.bookmarkFor(viewModel.getDocument());
if (bookmark != null)
return "incomingInvoiceViewModel:" + bookmark.getIdentifier();
else {
// object presumably deleted
return null;
}
} else if (Objects.equals(objectType, IncomingDocAsOrderViewModel.class.getName())) {
String identifier = instanceKey.getIdentifier();
final String xmlStr = urlEncodingService.decode(identifier);
IncomingDocAsOrderViewModel viewModel = jaxbService.fromXml(IncomingDocAsOrderViewModel.class, xmlStr);
final Bookmark bookmark = bookmarkService2.bookmarkFor(viewModel.getDocument());
if (bookmark != null)
return "incomingOrderViewModel:" + bookmark.getIdentifier();
else {
// object presumably deleted
return null;
}
} else {
return instanceKey.asBookmark().toString();
}
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class InvoiceSummaryForPropertyDueDateStatus_actionAbstract method findMostRecentAttachedTo.
Document findMostRecentAttachedTo(final Invoice invoice, final DocumentType documentType) {
final List<Paperclip> paperclips = paperclipRepository.findByAttachedTo(invoice);
for (Paperclip paperclip : paperclips) {
final DocumentAbstract documentAbstract = paperclip.getDocument();
if (!(documentAbstract instanceof Document)) {
continue;
}
final Document document = (Document) documentAbstract;
if (document.getType() == documentType) {
return document;
}
}
return null;
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class InvoiceSummaryForPropertyDueDateStatus_sendByEmailAbstract method $$.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public InvoiceSummaryForPropertyDueDateStatus $$() throws IOException {
final List<InvoiceAndDocument> invoiceAndDocuments = invoiceAndDocumentsToSend();
for (InvoiceAndDocument invoiceAndDocument : invoiceAndDocuments) {
final Invoice invoice = invoiceAndDocument.getInvoice();
final Document document = invoiceAndDocument.getDocument();
final InvoiceForLease_sendByEmail invoice_sendByEmail = invoice_email(invoice);
final EmailAddress emailAddress = invoice_sendByEmail.default1$$(document);
final String cc = invoice_sendByEmail.default2$$(document);
final String bcc = invoice_sendByEmail.default5$$(document);
invoice_sendByEmail.$$(document, emailAddress, cc, null, null, bcc, null);
}
return this.invoiceSummary;
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class ForPrimaryDocOfInvoiceAttachToInvoiceAndAnyRelevantSupportingDocuments method doAdvise.
@Override
protected List<AttachmentAdvisor.PaperclipSpec> doAdvise(final DocumentTemplate documentTemplate, final Invoice invoice, final Document createdDocument) {
final List<PaperclipSpec> paperclipSpecs = Lists.newArrayList();
paperclipSpecs.add(new PaperclipSpec(null, invoice, createdDocument));
// not every supporting doc type supports each type of primary document
// for example, TAX_REGISTER supports invoices (but not PLs), whereas CALCULATION is other way around.
// we therefore need to filter the supporting documents that we find attached to the invoice.
//
// to start with, we get hold of the set of doc type (data)s that _do_ support the primary doc just created
DocumentTypeData primaryDocTypeData = DocumentTypeData.docTypeDataFor(createdDocument);
List<DocumentTypeData> supportingDocTypeDatasForThisPrimaryDoc = DocumentTypeData.supports(primaryDocTypeData);
// copy over all relevant supporting attached to this primary document (invoice or prelim letter)
final List<Paperclip> paperclips = paperclipRepository.findByAttachedTo(invoice);
for (Paperclip paperclip : paperclips) {
if (PaperclipRoleNames.SUPPORTING_DOCUMENT.equals(paperclip.getRoleName())) {
final DocumentAbstract supportingDocAbs = paperclip.getDocument();
if (supportingDocAbs instanceof Document) {
final Document supportingDoc = (Document) supportingDocAbs;
final DocumentTypeData supportingDocTypeData = DocumentTypeData.docTypeDataFor(supportingDoc);
// (and here is where filter out to only attach those that are relevant)
if (supportingDocTypeDatasForThisPrimaryDoc.contains(supportingDocTypeData)) {
// note that the supporting documents point to the primary doc, rather than the other way around
paperclipSpecs.add(new PaperclipSpec(PaperclipRoleNames.INVOICE_DOCUMENT_SUPPORTED_BY, createdDocument, supportingDoc));
}
}
}
}
return paperclipSpecs;
}
use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.
the class InvoiceForLease_sendByPostPrelimLetterOrInvoiceDocAbstract method $$.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT, domainEvent = DomainEvent.class)
@ActionLayout(contributed = Contributed.AS_ACTION)
public Blob $$(@ParameterLayout(named = "to:") final PostalAddress toChannel) throws IOException {
final Document document = findDocument();
createPostalCommunicationAsSent(document, toChannel);
final byte[] mergedBytes = mergePdfBytes(document);
final String fileName = document.getName();
return new Blob(fileName, DocumentConstants.MIME_TYPE_APPLICATION_PDF, mergedBytes);
}
Aggregations