Fix up rendering of base64 content

This commit is contained in:
Grahame Grieve 2023-07-05 07:18:12 +10:00
parent 6956f39502
commit 70e123e69b
2 changed files with 10 additions and 6 deletions

View File

@ -25,6 +25,7 @@ import org.hl7.fhir.r5.model.Address;
import org.hl7.fhir.r5.model.Annotation; import org.hl7.fhir.r5.model.Annotation;
import org.hl7.fhir.r5.model.BackboneType; import org.hl7.fhir.r5.model.BackboneType;
import org.hl7.fhir.r5.model.Base; import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.Base64BinaryType;
import org.hl7.fhir.r5.model.BaseDateTimeType; import org.hl7.fhir.r5.model.BaseDateTimeType;
import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CanonicalType; import org.hl7.fhir.r5.model.CanonicalType;
@ -99,7 +100,7 @@ public class DataRenderer extends Renderer implements CodeResolver {
} }
// -- 2. Markdown support ------------------------------------------------------- // -- 2. Markdown support -------------------------------------------------------
public static String processRelativeUrls(String markdown, String path) { public static String processRelativeUrls(String markdown, String path) {
if (markdown == null) { if (markdown == null) {
return ""; return "";
@ -726,6 +727,8 @@ public class DataRenderer extends Renderer implements CodeResolver {
} }
} else if (type instanceof MarkdownType) { } else if (type instanceof MarkdownType) {
addMarkdown(x, ((MarkdownType) type).asStringValue()); addMarkdown(x, ((MarkdownType) type).asStringValue());
} else if (type instanceof Base64BinaryType) {
x.tx("(base64 data)");
} else if (type.isPrimitive()) { } else if (type.isPrimitive()) {
x.tx(type.primitiveValue()); x.tx(type.primitiveValue());
} else { } else {

View File

@ -377,9 +377,10 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
x.addText(((InstantType) e).toHumanDisplay()); x.addText(((InstantType) e).toHumanDisplay());
else if (e instanceof DateTimeType) { else if (e instanceof DateTimeType) {
renderDateTime(x, e); renderDateTime(x, e);
} else if (e instanceof Base64BinaryType) } else if (e instanceof Base64BinaryType) {
x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue())); Base64BinaryType b64 = (Base64BinaryType) e;
else if (e instanceof org.hl7.fhir.r5.model.DateType) { x.addText("(base64 data - "+(b64.getValue() == null ? "0" : b64.getValue().length)+" bytes)");
} else if (e instanceof org.hl7.fhir.r5.model.DateType) {
org.hl7.fhir.r5.model.DateType dt = ((org.hl7.fhir.r5.model.DateType) e); org.hl7.fhir.r5.model.DateType dt = ((org.hl7.fhir.r5.model.DateType) e);
renderDate(x, dt); renderDate(x, dt);
} else if (e instanceof Enumeration) { } else if (e instanceof Enumeration) {
@ -853,12 +854,12 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
XhtmlNode tbl = new XhtmlNode(NodeType.Element, "table"); XhtmlNode tbl = new XhtmlNode(NodeType.Element, "table");
tbl.setAttribute("class", "grid"); tbl.setAttribute("class", "grid");
XhtmlNode tr = tbl.tr(); XhtmlNode tr = tbl.tr();
tr.td().tx("-"); // work around problem with empty table rows tr.td().style("display: hidden").tx("-"); // work around problem with empty table rows
boolean add = addColumnHeadings(tr, grandChildren); boolean add = addColumnHeadings(tr, grandChildren);
for (BaseWrapper v : p.getValues()) { for (BaseWrapper v : p.getValues()) {
if (v != null) { if (v != null) {
tr = tbl.tr(); tr = tbl.tr();
tr.td().tx("*"); // work around problem with empty table rows tr.td().style("display: hidden").tx("*"); // work around problem with empty table rows
add = addColumnValues(res, tr, grandChildren, v, showCodeDetails, displayHints, path, indent) || add; add = addColumnValues(res, tr, grandChildren, v, showCodeDetails, displayHints, path, indent) || add;
} }
} }