Search in sources :

Example 1 with Applicability

use of org.incode.module.document.dom.impl.applicability.Applicability 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 2 with Applicability

use of org.incode.module.document.dom.impl.applicability.Applicability 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 3 with Applicability

use of org.incode.module.document.dom.impl.applicability.Applicability in project estatio by estatio.

the class DocumentTypeAndTemplatesFSForInvoicesUsingSsrs method upsertDocumentTemplateForTextHtmlWithApplicability.

private void upsertDocumentTemplateForTextHtmlWithApplicability(final DocumentType docType, final LocalDate templateDate, final String atPath, final String nameSuffixIfAny, final String contentText, final RenderingStrategy contentRenderingStrategy, final String nameText, final RenderingStrategy nameRenderingStrategy, final Class<?> domainClass, final Class<? extends RendererModelFactory> rendererModelFactoryClass, final Class<? extends AttachmentAdvisor> attachmentAdvisorClass, final ExecutionContext executionContext) {
    final Clob clob = new Clob(buildTemplateName(docType, nameSuffixIfAny, ".html"), "text/html", contentText);
    final DocumentTemplate documentTemplate = upsertDocumentClobTemplate(docType, templateDate, atPath, ".html", false, clob, contentRenderingStrategy, nameText, nameRenderingStrategy, executionContext);
    mixin(DocumentTemplate._applicable.class, documentTemplate).applicable(domainClass, rendererModelFactoryClass, attachmentAdvisorClass);
    // TODO: push down to incode document; for now this is a work-around that the 'DocumentTemplate#applicable' mixin isn't a full 'upsert'
    final Applicability applicability = existingApplicability(documentTemplate, domainClass.getName());
    applicability.setRendererModelFactoryClassName(rendererModelFactoryClass.getName());
    applicability.setAttachmentAdvisorClassName(attachmentAdvisorClass.getName());
    executionContext.addResult(this, documentTemplate);
}
Also used : DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) Applicability(org.incode.module.document.dom.impl.applicability.Applicability) Clob(org.apache.isis.applib.value.Clob)

Example 4 with Applicability

use of org.incode.module.document.dom.impl.applicability.Applicability in project estatio by estatio.

the class DocumentTemplate_cloneWhenText method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
@ActionLayout(named = "Clone", contributed = Contributed.AS_ACTION)
public DocumentTemplate $$(@Parameter(maxLength = NameType.Meta.MAX_LEN) @ParameterLayout(named = "Name") final String name, final ApplicationTenancy applicationTenancy, @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "Date") final LocalDate date, @ParameterLayout(named = "Text", multiLine = DocumentModule.Constants.TEXT_MULTILINE) final String templateText, @ParameterLayout(named = "Content rendering strategy") final RenderingStrategy contentRenderingStrategy, @Parameter(maxLength = DocumentTemplate.NameTextType.Meta.MAX_LEN) final String nameText, @ParameterLayout(named = "Name rendering strategy") final RenderingStrategy nameRenderingStrategy, @ParameterLayout(named = "Preview only?") final boolean previewOnly) {
    final DocumentType type = documentTemplate.getType();
    final String mimeType = documentTemplate.getMimeType();
    final String fileSuffix = documentTemplate.getFileSuffix();
    final DocumentTemplate template = documentTemplateRepository.createText(type, date, applicationTenancy.getPath(), fileSuffix, previewOnly, name, mimeType, templateText, contentRenderingStrategy, nameText, nameRenderingStrategy);
    final DocumentTemplate._applicable template_applicable = factoryService.mixin(DocumentTemplate._applicable.class, template);
    for (Applicability applicability : documentTemplate.getAppliesTo()) {
        template_applicable.applicable(applicability.getDomainClassName(), applicability.getRendererModelFactoryClassName(), applicability.getAttachmentAdvisorClassName());
    }
    return template;
}
Also used : DocumentType(org.incode.module.document.dom.impl.types.DocumentType) DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) TranslatableString(org.apache.isis.applib.services.i18n.TranslatableString) Applicability(org.incode.module.document.dom.impl.applicability.Applicability) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Aggregations

Applicability (org.incode.module.document.dom.impl.applicability.Applicability)4 Action (org.apache.isis.applib.annotation.Action)3 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)3 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)3 Clob (org.apache.isis.applib.value.Clob)3 DocumentType (org.incode.module.document.dom.impl.types.DocumentType)3 FluentIterable (com.google.common.collect.FluentIterable)2 Subscribe (com.google.common.eventbus.Subscribe)2 IOException (java.io.IOException)2 URL (java.net.URL)2 List (java.util.List)2 SortedSet (java.util.SortedSet)2 TreeSet (java.util.TreeSet)2 Inject (javax.inject.Inject)2 JDOHelper (javax.jdo.JDOHelper)2 Column (javax.jdo.annotations.Column)2 IdentityType (javax.jdo.annotations.IdentityType)2 Index (javax.jdo.annotations.Index)2 Indices (javax.jdo.annotations.Indices)2 Inheritance (javax.jdo.annotations.Inheritance)2