Merge pull request #342 from hapifhir/gg-v519

various minor fixes
This commit is contained in:
Grahame Grieve 2020-09-09 14:32:24 +10:00 committed by GitHub
commit 17451a4141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 58 additions and 32 deletions

View File

@ -0,0 +1,8 @@
Validator:
* fix bug loading implied packages with no version
Other Changes:
* fix bug generating error messages rendering bundles
* fix problems generating snapshots in some profiles
* fix for FHIRPath changes after discussion on Zulip

View File

@ -514,7 +514,6 @@ public class ProfileUtilities extends TranslatingUtilities {
}
checkNotGenerating(base, "Base for generating a snapshot for the profile "+derived.getUrl());
checkNotGenerating(derived, "Focus for generating a snapshot");
derived.setUserData("profileutils.snapshot.generating", true);
if (!base.hasType()) {
throw new DefinitionException(context.formatMessage(I18nConstants.BASE_PROFILE__HAS_NO_TYPE, base.getUrl()));
@ -532,6 +531,7 @@ public class ProfileUtilities extends TranslatingUtilities {
if (snapshotStack.contains(derived.getUrl())) {
throw new DefinitionException(context.formatMessage(I18nConstants.CIRCULAR_SNAPSHOT_REFERENCES_DETECTED_CANNOT_GENERATE_SNAPSHOT_STACK__, snapshotStack.toString()));
}
derived.setUserData("profileutils.snapshot.generating", true);
snapshotStack.add(derived.getUrl());
if (!Utilities.noString(webUrl) && !webUrl.endsWith("/"))
@ -695,6 +695,7 @@ public class ProfileUtilities extends TranslatingUtilities {
} catch (Exception e) {
// if we had an exception generating the snapshot, make sure we don't leave any half generated snapshot behind
derived.setSnapshot(null);
derived.clearUserData("profileutils.snapshot.generating");
throw e;
}
derived.clearUserData("profileutils.snapshot.generating");
@ -786,7 +787,7 @@ public class ProfileUtilities extends TranslatingUtilities {
throw new FHIRException(context.formatMessage(I18nConstants.NO_PATH_VALUE_ON_ELEMENT_IN_DIFFERENTIAL_IN_, url));
}
if (!((first && type.equals(p)) || p.startsWith(type+"."))) {
throw new FHIRException(context.formatMessage(I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__MUST_START_WITH_, p, url, type, (first ? " (o be '"+type+"')" : "")));
throw new FHIRException(context.formatMessage(I18nConstants.ILLEGAL_PATH__IN_DIFFERENTIAL_IN__MUST_START_WITH_, p, url, type, (first ? " (or be '"+type+"')" : "")));
}
if (p.contains(".")) {
// Element names (the parts of a path delineated by the '.' character) SHALL NOT contain whitespace (i.e. Unicode characters marked as whitespace)
@ -6096,7 +6097,12 @@ public class ProfileUtilities extends TranslatingUtilities {
if (!c.hasExpression()) {
return null;
}
ExpressionNode expr = fpe.parse(c.getExpression());
ExpressionNode expr = null;
try {
expr = fpe.parse(c.getExpression());
} catch (Exception e) {
return null;
}
if (expr.getKind() != Kind.Group || expr.getOpNext() == null || !(expr.getOperation() == Operation.Equals || expr.getOperation() == Operation.LessOrEqual)) {
return null;
}

View File

@ -866,8 +866,6 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
if (hasTimezone() != theOther.hasTimezone()) {
if (!couldBeTheSameTime(this, theOther)) {
return false;
} else if (getPrecision() != theOther.getPrecision()) {
return false;
} else {
return null;
}
@ -885,8 +883,6 @@ public abstract class BaseDateTimeType extends PrimitiveType<Date> {
}
}
private boolean couldBeTheSameTime(BaseDateTimeType theArg1, BaseDateTimeType theArg2) {
long lowLeft = theArg1.getValue().getTime();
long highLeft = theArg1.getHighEdge().getValue().getTime();

View File

@ -533,11 +533,11 @@ public abstract class CanonicalResource extends DomainResource {
}
// Manual code (from Configuration.txt)t:
@Override
@Override
public String toString() {
return fhirType()+"["+getUrl()+"]";
}
public String present() {
if (hasTitle())
return getTitle();
@ -545,10 +545,14 @@ public abstract class CanonicalResource extends DomainResource {
return getName();
return toString();
}
public String getVUrl() {
public String getVUrl() {
return getUrl() + (hasVersion() ? "|"+getVersion() : "");
}
}
public boolean supportsCopyright() {
return true;
}
// end addition
}

View File

@ -4779,5 +4779,11 @@ public class OperationDefinition extends CanonicalResource {
public static final ca.uhn.fhir.rest.gclient.TokenClientParam VERSION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_VERSION);
//Manual code (from Configuration.txt)t:
public boolean supportsCopyright() {
return false;
}
// end
}

View File

@ -1025,7 +1025,9 @@ public class DataRenderer extends Renderer {
public XhtmlNode makeExceptionXhtml(Exception e, String function) {
XhtmlNode xn;
xn = new XhtmlNode(NodeType.Element, "div");
xn.para().b().tx("Exception "+function+": "+e.getMessage()).addComment(getStackTrace(e));
XhtmlNode p = xn.para();
p.b().tx("Exception "+function+": "+e.getMessage());
p.addComment(getStackTrace(e));
return xn;
}

View File

@ -55,12 +55,12 @@ public class BaseDateTimeTypeTest {
Assertions.assertFalse(compareDateTimes("2001-01-02T11:22:33.445Z", "2001-01-02T11:22:33.444Z"));
// FHIRPath tests:
Assertions.assertFalse(compareDateTimes("1974-12-25", "1974-12-25T12:34:00+10:00"));
Assertions.assertFalse(compareDateTimes("1974-12-25T12:34:00+10:00", "1974-12-25"));
Assertions.assertNull(compareDateTimes("1974-12-25", "1974-12-25T12:34:00+10:00"));
Assertions.assertNull(compareDateTimes("1974-12-25T12:34:00+10:00", "1974-12-25"));
Assertions.assertFalse(compareDateTimes("1974-12-25", "1974-12-23T12:34:00+10:00")); // false because they can't be the same date irrespective of precision
Assertions.assertFalse(compareDateTimes("1974-12-23T12:34:00+10:00", "1974-12-25"));
Assertions.assertFalse(compareDateTimes("1974-12-25", "1974-12-25T12:34:00Z"));
Assertions.assertFalse(compareDateTimes("1974-12-25T12:34:00Z", "1974-12-25"));
Assertions.assertNull(compareDateTimes("1974-12-25", "1974-12-25T12:34:00Z"));
Assertions.assertNull(compareDateTimes("1974-12-25T12:34:00Z", "1974-12-25"));
Assertions.assertFalse(compareDateTimes("2012-04-15", "2012-04-16"));
Assertions.assertFalse(compareDateTimes("2012-04-16", "2012-04-15"));
Assertions.assertFalse(compareDateTimes("2012-04-15T15:00:00", "2012-04-15T10:00:00"));

View File

@ -127,15 +127,17 @@ public class FHIRPathTests {
int ndx = 0;
for (int i = 0; i < p.getChildNodes().getLength(); i++) {
Node c = p.getChildNodes().item(i);
if (c == e)
if (c == e) {
break;
else if (c instanceof Element)
} else if (c instanceof Element) {
ndx++;
}
}
if (Utilities.noString(s))
if (Utilities.noString(s)) {
s = "?? - G " + p.getAttribute("name") + "[" + Integer.toString(ndx + 1) + "]";
else
} else {
s = s + " - G " + p.getAttribute("name") + "[" + Integer.toString(ndx + 1) + "]";
}
return s;
}
@ -157,9 +159,9 @@ public class FHIRPathTests {
ExpressionNode node = fp.parse(expression);
try {
if (Utilities.noString(input))
if (Utilities.noString(input)) {
fp.check(null, null, node);
else {
} else {
res = resources.get(input);
if (res == null) {
res = new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", input));
@ -191,15 +193,17 @@ public class FHIRPathTests {
for (int i = 0; i < Math.min(outcome.size(), expected.size()); i++) {
String tn = outcome.get(i).fhirType();
String s;
if (outcome.get(i) instanceof Quantity)
if (outcome.get(i) instanceof Quantity) {
s = fp.convertToString(outcome.get(i));
else
} else {
s = ((PrimitiveType) outcome.get(i)).asStringValue();
}
boolean found = false;
for (Element e : expected) {
if ((Utilities.noString(e.getAttribute("type")) || e.getAttribute("type").equals(tn)) &&
(Utilities.noString(e.getTextContent()) || e.getTextContent().equals(s)))
(Utilities.noString(e.getTextContent()) || e.getTextContent().equals(s))) {
found = true;
}
}
Assertions.assertTrue(found, String.format("Outcome %d: Value %s of type %s not expected for %s", i, s, tn, expression));
}

View File

@ -86,7 +86,7 @@ public class PackageClient {
public boolean exists(String id, String ver) throws IOException {
List<PackageInfo> vl = getVersions(id);
for (PackageInfo pi : vl) {
if (ver.equals(pi.getVersion())) {
if (ver == null || ver.equals(pi.getVersion())) {
return true;
}
}

View File

@ -224,7 +224,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
else
val.validate(null, errors, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.XML);
System.out.println(val.reportTimes());
checkOutcomes(errors, content, null);
checkOutcomes(errors, content, null, name);
}
if (content.has("profile")) {
System.out.print("** Profile: ");
@ -256,7 +256,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
else
val.validate(null, errorsProfile, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.XML, asSdList(sd));
System.out.println(val.reportTimes());
checkOutcomes(errorsProfile, profile, filename);
checkOutcomes(errorsProfile, profile, filename, name);
}
if (content.has("logical")) {
JsonObject logical = content.getAsJsonObject("logical");
@ -280,7 +280,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
Assert.assertTrue(fp.evaluateToBoolean(null, le, le, le, fp.parse(exp)));
}
}
checkOutcomes(errorsLogical, logical, "logical");
checkOutcomes(errorsLogical, logical, "logical", name);
}
}
@ -342,7 +342,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
}
}
private void checkOutcomes(List<ValidationMessage> errors, JsonObject focus, String profile) {
private void checkOutcomes(List<ValidationMessage> errors, JsonObject focus, String profile, String name) {
JsonObject java = focus.getAsJsonObject("java");
int ec = 0;
int wc = 0;

View File

@ -17,7 +17,7 @@
<properties>
<hapi_fhir_version>5.1.0</hapi_fhir_version>
<validator_test_case_version>1.1.36</validator_test_case_version>
<validator_test_case_version>1.1.37</validator_test_case_version>
<junit_jupiter_version>5.6.2</junit_jupiter_version>
<maven_surefire_version>3.0.0-M4</maven_surefire_version>
<jacoco_version>0.8.5</jacoco_version>