fix so recursive loading is only by request
This commit is contained in:
parent
539eee9266
commit
6d611afd48
|
@ -164,7 +164,7 @@ public class NativeHostServices {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void load(String pack) throws Exception {
|
public void load(String pack) throws Exception {
|
||||||
validator.loadIg(pack);
|
validator.loadIg(pack, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -292,7 +292,7 @@ public class ValidationEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadInitialDefinitions(String src) throws Exception {
|
public void loadInitialDefinitions(String src) throws Exception {
|
||||||
loadDefinitions(src);
|
loadDefinitions(src, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTerminologyServer(String src, String log, FhirPublication version) throws Exception {
|
public void setTerminologyServer(String src, String log, FhirPublication version) throws Exception {
|
||||||
|
@ -329,7 +329,7 @@ public class ValidationEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValidationEngine(String src) throws Exception {
|
public ValidationEngine(String src) throws Exception {
|
||||||
loadDefinitions(src);
|
loadDefinitions(src, false);
|
||||||
pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,8 +341,8 @@ public class ValidationEngine {
|
||||||
this.language = language;
|
this.language = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadDefinitions(String src) throws Exception {
|
private void loadDefinitions(String src, boolean recursive) throws Exception {
|
||||||
Map<String, byte[]> source = loadIgSource(src);
|
Map<String, byte[]> source = loadIgSource(src, recursive);
|
||||||
if (version == null)
|
if (version == null)
|
||||||
version = getVersionFromPack(source);
|
version = getVersionFromPack(source);
|
||||||
context = SimpleWorkerContext.fromDefinitions(source, loaderForVersion());
|
context = SimpleWorkerContext.fromDefinitions(source, loaderForVersion());
|
||||||
|
@ -417,7 +417,7 @@ public class ValidationEngine {
|
||||||
return TextFile.fileToBytes(src);
|
return TextFile.fileToBytes(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, byte[]> loadIgSource(String src) throws Exception {
|
private Map<String, byte[]> loadIgSource(String src, boolean recursive) throws Exception {
|
||||||
// src can be one of the following:
|
// src can be one of the following:
|
||||||
// - a canonical url for an ig - this will be converted to a package id and loaded into the cache
|
// - a canonical url for an ig - this will be converted to a package id and loaded into the cache
|
||||||
// - a package id for an ig - this will be loaded into the cache
|
// - a package id for an ig - this will be loaded into the cache
|
||||||
|
@ -445,7 +445,7 @@ public class ValidationEngine {
|
||||||
if (f.isDirectory() && new File(Utilities.path(src, "validator.pack")).exists())
|
if (f.isDirectory() && new File(Utilities.path(src, "validator.pack")).exists())
|
||||||
return readZip(new FileInputStream(Utilities.path(src, "validator.pack")));
|
return readZip(new FileInputStream(Utilities.path(src, "validator.pack")));
|
||||||
if (f.isDirectory())
|
if (f.isDirectory())
|
||||||
return scanDirectory(f);
|
return scanDirectory(f, recursive);
|
||||||
if (src.endsWith(".tgz"))
|
if (src.endsWith(".tgz"))
|
||||||
return loadPackage(new FileInputStream(src), src);
|
return loadPackage(new FileInputStream(src), src);
|
||||||
if (src.endsWith(".pack"))
|
if (src.endsWith(".pack"))
|
||||||
|
@ -505,11 +505,12 @@ public class ValidationEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, byte[]> scanDirectory(File f) throws FileNotFoundException, IOException {
|
private Map<String, byte[]> scanDirectory(File f, boolean recursive) throws FileNotFoundException, IOException {
|
||||||
Map<String, byte[]> res = new HashMap<>();
|
Map<String, byte[]> res = new HashMap<>();
|
||||||
for (File ff : f.listFiles()) {
|
for (File ff : f.listFiles()) {
|
||||||
if (ff.isDirectory()){
|
if (ff.isDirectory()){
|
||||||
res.putAll(scanDirectory(ff));
|
if (recursive)
|
||||||
|
res.putAll(scanDirectory(ff, true));
|
||||||
}
|
}
|
||||||
else if (!isIgnoreFile(ff)) {
|
else if (!isIgnoreFile(ff)) {
|
||||||
FhirFormat fmt = checkIsResource(ff.getAbsolutePath());
|
FhirFormat fmt = checkIsResource(ff.getAbsolutePath());
|
||||||
|
@ -685,9 +686,9 @@ public class ValidationEngine {
|
||||||
context.cacheResource(r);
|
context.cacheResource(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadIg(String src) throws IOException, FHIRException, Exception {
|
public void loadIg(String src, boolean recursive) throws IOException, FHIRException, Exception {
|
||||||
String canonical = null;
|
String canonical = null;
|
||||||
Map<String, byte[]> source = loadIgSource(src);
|
Map<String, byte[]> source = loadIgSource(src, recursive);
|
||||||
String version = Constants.VERSION;
|
String version = Constants.VERSION;
|
||||||
if (this.version != null)
|
if (this.version != null)
|
||||||
version = this.version;
|
version = this.version;
|
||||||
|
@ -808,7 +809,7 @@ public class ValidationEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Content loadContent(String source, String opName) throws Exception {
|
public Content loadContent(String source, String opName) throws Exception {
|
||||||
Map<String, byte[]> s = loadIgSource(source);
|
Map<String, byte[]> s = loadIgSource(source, false);
|
||||||
Content res = new Content();
|
Content res = new Content();
|
||||||
if (s.size() != 1)
|
if (s.size() != 1)
|
||||||
throw new Exception("Unable to find resource " + source + " to "+opName);
|
throw new Exception("Unable to find resource " + source + " to "+opName);
|
||||||
|
|
|
@ -163,6 +163,8 @@ public class Validator {
|
||||||
System.out.println(" Default: results are sent to the std out.");
|
System.out.println(" Default: results are sent to the std out.");
|
||||||
System.out.println("-debug");
|
System.out.println("-debug");
|
||||||
System.out.println(" Produce additional information about the loading/validation process");
|
System.out.println(" Produce additional information about the loading/validation process");
|
||||||
|
System.out.println("-recurse");
|
||||||
|
System.out.println(" Look in subfolders when -ig refers to a folder");
|
||||||
System.out.println("-native: use schema for validation as well");
|
System.out.println("-native: use schema for validation as well");
|
||||||
System.out.println(" * XML: w3c schema+schematron");
|
System.out.println(" * XML: w3c schema+schematron");
|
||||||
System.out.println(" * JSON: json.schema");
|
System.out.println(" * JSON: json.schema");
|
||||||
|
@ -228,7 +230,7 @@ public class Validator {
|
||||||
String s = args[++i];
|
String s = args[++i];
|
||||||
if (!s.startsWith("hl7.fhir.core-")) {
|
if (!s.startsWith("hl7.fhir.core-")) {
|
||||||
System.out.println("Load Package: "+s);
|
System.out.println("Load Package: "+s);
|
||||||
validator.loadIg(s);
|
validator.loadIg(s, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,6 +270,7 @@ public class Validator {
|
||||||
boolean doNative = false;
|
boolean doNative = false;
|
||||||
boolean anyExtensionsAllowed = true;
|
boolean anyExtensionsAllowed = true;
|
||||||
boolean hintAboutNonMustSupport = false;
|
boolean hintAboutNonMustSupport = false;
|
||||||
|
boolean recursive = false;
|
||||||
List<String> profiles = new ArrayList<String>();
|
List<String> profiles = new ArrayList<String>();
|
||||||
EngineMode mode = EngineMode.VALIDATION;
|
EngineMode mode = EngineMode.VALIDATION;
|
||||||
String output = null;
|
String output = null;
|
||||||
|
@ -323,6 +326,8 @@ public class Validator {
|
||||||
doNative = true;
|
doNative = true;
|
||||||
else if (args[i].equals("-debug"))
|
else if (args[i].equals("-debug"))
|
||||||
doDebug = true;
|
doDebug = true;
|
||||||
|
else if (args[i].equals("-recurse"))
|
||||||
|
recursive = true;
|
||||||
else if (args[i].equals("-strictExtensions"))
|
else if (args[i].equals("-strictExtensions"))
|
||||||
anyExtensionsAllowed = false;
|
anyExtensionsAllowed = false;
|
||||||
else if (args[i].equals("-hintAboutNonMustSupport"))
|
else if (args[i].equals("-hintAboutNonMustSupport"))
|
||||||
|
@ -390,7 +395,7 @@ public class Validator {
|
||||||
validator.setVersion(sv);
|
validator.setVersion(sv);
|
||||||
for (String src : igs) {
|
for (String src : igs) {
|
||||||
System.out.println("+ .. load IG from "+src);
|
System.out.println("+ .. load IG from "+src);
|
||||||
validator.loadIg(src);
|
validator.loadIg(src, recursive);
|
||||||
}
|
}
|
||||||
validator.setQuestionnaires(questionnaires);
|
validator.setQuestionnaires(questionnaires);
|
||||||
validator.setNative(doNative);
|
validator.setNative(doNative);
|
||||||
|
|
|
@ -22,8 +22,8 @@ public class ProfileComparisonTests {
|
||||||
if (!TestUtilities.silent)
|
if (!TestUtilities.silent)
|
||||||
System.out.println("Compare US Patient Core with AU Patient Base");
|
System.out.println("Compare US Patient Core with AU Patient Base");
|
||||||
ValidationEngine ve = new ValidationEngine("hl7.fhir.core#3.0.1", DEF_TX, null, FhirPublication.R4);
|
ValidationEngine ve = new ValidationEngine("hl7.fhir.core#3.0.1", DEF_TX, null, FhirPublication.R4);
|
||||||
ve.loadIg("hl7.fhir.us.core#1.0.1");
|
ve.loadIg("hl7.fhir.us.core#1.0.1", false);
|
||||||
ve.loadIg("hl7.fhir.au.base#dev");
|
ve.loadIg("hl7.fhir.au.base#dev", false);
|
||||||
|
|
||||||
|
|
||||||
String left = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient";
|
String left = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient";
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class ValidationEngineTests {
|
||||||
ValidationEngine ve = new ValidationEngine("hl7.fhir.core#3.0.1", DEF_TX, null, FhirPublication.STU3);
|
ValidationEngine ve = new ValidationEngine("hl7.fhir.core#3.0.1", DEF_TX, null, FhirPublication.STU3);
|
||||||
if (!TestUtilities.silent)
|
if (!TestUtilities.silent)
|
||||||
System.out.println(" .. load USCore");
|
System.out.println(" .. load USCore");
|
||||||
ve.loadIg("hl7.fhir.us.core#1.0.1");
|
ve.loadIg("hl7.fhir.us.core#1.0.1", false);
|
||||||
List<String> profiles = new ArrayList<>();
|
List<String> profiles = new ArrayList<>();
|
||||||
profiles.add("http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient");
|
profiles.add("http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient");
|
||||||
OperationOutcome op = ve.validate(TestUtilities.resourceNameToFile("validation-examples", "patient301.xml"), profiles);
|
OperationOutcome op = ve.validate(TestUtilities.resourceNameToFile("validation-examples", "patient301.xml"), profiles);
|
||||||
|
|
Loading…
Reference in New Issue