Search in sources :

Example 16 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class DocumentAbstract method getId.

// endregion
// region > id (programmatic, for comparison)
@Programmatic
public String getId() {
    Object objectId = JDOHelper.getObjectId(this);
    if (objectId == null) {
        return "";
    }
    String objectIdStr = objectId.toString();
    final String id = objectIdStr.split("\\[OID\\]")[0];
    return id;
}
Also used : DomainObject(org.apache.isis.applib.annotation.DomainObject) TranslatableString(org.apache.isis.applib.services.i18n.TranslatableString) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 17 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class DocumentTemplate method newAttachmentAdvisor.

@Programmatic
public AttachmentAdvisor newAttachmentAdvisor(final Object domainObject) {
    final Class<?> domainObjectClass = domainObject.getClass();
    final com.google.common.base.Optional<Applicability> applicabilityIfAny = FluentIterable.from(getAppliesTo()).filter(applicability -> applies(applicability, domainObjectClass)).first();
    if (!applicabilityIfAny.isPresent()) {
        return null;
    }
    final AttachmentAdvisor attachmentAdvisor = (AttachmentAdvisor) classService.instantiate(applicabilityIfAny.get().getAttachmentAdvisorClassName());
    serviceRegistry2.injectServicesInto(attachmentAdvisor);
    return attachmentAdvisor;
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType) EventHandler(org.axonframework.eventhandling.annotation.EventHandler) SortedSet(java.util.SortedSet) FqcnType(org.incode.module.document.dom.types.FqcnType) URL(java.net.URL) RendererFromCharsToCharsWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromCharsToCharsWithPreviewToUrl) Unique(javax.jdo.annotations.Unique) StringUtils(org.apache.commons.lang3.StringUtils) JDOHelper(javax.jdo.JDOHelper) Collection(org.apache.isis.applib.annotation.Collection) DomainObjectLayout(org.apache.isis.applib.annotation.DomainObjectLayout) ActionLayout(org.apache.isis.applib.annotation.ActionLayout) TitleService(org.apache.isis.applib.services.title.TitleService) FluentIterable(com.google.common.collect.FluentIterable) ApplicationException(org.apache.isis.applib.ApplicationException) IdentityType(javax.jdo.annotations.IdentityType) FactoryService(org.apache.isis.applib.services.factory.FactoryService) ClassNameViewModel(org.incode.module.document.dom.services.ClassNameViewModel) Blob(org.apache.isis.applib.value.Blob) RendererModelFactory(org.incode.module.document.dom.impl.applicability.RendererModelFactory) TranslatableString(org.apache.isis.applib.services.i18n.TranslatableString) ServiceRegistry2(org.apache.isis.applib.services.registry.ServiceRegistry2) Applicability(org.incode.module.document.dom.impl.applicability.Applicability) RendererFromCharsToBytes(org.incode.module.document.dom.impl.renderers.RendererFromCharsToBytes) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ApplicabilityRepository(org.incode.module.document.dom.impl.applicability.ApplicabilityRepository) List(java.util.List) DomainObject(org.apache.isis.applib.annotation.DomainObject) RendererFromCharsToChars(org.incode.module.document.dom.impl.renderers.RendererFromCharsToChars) TransactionService(org.apache.isis.applib.services.xactn.TransactionService) DocumentModule(org.incode.module.document.DocumentModule) AttachmentAdvisorAttachToNone(org.incode.module.document.dom.impl.applicability.AttachmentAdvisorAttachToNone) Clob(org.apache.isis.applib.value.Clob) Setter(lombok.Setter) PersistenceCapable(javax.jdo.annotations.PersistenceCapable) Renderer(org.incode.module.document.dom.impl.renderers.Renderer) AtPathType(org.incode.module.document.dom.types.AtPathType) Getter(lombok.Getter) Column(javax.jdo.annotations.Column) DomainService(org.apache.isis.applib.annotation.DomainService) TreeSet(java.util.TreeSet) Programmatic(org.apache.isis.applib.annotation.Programmatic) AttachmentAdvisor(org.incode.module.document.dom.impl.applicability.AttachmentAdvisor) AttachmentAdvisorClassNameService(org.incode.module.document.dom.spi.AttachmentAdvisorClassNameService) Inject(javax.inject.Inject) Indices(javax.jdo.annotations.Indices) Uniques(javax.jdo.annotations.Uniques) Inheritance(javax.jdo.annotations.Inheritance) Subscribe(com.google.common.eventbus.Subscribe) Parameter(org.apache.isis.applib.annotation.Parameter) RenderingStrategy(org.incode.module.document.dom.impl.rendering.RenderingStrategy) Queries(javax.jdo.annotations.Queries) Action(org.apache.isis.applib.annotation.Action) NatureOfService(org.apache.isis.applib.annotation.NatureOfService) Property(org.apache.isis.applib.annotation.Property) RendererFromBytesToBytes(org.incode.module.document.dom.impl.renderers.RendererFromBytesToBytes) RendererFromBytesToBytesWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromBytesToBytesWithPreviewToUrl) RendererFromCharsToBytesWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromCharsToBytesWithPreviewToUrl) IOException(java.io.IOException) Where(org.apache.isis.applib.annotation.Where) InheritanceStrategy(javax.jdo.annotations.InheritanceStrategy) AbstractSubscriber(org.apache.isis.applib.AbstractSubscriber) BookmarkPolicy(org.apache.isis.applib.annotation.BookmarkPolicy) LocalDate(org.joda.time.LocalDate) Mixin(org.apache.isis.applib.annotation.Mixin) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) Editing(org.apache.isis.applib.annotation.Editing) RendererFromBytesToChars(org.incode.module.document.dom.impl.renderers.RendererFromBytesToChars) RendererFromBytesToCharsWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromBytesToCharsWithPreviewToUrl) ParameterLayout(org.apache.isis.applib.annotation.ParameterLayout) RendererModelFactoryClassNameService(org.incode.module.document.dom.spi.RendererModelFactoryClassNameService) Index(javax.jdo.annotations.Index) Contributed(org.apache.isis.applib.annotation.Contributed) BackgroundService2(org.apache.isis.applib.services.background.BackgroundService2) ClassService(org.incode.module.document.dom.services.ClassService) AttachmentAdvisor(org.incode.module.document.dom.impl.applicability.AttachmentAdvisor) Applicability(org.incode.module.document.dom.impl.applicability.Applicability) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 18 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class DocumentTemplate method newRendererModelFactory.

