fix issues with rendering example scenario
This commit is contained in:
parent
4a1aa461a9
commit
88d0cc8a68
|
@ -441,8 +441,9 @@ public class ExampleScenario40_50 {
|
|||
tgt.setPauseElement(Boolean40_50.convertBoolean(src.getPauseElement()));
|
||||
if (src.hasOperation())
|
||||
tgt.setOperation(convertExampleScenarioProcessStepOperationComponent(src.getOperation(), src.getNumber()));
|
||||
else
|
||||
else if (src.hasNumber()) {
|
||||
tgt.addExtension(PROCESS_STEP_NUMBER, String40_50.convertString(src.getNumberElement()));
|
||||
}
|
||||
for (org.hl7.fhir.r5.model.ExampleScenario.ExampleScenarioProcessStepAlternativeComponent t : src.getAlternative())
|
||||
tgt.addAlternative(convertExampleScenarioProcessStepAlternativeComponent(t));
|
||||
return tgt;
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.hl7.fhir.r5.renderers.utils.RenderingContext;
|
|||
import org.hl7.fhir.r5.renderers.utils.RenderingContext.KnownLinkType;
|
||||
import org.hl7.fhir.r5.renderers.utils.ResourceWrapper;
|
||||
import org.hl7.fhir.r5.utils.EOperationOutcome;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlDocument;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
|
||||
|
@ -80,19 +81,24 @@ public class ExampleScenarioRenderer extends TerminologyRenderer {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new FHIRException(context.formatPhrase(RenderingContext.EX_SCEN_ERR_REN, scen.getUrl(), e) + " ");
|
||||
}
|
||||
}
|
||||
|
||||
public String renderDiagram(RenderingStatus status, ResourceWrapper res, ExampleScenario scen) throws IOException {
|
||||
String plantUml = toPlantUml(status, res, scen);
|
||||
SourceStringReader reader = new SourceStringReader(plantUml);
|
||||
final ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
reader.outputImage(os, new FileFormatOption(FileFormat.SVG));
|
||||
os.close();
|
||||
try {
|
||||
String plantUml = toPlantUml(status, res, scen);
|
||||
SourceStringReader reader = new SourceStringReader(plantUml);
|
||||
final ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
reader.outputImage(os, new FileFormatOption(FileFormat.SVG));
|
||||
os.close();
|
||||
|
||||
final String svg = new String(os.toByteArray(), Charset.forName("UTF-8"));
|
||||
return svg;
|
||||
final String svg = new String(os.toByteArray(), Charset.forName("UTF-8"));
|
||||
return svg;
|
||||
} catch (Exception e) {
|
||||
return "<p style=\"color: maroon\"><b>"+Utilities.escapeXml(e.getMessage())+"</b></p>";
|
||||
}
|
||||
}
|
||||
|
||||
protected String toPlantUml(RenderingStatus status, ResourceWrapper res, ExampleScenario scen) throws IOException {
|
||||
|
@ -197,12 +203,14 @@ public class ExampleScenarioRenderer extends TerminologyRenderer {
|
|||
private String handleDeactivation(String actorId, boolean active, Map<String,Boolean> actorsActive, Map<String, String> actorKeys) {
|
||||
String plantUml = "";
|
||||
Boolean actorWasActive = actorsActive.get(actorId);
|
||||
if (!active && actorWasActive) {
|
||||
plantUml += "deactivate " + actorKeys.get(actorId) + "\r\n";
|
||||
}
|
||||
if (active != actorWasActive) {
|
||||
actorsActive.remove(actorId);
|
||||
actorsActive.put(actorId, Boolean.valueOf(active));
|
||||
if (actorWasActive != null) {
|
||||
if (!active && actorWasActive) {
|
||||
plantUml += "deactivate " + actorKeys.get(actorId) + "\r\n";
|
||||
}
|
||||
if (active != actorWasActive) {
|
||||
actorsActive.remove(actorId);
|
||||
actorsActive.put(actorId, Boolean.valueOf(active));
|
||||
}
|
||||
}
|
||||
return plantUml;
|
||||
}
|
||||
|
@ -505,9 +513,9 @@ public class ExampleScenarioRenderer extends TerminologyRenderer {
|
|||
if (instanceRef==null || instanceRef.getInstanceReference()==null)
|
||||
return;
|
||||
ExampleScenarioInstanceComponent instance = instances.get(instanceRef.getInstanceReference());
|
||||
if (instance==null)
|
||||
throw new FHIRException(context.formatPhrase(RenderingContext.EX_SCEN_UN_INST, instanceRef.getInstanceReference())+" ");
|
||||
if (instanceRef.hasVersionReference()) {
|
||||
if (instance==null) {
|
||||
instanceCell.b().tx("Bad reference: "+instanceRef.getInstanceReference());
|
||||
} else if (instanceRef.hasVersionReference()) {
|
||||
ExampleScenarioInstanceVersionComponent theVersion = null;
|
||||
for (ExampleScenarioInstanceVersionComponent version: instance.getVersion()) {
|
||||
if (version.getKey().equals(instanceRef.getVersionReference())) {
|
||||
|
|
Loading…
Reference in New Issue