fix bugs in FHIRPath checking and track special time when validating resources
This commit is contained in:
parent
2deb88cdc9
commit
4bba1c2cde
|
@ -264,9 +264,6 @@ public class CanonicalResourceManager<T extends CanonicalResource> {
|
|||
public void see(CachedCanonicalResource<T> cr) {
|
||||
// -- 1. exit conditions -----------------------------------------------------------------------------
|
||||
|
||||
if ("http://hl7.org/fhir/StructureDefinition/Address".equals(cr.getUrl())) {
|
||||
System.out.println("!"); // #FIXME
|
||||
}
|
||||
// ignore UTG NUCC erroneous code system
|
||||
if (cr.getPackageInfo() != null
|
||||
&& cr.getPackageInfo().getId() != null
|
||||
|
|
|
@ -444,7 +444,7 @@ public class FHIRPathEngine {
|
|||
if (context == null) {
|
||||
types = null; // this is a special case; the first path reference will have to resolve to something in the context
|
||||
} else if (!context.contains(".")) {
|
||||
StructureDefinition sd = worker.fetchTypeDefinition(resourceType);
|
||||
StructureDefinition sd = worker.fetchTypeDefinition(context);
|
||||
if (sd == null) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONTEXT, context);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -65,6 +66,7 @@ import javax.annotation.Nullable;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.FileNotifier.FileNotifier2;
|
||||
import org.hl7.fhir.utilities.Utilities.CaseInsensitiveSorter;
|
||||
import org.hl7.fhir.utilities.settings.FhirSettings;
|
||||
|
||||
public class Utilities {
|
||||
|
@ -1306,6 +1308,21 @@ public class Utilities {
|
|||
return id.matches("[A-Za-z0-9\\-\\.]{1,64}");
|
||||
}
|
||||
|
||||
public static class CaseInsensitiveSorter implements Comparator<String> {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
return o1.compareToIgnoreCase(o2);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> sortedCaseInsensitive(Collection<String> set) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.addAll(set);
|
||||
Collections.sort(list, new CaseInsensitiveSorter());
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static List<String> sorted(Collection<String> set) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.addAll(set);
|
||||
|
|
|
@ -6,6 +6,7 @@ public class TimeTracker {
|
|||
private long sdTime = 0;
|
||||
private long loadTime = 0;
|
||||
private long fpeTime = 0;
|
||||
private long specTime = 0;
|
||||
|
||||
public long getOverall() {
|
||||
return overall;
|
||||
|
@ -23,6 +24,10 @@ public class TimeTracker {
|
|||
return fpeTime;
|
||||
}
|
||||
|
||||
public long getSpecTime() {
|
||||
return specTime;
|
||||
}
|
||||
|
||||
public void load(long start) {
|
||||
loadTime = loadTime + (System.nanoTime() - start);
|
||||
}
|
||||
|
@ -45,11 +50,16 @@ public class TimeTracker {
|
|||
fpeTime = fpeTime + (System.nanoTime() - start);
|
||||
}
|
||||
|
||||
public void spec(long start) {
|
||||
specTime = specTime + (System.nanoTime() - start);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
overall = 0;
|
||||
txTime = 0;
|
||||
sdTime = 0;
|
||||
loadTime = 0;
|
||||
fpeTime = 0;
|
||||
specTime = 0;
|
||||
}
|
||||
}
|
|
@ -5202,6 +5202,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
}
|
||||
|
||||
public boolean checkSpecials(ValidatorHostContext hostContext, List<ValidationMessage> errors, Element element, NodeStack stack, boolean checkSpecials, PercentageTracker pct, ValidationMode mode) {
|
||||
|
||||
long t = System.nanoTime();
|
||||
try {
|
||||
if (VersionUtilities.getCanonicalResourceNames(context.getVersion()).contains(element.getType())) {
|
||||
Base base = element.getExtensionValue(ToolingExtensions.EXT_STANDARDS_STATUS);
|
||||
String standardsStatus = base != null && base.isPrimitive() ? base.primitiveValue() : null;
|
||||
|
@ -5241,6 +5244,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
} else {
|
||||
return true;
|
||||
}
|
||||
} finally {
|
||||
timeTracker.spec(t);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean statusCodesConsistent(String status, String standardsStatus) {
|
||||
|
@ -6535,7 +6541,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
|
||||
|
||||
public String reportTimes() {
|
||||
String s = String.format("Times (ms): overall = %d, tx = %d, sd = %d, load = %d, fpe = %d", timeTracker.getOverall() / 1000000, timeTracker.getTxTime() / 1000000, timeTracker.getSdTime() / 1000000, timeTracker.getLoadTime() / 1000000, timeTracker.getFpeTime() / 1000000);
|
||||
String s = String.format("Times (ms): overall = %d, tx = %d, sd = %d, load = %d, fpe = %d, spec = %d", timeTracker.getOverall() / 1000000, timeTracker.getTxTime() / 1000000, timeTracker.getSdTime() / 1000000, timeTracker.getLoadTime() / 1000000, timeTracker.getFpeTime() / 1000000, timeTracker.getSpecTime() / 1000000);
|
||||
timeTracker.reset();
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -536,7 +536,7 @@ public class StructureDefinitionValidator extends BaseValidator {
|
|||
types.add(elements.get(0).getNamedChildValue("path"));
|
||||
}
|
||||
List<String> warnings = new ArrayList<>();
|
||||
fpe.checkOnTypes(invariant, rootPath, types, fpe.parse(exp), warnings);
|
||||
fpe.checkOnTypes(invariant, "DomainResource", types, fpe.parse(exp), warnings);
|
||||
for (String s : warnings) {
|
||||
warning(errors, "2023-07-27", IssueType.BUSINESSRULE, stack, false, key+": "+s);
|
||||
}
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -20,7 +20,7 @@
|
|||
<properties>
|
||||
<guava_version>32.0.1-jre</guava_version>
|
||||
<hapi_fhir_version>6.4.1</hapi_fhir_version>
|
||||
<validator_test_case_version>1.4.1</validator_test_case_version>
|
||||
<validator_test_case_version>1.4.2-SNAPSHOT</validator_test_case_version>
|
||||
<jackson_version>2.15.2</jackson_version>
|
||||
<junit_jupiter_version>5.9.2</junit_jupiter_version>
|
||||
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
|
||||
|
|
Loading…
Reference in New Issue