@Programmatic
public RendererModelFactory newRendererModelFactory(final Object domainObject) {
    final Class<?> domainObjectClass = domainObject.getClass();
    final com.google.common.base.Optional<Applicability> applicabilityIfAny = FluentIterable.from(getAppliesTo()).filter(applicability -> applies(applicability, domainObjectClass)).first();
    if (!applicabilityIfAny.isPresent()) {
        return null;
    }
    final RendererModelFactory rendererModelFactory = (RendererModelFactory) classService.instantiate(applicabilityIfAny.get().getRendererModelFactoryClassName());
    serviceRegistry2.injectServicesInto(rendererModelFactory);
    return rendererModelFactory;
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType) EventHandler(org.axonframework.eventhandling.annotation.EventHandler) SortedSet(java.util.SortedSet) FqcnType(org.incode.module.document.dom.types.FqcnType) URL(java.net.URL) RendererFromCharsToCharsWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromCharsToCharsWithPreviewToUrl) Unique(javax.jdo.annotations.Unique) StringUtils(org.apache.commons.lang3.StringUtils) JDOHelper(javax.jdo.JDOHelper) Collection(org.apache.isis.applib.annotation.Collection) DomainObjectLayout(org.apache.isis.applib.annotation.DomainObjectLayout) ActionLayout(org.apache.isis.applib.annotation.ActionLayout) TitleService(org.apache.isis.applib.services.title.TitleService) FluentIterable(com.google.common.collect.FluentIterable) ApplicationException(org.apache.isis.applib.ApplicationException) IdentityType(javax.jdo.annotations.IdentityType) FactoryService(org.apache.isis.applib.services.factory.FactoryService) ClassNameViewModel(org.incode.module.document.dom.services.ClassNameViewModel) Blob(org.apache.isis.applib.value.Blob) RendererModelFactory(org.incode.module.document.dom.impl.applicability.RendererModelFactory) TranslatableString(org.apache.isis.applib.services.i18n.TranslatableString) ServiceRegistry2(org.apache.isis.applib.services.registry.ServiceRegistry2) Applicability(org.incode.module.document.dom.impl.applicability.Applicability) RendererFromCharsToBytes(org.incode.module.document.dom.impl.renderers.RendererFromCharsToBytes) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ApplicabilityRepository(org.incode.module.document.dom.impl.applicability.ApplicabilityRepository) List(java.util.List) DomainObject(org.apache.isis.applib.annotation.DomainObject) RendererFromCharsToChars(org.incode.module.document.dom.impl.renderers.RendererFromCharsToChars) TransactionService(org.apache.isis.applib.services.xactn.TransactionService) DocumentModule(org.incode.module.document.DocumentModule) AttachmentAdvisorAttachToNone(org.incode.module.document.dom.impl.applicability.AttachmentAdvisorAttachToNone) Clob(org.apache.isis.applib.value.Clob) Setter(lombok.Setter) PersistenceCapable(javax.jdo.annotations.PersistenceCapable) Renderer(org.incode.module.document.dom.impl.renderers.Renderer) AtPathType(org.incode.module.document.dom.types.AtPathType) Getter(lombok.Getter) Column(javax.jdo.annotations.Column) DomainService(org.apache.isis.applib.annotation.DomainService) TreeSet(java.util.TreeSet) Programmatic(org.apache.isis.applib.annotation.Programmatic) AttachmentAdvisor(org.incode.module.document.dom.impl.applicability.AttachmentAdvisor) AttachmentAdvisorClassNameService(org.incode.module.document.dom.spi.AttachmentAdvisorClassNameService) Inject(javax.inject.Inject) Indices(javax.jdo.annotations.Indices) Uniques(javax.jdo.annotations.Uniques) Inheritance(javax.jdo.annotations.Inheritance) Subscribe(com.google.common.eventbus.Subscribe) Parameter(org.apache.isis.applib.annotation.Parameter) RenderingStrategy(org.incode.module.document.dom.impl.rendering.RenderingStrategy) Queries(javax.jdo.annotations.Queries) Action(org.apache.isis.applib.annotation.Action) NatureOfService(org.apache.isis.applib.annotation.NatureOfService) Property(org.apache.isis.applib.annotation.Property) RendererFromBytesToBytes(org.incode.module.document.dom.impl.renderers.RendererFromBytesToBytes) RendererFromBytesToBytesWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromBytesToBytesWithPreviewToUrl) RendererFromCharsToBytesWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromCharsToBytesWithPreviewToUrl) IOException(java.io.IOException) Where(org.apache.isis.applib.annotation.Where) InheritanceStrategy(javax.jdo.annotations.InheritanceStrategy) AbstractSubscriber(org.apache.isis.applib.AbstractSubscriber) BookmarkPolicy(org.apache.isis.applib.annotation.BookmarkPolicy) LocalDate(org.joda.time.LocalDate) Mixin(org.apache.isis.applib.annotation.Mixin) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) Editing(org.apache.isis.applib.annotation.Editing) RendererFromBytesToChars(org.incode.module.document.dom.impl.renderers.RendererFromBytesToChars) RendererFromBytesToCharsWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromBytesToCharsWithPreviewToUrl) ParameterLayout(org.apache.isis.applib.annotation.ParameterLayout) RendererModelFactoryClassNameService(org.incode.module.document.dom.spi.RendererModelFactoryClassNameService) Index(javax.jdo.annotations.Index) Contributed(org.apache.isis.applib.annotation.Contributed) BackgroundService2(org.apache.isis.applib.services.background.BackgroundService2) ClassService(org.incode.module.document.dom.services.ClassService) Applicability(org.incode.module.document.dom.impl.applicability.Applicability) RendererModelFactory(org.incode.module.document.dom.impl.applicability.RendererModelFactory) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 19 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class DocumentTemplate method renderContent.

