Merge pull request #199 from ahdis/oliveregger_validatortransformdifferential

add snapshot generation for the java validator -transform option
This commit is contained in:
Grahame Grieve 2020-06-01 17:03:38 +10:00 committed by GitHub
commit 4df8b557c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import org.hl7.fhir.r5.formats.IParser;
import org.hl7.fhir.r5.formats.JsonParser;
import org.hl7.fhir.r5.formats.XmlParser;
import org.hl7.fhir.r5.model.*;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
@ -123,6 +124,16 @@ public class ValidationService {
if (cliContext.getMap() == null)
throw new Exception("Must provide a map when doing a transform");
try {
List<StructureDefinition> structures = validator.getContext().allStructures();
for (StructureDefinition sd : structures) {
if (!sd.hasSnapshot()) {
if (sd.getKind()!=null && sd.getKind() == StructureDefinitionKind.LOGICAL) {
validator.getContext().generateSnapshot(sd, true);
} else {
validator.getContext().generateSnapshot(sd, false);
}
}
}
validator.setMapLog(cliContext.getMapLog());
org.hl7.fhir.r5.elementmodel.Element r = validator.transform(cliContext.getSources().get(0), cliContext.getMap());
System.out.println(" ...success");