Search in sources :

Example 1 with IncomingDocAsInvoiceViewModel

use of org.estatio.module.capex.app.invoice.IncomingDocAsInvoiceViewModel 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();
    }
}
Also used : Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) IncomingDocAsInvoiceViewModel(org.estatio.module.capex.app.invoice.IncomingDocAsInvoiceViewModel) Document(org.incode.module.document.dom.impl.docs.Document) IncomingDocAsOrderViewModel(org.estatio.module.capex.app.order.IncomingDocAsOrderViewModel)

Aggregations

Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)1 IncomingDocAsInvoiceViewModel (org.estatio.module.capex.app.invoice.IncomingDocAsInvoiceViewModel)1 IncomingDocAsOrderViewModel (org.estatio.module.capex.app.order.IncomingDocAsOrderViewModel)1 Document (org.incode.module.document.dom.impl.docs.Document)1