// endregion
// region > renderContent (programmatic)
@Programmatic
public void renderContent(final Document document, final Object contentDataModel) {
    final String variant = "content";
    final String documentName = document.getName();
    try {
        final DocumentNature inputNature = getContentRenderingStrategy().getInputNature();
        final DocumentNature outputNature = getContentRenderingStrategy().getOutputNature();
        final Renderer renderer = getContentRenderingStrategy().newRenderer();
        switch(inputNature) {
            case BYTES:
                switch(outputNature) {
                    case BYTES:
                        final byte[] renderedBytes = ((RendererFromBytesToBytes) renderer).renderBytesToBytes(getType(), variant, getAtPath(), getVersion(), asBytes(), contentDataModel);
                        final Blob blob = new Blob(documentName, getMimeType(), renderedBytes);
                        document.modifyBlob(blob);
                        return;
                    case CHARACTERS:
                        final String renderedChars = ((RendererFromBytesToChars) renderer).renderBytesToChars(getType(), variant, getAtPath(), getVersion(), asBytes(), contentDataModel);
                        if (renderedChars.length() <= TextType.Meta.MAX_LEN) {
                            document.setTextData(getName(), getMimeType(), renderedChars);
                        } else {
                            final Clob clob = new Clob(documentName, getMimeType(), renderedChars);
                            document.modifyClob(clob);
                        }
                        return;
                    default:
                        // shouldn't happen, above switch statement is complete
                        throw new IllegalArgumentException(String.format("Unknown output DocumentNature '%s'", outputNature));
                }
            case CHARACTERS:
                switch(outputNature) {
                    case BYTES:
                        final byte[] renderedBytes = ((RendererFromCharsToBytes) renderer).renderCharsToBytes(getType(), variant, getAtPath(), getVersion(), asChars(), contentDataModel);
                        final Blob blob = new Blob(documentName, getMimeType(), renderedBytes);
                        document.modifyBlob(blob);
                        return;
                    case CHARACTERS:
                        final String renderedChars = ((RendererFromCharsToChars) renderer).renderCharsToChars(getType(), variant, getAtPath(), getVersion(), asChars(), contentDataModel);
                        if (renderedChars.length() <= TextType.Meta.MAX_LEN) {
                            document.setTextData(getName(), getMimeType(), renderedChars);
                        } else {
                            final Clob clob = new Clob(documentName, getMimeType(), renderedChars);
                            document.modifyClob(clob);
                        }
                        return;
                    default:
                        // shouldn't happen, above switch statement is complete
                        throw new IllegalArgumentException(String.format("Unknown output DocumentNature '%s'", outputNature));
                }
            default:
                // shouldn't happen, above switch statement is complete
                throw new IllegalArgumentException(String.format("Unknown input DocumentNature '%s'", inputNature));
        }
    } catch (IOException e) {
        throw new ApplicationException("Unable to render document template", e);
    }
}
Also used : Blob(org.apache.isis.applib.value.Blob) RendererFromCharsToChars(org.incode.module.document.dom.impl.renderers.RendererFromCharsToChars) TranslatableString(org.apache.isis.applib.services.i18n.TranslatableString) RendererFromCharsToBytes(org.incode.module.document.dom.impl.renderers.RendererFromCharsToBytes) IOException(java.io.IOException) RendererFromBytesToChars(org.incode.module.document.dom.impl.renderers.RendererFromBytesToChars) RendererFromBytesToBytes(org.incode.module.document.dom.impl.renderers.RendererFromBytesToBytes) ApplicationException(org.apache.isis.applib.ApplicationException) Renderer(org.incode.module.document.dom.impl.renderers.Renderer) Clob(org.apache.isis.applib.value.Clob) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 20 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class DocumentTemplate method preview.

