All compiles for the first time

This commit is contained in:
Grahame Grieve 2024-06-17 22:53:29 +10:00
parent b1a3141214
commit e91d8152b2
8 changed files with 30 additions and 12 deletions

View File

@ -171,7 +171,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
boolean last = false;
for (NamedResourceElementList p : res.childrenInGroups()) {
if (!ignoreProperty(p) && !p.getPropertyDefinition().getBase().getPath().startsWith("Resource.")) {
ElementDefinition child = getPropertyDefinition(profile.getSnapshot().getElement(), path+"."+p.getName(), p);
ElementDefinition child = getElementDefinition(profile.getSnapshot().getElement(), path+"."+p.getName(), p);
if (p.getValues().size() > 0 && p.getValues().get(0) != null && child != null && isSimple(child) && includeInSummary(child, p)) {
if (firstElement)
firstElement = false;
@ -191,6 +191,16 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
}
}
}
private ElementDefinition getElementDefinition(List<ElementDefinition> elements, String path, NamedResourceElementList p) {
for (ElementDefinition element : elements)
if (element.getPath().equals(path))
return element;
if (path.endsWith("\"]") && p.getClassDefinition() != null)
return p.getClassDefinition().getSnapshot().getElement().get(0);
return null;
}
private boolean ignoreProperty(NamedResourceElementList p) {

View File

@ -56,6 +56,9 @@ public class ResourceElement {
public ElementDefinition getPropertyDefinition() {
return values.isEmpty() ? null : values.get(0).getPropertyDefinition();
}
public StructureDefinition getClassDefinition() {
return values.isEmpty() ? null : values.get(0).getClassDefinition();
}
}
private ContextUtilities contextUtils;

View File

@ -27,7 +27,7 @@ public class ResourceElementTests {
public void testDirect() throws FHIRFormatError, IOException {
IWorkerContext worker = TestingUtilities.getSharedWorkerContext();
Resource res = new XmlParser().parse(TestingUtilities.loadTestResource("r5", "bundle-resource-element-test.xml"));
ResourceElement re = new ResourceElement(new ContextUtilities(worker), new ProfileUtilities(worker, null, null), res);
ResourceElement re = ResourceElement.forResource(new ContextUtilities(worker), new ProfileUtilities(worker, null, null), res);
checkTree(re);
}
@ -35,7 +35,7 @@ public class ResourceElementTests {
public void testIndirect() throws FHIRFormatError, IOException {
IWorkerContext worker = TestingUtilities.getSharedWorkerContext();
List<ValidatedFragment> res = Manager.parse(worker, TestingUtilities.loadTestResourceStream("r5", "bundle-resource-element-test.xml"), FhirFormat.XML);
ResourceElement re = new ResourceElement(new ContextUtilities(worker), new ProfileUtilities(worker, null, null), res.get(0).getElement());
ResourceElement re = ResourceElement.forResource(new ContextUtilities(worker), new ProfileUtilities(worker, null, null), res.get(0).getElement());
checkTree(re);
}

View File

@ -30,6 +30,7 @@ import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.renderers.RendererFactory;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules;
import org.hl7.fhir.r5.renderers.utils.ResourceElement;
import org.hl7.fhir.r5.utils.EOperationOutcome;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
@ -260,7 +261,7 @@ public class Scanner {
protected void genScanOutputItem(ScanOutputItem item, String filename) throws IOException, FHIRException, EOperationOutcome {
RenderingContext rc = new RenderingContext(getContext(), null, null, "http://hl7.org/fhir", "", null, RenderingContext.ResourceRendererMode.END_USER, GenerationRules.VALID_RESOURCE);
rc.setNoSlowLookup(true);
RendererFactory.factory(item.getOutcome(), rc).render(item.getOutcome());
RendererFactory.factory(item.getOutcome(), rc).renderResource(ResourceElement.forResource(rc.getContextUtilities(), rc.getProfileUtilities(), item.getOutcome()));
String s = new XhtmlComposer(XhtmlComposer.HTML).compose(item.getOutcome().getText().getDiv());
String title = item.getTitle();
@ -313,7 +314,7 @@ public class Scanner {
OperationOutcome op = new OperationOutcome();
op.addIssue().setCode(OperationOutcome.IssueType.EXCEPTION).setSeverity(OperationOutcome.IssueSeverity.FATAL).getDetails().setText(ex.getMessage());
RenderingContext rc = new RenderingContext(getContext(), null, null, "http://hl7.org/fhir", "", null, RenderingContext.ResourceRendererMode.END_USER, GenerationRules.VALID_RESOURCE);
RendererFactory.factory(op, rc).render(op);
RendererFactory.factory(op, rc).renderResource(ResourceElement.forResource(rc.getContextUtilities(), rc.getProfileUtilities(), op));
return op;
}

View File

@ -61,6 +61,7 @@ import org.hl7.fhir.r5.model.StructureMap;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.renderers.RendererFactory;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.ResourceElement;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
import org.hl7.fhir.r5.utils.EOperationOutcome;
@ -800,7 +801,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IValidationP
}
}
} else {
RendererFactory.factory(res, rc).render((DomainResource) res);
RendererFactory.factory(res, rc).renderResource(ResourceElement.forResource(rc.getContextUtilities(), rc.getProfileUtilities(), res));
}
}

View File

@ -28,6 +28,7 @@ import org.hl7.fhir.r5.model.OperationOutcome;
import org.hl7.fhir.r5.renderers.RendererFactory;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules;
import org.hl7.fhir.r5.renderers.utils.ResourceElement;
import org.hl7.fhir.r5.utils.EOperationOutcome;
import org.hl7.fhir.r5.utils.OperationOutcomeUtilities;
import org.hl7.fhir.utilities.ByteProvider;
@ -151,7 +152,7 @@ public class ValidatorUtils {
op.addIssue().setSeverity(OperationOutcome.IssueSeverity.INFORMATION).setCode(OperationOutcome.IssueType.INFORMATIONAL).getDetails().setText(context.formatMessage(I18nConstants.ALL_OK));
}
RenderingContext rc = new RenderingContext(context, null, null, "http://hl7.org/fhir", "", null, RenderingContext.ResourceRendererMode.END_USER, GenerationRules.VALID_RESOURCE);
RendererFactory.factory(op, rc).render(op);
RendererFactory.factory(op, rc).renderResource(ResourceElement.forResource(rc.getContextUtilities(), rc.getProfileUtilities(), op));
return op;
}

