don't throw error for wrong rendering mode

This commit is contained in:
Grahame Grieve 2024-08-03 19:31:35 +08:00
parent eecd04924b
commit 7670422a6c
12 changed files with 50 additions and 36 deletions

View File

@ -53,7 +53,8 @@ public class CapabilityStatementRenderer extends ResourceRenderer {
renderResourceTechDetails(r, x);
render(status, x, (CapabilityStatement) r.getBase(), r);
} else {
throw new Error("CapabilityStatementRenderer only renders native resources directly");
// the intention is to change this in the future
x.para().tx("CapabilityStatementRenderer only renders native resources directly");
}
}
@ -422,7 +423,7 @@ public class CapabilityStatementRenderer extends ResourceRenderer {
private void addSupportedCSs(RenderingStatus status, XhtmlNode x, CapabilityStatement cap, ResourceWrapper res) throws UnsupportedEncodingException, IOException {
if (cap.hasInstantiates()) {
XhtmlNode p = x.para();
p.tx(cap.getInstantiates().size() > 1 ? "This CapabilityStatement instantiates these CapabilityStatements" : "This CapabilityStatement instantiates the CapabilityStatement");
p.tx(cap.getInstantiates().size() > 1 ? "This CapabilityStatement instantiates these CapabilityStatements " : "This CapabilityStatement instantiates the CapabilityStatement ");
boolean first = true;
for (CanonicalType ct : cap.getInstantiates()) {
if (first) {first = false;} else {p.tx(", ");};
@ -431,7 +432,7 @@ public class CapabilityStatementRenderer extends ResourceRenderer {
}
if (cap.hasImports()) {
XhtmlNode p = x.para();
p.tx(cap.getImports().size() > 1 ? "This CapabilityStatement imports these CapabilityStatements" : "This CapabilityStatement imports the CapabilityStatement");
p.tx(cap.getImports().size() > 1 ? "This CapabilityStatement imports these CapabilityStatements " : "This CapabilityStatement imports the CapabilityStatement ");
boolean first = true;
for (CanonicalType ct : cap.getImports()) {
if (first) {first = false;} else {p.tx(", ");};

View File

@ -53,7 +53,8 @@ public class CodeSystemRenderer extends TerminologyRenderer {
genSummaryTable(status, x, (CodeSystem) r.getBase());
render(status, x, (CodeSystem) r.getBase(), r);
} else {
throw new Error("CodeSystemRenderer only renders native resources directly");
// the intention is to change this in the future
x.para().tx("CodeSystemRenderer only renders native resources directly");
}
}

View File

@ -29,7 +29,8 @@ public class CompartmentDefinitionRenderer extends ResourceRenderer {
genSummaryTable(status, x, (CompartmentDefinition) r.getBase());
render(status, x, (CompartmentDefinition) r.getBase());
} else {
throw new Error("CompartmentDefinitionRenderer only renders native resources directly");
// it seems very inlikely this will change
x.para().tx("CompartmentDefinitionRenderer only renders native resources directly");
}
}

View File

@ -49,7 +49,8 @@ public class ConceptMapRenderer extends TerminologyRenderer {
genSummaryTable(status, x, (ConceptMap) r.getBase());
render(status, r, x, (ConceptMap) r.getBase(), false);
} else {
throw new Error("ConceptMapRenderer only renders native resources directly");
// the intention is to change this in the future
x.para().tx("ConceptMapRenderer only renders native resources directly");
}
}

View File

@ -50,7 +50,8 @@ public class ExampleScenarioRenderer extends TerminologyRenderer {
genSummaryTable(status, x, (ExampleScenario) r.getBase());
render(status, x, (ExampleScenario) r.getBase(), r);
} else {
throw new Error("ExampleScenarioRenderer only renders native resources directly");
// the intention is to change this in the future
x.para().tx("ExampleScenarioRenderer only renders native resources directly");
}
}

View File

@ -25,7 +25,8 @@ public class ImplementationGuideRenderer extends ResourceRenderer {
genSummaryTable(status, x, (ImplementationGuide) r.getBase());
render(status, x, (ImplementationGuide) r.getBase());
} else {
throw new Error("ImplementationGuideRenderer only renders native resources directly");
// the intention is to change this in the future
x.para().tx("ImplementationGuideRenderer only renders native resources directly");
}
}

View File

@ -29,7 +29,8 @@ public class NamingSystemRenderer extends ResourceRenderer {
genSummaryTable(status, x, (NamingSystem) r.getBase());
render(status, x, (NamingSystem) r.getBase());
} else {
throw new Error("NamingSystemRenderer only renders native resources directly");
// the intention is to change this in the future
x.para().tx("NamingSystemRenderer only renders native resources directly");
}
}

