Merge pull request #385 from hapifhir/gg-v522

5.2. cumulative release
This commit is contained in:
Grahame Grieve 2020-11-26 17:45:20 +11:00 committed by GitHub
commit dc6f04c512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 74 additions and 33 deletions

View File

@ -1 +1,8 @@
* fix for issue 383 Validator Changes:
* no effective changes
Other Code Changes:
* fix bug converting type mode in Structure Map
* fix bug converting Timing.when (issue 383)
* fix bug doing date time comparisons with seconds in FHIRPath
* Add support for instance-name and instance-description extensions

View File

@ -3,6 +3,7 @@ package org.hl7.fhir.convertors.conv40_50;
import org.hl7.fhir.convertors.VersionConvertor_40_50; import org.hl7.fhir.convertors.VersionConvertor_40_50;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -220,8 +221,11 @@ public class StructureMap40_50 extends VersionConvertor_40_50 {
tgt.setNameElement(convertId(src.getNameElement())); tgt.setNameElement(convertId(src.getNameElement()));
if (src.hasExtends()) if (src.hasExtends())
tgt.setExtendsElement(convertId(src.getExtendsElement())); tgt.setExtendsElement(convertId(src.getExtendsElement()));
if (src.hasTypeMode()) if (src.hasTypeMode()) {
tgt.setTypeModeElement(convertStructureMapGroupTypeMode(src.getTypeModeElement())); tgt.setTypeModeElement(convertStructureMapGroupTypeMode(src.getTypeModeElement()));
} else {
tgt.setTypeMode(StructureMapGroupTypeMode.NONE);
}
if (src.hasDocumentation()) if (src.hasDocumentation())
tgt.setDocumentationElement(convertString(src.getDocumentationElement())); tgt.setDocumentationElement(convertString(src.getDocumentationElement()));
for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent t : src.getInput()) tgt.addInput(convertStructureMapGroupInputComponent(t)); for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent t : src.getInput()) tgt.addInput(convertStructureMapGroupInputComponent(t));

View File

@ -812,6 +812,10 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
return loadedPackages.contains(id+"#"+ver); return loadedPackages.contains(id+"#"+ver);
} }
public boolean hasPackage(String idAndver) {
return loadedPackages.contains(idAndver);
}
public void setClock(TimeTracker tt) { public void setClock(TimeTracker tt) {
clock = tt; clock = tt;
} }

View File

@ -899,16 +899,12 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
lowRight = lowRight - (14 * DateUtils.MILLIS_PER_HOUR); lowRight = lowRight - (14 * DateUtils.MILLIS_PER_HOUR);
highRight = highRight + (14 * DateUtils.MILLIS_PER_HOUR); highRight = highRight + (14 * DateUtils.MILLIS_PER_HOUR);
} }
System.out.print("["+((lowLeft / 1000) - 130000000)+"-"+((highLeft / 1000) - 130000000)+"] vs ["+((lowRight / 1000) - 130000000)+"-"+((highRight / 1000) - 130000000)+"] = ");
if (highRight < lowLeft) { if (highRight < lowLeft) {
System.out.println("false");
return false; return false;
} }
if (highLeft < lowRight) { if (highLeft < lowRight) {
System.out.println("false");
return false; return false;
} }
System.out.println("true");
return true; return true;
} }
@ -1000,6 +996,14 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
return def; return def;
} }
if (left.getSecond() < right.getSecond()) {
return -1;
} else if (left.getSecond() > right.getSecond()) {
return 1;
} else if (left.getPrecision() == TemporalPrecisionEnum.SECOND && right.getPrecision() == TemporalPrecisionEnum.SECOND) {
return 0;
}
if (left.getSecondsMilli() < right.getSecondsMilli()) { if (left.getSecondsMilli() < right.getSecondsMilli()) {
return -1; return -1;
} else if (left.getSecondsMilli() > right.getSecondsMilli()) { } else if (left.getSecondsMilli() > right.getSecondsMilli()) {

View File

@ -523,7 +523,7 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
InputStream stream = fetchFromUrlSpecific(Utilities.pathURL("http://build.fhir.org", id + ".tgz"), false); InputStream stream = fetchFromUrlSpecific(Utilities.pathURL("http://build.fhir.org", id + ".tgz"), false);
return new InputStreamWithSrc(stream, Utilities.pathURL("http://build.fhir.org", id + ".tgz"), "current"); return new InputStreamWithSrc(stream, Utilities.pathURL("http://build.fhir.org", id + ".tgz"), "current");
} else { } else {
throw new FHIRException("The package '" + id + "' has not entry on the current build server"); throw new FHIRException("The package '" + id + "' has no entry on the current build server");
} }
} }