// endregion
// region > preview (programmatic)
@Programmatic
public URL preview(final Object rendererModel) throws IOException {
    serviceRegistry2.injectServicesInto(rendererModel);
    if (!getContentRenderingStrategy().isPreviewsToUrl()) {
        throw new IllegalStateException(String.format("RenderingStrategy '%s' does not support previewing to URL", getContentRenderingStrategy().getReference()));
    }
    final DocumentNature inputNature = getContentRenderingStrategy().getInputNature();
    final DocumentNature outputNature = getContentRenderingStrategy().getOutputNature();
    final Renderer renderer = getContentRenderingStrategy().newRenderer();
    switch(inputNature) {
        case BYTES:
            switch(outputNature) {
                case BYTES:
                    return ((RendererFromBytesToBytesWithPreviewToUrl) renderer).previewBytesToBytes(getType(), getAtPath(), getVersion(), asBytes(), rendererModel);
                case CHARACTERS:
                    return ((RendererFromBytesToCharsWithPreviewToUrl) renderer).previewBytesToChars(getType(), getAtPath(), getVersion(), asBytes(), rendererModel);
                default:
                    // shouldn't happen, above switch statement is complete
                    throw new IllegalArgumentException(String.format("Unknown output DocumentNature '%s'", outputNature));
            }
        case CHARACTERS:
            switch(outputNature) {
                case BYTES:
                    return ((RendererFromCharsToBytesWithPreviewToUrl) renderer).previewCharsToBytes(getType(), getAtPath(), getVersion(), asChars(), rendererModel);
                case CHARACTERS:
                    return ((RendererFromCharsToCharsWithPreviewToUrl) renderer).previewCharsToChars(getType(), getAtPath(), getVersion(), asChars(), rendererModel);
                default:
                    // shouldn't happen, above switch statement is complete
                    throw new IllegalArgumentException(String.format("Unknown output DocumentNature '%s'", outputNature));
            }
        default:
            // shouldn't happen, above switch statement is complete
            throw new IllegalArgumentException(String.format("Unknown input DocumentNature '%s'", inputNature));
    }
}
Also used : RendererFromCharsToCharsWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromCharsToCharsWithPreviewToUrl) RendererFromBytesToBytesWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromBytesToBytesWithPreviewToUrl) RendererFromBytesToCharsWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromBytesToCharsWithPreviewToUrl) RendererFromCharsToBytesWithPreviewToUrl(org.incode.module.document.dom.impl.renderers.RendererFromCharsToBytesWithPreviewToUrl) Renderer(org.incode.module.document.dom.impl.renderers.Renderer) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Programmatic (org.apache.isis.applib.annotation.Programmatic)162 Party (org.estatio.module.party.dom.Party)21 Lease (org.estatio.module.lease.dom.Lease)16 DomainObject (org.apache.isis.applib.annotation.DomainObject)11 BankAccount (org.estatio.module.financial.dom.BankAccount)11 Charge (org.estatio.module.charge.dom.Charge)10 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)10 LocalDate (org.joda.time.LocalDate)10 BigDecimal (java.math.BigDecimal)9 Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)9 ApplicationException (org.apache.isis.applib.ApplicationException)8 Property (org.estatio.module.asset.dom.Property)8 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)8 ArrayList (java.util.ArrayList)7 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)7 InvoiceItem (org.estatio.module.invoice.dom.InvoiceItem)7 LeaseItem (org.estatio.module.lease.dom.LeaseItem)7 Inject (javax.inject.Inject)6 Unit (org.estatio.module.asset.dom.Unit)6 Document (org.incode.module.document.dom.impl.docs.Document)6