use of org.incode.module.document.dom.impl.renderers.RendererFromCharsToChars in project estatio by estatio.
the class DocumentTemplate method determineDocumentName.
private String determineDocumentName(final Object contentDataModel) {
serviceRegistry2.injectServicesInto(contentDataModel);
// subject
final RendererFromCharsToChars nameRenderer = (RendererFromCharsToChars) getNameRenderingStrategy().newRenderer();
String renderedDocumentName;
try {
renderedDocumentName = nameRenderer.renderCharsToChars(getType(), "name", getAtPath(), getVersion(), getNameText(), contentDataModel);
} catch (IOException e) {
renderedDocumentName = getName();
}
return withFileSuffix(renderedDocumentName);
}
use of org.incode.module.document.dom.impl.renderers.RendererFromCharsToChars 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);
}
}
Aggregations