Search in sources :

Example 1 with DocFragment

use of org.incode.module.docfragment.dom.impl.DocFragment in project estatio by estatio.

the class DocFragmentService method render.

/**
 * Overload of {@link #render(Object, String)}, but allowing the atPath to be specified explicitly rather than inferred from the supplied domain object.
 *
 * @param domainObject provides the state for the interpolation into the fragment's {@link DocFragment#getTemplateText() template text}
 * @param name corresponds to the {@link DocFragment#getName() name} of the {@link DocFragment} to use to render.
 * @param atPath corrsponds to the {@link ApplicationTenancyService#atPathFor(Object) atPath} of the {@link DocFragment} to use to render
 *
 * @throws IOException
 * @throws TemplateException
 * @throws RenderException - if could not locate any {@link DocFragment}.
 */
@Programmatic
public String render(final Object domainObject, final String name, final String atPath) throws IOException, TemplateException, RenderException {
    final String objectType = objectTypeFor(domainObject);
    final DocFragment fragment = repo.findByObjectTypeAndNameAndApplicableToAtPath(objectType, name, atPath);
    if (fragment != null)
        return fragment.render(domainObject);
    else
        throw new RenderException("No fragment found for objectType: %s, name: %s, atPath: %s", objectType, name, atPath);
}
Also used : DocFragment(org.incode.module.docfragment.dom.impl.DocFragment) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 2 with DocFragment

use of org.incode.module.docfragment.dom.impl.DocFragment in project estatio by estatio.

the class DocFragmentBuilder method execute.

@Override
public void execute(final ExecutionContext executionContext) {
    final DocFragment docFrag = docFragmentRepository.findByObjectTypeAndNameAndApplicableToAtPath(objectType, name, atPath);
    if (docFrag != null && Objects.equals(docFrag.getAtPath(), atPath)) {
        return;
    }
    docFragmentRepository.create(objectType, name, atPath, getTemplateText());
}
Also used : DocFragment(org.incode.module.docfragment.dom.impl.DocFragment)

Aggregations

DocFragment (org.incode.module.docfragment.dom.impl.DocFragment)2 Programmatic (org.apache.isis.applib.annotation.Programmatic)1