fixes for validation loading
This commit is contained in:
parent
5a1dfba236
commit
88c145a00c
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.7-SNAPSHOT</version>
|
||||
<version>3.7.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -11574,7 +11574,7 @@ public org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent c
|
|||
if (src.hasExtension("http://hl7.org/fhir/StructureDefinition/valueset-extensible"))
|
||||
tgt.setExtensible(((BooleanType) src.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/valueset-extensible").getValue()).booleanValue());
|
||||
org.hl7.fhir.r5.model.CodeSystem srcCS = (CodeSystem) src.getUserData("r2-cs");
|
||||
if (srcCS == null)
|
||||
if (srcCS == null && advisor != null)
|
||||
srcCS = advisor.getCodeSystem(src);
|
||||
if (srcCS != null) {
|
||||
tgt.getCodeSystem().setSystem(srcCS.getUrl());
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.7-SNAPSHOT</version>
|
||||
<version>3.7.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.7-SNAPSHOT</version>
|
||||
<version>3.7.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.7-SNAPSHOT</version>
|
||||
<version>3.7.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.7-SNAPSHOT</version>
|
||||
<version>3.7.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.7-SNAPSHOT</version>
|
||||
<version>3.7.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.7-SNAPSHOT</version>
|
||||
<version>3.7.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.7-SNAPSHOT</version>
|
||||
<version>3.7.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>3.7.7-SNAPSHOT</version>
|
||||
<version>3.7.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -463,7 +463,7 @@ public class ValidationEngine {
|
|||
if (stream != null)
|
||||
return readZip(stream);
|
||||
stream = fetchFromUrlSpecific(Utilities.pathURL(src, "validator.pack"), true);
|
||||
FhirFormat fmt = checkIsResource(stream);
|
||||
FhirFormat fmt = checkIsResource(stream, src);
|
||||
if (fmt != null) {
|
||||
Map<String, byte[]> res = new HashMap<String, byte[]>();
|
||||
res.put(Utilities.changeFileExt(src, "."+fmt.getExtension()), TextFile.fileToBytes(src));
|
||||
|
@ -488,15 +488,21 @@ public class ValidationEngine {
|
|||
private Map<String, byte[]> scanDirectory(File f) throws FileNotFoundException, IOException {
|
||||
Map<String, byte[]> res = new HashMap<String, byte[]>();
|
||||
for (File ff : f.listFiles()) {
|
||||
if (!isIgnoreFile(ff)) {
|
||||
FhirFormat fmt = checkIsResource(ff.getAbsolutePath());
|
||||
if (fmt != null) {
|
||||
res.put(Utilities.changeFileExt(ff.getName(), "."+fmt.getExtension()), TextFile.fileToBytes(ff.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private boolean isIgnoreFile(File ff) {
|
||||
return Utilities.existsInList(ff.getName(), ".DS_Store");
|
||||
}
|
||||
|
||||
private Map<String, byte[]> loadPackage(InputStream stream, String name) throws FileNotFoundException, IOException {
|
||||
return loadPackage(pcm.extractLocally(stream, name));
|
||||
}
|
||||
|
@ -585,7 +591,8 @@ public class ValidationEngine {
|
|||
this.noInvariantChecks = value;
|
||||
}
|
||||
|
||||
private FhirFormat checkIsResource(InputStream stream) {
|
||||
private FhirFormat checkIsResource(InputStream stream, String filename) {
|
||||
System.out.println(" ..Detect format for "+filename);
|
||||
try {
|
||||
Manager.parse(context, stream, FhirFormat.XML);
|
||||
return FhirFormat.XML;
|
||||
|
@ -606,6 +613,7 @@ public class ValidationEngine {
|
|||
return FhirFormat.TEXT;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
System.out.println(" .. not a resource: "+filename);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -622,7 +630,7 @@ public class ValidationEngine {
|
|||
if (Utilities.existsInList(ext, "txt"))
|
||||
return FhirFormat.TEXT;
|
||||
|
||||
return checkIsResource(new FileInputStream(path));
|
||||
return checkIsResource(new FileInputStream(path), path);
|
||||
}
|
||||
|
||||
public void connectToTSServer(String url, String log, FhirPublication version) throws URISyntaxException, FHIRException {
|
||||
|
@ -667,6 +675,8 @@ public class ValidationEngine {
|
|||
res = new org.hl7.fhir.dstu3.formats.XmlParser().parse(new ByteArrayInputStream(t.getValue()));
|
||||
else if (fn.endsWith(".json") && !fn.endsWith("template.json"))
|
||||
res = new org.hl7.fhir.dstu3.formats.JsonParser().parse(new ByteArrayInputStream(t.getValue()));
|
||||
else if (fn.endsWith(".txt") || fn.endsWith(".map") )
|
||||
res = new org.hl7.fhir.dstu3.utils.StructureMapUtilities(null).parse(new String(t.getValue()));
|
||||
else
|
||||
throw new Exception("Unsupported format for "+fn);
|
||||
r = VersionConvertor_30_40.convertResource(res, false);
|
||||
|
@ -696,6 +706,8 @@ public class ValidationEngine {
|
|||
r = new JsonParser().parse(new ByteArrayInputStream(t.getValue()));
|
||||
else if (fn.endsWith(".txt"))
|
||||
r = new StructureMapUtilities(context, null, null).parse(TextFile.bytesToString(t.getValue()), fn);
|
||||
else if (fn.endsWith(".txt") || fn.endsWith(".map") )
|
||||
r = new org.hl7.fhir.r4.utils.StructureMapUtilities(null).parse(new String(t.getValue()), fn);
|
||||
else
|
||||
throw new Exception("Unsupported format for "+fn);
|
||||
} else
|
||||
|
@ -764,6 +776,8 @@ public class ValidationEngine {
|
|||
res.cntType = FhirFormat.XML;
|
||||
else if (t.getKey().endsWith(".ttl"))
|
||||
res.cntType = FhirFormat.TURTLE;
|
||||
else if (t.getKey().endsWith(".txt") || t.getKey().endsWith(".map"))
|
||||
res.cntType = FhirFormat.TEXT;
|
||||
else
|
||||
throw new Exception("Todo: Determining resource type is not yet done");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue