Search in sources :

Example 11 with Bookmark

use of org.apache.isis.applib.services.bookmark.Bookmark 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)

Example 12 with Bookmark

use of org.apache.isis.applib.services.bookmark.Bookmark in project estatio by estatio.

the class PropertyOrderingViewModel method viewModelMemento.

@Override
public String viewModelMemento() {
    final Property property = getProperty();
    final Bookmark bookmark = bookmarkService.bookmarkFor(property);
    return bookmark.getIdentifier();
}
Also used : Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) Property(org.estatio.module.asset.dom.Property)

Example 13 with Bookmark

use of org.apache.isis.applib.services.bookmark.Bookmark in project estatio by estatio.

the class NumeratorRepository method createNumerator.

private Numerator createNumerator(final String numeratorName, final Object scopedToIfAny, final String format, final BigInteger lastIncrement, final ApplicationTenancy applicationTenancy) {
    final Numerator numerator = newTransientInstance();
    numerator.setName(numeratorName);
    numerator.setApplicationTenancyPath(applicationTenancy.getPath());
    if (scopedToIfAny != null) {
        final Bookmark bookmark = getBookmarkService().bookmarkFor(scopedToIfAny);
        numerator.setObjectType(bookmark.getObjectType());
        numerator.setObjectIdentifier(bookmark.getIdentifier());
    }
    numerator.setFormat(format);
    numerator.setLastIncrement(lastIncrement);
    persist(numerator);
    return numerator;
}
Also used : Bookmark(org.apache.isis.applib.services.bookmark.Bookmark)

Example 14 with Bookmark

use of org.apache.isis.applib.services.bookmark.Bookmark in project estatio by estatio.

the class PaperclipRepository method findByAttachedToAndRoleName.

// endregion
// region > findByAttachedToAndRoleName (programmatic)
@Programmatic
public List<Paperclip> findByAttachedToAndRoleName(final Object attachedTo, final String roleName) {
    if (attachedTo == null) {
        return null;
    }
    if (roleName == null) {
        return null;
    }
    final Bookmark bookmark = bookmarkService.bookmarkFor(attachedTo);
    if (bookmark == null) {
        return null;
    }
    final String attachedToStr = bookmark.toString();
    return repositoryService.allMatches(new QueryDefault<>(Paperclip.class, "findByAttachedToAndRoleName", "attachedToStr", attachedToStr, "roleName", roleName));
}
Also used : Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 15 with Bookmark

use of org.apache.isis.applib.services.bookmark.Bookmark in project estatio by estatio.

the class PaperclipRepository method findByDocumentAndAttachedToAndRoleName.

// endregion
// region > findByDocumentAndAttachedToAndRoleName (programmatic)
@Programmatic
public Paperclip findByDocumentAndAttachedToAndRoleName(final DocumentAbstract<?> document, final Object attachedTo, final String roleName) {
    if (document == null) {
        return null;
    }
    if (attachedTo == null) {
        return null;
    }
    if (roleName == null) {
        return null;
    }
    final Bookmark bookmark = bookmarkService.bookmarkFor(attachedTo);
    if (bookmark == null) {
        return null;
    }
    final String attachedToStr = bookmark.toString();
    return repositoryService.firstMatch(new QueryDefault<>(Paperclip.class, "findByDocumentAndAttachedToAndRoleName", "document", document, "attachedToStr", attachedToStr, "roleName", roleName));
}
Also used : Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)16 Programmatic (org.apache.isis.applib.annotation.Programmatic)9 Document (org.incode.module.document.dom.impl.docs.Document)3 List (java.util.List)1 ParamDto (org.apache.isis.schema.cmd.v1.ParamDto)1 Property (org.estatio.module.asset.dom.Property)1 IncomingDocAsInvoiceViewModel (org.estatio.module.capex.app.invoice.IncomingDocAsInvoiceViewModel)1 IncomingDocAsOrderViewModel (org.estatio.module.capex.app.order.IncomingDocAsOrderViewModel)1 Taxonomy (org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy)1 FinderInteraction (org.incode.module.unittestsupport.dom.repo.FinderInteraction)1 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)1 Expectations (org.jmock.Expectations)1 Before (org.junit.Before)1