View File

@ -1087,6 +1087,12 @@ public class NpmPackage {
return false; return false;
} }
} }
if (Utilities.existsInList(name(), "fhir.test.data.r2", "fhir.test.data.r3", "fhir.test.data.r4", "fhir.tx.support.r2", "fhir.tx.support.r3", "fhir.tx.support.r4", "us.nlm.vsac")) {
return true;
}
if (JSONUtil.bool(npm, "lazy-load")) {
return true;
}
if (!hasFile("other", "spec.internals")) { if (!hasFile("other", "spec.internals")) {
return false; return false;
} }

View File

@ -55,6 +55,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class XhtmlParser { public class XhtmlParser {
public static final String XHTML_NS = "http://www.w3.org/1999/xhtml"; public static final String XHTML_NS = "http://www.w3.org/1999/xhtml";
private static final char END_OF_CHARS = (char) -1;
public class NSMap { public class NSMap {
private Map<String, String> nslist = new HashMap<String, String>(); private Map<String, String> nslist = new HashMap<String, String>();
@ -515,7 +516,7 @@ private boolean elementIsOk(String name) throws FHIRFormatError {
private void parseElementInner(XhtmlNode node, List<XhtmlNode> parents, NSMap nsm, boolean escaping) throws FHIRFormatError, IOException private void parseElementInner(XhtmlNode node, List<XhtmlNode> parents, NSMap nsm, boolean escaping) throws FHIRFormatError, IOException
{ {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
while (peekChar() != '\0' && !parents.contains(unwindPoint) && !(node == unwindPoint)) while (peekChar() != END_OF_CHARS && !parents.contains(unwindPoint) && !(node == unwindPoint))
{ {
if (peekChar() == '<') if (peekChar() == '<')
{ {
@ -606,7 +607,7 @@ private boolean elementIsOk(String name) throws FHIRFormatError {
{ {
while (Character.isWhitespace(peekChar())) while (Character.isWhitespace(peekChar()))
readChar(); readChar();
while (peekChar() != '>' && peekChar() != '/' && peekChar() != '\0') while (peekChar() != '>' && peekChar() != '/' && peekChar() != END_OF_CHARS)
{ {
String name = readName(); String name = readName();
if (name.length() == 0) if (name.length() == 0)
@ -630,7 +631,7 @@ private boolean elementIsOk(String name) throws FHIRFormatError {
if (peekChar() == '"' || peekChar() == '\'') if (peekChar() == '"' || peekChar() == '\'')
node.getAttributes().put(name, parseAttributeValue(readChar())); node.getAttributes().put(name, parseAttributeValue(readChar()));
else else
node.getAttributes().put(name, parseAttributeValue('\0')); node.getAttributes().put(name, parseAttributeValue(END_OF_CHARS));
} }
while (Character.isWhitespace(peekChar())) while (Character.isWhitespace(peekChar()))
readChar(); readChar();
@ -640,7 +641,7 @@ private boolean elementIsOk(String name) throws FHIRFormatError {
private String parseAttributeValue(char term) throws IOException, FHIRFormatError private String parseAttributeValue(char term) throws IOException, FHIRFormatError
{ {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
while (peekChar() != '\0' && peekChar() != '>' && (term != '\0' || peekChar() != '/') && peekChar() != term) while (peekChar() != END_OF_CHARS && peekChar() != '>' && (term != END_OF_CHARS || peekChar() != '/') && peekChar() != term)
{ {
if (peekChar() == '&') if (peekChar() == '&')
{ {
@ -704,15 +705,15 @@ private boolean elementIsOk(String name) throws FHIRFormatError {
if (cache.length() > 0) if (cache.length() > 0)
return cache.charAt(0); return cache.charAt(0);
else if (!rdr.ready()) else if (!rdr.ready())
return '\0'; return END_OF_CHARS;
else else
{ {
char c = (char)rdr.read(); int i = rdr.read();
if (c == (char)-1) if (i == -1) {
{
cache = ""; cache = "";
return '\0'; return END_OF_CHARS;
} }
char c = (char) i;
cache = Character.toString(c); cache = Character.toString(c);
return c; return c;
} }
@ -727,7 +728,7 @@ private boolean elementIsOk(String name) throws FHIRFormatError {
cache = cache.length() == 1 ? "" : cache.substring(1); cache = cache.length() == 1 ? "" : cache.substring(1);
} }
else if (!rdr.ready()) else if (!rdr.ready())
c = '\0'; c = END_OF_CHARS;
else else
c = (char)rdr.read(); c = (char)rdr.read();
if (c == '\r' || c == '\n') { if (c == '\r' || c == '\n') {
@ -744,9 +745,9 @@ private boolean elementIsOk(String name) throws FHIRFormatError {
private String readToTagEnd() throws IOException, FHIRFormatError private String readToTagEnd() throws IOException, FHIRFormatError
{ {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
while (peekChar() != '>' && peekChar() != '\0') while (peekChar() != '>' && peekChar() != END_OF_CHARS)
s.append(readChar()); s.append(readChar());
if (peekChar() != '\0') if (peekChar() != END_OF_CHARS)
{ {
readChar(); readChar();
skipWhiteSpace(); skipWhiteSpace();
@ -765,7 +766,7 @@ private boolean elementIsOk(String name) throws FHIRFormatError {
if (c == '>') { if (c == '>') {
done = true; done = true;
readChar(); readChar();
} else if (c != '\0') } else if (c != END_OF_CHARS)
s.append(readChar()); s.append(readChar());
else if (mustBeWellFormed) else if (mustBeWellFormed)
throw new FHIRFormatError("Unexpected termination of html source"+descLoc()); throw new FHIRFormatError("Unexpected termination of html source"+descLoc());
@ -814,12 +815,12 @@ private boolean elementIsOk(String name) throws FHIRFormatError {
} else if (c == '[' && s.toString().startsWith("DOCTYPE ")) { } else if (c == '[' && s.toString().startsWith("DOCTYPE ")) {
doctypeEntities = true; doctypeEntities = true;
s.append(readChar()); s.append(readChar());
} else if (c != '\0') } else if (c != END_OF_CHARS)
s.append(readChar()); s.append(readChar());
else if (mustBeWellFormed) else if (mustBeWellFormed)
throw new FHIRFormatError("Unexpected termination of html source"+descLoc()); throw new FHIRFormatError("Unexpected termination of html source"+descLoc());
} }
if (peekChar() != '\0') if (peekChar() != END_OF_CHARS)
{ {
readChar(); readChar();
skipWhiteSpace(); skipWhiteSpace();

View File

@ -1,6 +1,8 @@
package org.hl7.fhir.utilities.tests; package org.hl7.fhir.utilities.tests;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.utilities.xhtml.XhtmlNode; import org.hl7.fhir.utilities.xhtml.XhtmlNode;
import org.hl7.fhir.utilities.xhtml.XhtmlParser;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -88,4 +90,9 @@ public class XhtmlNodeTest {
ObjectOutputStream oout = new ObjectOutputStream(bout); ObjectOutputStream oout = new ObjectOutputStream(bout);
oout.writeObject(node); oout.writeObject(node);
} }
@Test
public void testParseBadChars() throws FHIRFormatError, IOException {
XhtmlNode x = new XhtmlParser().parse(BaseTestingUtilities.loadTestResource("xhtml", "bad-chars.html"), "div");
}
} }

View File

@ -1007,7 +1007,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IPackageInst
} }
public void loadIg(String src, boolean recursive) throws IOException, FHIRException { public void loadIg(String src, boolean recursive) throws IOException, FHIRException {
NpmPackage npm = src.matches(FilesystemPackageCacheManager.PACKAGE_VERSION_REGEX_OPT) ? pcm.loadPackage(src, null) : null; NpmPackage npm = src.matches(FilesystemPackageCacheManager.PACKAGE_VERSION_REGEX_OPT) && !new File(src).exists() ? pcm.loadPackage(src, null) : null;
if (npm != null) { if (npm != null) {
for (String s : npm.dependencies()) { for (String s : npm.dependencies()) {
if (!context.getLoadedPackages().contains(s)) { if (!context.getLoadedPackages().contains(s)) {

View File

@ -52,6 +52,7 @@ import org.hl7.fhir.r5.utils.IResourceValidator.ReferenceValidationPolicy;
import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.json.JSONUtil;
import org.hl7.fhir.utilities.npm.NpmPackage; import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
@ -81,8 +82,9 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
Map<String, JsonObject> examples = new HashMap<String, JsonObject>(); Map<String, JsonObject> examples = new HashMap<String, JsonObject>();
manifest = (JsonObject) new com.google.gson.JsonParser().parse(contents); manifest = (JsonObject) new com.google.gson.JsonParser().parse(contents);
for (Entry<String, JsonElement> e : manifest.getAsJsonObject("test-cases").entrySet()) { for (JsonElement e : manifest.getAsJsonArray("test-cases")) {
examples.put(e.getKey(), e.getValue().getAsJsonObject()); JsonObject o = (JsonObject) e;
examples.put(JSONUtil.str(o, "name"), o);
} }
List<String> names = new ArrayList<String>(examples.size()); List<String> names = new ArrayList<String>(examples.size());
@ -154,7 +156,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
if (content.has("use-test") && !content.get("use-test").getAsBoolean()) if (content.has("use-test") && !content.get("use-test").getAsBoolean())
return; return;
String testCaseContent = TestingUtilities.loadTestResource("validator", name); String testCaseContent = TestingUtilities.loadTestResource("validator", JSONUtil.str(content, "file"));
InstanceValidator val = vCurr.getValidator(); InstanceValidator val = vCurr.getValidator();
val.setWantCheckSnapshotUnchanged(true); val.setWantCheckSnapshotUnchanged(true);
val.getContext().setClientRetryCount(4); val.getContext().setClientRetryCount(4);
@ -226,7 +228,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
if (content.has("logical")==false) { if (content.has("logical")==false) {
val.setAssumeValidRestReferences(content.has("assumeValidRestReferences") ? content.get("assumeValidRestReferences").getAsBoolean() : false); val.setAssumeValidRestReferences(content.has("assumeValidRestReferences") ? content.get("assumeValidRestReferences").getAsBoolean() : false);
System.out.println(String.format("Start Validating (%d to set up)", (System.nanoTime() - setup) / 1000000)); System.out.println(String.format("Start Validating (%d to set up)", (System.nanoTime() - setup) / 1000000));
if (name.endsWith(".json")) if (JSONUtil.str(content, "file").endsWith(".json"))
val.validate(null, errors, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.JSON); val.validate(null, errors, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.JSON);
else else
val.validate(null, errors, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.XML); val.validate(null, errors, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.XML);
@ -258,7 +260,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
val.getContext().cacheResource(sd); val.getContext().cacheResource(sd);
val.setAssumeValidRestReferences(profile.has("assumeValidRestReferences") ? profile.get("assumeValidRestReferences").getAsBoolean() : false); val.setAssumeValidRestReferences(profile.has("assumeValidRestReferences") ? profile.get("assumeValidRestReferences").getAsBoolean() : false);
List<ValidationMessage> errorsProfile = new ArrayList<ValidationMessage>(); List<ValidationMessage> errorsProfile = new ArrayList<ValidationMessage>();
if (name.endsWith(".json")) if (JSONUtil.str(content, "file").endsWith(".json"))
val.validate(null, errorsProfile, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.JSON, asSdList(sd)); val.validate(null, errorsProfile, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.JSON, asSdList(sd));
else else
val.validate(null, errorsProfile, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.XML, asSdList(sd)); val.validate(null, errorsProfile, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.XML, asSdList(sd));

View File

@ -19,7 +19,7 @@
<properties> <properties>
<hapi_fhir_version>5.1.0</hapi_fhir_version> <hapi_fhir_version>5.1.0</hapi_fhir_version>
<validator_test_case_version>1.1.50</validator_test_case_version> <validator_test_case_version>1.1.51-SNAPSHOT</validator_test_case_version>
<junit_jupiter_version>5.6.2</junit_jupiter_version> <junit_jupiter_version>5.6.2</junit_jupiter_version>
<maven_surefire_version>3.0.0-M4</maven_surefire_version> <maven_surefire_version>3.0.0-M4</maven_surefire_version>
<jacoco_version>0.8.5</jacoco_version> <jacoco_version>0.8.5</jacoco_version>