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;
}
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;
}
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);
}
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;
}
Aggregations