View File

@ -54,6 +54,7 @@ import org.hl7.fhir.r5.renderers.CodeSystemRenderer;
import org.hl7.fhir.r5.renderers.StructureDefinitionRenderer;
import org.hl7.fhir.r5.renderers.ValueSetRenderer;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.ResourceElement;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.StructureDefinitionRendererMode;
@ -179,7 +180,7 @@ public class ComparisonTests {
String xml2 = new XhtmlComposer(true).compose(cs.renderConcepts(csc, "", ""));
TextFile.stringToFile(HEADER + hd("Messages") + xmle + BREAK + hd("Metadata") + xml1 + BREAK + hd("Concepts") + xml2 + FOOTER, Utilities.path("[tmp]", "comparison", name + ".html"));
checkOutcomes(csc.getMessages(), content);
new CodeSystemRenderer(lrc).render(right);
new CodeSystemRenderer(lrc).renderResource(ResourceElement.forResource(lrc.getContextUtilities(), lrc.getProfileUtilities(), right));
checkOutput(id, content.getJsonObject("version").asString("filename"), right);
} else if (left instanceof ValueSet && right instanceof ValueSet) {
ValueSetComparer cs = new ValueSetComparer(session);
@ -193,7 +194,7 @@ public class ComparisonTests {
String xml3 = new XhtmlComposer(true).compose(cs.renderExpansion(csc, "", ""));
TextFile.stringToFile(HEADER + hd("Messages") + xmle + BREAK + hd("Metadata") + xml1 + BREAK + hd("Definition") + xml2 + BREAK + hd("Expansion") + xml3 + FOOTER, Utilities.path("[tmp]", "comparison", name + ".html"));
checkOutcomes(csc.getMessages(), content);
new ValueSetRenderer(lrc).render(right);
new ValueSetRenderer(lrc).renderResource(ResourceElement.forResource(lrc.getContextUtilities(), lrc.getProfileUtilities(), right));
checkOutput(id, content.getJsonObject("version").asString("filename"), right);
} else if (left instanceof StructureDefinition && right instanceof StructureDefinition) {
ProfileUtilities utils = new ProfileUtilities(context, null, null);
@ -213,11 +214,11 @@ public class ComparisonTests {
lrc.setStructureMode(StructureDefinitionRendererMode.DATA_DICT);
new StructureDefinitionRenderer(lrc).render(right);
new StructureDefinitionRenderer(lrc).renderResource(ResourceElement.forResource(lrc.getContextUtilities(), lrc.getProfileUtilities(), right));
checkOutput(id, content.getJsonObject("version").asString("filename-dd"), right);
lrc.setStructureMode(StructureDefinitionRendererMode.SUMMARY);
new StructureDefinitionRenderer(lrc).render(right);
new StructureDefinitionRenderer(lrc).renderResource(ResourceElement.forResource(lrc.getContextUtilities(), lrc.getProfileUtilities(), right));
checkOutput(id, content.getJsonObject("version").asString("filename-tree"), right);
} else if (left instanceof CapabilityStatement && right instanceof CapabilityStatement) {
CapabilityStatementComparer pc = new CapabilityStatementComparer(session);

View File

@ -37,6 +37,7 @@ import org.hl7.fhir.r5.renderers.RendererFactory;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
import org.hl7.fhir.r5.renderers.utils.ResourceElement;
import org.hl7.fhir.r5.test.utils.TestingUtilities;
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
import org.hl7.fhir.utilities.Utilities;
@ -541,7 +542,7 @@ public class SnapShotGenerationXTests {
RenderingContext rc = new RenderingContext(TestingUtilities.getSharedWorkerContext(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER, GenerationRules.VALID_RESOURCE);
rc.setDestDir(makeTempDir());
rc.setProfileUtilities(new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), null, new TestPKP()));
RendererFactory.factory(output, rc).render(output);
RendererFactory.factory(output, rc).renderResource(ResourceElement.forResource(rc.getContextUtilities(), rc.getProfileUtilities(), output));
}
if (!fail) {
test.output = output;