View File

@ -40,7 +40,8 @@ public class OperationDefinitionRenderer extends TerminologyRenderer {
genSummaryTable(status, x, (OperationDefinition) r.getBase());
render(status, x, (OperationDefinition) r.getBase());
} else {
throw new Error("OperationDefinitionRenderer only renders native resources directly");
// the intention is to change this in the future
x.para().tx("OperationDefinitionRenderer only renders native resources directly");
}
}

View File

@ -41,7 +41,8 @@ public class SearchParameterRenderer extends TerminologyRenderer {
render(status, x, (SearchParameter) r.getBase());
} else {
throw new Error("SearchParameterRenderer only renders native resources directly");
// the intention is to change this in the future
x.para().tx("SearchParameterRenderer only renders native resources directly");
}
}

View File

@ -103,18 +103,20 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
@Override
public void buildNarrative(RenderingStatus status, XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
if (!r.isDirect()) {
throw new Error("StructureDefinitionRenderer only renders native resources directly");
}
renderResourceTechDetails(r, x);
StructureDefinition sd = (StructureDefinition) r.getBase();
genSummaryTable(status, x, sd);
if (context.getStructureMode() == StructureDefinitionRendererMode.DATA_DICT) {
renderDict(status, sd, sd.getDifferential().getElement(), x.table("dict"), false, GEN_MODE_DIFF, "", r);
} else {
x.addChildNode(generateTable(status, context.getDefinitionsTarget(), sd, true, context.getDestDir(), false, sd.getId(), false,
context.getLink(KnownLinkType.SPEC), "", sd.getKind() == StructureDefinitionKind.LOGICAL, false, null, false, context.withUniqueLocalPrefix(null), "r", r));
}
status.setExtensions(true);
// it seems very unlikely that this will change in the future
x.para().tx("StructureDefinitionRenderer only renders native resources directly");
} else {
renderResourceTechDetails(r, x);
StructureDefinition sd = (StructureDefinition) r.getBase();
genSummaryTable(status, x, sd);
if (context.getStructureMode() == StructureDefinitionRendererMode.DATA_DICT) {
renderDict(status, sd, sd.getDifferential().getElement(), x.table("dict"), false, GEN_MODE_DIFF, "", r);
} else {
x.addChildNode(generateTable(status, context.getDefinitionsTarget(), sd, true, context.getDestDir(), false, sd.getId(), false,
context.getLink(KnownLinkType.SPEC), "", sd.getKind() == StructureDefinitionKind.LOGICAL, false, null, false, context.withUniqueLocalPrefix(null), "r", r));
}
status.setExtensions(true);
}
}
@Override

View File

@ -57,7 +57,8 @@ public class StructureMapRenderer extends TerminologyRenderer {
genSummaryTable(status, x, (StructureMap) r.getBase());
renderMap(status, x.pre("fml"), (StructureMap) r.getBase());
} else {
throw new Error("StructureMapRenderer only renders native resources directly");
// the intention is to change this in the future
x.para().tx("StructureMapRenderer only renders native resources directly");
}
}

View File

@ -73,21 +73,23 @@ public class ValueSetRenderer extends TerminologyRenderer {
@Override
public void buildNarrative(RenderingStatus status, XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
if (!r.isDirect()) {
throw new Error("ValueSetRenderer only renders native resources directly");
}
renderResourceTechDetails(r, x);
ValueSet vs = (ValueSet) r.getBase();
genSummaryTable(status, x, vs);
List<UsedConceptMap> maps = findReleventMaps(vs);
if (vs.hasExpansion()) {
// for now, we just accept an expansion if there is one
generateExpansion(status, r, x, vs, false, maps);
// the intention is to change this in the future
x.para().tx("ValueSetRenderer only renders native resources directly");
} else {
generateComposition(status, r, x, vs, false, maps);
renderResourceTechDetails(r, x);
ValueSet vs = (ValueSet) r.getBase();
genSummaryTable(status, x, vs);
List<UsedConceptMap> maps = findReleventMaps(vs);
if (vs.hasExpansion()) {
// for now, we just accept an expansion if there is one
generateExpansion(status, r, x, vs, false, maps);
} else {
generateComposition(status, r, x, vs, false, maps);
}
}
}
@Override
public String buildSummary(ResourceWrapper r) throws UnsupportedEncodingException, IOException {