use of org.incode.module.document.dom.impl.docs.DocumentTemplate in project estatio by estatio.
the class DocumentTemplateForAtPathService method documentTemplatesForCreateAndAttach.
@Programmatic
public List<DocumentTemplate> documentTemplatesForCreateAndAttach(final Object domainObject) {
final List<DocumentTemplate> templates = Lists.newArrayList();
final String atPath = atPathFor(domainObject);
if (atPath == null) {
return templates;
}
final List<DocumentTemplate> templatesForPath = documentTemplateRepository.findByApplicableToAtPath(atPath);
return Lists.newArrayList(templatesForPath.stream().filter(template -> {
final AttachmentAdvisor advisor = template.newAttachmentAdvisor(domainObject);
if (advisor == null) {
return false;
}
// at this stage we are asking the advisor if it would be able to attach a document
// if created. We don't yet have that document, so it is null.
final Document document = null;
final List<AttachmentAdvisor.PaperclipSpec> paperclipSpecs = advisor.advise(template, domainObject, document);
return canCreate(template, paperclipSpecs);
}).collect(Collectors.toList()));
}
Aggregations