Merge remote-tracking branch 'origin/master' into do-20240319-tx-test-reuse
This commit is contained in:
commit
7a8ac05075
|
@ -50,17 +50,17 @@ public class MavenWrapperDownloader {
|
|||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("- Downloader started");
|
||||
File baseDirectory = new File(args[0]);
|
||||
File baseDirectory = ManagedFileAccess.file(args[0]);
|
||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||
|
||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||
// wrapperUrl parameter.
|
||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||
File mavenWrapperPropertyFile = ManagedFileAccess.file(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||
String url = DEFAULT_DOWNLOAD_URL;
|
||||
if(mavenWrapperPropertyFile.exists()) {
|
||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||
try {
|
||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||
mavenWrapperPropertyFileInputStream = ManagedFileAccess.inStream(mavenWrapperPropertyFile);
|
||||
Properties mavenWrapperProperties = new Properties();
|
||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||
|
@ -78,7 +78,7 @@ public class MavenWrapperDownloader {
|
|||
}
|
||||
System.out.println("- Downloading from: : " + url);
|
||||
|
||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||
File outputFile = ManagedFileAccess.file(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||
if(!outputFile.getParentFile().exists()) {
|
||||
if(!outputFile.getParentFile().mkdirs()) {
|
||||
System.out.println(
|
||||
|
@ -101,7 +101,7 @@ public class MavenWrapperDownloader {
|
|||
URL website = new URL(urlString);
|
||||
ReadableByteChannel rbc;
|
||||
rbc = Channels.newChannel(website.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(destination);
|
||||
FileOutputStream fos = ManagedFileAccess.outStream(destination);
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
fos.close();
|
||||
rbc.close();
|
||||
|
|
|
@ -67,6 +67,7 @@ import org.hl7.fhir.dstu3.utils.StructureMapUtilities;
|
|||
import org.hl7.fhir.dstu3.utils.StructureMapUtilities.ITransformerServices;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
/**
|
||||
* This class manages conversion from R2 to R3 and vice versa
|
||||
|
@ -113,8 +114,8 @@ public class R2R3ConversionManager implements ITransformerServices {
|
|||
self.setR3Definitions(getNamedParam(args, "-d3"));
|
||||
self.setMappingLibrary(getNamedParam(args, "-maps"));
|
||||
FhirFormat fmt = hasParam(args, "-fmt") ? getNamedParam(args, "-fmt").equalsIgnoreCase("json") ? FhirFormat.JSON : FhirFormat.XML : FhirFormat.XML;
|
||||
InputStream src = new FileInputStream(getNamedParam(args, "-src"));
|
||||
OutputStream dst = new FileOutputStream(getNamedParam(args, "-dest"));
|
||||
InputStream src = ManagedFileAccess.inStream(getNamedParam(args, "-src"));
|
||||
OutputStream dst = ManagedFileAccess.outStream(getNamedParam(args, "-dest"));
|
||||
self.convert(src, dst, hasParam(args, "-r2"), fmt);
|
||||
}
|
||||
}
|
||||
|
@ -164,9 +165,9 @@ public class R2R3ConversionManager implements ITransformerServices {
|
|||
}
|
||||
|
||||
public void setR2Definitions(String source) throws IOException, FHIRException {
|
||||
File f = new File(source);
|
||||
File f = ManagedFileAccess.file(source);
|
||||
if (f.exists())
|
||||
setR2Definitions(new FileInputStream(f));
|
||||
setR2Definitions(ManagedFileAccess.inStream(f));
|
||||
else
|
||||
setR2Definitions(fetch(source));
|
||||
}
|
||||
|
@ -184,9 +185,9 @@ public class R2R3ConversionManager implements ITransformerServices {
|
|||
}
|
||||
|
||||
public void setR3Definitions(String source) throws IOException, FHIRException {
|
||||
File f = new File(source);
|
||||
File f = ManagedFileAccess.file(source);
|
||||
if (f.exists())
|
||||
setR3Definitions(new FileInputStream(f));
|
||||
setR3Definitions(ManagedFileAccess.inStream(f));
|
||||
else
|
||||
setR3Definitions(fetch(source));
|
||||
}
|
||||
|
@ -201,9 +202,9 @@ public class R2R3ConversionManager implements ITransformerServices {
|
|||
}
|
||||
|
||||
public void setMappingLibrary(String source) throws IOException, FHIRException {
|
||||
File f = new File(source);
|
||||
File f = ManagedFileAccess.file(source);
|
||||
if (f.exists())
|
||||
setMappingLibrary(new FileInputStream(f));
|
||||
setMappingLibrary(ManagedFileAccess.inStream(f));
|
||||
else
|
||||
setMappingLibrary(fetch(source));
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.hl7.fhir.utilities.IniFile;
|
|||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.ZipGenerator;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xhtml.NodeType;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
|
@ -132,7 +133,7 @@ public class SpecDifferenceEvaluator {
|
|||
}
|
||||
|
||||
private static void loadSD4(Map<String, StructureDefinition> map, String fn) throws FHIRException, IOException {
|
||||
org.hl7.fhir.r4.model.Bundle bundle = (org.hl7.fhir.r4.model.Bundle) new org.hl7.fhir.r4.formats.XmlParser().parse(new FileInputStream(fn));
|
||||
org.hl7.fhir.r4.model.Bundle bundle = (org.hl7.fhir.r4.model.Bundle) new org.hl7.fhir.r4.formats.XmlParser().parse(ManagedFileAccess.inStream(fn));
|
||||
for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent be : bundle.getEntry()) {
|
||||
if (be.getResource() instanceof org.hl7.fhir.r4.model.StructureDefinition) {
|
||||
org.hl7.fhir.r4.model.StructureDefinition sd = (org.hl7.fhir.r4.model.StructureDefinition) be.getResource();
|
||||
|
@ -143,7 +144,7 @@ public class SpecDifferenceEvaluator {
|
|||
}
|
||||
|
||||
private static void loadSD(Map<String, StructureDefinition> map, String fn) throws FHIRFormatError, IOException {
|
||||
Bundle bundle = (Bundle) new XmlParser().parse(new FileInputStream(fn));
|
||||
Bundle bundle = (Bundle) new XmlParser().parse(ManagedFileAccess.inStream(fn));
|
||||
for (BundleEntryComponent be : bundle.getEntry()) {
|
||||
if (be.getResource() instanceof StructureDefinition) {
|
||||
StructureDefinition sd = (StructureDefinition) be.getResource();
|
||||
|
@ -153,7 +154,7 @@ public class SpecDifferenceEvaluator {
|
|||
}
|
||||
|
||||
private static void loadVS4(Map<String, ValueSet> map, String fn) throws FHIRException, IOException {
|
||||
org.hl7.fhir.r4.model.Bundle bundle = (org.hl7.fhir.r4.model.Bundle) new org.hl7.fhir.r4.formats.XmlParser().parse(new FileInputStream(fn));
|
||||
org.hl7.fhir.r4.model.Bundle bundle = (org.hl7.fhir.r4.model.Bundle) new org.hl7.fhir.r4.formats.XmlParser().parse(ManagedFileAccess.inStream(fn));
|
||||
for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent be : bundle.getEntry()) {
|
||||
if (be.getResource() instanceof org.hl7.fhir.r4.model.ValueSet) {
|
||||
org.hl7.fhir.r4.model.ValueSet sd = (org.hl7.fhir.r4.model.ValueSet) be.getResource();
|
||||
|
@ -163,7 +164,7 @@ public class SpecDifferenceEvaluator {
|
|||
}
|
||||
|
||||
private static void loadVS(Map<String, ValueSet> map, String fn) throws FHIRFormatError, IOException {
|
||||
Bundle bundle = (Bundle) new XmlParser().parse(new FileInputStream(fn));
|
||||
Bundle bundle = (Bundle) new XmlParser().parse(ManagedFileAccess.inStream(fn));
|
||||
for (BundleEntryComponent be : bundle.getEntry()) {
|
||||
if (be.getResource() instanceof ValueSet) {
|
||||
ValueSet sd = (ValueSet) be.getResource();
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.hl7.fhir.utilities.SimpleHTTPClient;
|
|||
import org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonArray;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
|
@ -230,14 +231,14 @@ public class PackageVisitor {
|
|||
String[] p = url.split("\\/");
|
||||
String repo = "https://build.fhir.org/ig/"+p[0]+"/"+p[1];
|
||||
JsonObject manifest = JsonParser.parseObjectFromUrl(repo+"/package.manifest.json");
|
||||
File co = new File(Utilities.path(cache, pid+"."+manifest.asString("date")+".tgz"));
|
||||
File co = ManagedFileAccess.file(Utilities.path(cache, pid+"."+manifest.asString("date")+".tgz"));
|
||||
if (!co.exists()) {
|
||||
SimpleHTTPClient fetcher = new SimpleHTTPClient();
|
||||
HTTPResult res = fetcher.get(repo+"/package.tgz?nocache=" + System.currentTimeMillis());
|
||||
res.checkThrowException();
|
||||
TextFile.bytesToFile(res.getContent(), co);
|
||||
}
|
||||
NpmPackage npm = NpmPackage.fromPackage(new FileInputStream(co));
|
||||
NpmPackage npm = NpmPackage.fromPackage(ManagedFileAccess.inStream(co));
|
||||
String fv = npm.fhirVersion();
|
||||
long ms2 = System.currentTimeMillis();
|
||||
|
||||
|
|
|
@ -9,11 +9,12 @@ import java.io.InputStreamReader;
|
|||
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class BOMRemover {
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException, IOException {
|
||||
new BOMRemover().execute(new File(args[0]));
|
||||
new BOMRemover().execute(ManagedFileAccess.file(args[0]));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -9,20 +9,21 @@ import java.io.IOException;
|
|||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.model.CodeSystem;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class BigCodeSystemGenerator {
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException, IOException {
|
||||
new BigCodeSystemGenerator().execute(new File("/Users/grahamegrieve/work/test-cases/tx/big/codesystem-big.json"));
|
||||
new BigCodeSystemGenerator().execute(ManagedFileAccess.file("/Users/grahamegrieve/work/test-cases/tx/big/codesystem-big.json"));
|
||||
}
|
||||
|
||||
private void execute(File file) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
CodeSystem cs = (CodeSystem) new JsonParser().parse(new FileInputStream(file));
|
||||
CodeSystem cs = (CodeSystem) new JsonParser().parse(ManagedFileAccess.inStream(file));
|
||||
cs.getConcept().clear();
|
||||
for (int i = 1; i <= 2000; i++) {
|
||||
cs.addConcept().setCode("code"+i).setDisplay("Display "+i).setDefinition("This is code "+i);
|
||||
}
|
||||
new JsonParser().compose(new FileOutputStream(file), cs);
|
||||
new JsonParser().compose(ManagedFileAccess.outStream(file), cs);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.hl7.fhir.utilities.SimpleHTTPClient;
|
|||
import org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -115,9 +116,9 @@ public class CKMImporter {
|
|||
String src = Utilities.path(Utilities.path("[tmp]"), id + ".xml");
|
||||
String dst = Utilities.path(dest, id + ".xml");
|
||||
|
||||
if (!new File(src).exists())
|
||||
if (!ManagedFileAccess.file(src).exists())
|
||||
downloadArchetype(id);
|
||||
if (cfg != null && new File(cfg).exists())
|
||||
if (cfg != null && ManagedFileAccess.file(cfg).exists())
|
||||
ADLImporter.main(new String[]{"-source", src, "-dest", dst, "-config", config, "-info", cfg});
|
||||
else
|
||||
ADLImporter.main(new String[]{"-source", src, "-dest", dst, "-config", config});
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
|
|||
import org.hl7.fhir.r5.terminologies.CodeSystemUtilities;
|
||||
import org.hl7.fhir.utilities.CSVReader;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class CPTImporter {
|
||||
|
||||
|
@ -89,12 +90,12 @@ public class CPTImporter {
|
|||
System.out.println(c);
|
||||
System.out.println(k);
|
||||
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(dst), cs);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(dst), cs);
|
||||
produceDB(Utilities.changeFileExt(dst, ".db"), cs);
|
||||
|
||||
cs.setContent(CodeSystemContentMode.FRAGMENT);
|
||||
cs.getConcept().removeIf(cc -> !Utilities.existsInList(cc.getCode(), "metadata-kinds", "metadata-designations", "99202", "99203", "0001A", "99252", "25", "P1", "1P", "F1", "95"));
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.changeFileExt(dst, "-fragment.json")), cs);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.changeFileExt(dst, "-fragment.json")), cs);
|
||||
produceDB(Utilities.changeFileExt(dst, "-fragment.db"), cs);
|
||||
}
|
||||
|
||||
|
@ -146,7 +147,7 @@ public class CPTImporter {
|
|||
}
|
||||
|
||||
|
||||
private void produceDB(String path, CodeSystem cs) throws ClassNotFoundException, SQLException {
|
||||
private void produceDB(String path, CodeSystem cs) throws ClassNotFoundException, SQLException, IOException {
|
||||
Connection con = connect(path);
|
||||
|
||||
Statement stmt = con.createStatement();
|
||||
|
@ -185,10 +186,10 @@ public class CPTImporter {
|
|||
}
|
||||
|
||||
|
||||
private Connection connect(String dest) throws SQLException, ClassNotFoundException {
|
||||
private Connection connect(String dest) throws SQLException, ClassNotFoundException, IOException {
|
||||
// Class.forName("com.mysql.jdbc.Driver");
|
||||
// con = DriverManager.getConnection("jdbc:mysql://localhost:3306/omop?useSSL=false","root",{pwd});
|
||||
new File(dest).delete();
|
||||
ManagedFileAccess.file(dest).delete();
|
||||
Connection con = DriverManager.getConnection("jdbc:sqlite:"+dest);
|
||||
makeMetadataTable(con);
|
||||
makeConceptsTable(con);
|
||||
|
@ -267,7 +268,7 @@ public class CPTImporter {
|
|||
}
|
||||
|
||||
private int processModifiers(CodeSystem cs, String path) throws FHIRException, FileNotFoundException, IOException {
|
||||
CSVReader csv = new CSVReader(new FileInputStream(path));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(path));
|
||||
csv.readHeaders();
|
||||
|
||||
int res = 0;
|
||||
|
@ -309,7 +310,7 @@ public class CPTImporter {
|
|||
FileInputStream inputStream = null;
|
||||
Scanner sc = null;
|
||||
try {
|
||||
inputStream = new FileInputStream(path);
|
||||
inputStream = ManagedFileAccess.inStream(path);
|
||||
sc = new Scanner(inputStream, "UTF-8");
|
||||
while (sc.hasNextLine()) {
|
||||
String line = sc.nextLine();
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.hl7.fhir.r4.model.Coding;
|
|||
import org.hl7.fhir.r4.model.DateTimeType;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.hl7.fhir.r4.terminologies.CodeSystemUtilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -58,7 +59,7 @@ public class CVXImporter {
|
|||
}
|
||||
|
||||
private void doUpdate(String source, String dest) throws FHIRFormatError, FileNotFoundException, IOException, ParserConfigurationException, SAXException {
|
||||
CodeSystem cvx = (CodeSystem) new JsonParser().parse(new FileInputStream(dest));
|
||||
CodeSystem cvx = (CodeSystem) new JsonParser().parse(ManagedFileAccess.inStream(dest));
|
||||
|
||||
String ldate = null;
|
||||
|
||||
|
@ -94,7 +95,7 @@ public class CVXImporter {
|
|||
Collections.sort(cvx.getConcept(), new CVXSorter());
|
||||
cvx.setDateElement(new DateTimeType(ldate));
|
||||
cvx.setVersion(ldate.replace("-", ""));
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(dest), cvx);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(dest), cvx);
|
||||
}
|
||||
|
||||
private ConceptDefinitionComponent findCVXCode(CodeSystem cvx, String code) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
|||
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
|
@ -26,12 +27,12 @@ public class CorePackageTools {
|
|||
private void buildPackage(String path, String output) throws IOException {
|
||||
NpmPackage npm = NpmPackage.fromFolder(path);
|
||||
npm.loadAllFiles();
|
||||
npm.save(new FileOutputStream(output));
|
||||
npm.save(ManagedFileAccess.outStream(output));
|
||||
|
||||
}
|
||||
|
||||
private void buildXml(String json, String xml, String version) throws FHIRFormatError, IOException {
|
||||
for (File f : new File(Utilities.path(json, "package")).listFiles()) {
|
||||
for (File f : ManagedFileAccess.file(Utilities.path(json, "package")).listFiles()) {
|
||||
if (f.getName().endsWith(".json")) {
|
||||
JsonObject j = JsonParser.parseObject(f);
|
||||
if (j.has("resourceType")) {
|
||||
|
@ -39,8 +40,8 @@ public class CorePackageTools {
|
|||
String n = f.getName();
|
||||
System.out.println(n);
|
||||
String xn = Utilities.changeFileExt(n, ".xml");
|
||||
org.hl7.fhir.dstu2016may.model.Resource r = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new FileInputStream(f));
|
||||
new org.hl7.fhir.dstu2016may.formats.XmlParser().setOutputStyle(org.hl7.fhir.dstu2016may.formats.IParser.OutputStyle.NORMAL).compose(new FileOutputStream(Utilities.path(xml, "package", xn)), r);
|
||||
org.hl7.fhir.dstu2016may.model.Resource r = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(ManagedFileAccess.inStream(f));
|
||||
new org.hl7.fhir.dstu2016may.formats.XmlParser().setOutputStyle(org.hl7.fhir.dstu2016may.formats.IParser.OutputStyle.NORMAL).compose(ManagedFileAccess.outStream(Utilities.path(xml, "package", xn)), r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.hl7.fhir.r4.model.CodeType;
|
|||
import org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem;
|
||||
import org.hl7.fhir.r4.model.DateTimeType;
|
||||
import org.hl7.fhir.r4.model.Enumerations.PublicationStatus;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -123,10 +124,10 @@ public class CountryCodesConverter {
|
|||
cs1.setCount(cs1.getConcept().size());
|
||||
cs2.setCount(cs2.getConcept().size());
|
||||
throw new Error("Needs revisiting");
|
||||
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "4.0.1", "package", "CodeSstem-iso3166.json")), cs1);
|
||||
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "3.0.2", "package", "CodeSstem-iso3166.json")), cs1); // format hasn't changed
|
||||
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "4.0.1", "package", "CodeSstem-iso3166-2.json")), cs2);
|
||||
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "3.0.2", "package", "CodeSstem-iso3166-2.json")), cs2); // format hasn't changed
|
||||
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "4.0.1", "package", "CodeSstem-iso3166.json")), cs1);
|
||||
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "3.0.2", "package", "CodeSstem-iso3166.json")), cs1); // format hasn't changed
|
||||
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "4.0.1", "package", "CodeSstem-iso3166-2.json")), cs2);
|
||||
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "3.0.2", "package", "CodeSstem-iso3166-2.json")), cs2); // format hasn't changed
|
||||
}
|
||||
|
||||
public void setMetadata(Document src, CodeSystem cs, String id, String url, String partName, String partTitle) {
|
||||
|
@ -360,7 +361,7 @@ public class CountryCodesConverter {
|
|||
factory.setNamespaceAware(true);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
return builder.parse(new FileInputStream(source));
|
||||
return builder.parse(ManagedFileAccess.inStream(source));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.hl7.fhir.r4.model.ValueSet;
|
|||
import org.hl7.fhir.r4.utils.NPMPackageGenerator;
|
||||
import org.hl7.fhir.r4.utils.NPMPackageGenerator.Category;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -73,8 +74,8 @@ public class DicomPackageBuilder {
|
|||
Set<String> ids = new HashSet<>();
|
||||
ids.add(vs.getId());
|
||||
|
||||
for (File f : new File(Utilities.path(source, "Resources", "valuesets", "fhir", "json")).listFiles()) {
|
||||
vs = (ValueSet) JsonParser.loadFile(new FileInputStream(f));
|
||||
for (File f : ManagedFileAccess.file(Utilities.path(source, "Resources", "valuesets", "fhir", "json")).listFiles()) {
|
||||
vs = (ValueSet) JsonParser.loadFile(ManagedFileAccess.inStream(f));
|
||||
vs.setVersion(version);
|
||||
if (vs.getId().length() > 64) {
|
||||
vs.setId(vs.getId().substring(0, 64));
|
||||
|
@ -133,7 +134,7 @@ public class DicomPackageBuilder {
|
|||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document doc = builder.parse(new FileInputStream(Utilities.path(source, "Resources", "Ontology", "DCM", "dcm.owl")));
|
||||
Document doc = builder.parse(ManagedFileAccess.inStream(Utilities.path(source, "Resources", "Ontology", "DCM", "dcm.owl")));
|
||||
Element rdf = doc.getDocumentElement();
|
||||
Element d = XMLUtil.getFirstChild(rdf);
|
||||
version = processVersion(XMLUtil.getNamedChildText(d, "versionInfo"));
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Set;
|
|||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
|
||||
|
@ -22,9 +23,9 @@ public class ExamplesPackageBuilder {
|
|||
|
||||
private void process(String source) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
Set<String> set = new HashSet<>();
|
||||
for (File f : new File(source).listFiles()) {
|
||||
for (File f : ManagedFileAccess.file(source).listFiles()) {
|
||||
if (f.getName().endsWith(".json")) {
|
||||
JsonObject obj = JsonParser.parseObject(new FileInputStream(f));
|
||||
JsonObject obj = JsonParser.parseObject(ManagedFileAccess.inStream(f));
|
||||
if (obj.has("resourceType") && obj.has("id")) {
|
||||
String type = obj.asString("resourceType");
|
||||
String id = obj.asString("id");
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
|
|||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
|
@ -131,7 +132,7 @@ public class ExtensionExtractor {
|
|||
save(cs, dst,s, ids);
|
||||
}
|
||||
|
||||
deleteMatchingResources(ids, new File("/Users/grahamegrieve/work/r5/source"));
|
||||
deleteMatchingResources(ids, ManagedFileAccess.file("/Users/grahamegrieve/work/r5/source"));
|
||||
}
|
||||
|
||||
private void deleteMatchingResources(Set<String> ids, File folder) {
|
||||
|
@ -172,9 +173,9 @@ public class ExtensionExtractor {
|
|||
ids.add(cr.getId());
|
||||
String fn = Utilities.path(dst, folder, cr.fhirType()+"-"+cr.getId()+".xml");
|
||||
cr.setUserData("folder", folder);
|
||||
if (!new File(fn).exists()) {
|
||||
if (!ManagedFileAccess.file(fn).exists()) {
|
||||
Utilities.createDirectory(Utilities.getDirectoryForFile(fn));
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), cr);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(fn), cr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,13 +43,14 @@ import org.hl7.fhir.dstu2.model.Resource;
|
|||
import org.hl7.fhir.dstu2.model.ValueSet;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class GenValueSetExpansionConvertor {
|
||||
|
||||
public static void main(String[] args) throws FHIRFormatError, IOException {
|
||||
String src = args[0];
|
||||
String tgt = args[1];
|
||||
Bundle bundle = (Bundle) new XmlParser().parse(new FileInputStream(src));
|
||||
Bundle bundle = (Bundle) new XmlParser().parse(ManagedFileAccess.inStream(src));
|
||||
for (BundleEntryComponent be : bundle.getEntry()) {
|
||||
Resource res = be.getResource();
|
||||
if (res != null) {
|
||||
|
@ -58,7 +59,7 @@ public class GenValueSetExpansionConvertor {
|
|||
id = tail(((ValueSet) res).getUrl());
|
||||
String dst = Utilities.path(tgt, res.fhirType() + "-" + id + ".json");
|
||||
System.out.println(dst);
|
||||
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(new FileOutputStream(dst), res);
|
||||
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(ManagedFileAccess.outStream(dst), res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.hl7.fhir.r4.utils.ToolingExtensions;
|
|||
import org.hl7.fhir.utilities.SimpleHTTPClient;
|
||||
import org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonElement;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
|
@ -49,7 +50,7 @@ public class ICD11Generator {
|
|||
processMMSEntity(cs, base, child.asString(), cs.addConcept(), dest);
|
||||
System.out.println();
|
||||
}
|
||||
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "icd-11-mms.xml")), cs);
|
||||
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "icd-11-mms.xml")), cs);
|
||||
makeFullVs(dest, cs);
|
||||
|
||||
cs = makeEntityCodeSystem();
|
||||
|
@ -62,7 +63,7 @@ public class ICD11Generator {
|
|||
processEntity(cs, ids, base, tail(child.asString()), dest);
|
||||
System.out.println();
|
||||
}
|
||||
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "icd-11-foundation.xml")), cs);
|
||||
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "icd-11-foundation.xml")), cs);
|
||||
makeFullVs2(dest, cs);
|
||||
System.out.println("finished");
|
||||
}
|
||||
|
@ -153,7 +154,7 @@ public class ICD11Generator {
|
|||
vs.setStatus(cs.getStatus());
|
||||
ConceptSetComponent inc = vs.getCompose().addInclude();
|
||||
inc.setSystem(cs.getUrl());
|
||||
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "vs-all-MMS.xml")), vs);
|
||||
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "vs-all-MMS.xml")), vs);
|
||||
}
|
||||
|
||||
private void makeFullVs2(String dest, CodeSystem cs) throws IOException {
|
||||
|
@ -172,7 +173,7 @@ public class ICD11Generator {
|
|||
vs.setStatus(cs.getStatus());
|
||||
ConceptSetComponent inc = vs.getCompose().addInclude();
|
||||
inc.setSystem(cs.getUrl());
|
||||
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "vs-all-foundation.xml")), vs);
|
||||
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "vs-all-foundation.xml")), vs);
|
||||
}
|
||||
|
||||
private void processMMSEntity(CodeSystem cs, String base, String ref, org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent cc, String dest) throws IOException {
|
||||
|
@ -281,7 +282,7 @@ public class ICD11Generator {
|
|||
for (JsonElement e : o.getJsonArray("scaleEntity")) {
|
||||
inc.addFilter().setProperty("concept").setOp(FilterOperator.ISA).setValue(tail(e.asString()));
|
||||
}
|
||||
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "vs-" + id + ".xml")), vs);
|
||||
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "vs-" + id + ".xml")), vs);
|
||||
return url;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent;
|
|||
import org.hl7.fhir.r5.model.CodeSystem.PropertyType;
|
||||
import org.hl7.fhir.r5.model.CodeType;
|
||||
import org.hl7.fhir.utilities.CSVReader;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class ICFImporter {
|
||||
|
||||
|
@ -28,7 +29,7 @@ public class ICFImporter {
|
|||
}
|
||||
|
||||
private void doImport(String src, String dst) throws FHIRException, FileNotFoundException, IOException {
|
||||
CSVReader csv = new CSVReader(new FileInputStream(src));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(src));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
|
||||
|
@ -98,7 +99,7 @@ public class ICFImporter {
|
|||
|
||||
}
|
||||
csv.close();
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(dst), cs);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(dst), cs);
|
||||
}
|
||||
//
|
||||
// private String processLink(String cell) {
|
||||
|
|
|
@ -53,6 +53,7 @@ import org.hl7.fhir.dstu3.model.ValueSet;
|
|||
import org.hl7.fhir.dstu3.terminologies.CodeSystemUtilities;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -122,7 +123,7 @@ public class ICPC2Importer {
|
|||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(false);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document doc = builder.parse(new FileInputStream(sourceFileName));
|
||||
Document doc = builder.parse(ManagedFileAccess.inStream(sourceFileName));
|
||||
|
||||
ValueSet vs = new ValueSet();
|
||||
vs.setUrl("http://hl7.org/fhir/sid/icpc2/vs");
|
||||
|
@ -170,8 +171,8 @@ public class ICPC2Importer {
|
|||
|
||||
XmlParser xml = new XmlParser();
|
||||
xml.setOutputStyle(OutputStyle.PRETTY);
|
||||
xml.compose(new FileOutputStream(targetFileNameVS), vs);
|
||||
xml.compose(new FileOutputStream(targetFileNameCS), cs);
|
||||
xml.compose(ManagedFileAccess.outStream(targetFileNameVS), vs);
|
||||
xml.compose(ManagedFileAccess.outStream(targetFileNameCS), cs);
|
||||
}
|
||||
|
||||
private void processClass(Element cls, Map<String, ConceptDefinitionComponent> concepts, CodeSystem define) throws FHIRFormatError {
|
||||
|
|
|
@ -68,6 +68,7 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.utilities.CSVReader;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class IEEE11073Convertor {
|
||||
|
||||
|
@ -113,7 +114,7 @@ public class IEEE11073Convertor {
|
|||
g.setSource("urn:iso:std:iso:11073:10101");
|
||||
g.setTarget("http://loinc.org");
|
||||
|
||||
CSVReader csv = new CSVReader(new FileInputStream(src));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(src));
|
||||
csv.readHeaders();
|
||||
while (csv.line()) {
|
||||
SourceElementComponent e = g.addElement();
|
||||
|
@ -124,13 +125,13 @@ public class IEEE11073Convertor {
|
|||
t.setCode(csv.cell("LOINC_NUM"));
|
||||
t.setDisplay(csv.cell("LOINC_LONG_COMMON_NAME"));
|
||||
}
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "conceptmap-" + cm.getId() + ".xml")), cm);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dst, "conceptmap-" + cm.getId() + ".xml")), cm);
|
||||
System.out.println("Done");
|
||||
return cm;
|
||||
}
|
||||
|
||||
public static CodeSystem generateMDC(String src, String dst, UcumService ucum) throws IOException, FHIRException {
|
||||
CSVReader csv = new CSVReader(new FileInputStream(src));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(src));
|
||||
csv.readHeaders();
|
||||
CodeSystem cs = new CodeSystem();
|
||||
Map<String, String> ucumIssues = new HashMap<String, String>();
|
||||
|
@ -206,7 +207,7 @@ public class IEEE11073Convertor {
|
|||
}
|
||||
}
|
||||
csv.close();
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "codesystem-" + cs.getId() + ".xml")), cs);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dst, "codesystem-" + cs.getId() + ".xml")), cs);
|
||||
System.out.println(errorCount + "UCUM errors");
|
||||
|
||||
for (String u : sorted(ucumIssues.keySet()))
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.hl7.fhir.dstu3.model.ValueSet;
|
|||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.FhirPublication;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class IGPackConverter102 extends BaseAdvisor_10_30 {
|
||||
|
||||
|
@ -60,21 +61,21 @@ public class IGPackConverter102 extends BaseAdvisor_10_30 {
|
|||
|
||||
private void process() throws IOException, FHIRException {
|
||||
initCSList();
|
||||
for (String s : new File(Utilities.path("[tmp]", "igpack2")).list()) {
|
||||
for (String s : ManagedFileAccess.file(Utilities.path("[tmp]", "igpack2")).list()) {
|
||||
if (s.endsWith(".xml") && !s.startsWith("z-") && !Utilities.existsInList(s, "expansions.xml", "v3-codesystems.xml", "v2-tables.xml")) {
|
||||
System.out.println("process " + s);
|
||||
org.hl7.fhir.dstu2.formats.XmlParser xp = new org.hl7.fhir.dstu2.formats.XmlParser();
|
||||
org.hl7.fhir.dstu2.model.Resource r10 = xp.parse(new FileInputStream(Utilities.path("[tmp]", "igpack2\\" + s)));
|
||||
org.hl7.fhir.dstu2.model.Resource r10 = xp.parse(ManagedFileAccess.inStream(Utilities.path("[tmp]", "igpack2\\" + s)));
|
||||
org.hl7.fhir.dstu3.model.Resource r17 = VersionConvertorFactory_10_30.convertResource(r10, this);
|
||||
org.hl7.fhir.dstu3.formats.XmlParser xc = new org.hl7.fhir.dstu3.formats.XmlParser();
|
||||
xc.setOutputStyle(OutputStyle.PRETTY);
|
||||
xc.compose(new FileOutputStream(Utilities.path("[tmp]", "igpack2\\" + s)), r17);
|
||||
xc.compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "igpack2\\" + s)), r17);
|
||||
}
|
||||
}
|
||||
System.out.println("save codesystems");
|
||||
org.hl7.fhir.dstu3.formats.XmlParser xc = new org.hl7.fhir.dstu3.formats.XmlParser();
|
||||
xc.setOutputStyle(OutputStyle.PRETTY);
|
||||
xc.compose(new FileOutputStream(Utilities.path("[tmp]", "igpack2\\codesystems.xml")), cslist);
|
||||
xc.compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "igpack2\\codesystems.xml")), cslist);
|
||||
System.out.println("done");
|
||||
}
|
||||
|
||||
|
|
|
@ -37,20 +37,21 @@ import java.io.FileOutputStream;
|
|||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_30;
|
||||
import org.hl7.fhir.dstu3.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class IGPackConverter140 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
for (String s : new File(Utilities.path("[tmp]", "igpack")).list()) {
|
||||
for (String s : ManagedFileAccess.file(Utilities.path("[tmp]", "igpack")).list()) {
|
||||
// if (s.endsWith(".xml") && !s.contains("z-")) {
|
||||
if (s.equals("expansions.xml")) {
|
||||
System.out.println("process " + s);
|
||||
org.hl7.fhir.dstu2016may.formats.XmlParser xp = new org.hl7.fhir.dstu2016may.formats.XmlParser();
|
||||
org.hl7.fhir.dstu2016may.model.Resource r14 = xp.parse(new FileInputStream(Utilities.path("[tmp]", "igpack\\" + s)));
|
||||
org.hl7.fhir.dstu2016may.model.Resource r14 = xp.parse(ManagedFileAccess.inStream(Utilities.path("[tmp]", "igpack\\" + s)));
|
||||
org.hl7.fhir.dstu3.model.Resource r17 = VersionConvertorFactory_14_30.convertResource(r14);
|
||||
org.hl7.fhir.dstu3.formats.XmlParser xc = new org.hl7.fhir.dstu3.formats.XmlParser();
|
||||
xc.setOutputStyle(OutputStyle.PRETTY);
|
||||
xc.compose(new FileOutputStream(Utilities.path("[tmp]", "igpack\\z-" + s)), r17);
|
||||
xc.compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "igpack\\z-" + s)), r17);
|
||||
}
|
||||
}
|
||||
System.out.println("done");
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.hl7.fhir.convertors.misc;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
|
||||
|
@ -15,7 +16,7 @@ public class JsonProcessor {
|
|||
private void process(String source) throws IOException {
|
||||
JsonObject json = JsonParser.parseObjectFromFile(source);
|
||||
process(json);
|
||||
JsonParser.compose(json, new FileOutputStream(source), true);
|
||||
JsonParser.compose(json, ManagedFileAccess.outStream(source), true);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.hl7.fhir.r5.model.DateTimeType;
|
|||
import org.hl7.fhir.r5.model.InstantType;
|
||||
import org.hl7.fhir.r5.model.Meta;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -151,12 +152,12 @@ public class LoincToDEConvertor {
|
|||
factory.setNamespaceAware(true);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
xml = builder.parse(new FileInputStream(definitions));
|
||||
xml = builder.parse(ManagedFileAccess.inStream(definitions));
|
||||
}
|
||||
|
||||
private void saveBundle() throws FHIRFormatError, IOException, XmlPullParserException {
|
||||
XmlParser xml = new XmlParser();
|
||||
FileOutputStream s = new FileOutputStream(dest);
|
||||
FileOutputStream s = ManagedFileAccess.outStream(dest);
|
||||
xml.compose(s, bundle, true);
|
||||
s.close();
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.hl7.fhir.r4.model.Enumerations.PublicationStatus;
|
|||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.hl7.fhir.utilities.CSVReader;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class NUCCConvertor {
|
||||
|
||||
|
@ -56,7 +57,7 @@ public class NUCCConvertor {
|
|||
}
|
||||
|
||||
public void execute() throws IOException, FHIRException {
|
||||
CSVReader csv = new CSVReader(new FileInputStream(Utilities.path("[tmp]", "nucc.csv")));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path("[tmp]", "nucc.csv")));
|
||||
CodeSystem cs = new CodeSystem();
|
||||
cs.setId("nucc-provider-taxonomy");
|
||||
cs.setUrl("http://nucc.org/provider-taxonomy");
|
||||
|
@ -79,7 +80,7 @@ public class NUCCConvertor {
|
|||
}
|
||||
csv.close();
|
||||
cs.sort();
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "nucc.json")), cs);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "nucc.json")), cs);
|
||||
}
|
||||
|
||||
private void processLine(CodeSystem cs, String[] values) throws FHIRFormatError {
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.hl7.fhir.r5.model.Resource;
|
|||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonArray;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
|
@ -80,7 +81,7 @@ public class NpmPackageVersionConverter {
|
|||
}
|
||||
|
||||
public void execute() throws IOException {
|
||||
Map<String, byte[]> content = loadContentMap(new FileInputStream(source));
|
||||
Map<String, byte[]> content = loadContentMap(ManagedFileAccess.inStream(source));
|
||||
|
||||
Map<String, byte[]> output = new HashMap<>();
|
||||
output.put("package/package.json", convertPackage(content.get("package/package.json")));
|
||||
|
@ -141,7 +142,7 @@ public class NpmPackageVersionConverter {
|
|||
tar.write(cnt);
|
||||
tar.closeArchiveEntry();
|
||||
cnt = TextFile.fileToBytes(e.getValue().getDbFilename());
|
||||
new File(e.getValue().getDbFilename()).delete();
|
||||
ManagedFileAccess.file(e.getValue().getDbFilename()).delete();
|
||||
entry = new TarArchiveEntry(e.getKey() + "/.index.db");
|
||||
entry.setSize(cnt.length);
|
||||
tar.putArchiveEntry(entry);
|
||||
|
|
|
@ -3,10 +3,12 @@ package org.hl7.fhir.convertors.misc;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
|
||||
import org.hl7.fhir.utilities.IniFile;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class OIDAssigner {
|
||||
|
||||
|
@ -15,9 +17,9 @@ public class OIDAssigner {
|
|||
new OIDAssigner().execute(args[0], args[1], args[2]);
|
||||
}
|
||||
|
||||
private void execute(String oidSource, String folder, String version) {
|
||||
private void execute(String oidSource, String folder, String version) throws IOException {
|
||||
IniFile oids = new IniFile(oidSource);
|
||||
File f = new File(folder);
|
||||
File f = ManagedFileAccess.file(folder);
|
||||
process(oids, f, version);
|
||||
}
|
||||
|
||||
|
@ -47,7 +49,7 @@ public class OIDAssigner {
|
|||
org.hl7.fhir.dstu2.formats.IParser parser = fmt == FhirFormat.JSON ? new org.hl7.fhir.dstu2.formats.JsonParser() : new org.hl7.fhir.dstu2.formats.XmlParser();
|
||||
try {
|
||||
boolean save = false;
|
||||
org.hl7.fhir.dstu2.model.Resource r = parser.parse(new FileInputStream(f));
|
||||
org.hl7.fhir.dstu2.model.Resource r = parser.parse(ManagedFileAccess.inStream(f));
|
||||
if (r instanceof org.hl7.fhir.dstu2.model.ValueSet) {
|
||||
org.hl7.fhir.dstu2.model.ValueSet vs = (org.hl7.fhir.dstu2.model.ValueSet) r;
|
||||
boolean hasOid = isOid(vs.getIdentifier());
|
||||
|
@ -81,7 +83,7 @@ public class OIDAssigner {
|
|||
}
|
||||
}
|
||||
if (save) {
|
||||
parser.setOutputStyle(org.hl7.fhir.dstu2.formats.IParser.OutputStyle.PRETTY).compose(new FileOutputStream(f), r);
|
||||
parser.setOutputStyle(org.hl7.fhir.dstu2.formats.IParser.OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f), r);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Erro processing "+f.getAbsolutePath()+": "+e.getMessage());
|
||||
|
@ -93,7 +95,7 @@ public class OIDAssigner {
|
|||
org.hl7.fhir.dstu3.formats.IParser parser = fmt == FhirFormat.JSON ? new org.hl7.fhir.dstu3.formats.JsonParser() : new org.hl7.fhir.dstu3.formats.XmlParser();
|
||||
try {
|
||||
boolean save = false;
|
||||
org.hl7.fhir.dstu3.model.Resource r = parser.parse(new FileInputStream(f));
|
||||
org.hl7.fhir.dstu3.model.Resource r = parser.parse(ManagedFileAccess.inStream(f));
|
||||
if (r instanceof org.hl7.fhir.dstu3.model.CodeSystem) {
|
||||
org.hl7.fhir.dstu3.model.CodeSystem cs = (org.hl7.fhir.dstu3.model.CodeSystem) r;
|
||||
boolean hasOid = isOid(cs.getIdentifier());
|
||||
|
@ -141,7 +143,7 @@ public class OIDAssigner {
|
|||
}
|
||||
}
|
||||
if (save) {
|
||||
parser.setOutputStyle(org.hl7.fhir.dstu3.formats.IParser.OutputStyle.PRETTY).compose(new FileOutputStream(f), r);
|
||||
parser.setOutputStyle(org.hl7.fhir.dstu3.formats.IParser.OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f), r);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Erro processing "+f.getAbsolutePath()+": "+e.getMessage());
|
||||
|
@ -153,7 +155,7 @@ public class OIDAssigner {
|
|||
org.hl7.fhir.r4.formats.IParser parser = fmt == FhirFormat.JSON ? new org.hl7.fhir.r4.formats.JsonParser() : new org.hl7.fhir.r4.formats.XmlParser();
|
||||
try {
|
||||
boolean save = false;
|
||||
org.hl7.fhir.r4.model.Resource r = parser.parse(new FileInputStream(f));
|
||||
org.hl7.fhir.r4.model.Resource r = parser.parse(ManagedFileAccess.inStream(f));
|
||||
if (r instanceof org.hl7.fhir.r4.model.CodeSystem) {
|
||||
org.hl7.fhir.r4.model.CodeSystem cs = (org.hl7.fhir.r4.model.CodeSystem) r;
|
||||
boolean hasOid = false;
|
||||
|
@ -206,7 +208,7 @@ public class OIDAssigner {
|
|||
}
|
||||
}
|
||||
if (save) {
|
||||
parser.setOutputStyle(org.hl7.fhir.r4.formats.IParser.OutputStyle.PRETTY).compose(new FileOutputStream(f), r);
|
||||
parser.setOutputStyle(org.hl7.fhir.r4.formats.IParser.OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f), r);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Erro processing "+f.getAbsolutePath()+": "+e.getMessage());
|
||||
|
@ -217,7 +219,7 @@ public class OIDAssigner {
|
|||
org.hl7.fhir.r4b.formats.IParser parser = fmt == FhirFormat.JSON ? new org.hl7.fhir.r4b.formats.JsonParser() : new org.hl7.fhir.r4b.formats.XmlParser();
|
||||
try {
|
||||
boolean save = false;
|
||||
org.hl7.fhir.r4b.model.Resource r = parser.parse(new FileInputStream(f));
|
||||
org.hl7.fhir.r4b.model.Resource r = parser.parse(ManagedFileAccess.inStream(f));
|
||||
if (r instanceof org.hl7.fhir.r4b.model.CanonicalResource) {
|
||||
org.hl7.fhir.r4b.model.CanonicalResource cs = (org.hl7.fhir.r4b.model.CanonicalResource) r;
|
||||
boolean hasOid = false;
|
||||
|
@ -233,7 +235,7 @@ public class OIDAssigner {
|
|||
}
|
||||
}
|
||||
if (save) {
|
||||
parser.setOutputStyle(org.hl7.fhir.r4b.formats.IParser.OutputStyle.PRETTY).compose(new FileOutputStream(f), r);
|
||||
parser.setOutputStyle(org.hl7.fhir.r4b.formats.IParser.OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f), r);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Erro processing "+f.getAbsolutePath()+": "+e.getMessage());
|
||||
|
@ -245,7 +247,7 @@ public class OIDAssigner {
|
|||
org.hl7.fhir.r5.formats.IParser parser = fmt == FhirFormat.JSON ? new org.hl7.fhir.r5.formats.JsonParser() : new org.hl7.fhir.r5.formats.XmlParser();
|
||||
try {
|
||||
boolean save = false;
|
||||
org.hl7.fhir.r5.model.Resource r = parser.parse(new FileInputStream(f));
|
||||
org.hl7.fhir.r5.model.Resource r = parser.parse(ManagedFileAccess.inStream(f));
|
||||
if (r instanceof org.hl7.fhir.r5.model.CanonicalResource) {
|
||||
org.hl7.fhir.r5.model.CanonicalResource cs = (org.hl7.fhir.r5.model.CanonicalResource) r;
|
||||
boolean hasOid = false;
|
||||
|
@ -261,7 +263,7 @@ public class OIDAssigner {
|
|||
}
|
||||
}
|
||||
if (save) {
|
||||
parser.setOutputStyle(org.hl7.fhir.r5.formats.IParser.OutputStyle.PRETTY).compose(new FileOutputStream(f), r);
|
||||
parser.setOutputStyle(org.hl7.fhir.r5.formats.IParser.OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f), r);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Erro processing "+f.getAbsolutePath()+": "+e.getMessage());
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.Map;
|
|||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.CSVReader;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class OMOPImporter {
|
||||
|
||||
|
@ -107,15 +108,15 @@ public class OMOPImporter {
|
|||
}
|
||||
|
||||
|
||||
private void connect(String dest) throws SQLException, ClassNotFoundException {
|
||||
private void connect(String dest) throws SQLException, ClassNotFoundException, IOException {
|
||||
// Class.forName("com.mysql.jdbc.Driver");
|
||||
// con = DriverManager.getConnection("jdbc:mysql://localhost:3306/omop?useSSL=false","root",{pwd});
|
||||
new File("/Users/grahamegrieve/temp/omop/omop.db").delete();
|
||||
ManagedFileAccess.file("/Users/grahamegrieve/temp/omop/omop.db").delete();
|
||||
con = DriverManager.getConnection("jdbc:sqlite:"+dest);
|
||||
}
|
||||
private void processRelationships(String folder, boolean process) throws FHIRException, FileNotFoundException, IOException, SQLException {
|
||||
Tracker t = new Tracker("Relationships", 700);
|
||||
CSVReader csv = new CSVReader(new FileInputStream(Utilities.path(folder, "RELATIONSHIP.csv")));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "RELATIONSHIP.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -147,7 +148,7 @@ public class OMOPImporter {
|
|||
stmt.execute("Create Index `RelationshipsId` on Relationships (`relationship_id`)");
|
||||
stmt.execute("Create Index`RelationshipsReverse` on Relationships (`reverse_relationship_id`)");
|
||||
|
||||
csv = new CSVReader(new FileInputStream(Utilities.path(folder, "RELATIONSHIP.csv")));
|
||||
csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "RELATIONSHIP.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -182,7 +183,7 @@ public class OMOPImporter {
|
|||
|
||||
private void processVocabularies(String folder, boolean process) throws FHIRException, FileNotFoundException, IOException, SQLException {
|
||||
Tracker t = new Tracker("Vocabularies", 60);
|
||||
CSVReader csv = new CSVReader(new FileInputStream(Utilities.path(folder, "VOCABULARY.csv")));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "VOCABULARY.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -217,7 +218,7 @@ public class OMOPImporter {
|
|||
"\r\n");
|
||||
stmt.execute("CREATE INDEX `VocabulariesId` on Vocabularies (`vocabulary_id`)");
|
||||
|
||||
csv = new CSVReader(new FileInputStream(Utilities.path(folder, "VOCABULARY.csv")));
|
||||
csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "VOCABULARY.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -244,7 +245,7 @@ public class OMOPImporter {
|
|||
private void processDomains(String folder, boolean process) throws FHIRException, FileNotFoundException, IOException, SQLException {
|
||||
Tracker t = new Tracker("Domains", 50);
|
||||
|
||||
CSVReader csv = new CSVReader(new FileInputStream(Utilities.path(folder, "DOMAIN.csv")));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "DOMAIN.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -275,7 +276,7 @@ public class OMOPImporter {
|
|||
|
||||
stmt.execute("CREATE INDEX `DomainId` on Domains (`domain_id`)");
|
||||
|
||||
csv = new CSVReader(new FileInputStream(Utilities.path(folder, "DOMAIN.csv")));
|
||||
csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "DOMAIN.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -299,7 +300,7 @@ public class OMOPImporter {
|
|||
private void processConceptClasses(String folder, boolean process) throws FHIRException, FileNotFoundException, IOException, SQLException {
|
||||
Tracker t = new Tracker("ConceptClasses", 400);
|
||||
|
||||
CSVReader csv = new CSVReader(new FileInputStream(Utilities.path(folder, "CONCEPT_CLASS.csv")));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "CONCEPT_CLASS.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -325,7 +326,7 @@ public class OMOPImporter {
|
|||
" PRIMARY KEY (`concept_class_concept_id`)\r\n"+
|
||||
") \r\n"+
|
||||
"\r\n");
|
||||
csv = new CSVReader(new FileInputStream(Utilities.path(folder, "CONCEPT_CLASS.csv")));
|
||||
csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "CONCEPT_CLASS.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -356,7 +357,7 @@ public class OMOPImporter {
|
|||
return;
|
||||
}
|
||||
|
||||
CSVReader csv = new CSVReader(new FileInputStream(Utilities.path(folder, "DRUG_STRENGTH.csv")));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "DRUG_STRENGTH.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -398,7 +399,7 @@ public class OMOPImporter {
|
|||
" PRIMARY KEY (`drug_concept_id`,`ingredient_concept_id`)\r\n"+
|
||||
") \r\n"+
|
||||
"\r\n");
|
||||
csv = new CSVReader(new FileInputStream(Utilities.path(folder, "DRUG_STRENGTH.csv")));
|
||||
csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "DRUG_STRENGTH.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -446,7 +447,7 @@ public class OMOPImporter {
|
|||
return;
|
||||
}
|
||||
|
||||
CSVReader csv = new CSVReader(new FileInputStream(Utilities.path(folder, "CONCEPT.csv")));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "CONCEPT.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -485,7 +486,7 @@ public class OMOPImporter {
|
|||
stmt.execute("CREATE INDEX `ConceptVocabulary` on Concepts (`vocabulary_id`,`concept_code`)");
|
||||
stmt.execute("CREATE INDEX `ConceptClass` on Concepts (`concept_class_id`)");
|
||||
|
||||
csv = new CSVReader(new FileInputStream(Utilities.path(folder, "CONCEPT.csv")));
|
||||
csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "CONCEPT.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -523,7 +524,7 @@ public class OMOPImporter {
|
|||
}
|
||||
t.scan();
|
||||
|
||||
CSVReader csv = new CSVReader(new FileInputStream(Utilities.path(folder, "CONCEPT_SYNONYM.csv")));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "CONCEPT_SYNONYM.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -545,7 +546,7 @@ public class OMOPImporter {
|
|||
stmt.execute("CREATE INDEX `SynonymId` on ConceptSynonyms (`concept_id`)");
|
||||
stmt.execute("CREATE INDEX `SynonymLang` on ConceptSynonyms (`language_concept_id`)");
|
||||
|
||||
csv = new CSVReader(new FileInputStream(Utilities.path(folder, "CONCEPT_SYNONYM.csv")));
|
||||
csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "CONCEPT_SYNONYM.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -575,7 +576,7 @@ public class OMOPImporter {
|
|||
}
|
||||
|
||||
t.process();
|
||||
CSVReader csv = new CSVReader(new FileInputStream(Utilities.path(folder, "CONCEPT_ANCESTOR.csv")));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "CONCEPT_ANCESTOR.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -614,7 +615,7 @@ public class OMOPImporter {
|
|||
}
|
||||
|
||||
t.scan();
|
||||
CSVReader csv = new CSVReader(new FileInputStream(Utilities.path(folder, "CONCEPT_RELATIONSHIP.csv")));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "CONCEPT_RELATIONSHIP.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
@ -641,7 +642,7 @@ public class OMOPImporter {
|
|||
// stmt.execute("CREATE INDEX `type1` on ConceptRelationships (`relationship_id`,`concept_id_1`,`concept_id_2`)");
|
||||
// stmt.execute("CREATE INDEX `type2` on ConceptRelationships (`relationship_id`,`concept_id_2`,`concept_id_1`)");
|
||||
|
||||
csv = new CSVReader(new FileInputStream(Utilities.path(folder, "CONCEPT_RELATIONSHIP.csv")));
|
||||
csv = new CSVReader(ManagedFileAccess.inStream(Utilities.path(folder, "CONCEPT_RELATIONSHIP.csv")));
|
||||
csv.setDelimiter('\t');
|
||||
csv.readHeaders();
|
||||
csv.setDoingQuotes(false);
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.hl7.fhir.dstu3.model.Type;
|
|||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class ObservationStatsBuilder {
|
||||
|
||||
|
@ -78,7 +79,7 @@ public class ObservationStatsBuilder {
|
|||
vitals(b, base, 130, 95, 133, 97, 37.2);
|
||||
vitals(b, base, 150, 85, 125, 98, 37.1);
|
||||
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "vitals.xml")), b);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "vitals.xml")), b);
|
||||
}
|
||||
|
||||
private static void vitals(Bundle b, Calendar base, int minutes, int diastolic, int systolic, int sat, double temp) throws FHIRFormatError {
|
||||
|
@ -202,7 +203,7 @@ public class ObservationStatsBuilder {
|
|||
addAge(b, 10, 0, "31.9");
|
||||
|
||||
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "obs.xml")), b);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "obs.xml")), b);
|
||||
}
|
||||
|
||||
private static void addAge(Bundle b, int y, int m, String v) throws FHIRException {
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
|
||||
|
@ -67,15 +68,15 @@ public class PackageMaintainer {
|
|||
System.out.println("Examples contains " + s + " but core doesn't");
|
||||
}
|
||||
}
|
||||
strip(new File(Utilities.path(PATH, "hl7.fhir." + ver + ".core", "package")));
|
||||
strip(new File(Utilities.path(PATH, "hl7.fhir." + ver + ".expansions", "package")));
|
||||
strip(ManagedFileAccess.file(Utilities.path(PATH, "hl7.fhir." + ver + ".core", "package")));
|
||||
strip(ManagedFileAccess.file(Utilities.path(PATH, "hl7.fhir." + ver + ".expansions", "package")));
|
||||
if (!ver.equals("r2b"))
|
||||
strip(new File(Utilities.path(PATH, "hl7.fhir." + ver + ".elements", "package")));
|
||||
strip(ManagedFileAccess.file(Utilities.path(PATH, "hl7.fhir." + ver + ".elements", "package")));
|
||||
}
|
||||
|
||||
|
||||
private List<String> listResources(String dir) {
|
||||
File folder = new File(dir);
|
||||
private List<String> listResources(String dir) throws IOException {
|
||||
File folder = ManagedFileAccess.file(dir);
|
||||
List<String> res = new ArrayList<>();
|
||||
for (String fn : folder.list()) {
|
||||
if (fn.endsWith(".json") && fn.contains("-")) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
|||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.utils.ResourceMinifier;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage.PackageResourceInformation;
|
||||
|
@ -33,7 +34,7 @@ public class PackageMinifier {
|
|||
}
|
||||
}
|
||||
}
|
||||
tgt.save(new FileOutputStream(target));
|
||||
tgt.save(ManagedFileAccess.outStream(target));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.hl7.fhir.convertors.misc;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
|
@ -38,6 +39,7 @@ import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
|
|||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
/*
|
||||
* load reosurces in xml format, and sve them in package format (json, with correct name
|
||||
|
@ -48,10 +50,10 @@ import org.hl7.fhir.utilities.Utilities;
|
|||
public class PackagePreparer {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (File f : new File("C:\\work\\fhirserver\\resources\\mihin").listFiles()) {
|
||||
public static void main(String[] args) throws IOException {
|
||||
for (File f : ManagedFileAccess.file("C:\\work\\fhirserver\\resources\\mihin").listFiles()) {
|
||||
try {
|
||||
org.hl7.fhir.dstu3.model.Resource r = new org.hl7.fhir.dstu3.formats.JsonParser().parse(new FileInputStream(f));
|
||||
org.hl7.fhir.dstu3.model.Resource r = new org.hl7.fhir.dstu3.formats.JsonParser().parse(ManagedFileAccess.inStream(f));
|
||||
if (r instanceof Bundle) {
|
||||
Bundle b = (Bundle) r;
|
||||
for (BundleEntryComponent be : b.getEntry()) {
|
||||
|
@ -60,7 +62,7 @@ public class PackagePreparer {
|
|||
if (r4.getId().startsWith(r4.fhirType() + "-"))
|
||||
be.getResource().setId(r4.getId().substring(r4.fhirType().length() + 1));
|
||||
if (be.getResource().hasId())
|
||||
new org.hl7.fhir.r4.formats.JsonParser().compose(new FileOutputStream(Utilities.path("C:\\work\\fhirserver\\resources\\fhir.test.data\\3.5.0\\package", be.getResource().fhirType() + "-" + be.getResource().getId() + ".json")), r4);
|
||||
new org.hl7.fhir.r4.formats.JsonParser().compose(ManagedFileAccess.outStream(Utilities.path("C:\\work\\fhirserver\\resources\\fhir.test.data\\3.5.0\\package", be.getResource().fhirType() + "-" + be.getResource().getId() + ".json")), r4);
|
||||
else
|
||||
System.out.println(f.getName() + " bundle entry has no id");
|
||||
} catch (Exception e) {
|
||||
|
@ -68,7 +70,7 @@ public class PackagePreparer {
|
|||
}
|
||||
}
|
||||
} else if (r.hasId())
|
||||
new org.hl7.fhir.r4.formats.JsonParser().compose(new FileOutputStream(Utilities.path(Utilities.getDirectoryForFile(f.getAbsolutePath()), r.fhirType() + "-" + r.getId() + ".json")), VersionConvertorFactory_30_40.convertResource(r));
|
||||
new org.hl7.fhir.r4.formats.JsonParser().compose(ManagedFileAccess.outStream(Utilities.path(Utilities.getDirectoryForFile(f.getAbsolutePath()), r.fhirType() + "-" + r.getId() + ".json")), VersionConvertorFactory_30_40.convertResource(r));
|
||||
else
|
||||
System.out.println(f.getName() + " has no id");
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
|
|||
import org.hl7.fhir.utilities.CSVReader;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class PhinVadsImporter extends OIDBasedValueSetImporter {
|
||||
|
||||
|
@ -32,13 +33,13 @@ public class PhinVadsImporter extends OIDBasedValueSetImporter {
|
|||
self.process(args[0], args[1]);
|
||||
}
|
||||
|
||||
private void process(String source, String dest) {
|
||||
for (File f : new File(source).listFiles()) {
|
||||
private void process(String source, String dest) throws IOException {
|
||||
for (File f : ManagedFileAccess.file(source).listFiles()) {
|
||||
try {
|
||||
System.out.println("Process " + f.getName());
|
||||
ValueSet vs = importValueSet(TextFile.fileToBytes(f));
|
||||
if (vs.getId() != null) {
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "ValueSet-" + vs.getId() + ".json")), vs);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "ValueSet-" + vs.getId() + ".json")), vs);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.hl7.fhir.r5.utils.ResourceDependencyWalker;
|
|||
import org.hl7.fhir.r5.utils.ResourceDependencyWalker.IResourceDependencyNotifier;
|
||||
import org.hl7.fhir.r5.utils.ResourceMinifier;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.JsonException;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
|
@ -47,7 +48,7 @@ public class ResourceDependencyPackageBuilder {
|
|||
|
||||
new ResourceDependencyWalker(ctxt, pckBuilder).walk(ctxt.fetchResource(CapabilityStatement.class, args[2]));
|
||||
|
||||
pckBuilder.npm.save(new FileOutputStream(args[4]));
|
||||
pckBuilder.npm.save(ManagedFileAccess.outStream(args[4]));
|
||||
}
|
||||
|
||||
private static NpmPackage makeNpm(String vid, String version) throws JsonException, IOException {
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.hl7.fhir.r4.terminologies.CodeSystemUtilities;
|
|||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
|
||||
|
@ -27,7 +28,7 @@ public class SPDXImporter {
|
|||
|
||||
public void generate(String[] args) throws Exception {
|
||||
JsonObject json = JsonParser.parseObjectFromUrl("https://raw.githubusercontent.com/spdx/license-list-data/main/json/licenses.json");
|
||||
CodeSystem cs = (CodeSystem) new org.hl7.fhir.r4.formats.JsonParser().parse(new FileInputStream(args[0]));
|
||||
CodeSystem cs = (CodeSystem) new org.hl7.fhir.r4.formats.JsonParser().parse(ManagedFileAccess.inStream(args[0]));
|
||||
cs.getConcept().clear();
|
||||
cs.getProperty().clear();
|
||||
cs.addProperty().setCode("reference").setType(PropertyType.STRING);
|
||||
|
@ -58,7 +59,7 @@ public class SPDXImporter {
|
|||
}
|
||||
}
|
||||
CodeSystemUtilities.sortAllCodes(cs);
|
||||
new org.hl7.fhir.r4.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(args[1]), cs);
|
||||
new org.hl7.fhir.r4.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(args[1]), cs);
|
||||
b = new StringBuilder();
|
||||
generateEnum("SPDXLicense", cs);
|
||||
TextFile.stringToFile(b.toString(), Utilities.changeFileExt(args[1], ".java"));
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.hl7.fhir.dstu3.formats.JsonParser;
|
|||
import org.hl7.fhir.dstu3.formats.XmlParser;
|
||||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class Test {
|
||||
public final static String DEF_TS_SERVER = "http://fhir-dev.healthintersections.com.au/open";
|
||||
|
@ -58,13 +59,13 @@ public class Test {
|
|||
public static void main(String[] args) {
|
||||
try {
|
||||
CCDAConverter c = new CCDAConverter(new UcumEssenceService(UCUM_PATH), SimpleWorkerContext.fromPack(Utilities.path(SRC_PATH, "validation.zip")));
|
||||
Bundle a = c.convert(new FileInputStream(DEF_PATH + "ccda.xml"));
|
||||
Bundle a = c.convert(ManagedFileAccess.inStream(DEF_PATH + "ccda.xml"));
|
||||
String fx = DEF_PATH + "output.xml";
|
||||
IParser x = new XmlParser().setOutputStyle(OutputStyle.PRETTY);
|
||||
x.compose(new FileOutputStream(fx), a);
|
||||
x.compose(ManagedFileAccess.outStream(fx), a);
|
||||
String fj = DEF_PATH + "output.json";
|
||||
IParser j = new JsonParser().setOutputStyle(OutputStyle.PRETTY);
|
||||
j.compose(new FileOutputStream(fj), a);
|
||||
j.compose(ManagedFileAccess.outStream(fj), a);
|
||||
System.out.println("done. save as " + fx + " and " + fj);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.hl7.fhir.r4.utils.client.FHIRToolingClient;
|
|||
import org.hl7.fhir.r4.terminologies.JurisdictionUtilities;
|
||||
import org.hl7.fhir.utilities.CSVReader;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonArray;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.model.JsonProperty;
|
||||
|
@ -47,7 +48,7 @@ public class VSACImporter extends OIDBasedValueSetImporter {
|
|||
}
|
||||
|
||||
private void process(String source, String dest, String apiKey, boolean onlyNew) throws FHIRException, IOException, URISyntaxException {
|
||||
CSVReader csv = new CSVReader(new FileInputStream(source));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream(source));
|
||||
csv.readHeaders();
|
||||
Map<String, String> errs = new HashMap<>();
|
||||
|
||||
|
@ -59,13 +60,13 @@ public class VSACImporter extends OIDBasedValueSetImporter {
|
|||
|
||||
CapabilityStatement cs = fhirToolingClient.getCapabilitiesStatement();
|
||||
JsonParser json = new JsonParser();
|
||||
json.setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "vsac-capability-statmenet.json")), cs);
|
||||
json.setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "vsac-capability-statmenet.json")), cs);
|
||||
|
||||
System.out.println("Loading");
|
||||
List<String> oids = new ArrayList<>();
|
||||
while (csv.line()) {
|
||||
String oid = csv.cell("OID");
|
||||
if (!onlyNew || !(new File(Utilities.path(dest, "ValueSet-" + oid + ".json")).exists())) {
|
||||
if (!onlyNew || !(ManagedFileAccess.file(Utilities.path(dest, "ValueSet-" + oid + ".json")).exists())) {
|
||||
oids.add(oid);
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +100,7 @@ public class VSACImporter extends OIDBasedValueSetImporter {
|
|||
for (String oid : errs.keySet()) {
|
||||
oo.addIssue().setSeverity(IssueSeverity.ERROR).setCode(IssueType.EXCEPTION).setDiagnostics(errs.get(oid)).addLocation(oid);
|
||||
}
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "other", "OperationOutcome-vsac-errors.json")), oo);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "other", "OperationOutcome-vsac-errors.json")), oo);
|
||||
System.out.println("Done. " + i + " ValueSets in "+Utilities.describeDuration(System.currentTimeMillis() - tt));
|
||||
}
|
||||
|
||||
|
@ -164,7 +165,7 @@ public class VSACImporter extends OIDBasedValueSetImporter {
|
|||
}
|
||||
vs.setName(makeValidName(vs.getName()));
|
||||
JurisdictionUtilities.setJurisdictionCountry(vs.getJurisdiction(), "US");
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "ValueSet-" + oid + ".json")), vs);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(dest, "ValueSet-" + oid + ".json")), vs);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.model.JsonProperty;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
|
@ -11,7 +12,7 @@ import org.hl7.fhir.utilities.npm.NpmPackage;
|
|||
public class XMLPackageConvertor {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
new XMLPackageConvertor().process(new File("C:\\web\\hl7.org\\fhir"));
|
||||
new XMLPackageConvertor().process(ManagedFileAccess.file("C:\\web\\hl7.org\\fhir"));
|
||||
}
|
||||
|
||||
private void process(File folder) throws IOException {
|
||||
|
@ -21,7 +22,7 @@ public class XMLPackageConvertor {
|
|||
} else {
|
||||
if (f.getName().endsWith(".tgz")) {
|
||||
System.out.println("Package " + f.getAbsolutePath());
|
||||
NpmPackage p = NpmPackage.fromPackage(new FileInputStream(f));
|
||||
NpmPackage p = NpmPackage.fromPackage(ManagedFileAccess.inStream(f));
|
||||
if (p.getNpm().has("dependencies")) {
|
||||
JsonObject dep = p.getNpm().getJsonObject("dependencies");
|
||||
if (dep.getProperties().isEmpty()) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.hl7.fhir.dstu2.model.StructureDefinition;
|
|||
import org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.JsonTrackingParser;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
@ -66,7 +67,7 @@ public class XVerPackegeFixer {
|
|||
|
||||
public static void main(String[] args) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
|
||||
modCount = 0;
|
||||
for (File f : new File(args[0]).listFiles()) {
|
||||
for (File f : ManagedFileAccess.file(args[0]).listFiles()) {
|
||||
if (f.getName().startsWith("xver-") && f.getName().contains("1.0")) {
|
||||
JsonObject j = JsonTrackingParser.parseJson(f);
|
||||
fixUp(j, f.getName());
|
||||
|
@ -164,7 +165,7 @@ public class XVerPackegeFixer {
|
|||
if (map5.containsKey(tn)) {
|
||||
sd = map5.get(tn);
|
||||
} else {
|
||||
sd = (org.hl7.fhir.r5.model.StructureDefinition) new org.hl7.fhir.r5.formats.JsonParser().parse(new FileInputStream(Utilities.path(R5_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
sd = (org.hl7.fhir.r5.model.StructureDefinition) new org.hl7.fhir.r5.formats.JsonParser().parse(ManagedFileAccess.inStream(Utilities.path(R5_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
map5.put(tn, sd);
|
||||
}
|
||||
for (org.hl7.fhir.r5.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
|
@ -220,7 +221,7 @@ public class XVerPackegeFixer {
|
|||
if (map4.containsKey(tn)) {
|
||||
sd = map4.get(tn);
|
||||
} else {
|
||||
sd = (org.hl7.fhir.r4.model.StructureDefinition) new org.hl7.fhir.r4.formats.JsonParser().parse(new FileInputStream(Utilities.path(R4_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
sd = (org.hl7.fhir.r4.model.StructureDefinition) new org.hl7.fhir.r4.formats.JsonParser().parse(ManagedFileAccess.inStream(Utilities.path(R4_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
map4.put(tn, sd);
|
||||
}
|
||||
for (org.hl7.fhir.r4.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
|
@ -277,7 +278,7 @@ public class XVerPackegeFixer {
|
|||
if (map3.containsKey(tn)) {
|
||||
sd = map3.get(tn);
|
||||
} else {
|
||||
sd = (org.hl7.fhir.dstu3.model.StructureDefinition) new org.hl7.fhir.dstu3.formats.JsonParser().parse(new FileInputStream(Utilities.path(R3_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
sd = (org.hl7.fhir.dstu3.model.StructureDefinition) new org.hl7.fhir.dstu3.formats.JsonParser().parse(ManagedFileAccess.inStream(Utilities.path(R3_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
map3.put(tn, sd);
|
||||
}
|
||||
for (org.hl7.fhir.dstu3.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
|
@ -383,7 +384,7 @@ public class XVerPackegeFixer {
|
|||
if (map2.containsKey(tn)) {
|
||||
sd = map2.get(tn);
|
||||
} else {
|
||||
sd = (org.hl7.fhir.dstu2.model.StructureDefinition) new org.hl7.fhir.dstu2.formats.JsonParser().parse(new FileInputStream(Utilities.path(R2_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
sd = (org.hl7.fhir.dstu2.model.StructureDefinition) new org.hl7.fhir.dstu2.formats.JsonParser().parse(ManagedFileAccess.inStream(Utilities.path(R2_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
map2.put(tn, sd);
|
||||
}
|
||||
return sd;
|
||||
|
@ -431,7 +432,7 @@ public class XVerPackegeFixer {
|
|||
if (map2b.containsKey(tn)) {
|
||||
sd = map2b.get(tn);
|
||||
} else {
|
||||
sd = (org.hl7.fhir.dstu2016may.model.StructureDefinition) new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new FileInputStream(Utilities.path(R2B_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
sd = (org.hl7.fhir.dstu2016may.model.StructureDefinition) new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(ManagedFileAccess.inStream(Utilities.path(R2B_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
map2b.put(tn, sd);
|
||||
}
|
||||
for (org.hl7.fhir.dstu2016may.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.hl7.fhir.dstu3.formats.XmlParser;
|
|||
import org.hl7.fhir.dstu3.model.ElementDefinition;
|
||||
import org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus;
|
||||
import org.hl7.fhir.dstu3.model.StructureDefinition;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
|
@ -91,11 +92,11 @@ public class ADLImporter {
|
|||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
adlConfig = builder.parse(new FileInputStream(config)).getDocumentElement();
|
||||
adlConfig = builder.parse(ManagedFileAccess.inStream(config)).getDocumentElement();
|
||||
|
||||
// load ADL
|
||||
builder = factory.newDocumentBuilder();
|
||||
adl = builder.parse(new FileInputStream(source)).getDocumentElement();
|
||||
adl = builder.parse(ManagedFileAccess.inStream(source)).getDocumentElement();
|
||||
|
||||
check("root", adl.getNamespaceURI(), "http://schemas.openehr.org/v1", "Wrong namespace for ADL XML");
|
||||
check("root", adl.getNodeName(), "archetype", "Wrong XML for ADL XML");
|
||||
|
@ -150,7 +151,7 @@ public class ADLImporter {
|
|||
genElements(sd, root.getName(), root);
|
||||
|
||||
// save
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(dest), sd);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(dest), sd);
|
||||
System.out.println("done. saved as " + dest);
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ import org.hl7.fhir.dstu3.utils.NarrativeGenerator;
|
|||
import org.hl7.fhir.dstu3.utils.ResourceUtilities;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.ZipGenerator;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.xhtml.NodeType;
|
||||
|
@ -178,7 +179,7 @@ public class ArgonautConverter extends ConverterBase {
|
|||
}
|
||||
|
||||
public void convert(String sourceFolder, Coding clss) throws Exception {
|
||||
File source = new File(sourceFolder);
|
||||
File source = ManagedFileAccess.file(sourceFolder);
|
||||
for (String f : source.list()) {
|
||||
convert(sourceFolder, f, clss);
|
||||
}
|
||||
|
@ -221,13 +222,13 @@ public class ArgonautConverter extends ConverterBase {
|
|||
}
|
||||
|
||||
private void convert(String sourceFolder, String filename, Coding clss) throws IOException {
|
||||
if (new File(Utilities.path(sourceFolder, filename)).length() == 0)
|
||||
if (ManagedFileAccess.file(Utilities.path(sourceFolder, filename)).length() == 0)
|
||||
return;
|
||||
|
||||
CDAUtilities cda;
|
||||
try {
|
||||
System.out.println("Process " + Utilities.path(sourceFolder, filename));
|
||||
cda = new CDAUtilities(new FileInputStream(Utilities.path(sourceFolder, filename)));
|
||||
cda = new CDAUtilities(ManagedFileAccess.inStream(Utilities.path(sourceFolder, filename)));
|
||||
zipJ = new ZipGenerator(Utilities.path(destFolder, "json/doc", Utilities.changeFileExt(filename, ".json.zip")));
|
||||
zipX = new ZipGenerator(Utilities.path(destFolder, "xml/doc", Utilities.changeFileExt(filename, ".xml.zip")));
|
||||
Element doc = cda.getElement();
|
||||
|
@ -1320,7 +1321,7 @@ public class ArgonautConverter extends ConverterBase {
|
|||
Binary binary = new Binary();
|
||||
binary.setId(context.getBaseId() + "-binary");
|
||||
binary.setContentType("application/hl7-v3+xml");
|
||||
binary.setContent(IOUtils.toByteArray(new FileInputStream(Utilities.path(sourceFolder, filename))));
|
||||
binary.setContent(IOUtils.toByteArray(ManagedFileAccess.inStream(Utilities.path(sourceFolder, filename))));
|
||||
saveResource(binary);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent;
|
|||
import org.hl7.fhir.dstu3.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -125,7 +126,7 @@ public class ISO21090Importer {
|
|||
addParentProperties(sd.getSnapshot().getElement(), dt.getName(), dt.getParent(), false, true);
|
||||
produceProperties(sd.getSnapshot().getElement(), dt.getName(), dt.getProperties(), false, true);
|
||||
ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "iso21090\\StructureDefinition-" + dt.getName() + ".xml")), sd);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "iso21090\\StructureDefinition-" + dt.getName() + ".xml")), sd);
|
||||
}
|
||||
|
||||
private void addParentProperties(List<ElementDefinition> elements, String name, String parent, boolean attrMode, boolean snapshot) throws FHIRFormatError {
|
||||
|
@ -176,7 +177,7 @@ public class ISO21090Importer {
|
|||
for (String code : evs.getCodes()) {
|
||||
inc.addConcept().setCode(code);
|
||||
}
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "iso21090\\ValueSet-" + evs.getName() + ".xml")), vs);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "iso21090\\ValueSet-" + evs.getName() + ".xml")), vs);
|
||||
}
|
||||
|
||||
private void processDataTypes() {
|
||||
|
@ -319,7 +320,7 @@ public class ISO21090Importer {
|
|||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(false);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document doc = builder.parse(new FileInputStream("C:\\work\\projects\\org.hl7.v3.dt\\iso\\iso-21090-datatypes.xsd"));
|
||||
Document doc = builder.parse(ManagedFileAccess.inStream("C:\\work\\projects\\org.hl7.v3.dt\\iso\\iso-21090-datatypes.xsd"));
|
||||
schema = doc.getDocumentElement();
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship;
|
|||
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
|
||||
import org.hl7.fhir.utilities.CSVReader;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class SearchParameterProcessor {
|
||||
|
||||
|
@ -120,7 +121,7 @@ public class SearchParameterProcessor {
|
|||
e.addTarget().setCode(d).setRelationship(ConceptMapRelationship.RELATEDTO);
|
||||
}
|
||||
}
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(ROOT, "ConceptMap-" + map.getId() + ".json")), map);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(ROOT, "ConceptMap-" + map.getId() + ".json")), map);
|
||||
}
|
||||
|
||||
private SourceElementComponent makeElement(String code, ConceptMapGroupComponent group) {
|
||||
|
@ -208,7 +209,7 @@ public class SearchParameterProcessor {
|
|||
}
|
||||
|
||||
private void load4() throws FHIRFormatError, IOException {
|
||||
org.hl7.fhir.r4.model.Bundle bundle = (org.hl7.fhir.r4.model.Bundle) new org.hl7.fhir.r4.formats.JsonParser().parse(new FileInputStream(Utilities.path("[tmp]", "sp4.json")));
|
||||
org.hl7.fhir.r4.model.Bundle bundle = (org.hl7.fhir.r4.model.Bundle) new org.hl7.fhir.r4.formats.JsonParser().parse(ManagedFileAccess.inStream(Utilities.path("[tmp]", "sp4.json")));
|
||||
for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent be : bundle.getEntry()) {
|
||||
org.hl7.fhir.r4.model.SearchParameter sp = (org.hl7.fhir.r4.model.SearchParameter) be.getResource();
|
||||
for (org.hl7.fhir.r4.model.CodeType br : sp.getBase()) {
|
||||
|
@ -221,7 +222,7 @@ public class SearchParameterProcessor {
|
|||
}
|
||||
|
||||
private void load3() throws FHIRFormatError, IOException {
|
||||
org.hl7.fhir.dstu3.model.Bundle bundle = (org.hl7.fhir.dstu3.model.Bundle) new org.hl7.fhir.dstu3.formats.JsonParser().parse(new FileInputStream(Utilities.path("[tmp]", "sp3.json")));
|
||||
org.hl7.fhir.dstu3.model.Bundle bundle = (org.hl7.fhir.dstu3.model.Bundle) new org.hl7.fhir.dstu3.formats.JsonParser().parse(ManagedFileAccess.inStream(Utilities.path("[tmp]", "sp3.json")));
|
||||
for (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent be : bundle.getEntry()) {
|
||||
org.hl7.fhir.dstu3.model.SearchParameter sp = (org.hl7.fhir.dstu3.model.SearchParameter) be.getResource();
|
||||
for (org.hl7.fhir.dstu3.model.CodeType br : sp.getBase()) {
|
||||
|
@ -234,7 +235,7 @@ public class SearchParameterProcessor {
|
|||
}
|
||||
|
||||
private void load2() throws FHIRFormatError, IOException {
|
||||
org.hl7.fhir.dstu2.model.Bundle bundle = (org.hl7.fhir.dstu2.model.Bundle) new org.hl7.fhir.dstu2.formats.JsonParser().parse(new FileInputStream(Utilities.path("[tmp]", "sp2.json")));
|
||||
org.hl7.fhir.dstu2.model.Bundle bundle = (org.hl7.fhir.dstu2.model.Bundle) new org.hl7.fhir.dstu2.formats.JsonParser().parse(ManagedFileAccess.inStream(Utilities.path("[tmp]", "sp2.json")));
|
||||
for (org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent be : bundle.getEntry()) {
|
||||
org.hl7.fhir.dstu2.model.SearchParameter sp = (org.hl7.fhir.dstu2.model.SearchParameter) be.getResource();
|
||||
String br = sp.getBase();
|
||||
|
@ -246,7 +247,7 @@ public class SearchParameterProcessor {
|
|||
}
|
||||
|
||||
private void load2b() throws FHIRFormatError, IOException {
|
||||
org.hl7.fhir.dstu2016may.model.Bundle bundle = (org.hl7.fhir.dstu2016may.model.Bundle) new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new FileInputStream(Utilities.path("[tmp]", "sp2b.json")));
|
||||
org.hl7.fhir.dstu2016may.model.Bundle bundle = (org.hl7.fhir.dstu2016may.model.Bundle) new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(ManagedFileAccess.inStream(Utilities.path("[tmp]", "sp2b.json")));
|
||||
for (org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent be : bundle.getEntry()) {
|
||||
org.hl7.fhir.dstu2016may.model.SearchParameter sp = (org.hl7.fhir.dstu2016may.model.SearchParameter) be.getResource();
|
||||
String br = sp.getBase();
|
||||
|
@ -258,7 +259,7 @@ public class SearchParameterProcessor {
|
|||
}
|
||||
|
||||
private void loadCsv() throws IOException, FHIRException {
|
||||
CSVReader csv = new CSVReader(new FileInputStream("C:\\work\\org.hl7.fhir\\org.fhir.interversion\\work\\search-params.csv"));
|
||||
CSVReader csv = new CSVReader(ManagedFileAccess.inStream("C:\\work\\org.hl7.fhir\\org.fhir.interversion\\work\\search-params.csv"));
|
||||
csv.readHeaders();
|
||||
while (csv.line()) {
|
||||
String r4 = csv.cell("R4");
|
||||
|
|
|
@ -21,11 +21,12 @@ import org.hl7.fhir.r4.model.Provenance;
|
|||
import org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent;
|
||||
import org.hl7.fhir.r4.model.Resource;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class UTGCaseSensitivePopulator {
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException, IOException {
|
||||
new UTGCaseSensitivePopulator().process(new File(args[0]));
|
||||
new UTGCaseSensitivePopulator().process(ManagedFileAccess.file(args[0]));
|
||||
|
||||
}
|
||||
|
||||
|
@ -35,7 +36,7 @@ public class UTGCaseSensitivePopulator {
|
|||
bundle.setId("hxutg1-1-0-12");
|
||||
|
||||
scanFolders(root, bundle);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(root.getAbsolutePath(), "input", "sourceOfTruth", "history", "utgrel1hx-1-0-12.json")), bundle);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(root.getAbsolutePath(), "input", "sourceOfTruth", "history", "utgrel1hx-1-0-12.json")), bundle);
|
||||
System.out.println("Done");
|
||||
}
|
||||
|
||||
|
@ -60,10 +61,10 @@ public class UTGCaseSensitivePopulator {
|
|||
|
||||
private void processFile(File f, Bundle bundle, IParser parser, Date d, Date dt) {
|
||||
try {
|
||||
Resource r = parser.parse(new FileInputStream(f));
|
||||
Resource r = parser.parse(ManagedFileAccess.inStream(f));
|
||||
if (r instanceof CodeSystem) {
|
||||
if (processCodeSystem((CodeSystem) r, bundle, d, dt)) {
|
||||
parser.setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(f), r);
|
||||
parser.setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f), r);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.hl7.fhir.r5.model.Resource;
|
|||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage.PackageResourceInformation;
|
||||
|
@ -47,7 +48,7 @@ public class UTGVersionSorter {
|
|||
private void execute(String source) throws IOException {
|
||||
List<CanonicalResourceAnalysis> list = new ArrayList<>();
|
||||
System.out.println("Loading UTG");
|
||||
loadFromSource(list, new File(source));
|
||||
loadFromSource(list, ManagedFileAccess.file(source));
|
||||
|
||||
Map<String, CanonicalResource> r2 = loadPackageR2("hl7.fhir.r2.core");
|
||||
Map<String, CanonicalResource> r3 = loadPackageR3("hl7.fhir.r3.core");
|
||||
|
@ -58,7 +59,7 @@ public class UTGVersionSorter {
|
|||
cr.analyse(r2, r3, r4);
|
||||
}
|
||||
|
||||
Bundle b = (Bundle) new JsonParser().parse(new FileInputStream("C:\\work\\org.hl7.fhir.igs\\UTG\\input\\sourceOfTruth\\history\\utgrel1hx-1-0-6.json"));
|
||||
Bundle b = (Bundle) new JsonParser().parse(ManagedFileAccess.inStream("C:\\work\\org.hl7.fhir.igs\\UTG\\input\\sourceOfTruth\\history\\utgrel1hx-1-0-6.json"));
|
||||
|
||||
System.out.println("Summary");
|
||||
for (CanonicalResourceAnalysis cr : list) {
|
||||
|
@ -79,10 +80,10 @@ public class UTGVersionSorter {
|
|||
pa.getWho().setDisplay("Vocabulary WG");
|
||||
CanonicalResource res = cr.resource;
|
||||
res.setVersion(cr.recommendation);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(cr.filename), res);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(cr.filename), res);
|
||||
}
|
||||
System.out.println();
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("C:\\work\\org.hl7.fhir.igs\\UTG\\input\\sourceOfTruth\\history\\utgrel1hx-1-0-6.json"), b);
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream("C:\\work\\org.hl7.fhir.igs\\UTG\\input\\sourceOfTruth\\history\\utgrel1hx-1-0-6.json"), b);
|
||||
System.out.println("Done");
|
||||
}
|
||||
|
||||
|
@ -134,7 +135,7 @@ public class UTGVersionSorter {
|
|||
loadFromSource(list, f);
|
||||
} else if (f.getName().endsWith(".xml")) {
|
||||
try {
|
||||
Resource r = new XmlParser().parse(new FileInputStream(f));
|
||||
Resource r = new XmlParser().parse(ManagedFileAccess.inStream(f));
|
||||
if (r instanceof CanonicalResource) {
|
||||
CanonicalResource cr = (CanonicalResource) r;
|
||||
cr.setWebPath(f.getAbsolutePath());
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
|
|||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.json.model.JsonArray;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
|
@ -479,7 +480,7 @@ public class CorePackageVersionConvertor {
|
|||
// build a new package
|
||||
System.out.println("Convert "+packageSource+" to "+versionTarget);
|
||||
|
||||
NpmPackage src = NpmPackage.fromPackage(new FileInputStream(packageSource));
|
||||
NpmPackage src = NpmPackage.fromPackage(ManagedFileAccess.inStream(packageSource));
|
||||
IContentConvertor conv = contentConvertorFactory(src.fhirVersion(), versionTarget);
|
||||
|
||||
NpmPackage dst = NpmPackage.empty();
|
||||
|
@ -510,7 +511,7 @@ public class CorePackageVersionConvertor {
|
|||
}
|
||||
}
|
||||
}
|
||||
dst.save(new FileOutputStream(Utilities.changeFileExt(packageSource, ".as."+VersionUtilities.getNameForVersion(versionTarget).toLowerCase()+".tgz")));
|
||||
dst.save(ManagedFileAccess.outStream(Utilities.changeFileExt(packageSource, ".as."+VersionUtilities.getNameForVersion(versionTarget).toLowerCase()+".tgz")));
|
||||
}
|
||||
|
||||
private IContentConvertor contentConvertorFactory(String fhirVersion, String versionTarget) throws Exception {
|
||||
|
|
|
@ -33,7 +33,7 @@ public class RoundTripTests {
|
|||
|
||||
@Parameters(name = "{index}: file {0}")
|
||||
public static Iterable<Object[]> data() throws ParserConfigurationException, SAXException, IOException {
|
||||
File dir = new File(EXAMPLES_DIR);
|
||||
File dir = ManagedFileAccess.file(EXAMPLES_DIR);
|
||||
|
||||
String[] list = dir.list();
|
||||
List<Object[]> objects = new ArrayList<Object[]>(list.length);
|
||||
|
@ -77,7 +77,7 @@ public class RoundTripTests {
|
|||
}
|
||||
|
||||
private void save(byte[] src, String path) throws IOException {
|
||||
File f = new File(path);
|
||||
File f = ManagedFileAccess.file(path);
|
||||
if (f.exists()) {
|
||||
f.delete();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class Configuration {
|
|||
public Configuration(String path) throws FileNotFoundException, IOException {
|
||||
license = TextFile.fileToString(Utilities.path(path, "license.txt"));
|
||||
ini = new IniFile(Utilities.path(path, "configuration.ini"));
|
||||
for (File jfn : new File(path).listFiles()) {
|
||||
for (File jfn : ManagedFileAccess.file(path).listFiles()) {
|
||||
if (jfn.getName().endsWith(".java")) {
|
||||
adornments.put(Utilities.changeFileExt(jfn.getName(), ""), TextFile.fileToString(jfn));
|
||||
}
|
||||
|
|
|
@ -483,7 +483,7 @@ public class JavaResourceGenerator extends JavaBaseGenerator {
|
|||
//// write(" }\r\n");
|
||||
////
|
||||
//// // now, generate the implementation
|
||||
//// JavaPatternImplGenerator jrg = new JavaPatternImplGenerator(new FileOutputStream(javaPatternDir+jn+namenn+"Impl.java"), definitions, adornments, enumInfo);
|
||||
//// JavaPatternImplGenerator jrg = new JavaPatternImplGenerator(ManagedFileAccess.outStream(javaPatternDir+jn+namenn+"Impl.java"), definitions, adornments, enumInfo);
|
||||
//// jrg.generate(resourceDefn.getRoot(), jn, JavaGenClass.Resource, null, genDate, version, false, null, null, namenn, root);
|
||||
//// jrg.close();
|
||||
////
|
||||
|
|
|
@ -58,9 +58,9 @@ public class JavaExtensionsGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
JavaExtensionsFactoryGenerator gen = new JavaExtensionsFactoryGenerator(new FileOutputStream(Utilities.path(path, "Extensions.java")), master, config, version, date, jid, elementInfo, genClassList);
|
||||
JavaExtensionsFactoryGenerator gen = new JavaExtensionsFactoryGenerator(ManagedFileAccess.outStream(Utilities.path(path, "Extensions.java")), master, config, version, date, jid, elementInfo, genClassList);
|
||||
gen.start();
|
||||
JavaConstantsGenerator cgen = new JavaConstantsGenerator(new FileOutputStream(Utilities.path(path, "ExtensionConstants.java")), master, config, version, date, jid);
|
||||
JavaConstantsGenerator cgen = new JavaConstantsGenerator(ManagedFileAccess.outStream(Utilities.path(path, "ExtensionConstants.java")), master, config, version, date, jid);
|
||||
cgen.start();
|
||||
for (String url : urls) {
|
||||
StructureDefinition sd = extensions.get(url);
|
||||
|
|
|
@ -89,19 +89,19 @@ public class JavaCoreGenerator {
|
|||
|
||||
System.out.println("Generate Model in "+dest);
|
||||
System.out.println(" .. Constants");
|
||||
JavaConstantsGenerator cgen = new JavaConstantsGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "Constants.java")), master, config, date, npm.version(), jid);
|
||||
JavaConstantsGenerator cgen = new JavaConstantsGenerator(ManagedFileAccess.outStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "Constants.java")), master, config, date, npm.version(), jid);
|
||||
cgen.generate();
|
||||
cgen.close();
|
||||
System.out.println(" .. Enumerations");
|
||||
JavaEnumerationsGenerator egen = new JavaEnumerationsGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "Enumerations.java")), master, config, date, npm.version(), jid);
|
||||
JavaEnumerationsGenerator egen = new JavaEnumerationsGenerator(ManagedFileAccess.outStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "Enumerations.java")), master, config, date, npm.version(), jid);
|
||||
egen.generate();
|
||||
egen.close();
|
||||
|
||||
JavaFactoryGenerator fgen = new JavaFactoryGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "ResourceFactory.java")), master, config, date, npm.version(), jid);
|
||||
JavaTypeGenerator tgen = new JavaTypeGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "ResourceType.java")), master, config, date, npm.version(), jid);
|
||||
JavaParserJsonGenerator jgen = new JavaParserJsonGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "formats", "JsonParser.java")), master, config, date, npm.version(), jid);
|
||||
JavaParserXmlGenerator xgen = new JavaParserXmlGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "formats", "XmlParser.java")), master, config, date, npm.version(), jid);
|
||||
JavaParserRdfGenerator rgen = new JavaParserRdfGenerator(new FileOutputStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "formats", "RdfParser.java")), master, config, date, npm.version(), jid);
|
||||
JavaFactoryGenerator fgen = new JavaFactoryGenerator(ManagedFileAccess.outStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "ResourceFactory.java")), master, config, date, npm.version(), jid);
|
||||
JavaTypeGenerator tgen = new JavaTypeGenerator(ManagedFileAccess.outStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", "ResourceType.java")), master, config, date, npm.version(), jid);
|
||||
JavaParserJsonGenerator jgen = new JavaParserJsonGenerator(ManagedFileAccess.outStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "formats", "JsonParser.java")), master, config, date, npm.version(), jid);
|
||||
JavaParserXmlGenerator xgen = new JavaParserXmlGenerator(ManagedFileAccess.outStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "formats", "XmlParser.java")), master, config, date, npm.version(), jid);
|
||||
JavaParserRdfGenerator rgen = new JavaParserRdfGenerator(ManagedFileAccess.outStream(Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "formats", "RdfParser.java")), master, config, date, npm.version(), jid);
|
||||
|
||||
if (VersionUtilities.isR4BVer(version)) {
|
||||
StructureDefinition sd = master.getStructures().get("http://hl7.org/fhir/StructureDefinition/Element");
|
||||
|
@ -206,7 +206,7 @@ public class JavaCoreGenerator {
|
|||
Analysis analysis = jca.analyse(sd, elementInfo);
|
||||
|
||||
String fn = Utilities.path(dest, "src", "main", "java", "org", "hl7", "fhir", jid, "model", name+".java");
|
||||
JavaResourceGenerator gen = new JavaResourceGenerator(new FileOutputStream(fn), master, config, date, npm.version(), jid);
|
||||
JavaResourceGenerator gen = new JavaResourceGenerator(ManagedFileAccess.outStream(fn), master, config, date, npm.version(), jid);
|
||||
gen.generate(analysis);
|
||||
gen.close();
|
||||
jgen.seeClass(analysis);
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.hl7.fhir.dstu2.model.Meta;
|
|||
import org.hl7.fhir.dstu2.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -165,12 +166,12 @@ public class LoincToDEConvertor {
|
|||
factory.setNamespaceAware(true);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
xml = builder.parse(new FileInputStream(definitions));
|
||||
xml = builder.parse(ManagedFileAccess.inStream(definitions));
|
||||
}
|
||||
|
||||
private void saveBundle() throws FHIRFormatError, IOException, XmlPullParserException {
|
||||
XmlParser xml = new XmlParser();
|
||||
FileOutputStream s = new FileOutputStream(dest);
|
||||
FileOutputStream s = ManagedFileAccess.outStream(dest);
|
||||
xml.compose(s, bundle, true);
|
||||
s.close();
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ import org.hl7.fhir.dstu2.utils.IWorkerContext;
|
|||
import org.hl7.fhir.dstu2.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
|
||||
|
||||
public class ValueSetExpansionCache implements ValueSetExpanderFactory {
|
||||
|
@ -91,7 +92,7 @@ public class ValueSetExpansionCache implements ValueSetExpanderFactory {
|
|||
// well, we'll see if the designated server can expand it, and if it can, we'll
|
||||
// cache it locally
|
||||
vso = context.expandVS(source, false);
|
||||
FileOutputStream s = new FileOutputStream(Utilities.path(cacheFolder, makeFile(source.getUrl())));
|
||||
FileOutputStream s = ManagedFileAccess.outStream(Utilities.path(cacheFolder, makeFile(source.getUrl())));
|
||||
context.newXmlParser().setOutputStyle(OutputStyle.PRETTY).compose(s, vso.getValueset());
|
||||
s.close();
|
||||
}
|
||||
|
@ -125,10 +126,10 @@ public class ValueSetExpansionCache implements ValueSetExpanderFactory {
|
|||
}
|
||||
|
||||
private void loadCache() throws FHIRFormatError, IOException {
|
||||
File[] files = new File(cacheFolder).listFiles();
|
||||
File[] files = ManagedFileAccess.file(cacheFolder).listFiles();
|
||||
for (File f : files) {
|
||||
if (f.getName().endsWith(".xml")) {
|
||||
final FileInputStream is = new FileInputStream(f);
|
||||
final FileInputStream is = ManagedFileAccess.inStream(f);
|
||||
try {
|
||||
Resource r = context.newXmlParser().setOutputStyle(OutputStyle.PRETTY).parse(is);
|
||||
if (r instanceof OperationOutcome) {
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.hl7.fhir.dstu2.model.Resource;
|
|||
import org.hl7.fhir.dstu2.utils.client.FHIRToolingClient;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class BatchLoader {
|
||||
|
||||
|
@ -66,7 +67,7 @@ public class BatchLoader {
|
|||
throw new FHIRException("Unimplemented file type " + file);
|
||||
} else if (file.endsWith(".zip")) {
|
||||
LoadZipFile(server, file, p, size, 0, -1);
|
||||
} else if (new File(file).isDirectory()) {
|
||||
} else if (ManagedFileAccess.file(file).isDirectory()) {
|
||||
LoadDirectory(server, file, p, size);
|
||||
} else
|
||||
throw new FHIRException("Unknown file type " + file);
|
||||
|
@ -99,7 +100,7 @@ public class BatchLoader {
|
|||
Bundle b = new Bundle();
|
||||
b.setType(BundleType.COLLECTION);
|
||||
b.setId(UUID.randomUUID().toString().toLowerCase());
|
||||
ZipInputStream zip = new ZipInputStream(new FileInputStream(file));
|
||||
ZipInputStream zip = new ZipInputStream(ManagedFileAccess.inStream(file));
|
||||
ZipEntry entry;
|
||||
while ((entry = zip.getNextEntry()) != null) {
|
||||
try {
|
||||
|
|
|
@ -60,8 +60,8 @@ import org.hl7.fhir.dstu2.utils.client.FHIRToolingClient;
|
|||
import org.hl7.fhir.dstu2.utils.validation.IResourceValidator;
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import javax.xml.parsers.DocumentBuilder;
|
|||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent;
|
|||
import org.hl7.fhir.dstu2.model.Resource;
|
||||
import org.hl7.fhir.dstu2.model.ValueSet;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class Unbundler {
|
||||
|
||||
|
@ -51,7 +52,7 @@ public class Unbundler {
|
|||
|
||||
private static void unbundle(String src) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
String folder = Utilities.getDirectoryForFile(src);
|
||||
Bundle bnd = (Bundle) new JsonParser().parse(new FileInputStream(src));
|
||||
Bundle bnd = (Bundle) new JsonParser().parse(ManagedFileAccess.inStream(src));
|
||||
for (BundleEntryComponent be : bnd.getEntry()) {
|
||||
Resource r = be.getResource();
|
||||
if (r != null) {
|
||||
|
@ -61,7 +62,7 @@ public class Unbundler {
|
|||
}
|
||||
if (!StringUtils.isBlank(r.getId())) {
|
||||
String tgt = Utilities.path(folder, r.fhirType() + "-" + r.getId() + ".json");
|
||||
new JsonParser().compose(new FileOutputStream(tgt), r);
|
||||
new JsonParser().compose(ManagedFileAccess.outStream(tgt), r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.hl7.fhir.dstu2.utils.FHIRPathEngine;
|
|||
import org.hl7.fhir.dstu2.utils.SimpleWorkerContext;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
@ -55,7 +56,7 @@ public class FluentPathTests {
|
|||
fp.check(null, null, null, node);
|
||||
else {
|
||||
res = new XmlParser()
|
||||
.parse(new FileInputStream(Utilities.path("C:\\work\\org.hl7.fhir.dstu2\\build\\publish", input)));
|
||||
.parse(ManagedFileAccess.inStream(Utilities.path("C:\\work\\org.hl7.fhir.dstu2\\build\\publish", input)));
|
||||
fp.check(res, res.getResourceType().toString(), res.getResourceType().toString(), node);
|
||||
}
|
||||
outcome = fp.evaluate(res, node);
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.hl7.fhir.dstu2.utils.NarrativeGenerator;
|
|||
import org.hl7.fhir.dstu2.utils.SimpleWorkerContext;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
@ -40,9 +41,9 @@ public class NarrativeGeneratorTests {
|
|||
|
||||
private void process(String path) throws IOException, EOperationOutcome, FHIRException {
|
||||
XmlParser p = new XmlParser();
|
||||
DomainResource r = (DomainResource) p.parse(new FileInputStream(path));
|
||||
DomainResource r = (DomainResource) p.parse(ManagedFileAccess.inStream(path));
|
||||
gen.generate(r);
|
||||
FileOutputStream s = new FileOutputStream(Utilities.path("[tmp]", "gen.xml"));
|
||||
FileOutputStream s = ManagedFileAccess.outStream(Utilities.path("[tmp]", "gen.xml"));
|
||||
new XmlParser().compose(s, r, true);
|
||||
s.close();
|
||||
}
|
||||
|
|
|
@ -24,8 +24,9 @@ import org.hl7.fhir.dstu2.utils.SimpleWorkerContext;
|
|||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.CSFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFile;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
|
||||
|
@ -85,11 +86,11 @@ public class ProfileUtilitiesTests {
|
|||
for (ProfileComparison outcome : comp.getComparisons()) {
|
||||
if (outcome.getSubset() != null)
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(
|
||||
new FileOutputStream(Utilities.path("[tmp]", "intersection-" + outcome.getId() + ".xml")),
|
||||
ManagedFileAccess.outStream(Utilities.path("[tmp]", "intersection-" + outcome.getId() + ".xml")),
|
||||
outcome.getSubset());
|
||||
if (outcome.getSuperset() != null)
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(
|
||||
new FileOutputStream(Utilities.path("[tmp]", "union-" + outcome.getId() + ".xml")), outcome.getSuperset());
|
||||
ManagedFileAccess.outStream(Utilities.path("[tmp]", "union-" + outcome.getId() + ".xml")), outcome.getSuperset());
|
||||
|
||||
System.out.println("\r\n" + outcome.getId() + ": Comparison of " + outcome.getLeft().getUrl() + " and "
|
||||
+ outcome.getRight().getUrl());
|
||||
|
@ -115,9 +116,9 @@ public class ProfileUtilitiesTests {
|
|||
System.out.println("Compare " + fn1 + " to " + fn2);
|
||||
System.out.println(" .. load");
|
||||
StructureDefinition left = (StructureDefinition) new XmlParser()
|
||||
.parse(new FileInputStream(Utilities.path(root, fn1)));
|
||||
.parse(ManagedFileAccess.inStream(Utilities.path(root, fn1)));
|
||||
StructureDefinition right = (StructureDefinition) new XmlParser()
|
||||
.parse(new FileInputStream(Utilities.path(root, fn2)));
|
||||
.parse(ManagedFileAccess.inStream(Utilities.path(root, fn2)));
|
||||
System.out.println(" .. compare");
|
||||
comp.compareProfiles(left, right);
|
||||
|
||||
|
@ -918,16 +919,16 @@ public class ProfileUtilitiesTests {
|
|||
// focus.setDifferential(null);
|
||||
String f1 = Utilities.path("c:", "temp", "base.xml");
|
||||
String f2 = Utilities.path("c:", "temp", "derived.xml");
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(f1), base);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f1), base);
|
||||
;
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(f2), focus);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f2), focus);
|
||||
;
|
||||
String diff = Utilities.path(System.getenv("ProgramFiles(X86)"), "WinMerge", "WinMergeU.exe");
|
||||
List<String> command = new ArrayList<String>();
|
||||
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
builder.directory(new CSFile(Utilities.path("[tmp]")));
|
||||
builder.directory(ManagedFileAccess.csfile(Utilities.path("[tmp]")));
|
||||
builder.start();
|
||||
|
||||
}
|
||||
|
|
|
@ -2,27 +2,29 @@ package org.hl7.fhir.dstu2.test;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.dstu2.formats.XmlParser;
|
||||
import org.hl7.fhir.dstu2.model.StructureDefinition;
|
||||
import org.hl7.fhir.dstu2.utils.QuestionnaireBuilder;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class QuestionnaireBuilderTester {
|
||||
|
||||
private static final String TEST_PROFILE_DIR = "C:\\work\\org.hl7.fhir\\build\\publish";
|
||||
// private static final String TEST_DEST = Utilities.path("[tmp]", "questionnaires\\");
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws IOException {
|
||||
QuestionnaireBuilder b = new QuestionnaireBuilder(null);
|
||||
for (String f : new File(TEST_PROFILE_DIR).list()) {
|
||||
for (String f : ManagedFileAccess.file(TEST_PROFILE_DIR).list()) {
|
||||
if (f.endsWith(".profile.xml") && !f.contains("type-")) {
|
||||
System.out.println("process " + f);
|
||||
try {
|
||||
StructureDefinition p = (StructureDefinition) new XmlParser()
|
||||
.parse(new FileInputStream(TEST_PROFILE_DIR + "\\" + f));
|
||||
.parse(ManagedFileAccess.inStream(TEST_PROFILE_DIR + "\\" + f));
|
||||
// Questionnaire q = b.buildQuestionnaire(p);
|
||||
// new XmlComposer().compose(new FileOutputStream(TEST_DEST+f), q, true);
|
||||
// new XmlComposer().compose(ManagedFileAccess.outStream(TEST_DEST+f), q, true);
|
||||
throw new FHIRException("test");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.hl7.fhir.dstu2.formats.JsonParser;
|
|||
import org.hl7.fhir.dstu2.formats.XmlParser;
|
||||
import org.hl7.fhir.dstu2.model.Resource;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class ResourceTest {
|
||||
|
||||
|
@ -61,18 +62,18 @@ public class ResourceTest {
|
|||
p = new JsonParser();
|
||||
else
|
||||
p = new XmlParser(false);
|
||||
Resource rf = p.parse(new FileInputStream(source));
|
||||
Resource rf = p.parse(ManagedFileAccess.inStream(source));
|
||||
|
||||
FileOutputStream out = new FileOutputStream(source.getAbsoluteFile() + ".out.json");
|
||||
FileOutputStream out = ManagedFileAccess.outStream(source.getAbsoluteFile() + ".out.json");
|
||||
JsonParser json1 = new JsonParser();
|
||||
json1.setOutputStyle(OutputStyle.PRETTY);
|
||||
json1.compose(out, rf);
|
||||
out.close();
|
||||
|
||||
JsonParser json = new JsonParser();
|
||||
rf = json.parse(new FileInputStream(source.getAbsoluteFile() + ".out.json"));
|
||||
rf = json.parse(ManagedFileAccess.inStream(source.getAbsoluteFile() + ".out.json"));
|
||||
|
||||
out = new FileOutputStream(source.getAbsoluteFile() + ".out.xml");
|
||||
out = ManagedFileAccess.outStream(source.getAbsoluteFile() + ".out.xml");
|
||||
XmlParser atom = new XmlParser();
|
||||
atom.setOutputStyle(OutputStyle.PRETTY);
|
||||
atom.compose(out, rf, true);
|
||||
|
|
|
@ -30,6 +30,8 @@ package org.hl7.fhir.dstu2.test;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class SingleTest {
|
||||
|
||||
/**
|
||||
|
@ -38,7 +40,7 @@ public class SingleTest {
|
|||
public static void main(String[] args) {
|
||||
try {
|
||||
ResourceTest r = new ResourceTest();
|
||||
r.setSource(new File("C:\\work\\org.hl7.fhir\\build\\publish\\patient-example.xml"));
|
||||
r.setSource(ManagedFileAccess.file("C:\\work\\org.hl7.fhir\\build\\publish\\patient-example.xml"));
|
||||
r.test();
|
||||
System.out.println("Completed OK");
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -13,9 +13,10 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
|||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.hl7.fhir.dstu2.utils.IWorkerContext;
|
||||
import org.hl7.fhir.utilities.CSFile;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFile;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
|
@ -41,7 +42,7 @@ public class TestingUtilities {
|
|||
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
builder.directory(new CSFile(Utilities.path("[tmp]")));
|
||||
builder.directory(ManagedFileAccess.csfile(Utilities.path("[tmp]")));
|
||||
builder.start();
|
||||
|
||||
}
|
||||
|
@ -154,7 +155,7 @@ public class TestingUtilities {
|
|||
|
||||
factory.setNamespaceAware(true);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
return builder.parse(new FileInputStream(fn));
|
||||
return builder.parse(ManagedFileAccess.inStream(fn));
|
||||
}
|
||||
|
||||
public static String checkJsonIsSame(String f1, String f2)
|
||||
|
@ -166,7 +167,7 @@ public class TestingUtilities {
|
|||
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
builder.directory(new CSFile(Utilities.path("[tmp]")));
|
||||
builder.directory(ManagedFileAccess.csfile(Utilities.path("[tmp]")));
|
||||
builder.start();
|
||||
|
||||
}
|
||||
|
|
|
@ -55,10 +55,11 @@ import org.hl7.fhir.dstu2.model.Resource;
|
|||
import org.hl7.fhir.dstu2.utils.SimpleWorkerContext;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.CSFile;
|
||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFile;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
@ -103,7 +104,7 @@ public class ToolsHelper {
|
|||
private void executeExamples(String[] args) throws IOException {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> lines = FileUtils.readLines(new File(args[1]), "UTF-8");
|
||||
List<String> lines = FileUtils.readLines(ManagedFileAccess.file(args[1]), "UTF-8");
|
||||
String srcDir = lines.get(0);
|
||||
lines.remove(0);
|
||||
processExamples(srcDir, lines);
|
||||
|
@ -179,7 +180,7 @@ public class ToolsHelper {
|
|||
// } else
|
||||
if (definitions.startsWith("https:") || definitions.startsWith("http:")) {
|
||||
defn = loadFromUrl(definitions);
|
||||
} else if (new File(definitions).exists()) {
|
||||
} else if (ManagedFileAccess.file(definitions).exists()) {
|
||||
defn = loadFromFile(definitions);
|
||||
} else
|
||||
throw new FHIRException("Unable to find FHIR validation Pack (source = " + definitions + ")");
|
||||
|
@ -193,7 +194,7 @@ public class ToolsHelper {
|
|||
}
|
||||
|
||||
private byte[] loadFromFile(String src) throws IOException {
|
||||
FileInputStream in = new FileInputStream(src);
|
||||
FileInputStream in = ManagedFileAccess.inStream(src);
|
||||
byte[] b = new byte[in.available()];
|
||||
in.read(b);
|
||||
in.close();
|
||||
|
@ -220,10 +221,10 @@ public class ToolsHelper {
|
|||
|
||||
public void executeFragments(String[] args) throws IOException {
|
||||
try {
|
||||
File source = new CSFile(args[1]);
|
||||
File source = ManagedFileAccess.csfile(args[1]);
|
||||
if (!source.exists())
|
||||
throw new FHIRException("Source File \"" + source.getAbsolutePath() + "\" not found");
|
||||
XmlPullParser xpp = loadXml(new FileInputStream(source));
|
||||
XmlPullParser xpp = loadXml(ManagedFileAccess.inStream(source));
|
||||
nextNoWhitespace(xpp);
|
||||
if (!xpp.getName().equals("tests"))
|
||||
throw new FHIRFormatError("Unable to parse file - starts with " + xpp.getName());
|
||||
|
@ -269,8 +270,8 @@ public class ToolsHelper {
|
|||
|
||||
public void executeRoundTrip(String[] args) throws IOException, FHIRException {
|
||||
FileInputStream in;
|
||||
File source = new CSFile(args[1]);
|
||||
File dest = new CSFile(args[2]);
|
||||
File source = ManagedFileAccess.csfile(args[1]);
|
||||
File dest = ManagedFileAccess.csfile(args[2]);
|
||||
if (args.length >= 4) {
|
||||
Utilities.copyFile(args[1], args[3]);
|
||||
}
|
||||
|
@ -288,17 +289,17 @@ public class ToolsHelper {
|
|||
json.close();
|
||||
TextFile.stringToFile(new String(json.toByteArray()), Utilities.changeFileExt(dest.getAbsolutePath(), ".json"));
|
||||
rf = pj.parse(new ByteArrayInputStream(json.toByteArray()));
|
||||
FileOutputStream s = new FileOutputStream(dest);
|
||||
FileOutputStream s = ManagedFileAccess.outStream(dest);
|
||||
new XmlParser().compose(s, rf, true);
|
||||
s.close();
|
||||
}
|
||||
|
||||
public String executeJson(String[] args) throws IOException, FHIRException {
|
||||
FileInputStream in;
|
||||
File source = new CSFile(args[1]);
|
||||
File dest = new CSFile(args[2]);
|
||||
File destc = new CSFile(Utilities.changeFileExt(args[2], ".canonical.json"));
|
||||
File destt = new CSFile(args[2] + ".tmp");
|
||||
File source = ManagedFileAccess.csfile(args[1]);
|
||||
File dest = ManagedFileAccess.csfile(args[2]);
|
||||
File destc = ManagedFileAccess.csfile(Utilities.changeFileExt(args[2], ".canonical.json"));
|
||||
File destt = ManagedFileAccess.csfile(args[2] + ".tmp");
|
||||
|
||||
if (!source.exists())
|
||||
throw new FHIRException("Source File \"" + source.getAbsolutePath() + "\" not found");
|
||||
|
@ -307,16 +308,16 @@ public class ToolsHelper {
|
|||
Resource rf = p.parse(in);
|
||||
JsonParser json = new JsonParser();
|
||||
json.setOutputStyle(OutputStyle.PRETTY);
|
||||
FileOutputStream s = new FileOutputStream(dest);
|
||||
FileOutputStream s = ManagedFileAccess.outStream(dest);
|
||||
json.compose(s, rf);
|
||||
s.close();
|
||||
json.setOutputStyle(OutputStyle.CANONICAL);
|
||||
s = new FileOutputStream(destc);
|
||||
s = ManagedFileAccess.outStream(destc);
|
||||
json.compose(s, rf);
|
||||
s.close();
|
||||
json.setSuppressXhtml("Snipped for Brevity");
|
||||
json.setOutputStyle(OutputStyle.PRETTY);
|
||||
s = new FileOutputStream(destt);
|
||||
s = ManagedFileAccess.outStream(destt);
|
||||
json.compose(s, rf);
|
||||
s.close();
|
||||
return TextFile.fileToString(destt.getAbsolutePath());
|
||||
|
@ -324,8 +325,8 @@ public class ToolsHelper {
|
|||
|
||||
public void executeCanonicalXml(String[] args) throws FHIRException, IOException {
|
||||
FileInputStream in;
|
||||
File source = new CSFile(args[1]);
|
||||
File dest = new CSFile(args[2]);
|
||||
File source = ManagedFileAccess.csfile(args[1]);
|
||||
File dest = ManagedFileAccess.csfile(args[2]);
|
||||
|
||||
if (!source.exists())
|
||||
throw new FHIRException("Source File \"" + source.getAbsolutePath() + "\" not found");
|
||||
|
@ -334,7 +335,7 @@ public class ToolsHelper {
|
|||
Resource rf = p.parse(in);
|
||||
XmlParser cxml = new XmlParser();
|
||||
cxml.setOutputStyle(OutputStyle.NORMAL);
|
||||
cxml.compose(new FileOutputStream(dest), rf);
|
||||
cxml.compose(ManagedFileAccess.outStream(dest), rf);
|
||||
}
|
||||
|
||||
private void executeVersion(String[] args) throws IOException {
|
||||
|
@ -347,7 +348,7 @@ public class ToolsHelper {
|
|||
String filename = rootDir + n + ".xml";
|
||||
// 1. produce canonical XML
|
||||
CSFileInputStream source = new CSFileInputStream(filename);
|
||||
FileOutputStream dest = new FileOutputStream(Utilities.changeFileExt(filename, ".canonical.xml"));
|
||||
FileOutputStream dest = ManagedFileAccess.outStream(Utilities.changeFileExt(filename, ".canonical.xml"));
|
||||
XmlParser p = new XmlParser();
|
||||
Resource r = p.parse(source);
|
||||
XmlParser cxml = new XmlParser();
|
||||
|
@ -356,14 +357,14 @@ public class ToolsHelper {
|
|||
|
||||
// 2. produce JSON
|
||||
source = new CSFileInputStream(filename);
|
||||
dest = new FileOutputStream(Utilities.changeFileExt(filename, ".json"));
|
||||
dest = ManagedFileAccess.outStream(Utilities.changeFileExt(filename, ".json"));
|
||||
r = p.parse(source);
|
||||
JsonParser json = new JsonParser();
|
||||
json.setOutputStyle(OutputStyle.PRETTY);
|
||||
json.compose(dest, r);
|
||||
json = new JsonParser();
|
||||
json.setOutputStyle(OutputStyle.CANONICAL);
|
||||
dest = new FileOutputStream(Utilities.changeFileExt(filename, ".canonical.json"));
|
||||
dest = ManagedFileAccess.outStream(Utilities.changeFileExt(filename, ".canonical.json"));
|
||||
json.compose(dest, r);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -383,23 +384,23 @@ public class ToolsHelper {
|
|||
String tmp = tmpDir + n.replace(File.separator, "-") + ".tmp";
|
||||
String dest = tmpDir + n.replace(File.separator, "-") + ".java.xml";
|
||||
|
||||
FileInputStream in = new FileInputStream(source);
|
||||
FileInputStream in = ManagedFileAccess.inStream(source);
|
||||
XmlParser xp = new XmlParser();
|
||||
Resource r = xp.parse(in);
|
||||
System.err.print(".");
|
||||
JsonParser jp = new JsonParser();
|
||||
FileOutputStream out = new FileOutputStream(tmp);
|
||||
FileOutputStream out = ManagedFileAccess.outStream(tmp);
|
||||
jp.setOutputStyle(OutputStyle.PRETTY);
|
||||
jp.compose(out, r);
|
||||
out.close();
|
||||
r = null;
|
||||
System.err.print(".");
|
||||
|
||||
in = new FileInputStream(tmp);
|
||||
in = ManagedFileAccess.inStream(tmp);
|
||||
System.err.print(",");
|
||||
r = jp.parse(in);
|
||||
System.err.print(".");
|
||||
out = new FileOutputStream(dest);
|
||||
out = ManagedFileAccess.outStream(dest);
|
||||
new XmlParser().compose(out, r, true);
|
||||
System.err.println("!");
|
||||
out.close();
|
||||
|
@ -415,7 +416,7 @@ public class ToolsHelper {
|
|||
private void executeTest(String[] args) throws Throwable {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> lines = FileUtils.readLines(new File(args[1]), "UTF-8");
|
||||
List<String> lines = FileUtils.readLines(ManagedFileAccess.file(args[1]), "UTF-8");
|
||||
String srcDir = lines.get(0);
|
||||
lines.remove(0);
|
||||
String dstDir = lines.get(0).trim();
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.hl7.fhir.dstu2016may.utils.IWorkerContext;
|
|||
import org.hl7.fhir.dstu2016may.utils.SimpleWorkerContext;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
|
@ -52,21 +53,21 @@ public class Tester {
|
|||
.fromPack(Utilities.path("C:\\work\\org.hl7.fhir\\build\\publish", "validation-min.xml.zip"));
|
||||
int t = 0;
|
||||
int ok = 0;
|
||||
for (String f : new File("C:\\work\\org.hl7.fhir\\build\\publish").list()) {
|
||||
for (String f : ManagedFileAccess.file("C:\\work\\org.hl7.fhir\\build\\publish").list()) {
|
||||
if (f.endsWith(".xml") && !f.endsWith(".canonical.xml") && !f.contains("profile") && !f.contains("questionnaire")
|
||||
&& new File("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".ttl")).exists()) {
|
||||
&& ManagedFileAccess.file("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".ttl")).exists()) {
|
||||
// if (f.equals("account-questionnaire.xml")) {
|
||||
System.out.print("convert " + f);
|
||||
// Manager.convert(context, new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+f), FhirFormat.XML,
|
||||
// new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")), FhirFormat.JSON, OutputStyle.PRETTY);
|
||||
// Manager.convert(context, ManagedFileAccess.inStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+f), FhirFormat.XML,
|
||||
// ManagedFileAccess.outStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")), FhirFormat.JSON, OutputStyle.PRETTY);
|
||||
// String src = normalise(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")));
|
||||
// String tgt = normalise(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".json")));
|
||||
Element e = Manager.parse(context, new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\" + f),
|
||||
Element e = Manager.parse(context, ManagedFileAccess.inStream("C:\\work\\org.hl7.fhir\\build\\publish\\" + f),
|
||||
FhirFormat.XML);
|
||||
Manager.compose(context, e,
|
||||
new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".mm.ttl")),
|
||||
ManagedFileAccess.outStream("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".mm.ttl")),
|
||||
FhirFormat.TURTLE, OutputStyle.PRETTY, null);
|
||||
Manager.compose(context, e, new FileOutputStream(Utilities.path("[tmp]", "resource.xml")), FhirFormat.XML,
|
||||
Manager.compose(context, e, ManagedFileAccess.outStream(Utilities.path("[tmp]", "resource.xml")), FhirFormat.XML,
|
||||
OutputStyle.PRETTY, null);
|
||||
String src = TextFile
|
||||
.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".mm.ttl"));
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus;
|
|||
import org.hl7.fhir.dstu2016may.model.Identifier;
|
||||
import org.hl7.fhir.dstu2016may.model.ValueSet;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -118,7 +119,7 @@ public class ICPC2Importer {
|
|||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(false);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document doc = builder.parse(new FileInputStream(sourceFileName));
|
||||
Document doc = builder.parse(ManagedFileAccess.inStream(sourceFileName));
|
||||
|
||||
ValueSet vs = new ValueSet();
|
||||
vs.setUrl("http://hl7.org/fhir/sid/icpc2/vs");
|
||||
|
@ -167,8 +168,8 @@ public class ICPC2Importer {
|
|||
|
||||
XmlParser xml = new XmlParser();
|
||||
xml.setOutputStyle(OutputStyle.PRETTY);
|
||||
xml.compose(new FileOutputStream(targetFileNameVS), vs);
|
||||
xml.compose(new FileOutputStream(targetFileNameCS), cs);
|
||||
xml.compose(ManagedFileAccess.outStream(targetFileNameVS), vs);
|
||||
xml.compose(ManagedFileAccess.outStream(targetFileNameCS), cs);
|
||||
}
|
||||
|
||||
private void processClass(Element cls, Map<String, ConceptDefinitionComponent> concepts, CodeSystem define) {
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.hl7.fhir.dstu2016may.model.Meta;
|
|||
import org.hl7.fhir.dstu2016may.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -165,12 +166,12 @@ public class LoincToDEConvertor {
|
|||
factory.setNamespaceAware(true);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
xml = builder.parse(new FileInputStream(definitions));
|
||||
xml = builder.parse(ManagedFileAccess.inStream(definitions));
|
||||
}
|
||||
|
||||
private void saveBundle() throws FHIRFormatError, IOException, XmlPullParserException {
|
||||
XmlParser xml = new XmlParser();
|
||||
FileOutputStream s = new FileOutputStream(dest);
|
||||
FileOutputStream s = ManagedFileAccess.outStream(dest);
|
||||
xml.compose(s, bundle, true);
|
||||
s.close();
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ import org.hl7.fhir.dstu2016may.utils.IWorkerContext;
|
|||
import org.hl7.fhir.dstu2016may.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
|
||||
|
||||
public class ValueSetExpansionCache implements ValueSetExpanderFactory {
|
||||
|
@ -91,7 +92,7 @@ public class ValueSetExpansionCache implements ValueSetExpanderFactory {
|
|||
// well, we'll see if the designated server can expand it, and if it can, we'll
|
||||
// cache it locally
|
||||
vso = context.expandVS(source, false);
|
||||
FileOutputStream s = new FileOutputStream(Utilities.path(cacheFolder, makeFile(source.getUrl())));
|
||||
FileOutputStream s = ManagedFileAccess.outStream(Utilities.path(cacheFolder, makeFile(source.getUrl())));
|
||||
context.newXmlParser().setOutputStyle(OutputStyle.PRETTY).compose(s, vso.getValueset());
|
||||
s.close();
|
||||
}
|
||||
|
@ -125,10 +126,10 @@ public class ValueSetExpansionCache implements ValueSetExpanderFactory {
|
|||
}
|
||||
|
||||
private void loadCache() throws FHIRFormatError, IOException {
|
||||
File[] files = new File(cacheFolder).listFiles();
|
||||
File[] files = ManagedFileAccess.file(cacheFolder).listFiles();
|
||||
for (File f : files) {
|
||||
if (f.getName().endsWith(".xml")) {
|
||||
final FileInputStream is = new FileInputStream(f);
|
||||
final FileInputStream is = ManagedFileAccess.inStream(f);
|
||||
try {
|
||||
Resource r = context.newXmlParser().setOutputStyle(OutputStyle.PRETTY).parse(is);
|
||||
if (r instanceof OperationOutcome) {
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.hl7.fhir.dstu2016may.model.Resource;
|
|||
import org.hl7.fhir.dstu2016may.utils.client.FHIRToolingClient;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class BatchLoader {
|
||||
|
||||
|
@ -66,7 +67,7 @@ public class BatchLoader {
|
|||
throw new FHIRException("Unimplemented file type " + file);
|
||||
} else if (file.endsWith(".zip")) {
|
||||
LoadZipFile(server, file, p, size, 0, -1);
|
||||
} else if (new File(file).isDirectory()) {
|
||||
} else if (ManagedFileAccess.file(file).isDirectory()) {
|
||||
LoadDirectory(server, file, p, size);
|
||||
} else
|
||||
throw new FHIRException("Unknown file type " + file);
|
||||
|
@ -99,7 +100,7 @@ public class BatchLoader {
|
|||
Bundle b = new Bundle();
|
||||
b.setType(BundleType.COLLECTION);
|
||||
b.setId(UUID.randomUUID().toString().toLowerCase());
|
||||
ZipInputStream zip = new ZipInputStream(new FileInputStream(file));
|
||||
ZipInputStream zip = new ZipInputStream(ManagedFileAccess.inStream(file));
|
||||
ZipEntry entry;
|
||||
while ((entry = zip.getNextEntry()) != null) {
|
||||
try {
|
||||
|
|
|
@ -71,9 +71,10 @@ import org.hl7.fhir.dstu2016may.utils.client.FHIRToolingClient;
|
|||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.OIDUtils;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
|
||||
|
@ -425,7 +426,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
}
|
||||
|
||||
public void loadFromFolder(String folder) throws FileNotFoundException, Exception {
|
||||
for (String n : new File(folder).list()) {
|
||||
for (String n : ManagedFileAccess.file(folder).list()) {
|
||||
if (n.endsWith(".json"))
|
||||
loadFromFile(Utilities.path(folder, n), new JsonParser());
|
||||
else if (n.endsWith(".xml"))
|
||||
|
@ -436,7 +437,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
private void loadFromFile(String filename, IParser p) throws FileNotFoundException, Exception {
|
||||
Resource r;
|
||||
try {
|
||||
r = p.parse(new FileInputStream(filename));
|
||||
r = p.parse(ManagedFileAccess.inStream(filename));
|
||||
if (r.getResourceType() == ResourceType.Bundle) {
|
||||
for (BundleEntryComponent e : ((Bundle) r).getEntry()) {
|
||||
seeResource(null, e.getResource());
|
||||
|
|
|
@ -32,6 +32,7 @@ package org.hl7.fhir.dstu2016may.utils;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -45,6 +46,7 @@ import org.hl7.fhir.dstu2016may.model.Bundle;
|
|||
import org.hl7.fhir.dstu2016may.model.StructureMap;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class Transformer {
|
||||
|
||||
|
@ -117,7 +119,7 @@ public class Transformer {
|
|||
loadMaps(folder);
|
||||
}
|
||||
System.out.println(" .. load source from " + source);
|
||||
Element e = Manager.parse(context, new FileInputStream(source), FhirFormat.XML);
|
||||
Element e = Manager.parse(context, ManagedFileAccess.inStream(source), FhirFormat.XML);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
StructureMap map = scu.getLibrary().get(mapUri);
|
||||
|
@ -125,7 +127,7 @@ public class Transformer {
|
|||
throw new Error("Unable to find map " + mapUri + " (Known Maps = "
|
||||
+ Utilities.listCanonicalUrls(scu.getLibrary().keySet()) + ")");
|
||||
scu.transform(null, e, map, bundle);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(output), bundle);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(output), bundle);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -134,8 +136,8 @@ public class Transformer {
|
|||
}
|
||||
}
|
||||
|
||||
private void loadMaps(String folder) {
|
||||
for (String f : new File(folder).list()) {
|
||||
private void loadMaps(String folder) throws IOException {
|
||||
for (String f : ManagedFileAccess.file(folder).list()) {
|
||||
try {
|
||||
StructureMap map = scu.parse(TextFile.fileToString(Utilities.path(folder, f)));
|
||||
scu.getLibrary().put(map.getUrl(), map);
|
||||
|
|
|
@ -38,7 +38,7 @@ import javax.xml.parsers.DocumentBuilder;
|
|||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.hl7.fhir.dstu2016may.model.Bundle;
|
|||
import org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.dstu2016may.model.Resource;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class Unbundler {
|
||||
|
||||
|
@ -51,7 +52,7 @@ public class Unbundler {
|
|||
|
||||
private static void unbundle(String src) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
String folder = Utilities.getDirectoryForFile(src);
|
||||
Bundle bnd = (Bundle) new JsonParser().parse(new FileInputStream(src));
|
||||
Bundle bnd = (Bundle) new JsonParser().parse(ManagedFileAccess.inStream(src));
|
||||
for (BundleEntryComponent be : bnd.getEntry()) {
|
||||
Resource r = be.getResource();
|
||||
if (r != null) {
|
||||
|
@ -61,7 +62,7 @@ public class Unbundler {
|
|||
}
|
||||
if (!StringUtils.isBlank(r.getId())) {
|
||||
String tgt = Utilities.path(folder, r.fhirType() + "-" + r.getId() + ".json");
|
||||
new JsonParser().compose(new FileOutputStream(tgt), r);
|
||||
new JsonParser().compose(ManagedFileAccess.outStream(tgt), r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.exceptions.PathEngineException;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -46,35 +47,35 @@ public class FluentPathTests {
|
|||
private Patient patient() throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
if (patient == null)
|
||||
patient = (Patient) new JsonParser()
|
||||
.parse(new FileInputStream("C:/work/org.hl7.fhir.2016May/build/publish/patient-example.json"));
|
||||
.parse(ManagedFileAccess.inStream("C:/work/org.hl7.fhir.2016May/build/publish/patient-example.json"));
|
||||
return patient;
|
||||
}
|
||||
|
||||
private Appointment appointment() throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
if (appointment == null)
|
||||
appointment = (Appointment) new JsonParser()
|
||||
.parse(new FileInputStream("C:/work/org.hl7.fhir.2016May/build/publish/appointment-example-request.json"));
|
||||
.parse(ManagedFileAccess.inStream("C:/work/org.hl7.fhir.2016May/build/publish/appointment-example-request.json"));
|
||||
return appointment;
|
||||
}
|
||||
|
||||
private Questionnaire questionnaire() throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
if (questionnaire == null)
|
||||
questionnaire = (Questionnaire) new JsonParser()
|
||||
.parse(new FileInputStream("C:/work/org.hl7.fhir.2016May/build/publish/questionnaire-example.json"));
|
||||
.parse(ManagedFileAccess.inStream("C:/work/org.hl7.fhir.2016May/build/publish/questionnaire-example.json"));
|
||||
return questionnaire;
|
||||
}
|
||||
|
||||
private ValueSet valueset() throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
if (valueset == null)
|
||||
valueset = (ValueSet) new JsonParser()
|
||||
.parse(new FileInputStream("C:/work/org.hl7.fhir.2016May/build/publish/valueset-example-expansion.json"));
|
||||
.parse(ManagedFileAccess.inStream("C:/work/org.hl7.fhir.2016May/build/publish/valueset-example-expansion.json"));
|
||||
return valueset;
|
||||
}
|
||||
|
||||
private Observation observation() throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
if (observation == null)
|
||||
observation = (Observation) new JsonParser()
|
||||
.parse(new FileInputStream("C:/work/org.hl7.fhir.2016May/build/publish/observation-example.json"));
|
||||
.parse(ManagedFileAccess.inStream("C:/work/org.hl7.fhir.2016May/build/publish/observation-example.json"));
|
||||
return observation;
|
||||
}
|
||||
|
||||
|
@ -929,7 +930,7 @@ public class FluentPathTests {
|
|||
@Test
|
||||
public void testQuestionnaire() throws FileNotFoundException, IOException, FHIRException {
|
||||
Questionnaire q = (Questionnaire) new JsonParser()
|
||||
.parse(new FileInputStream("C:/work/org.hl7.fhir.2016May/build/publish/questionnaire-example-gcs.json"));
|
||||
.parse(ManagedFileAccess.inStream("C:/work/org.hl7.fhir.2016May/build/publish/questionnaire-example-gcs.json"));
|
||||
for (QuestionnaireItemComponent qi : q.getItem()) {
|
||||
testQItem(qi);
|
||||
}
|
||||
|
@ -943,7 +944,7 @@ public class FluentPathTests {
|
|||
@Test
|
||||
public void testExtensionDefinitions() throws FileNotFoundException, IOException, FHIRException {
|
||||
Bundle b = (Bundle) new JsonParser()
|
||||
.parse(new FileInputStream("C:/work/org.hl7.fhir.2016May/build/publish/extension-definitions.json"));
|
||||
.parse(ManagedFileAccess.inStream("C:/work/org.hl7.fhir.2016May/build/publish/extension-definitions.json"));
|
||||
for (BundleEntryComponent be : b.getEntry()) {
|
||||
testStructureDefinition((StructureDefinition) be.getResource());
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.hl7.fhir.dstu2016may.utils.NarrativeGenerator;
|
|||
import org.hl7.fhir.dstu2016may.utils.SimpleWorkerContext;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -41,9 +42,9 @@ public class NarrativeGeneratorTests {
|
|||
private void process(String path)
|
||||
throws FileNotFoundException, IOException, XmlPullParserException, EOperationOutcome, FHIRException {
|
||||
XmlParser p = new XmlParser();
|
||||
DomainResource r = (DomainResource) p.parse(new FileInputStream(path));
|
||||
DomainResource r = (DomainResource) p.parse(ManagedFileAccess.inStream(path));
|
||||
gen.generate(r);
|
||||
FileOutputStream s = new FileOutputStream(Utilities.path("[tmp]", "gen.xml"));
|
||||
FileOutputStream s = ManagedFileAccess.outStream(Utilities.path("[tmp]", "gen.xml"));
|
||||
new XmlParser().compose(s, r, true);
|
||||
s.close();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.hl7.fhir.dstu2016may.metamodel.Manager.FhirFormat;
|
|||
import org.hl7.fhir.dstu2016may.model.Resource;
|
||||
import org.hl7.fhir.dstu2016may.utils.SimpleWorkerContext;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -32,7 +32,7 @@ public class ParserTests {
|
|||
@Test
|
||||
public void testAll() throws Exception {
|
||||
String examples = Utilities.path(root, "examples");
|
||||
for (String fn : new File(examples).list()) {
|
||||
for (String fn : ManagedFileAccess.file(examples).list()) {
|
||||
if (fn.endsWith(".xml")) {
|
||||
testRoundTrip(Utilities.path(examples, fn), fn);
|
||||
}
|
||||
|
@ -41,50 +41,50 @@ public class ParserTests {
|
|||
|
||||
private void testRoundTrip(String filename, String name) throws Exception {
|
||||
System.out.println(name);
|
||||
Resource r = new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(new FileInputStream(filename));
|
||||
Resource r = new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(ManagedFileAccess.inStream(filename));
|
||||
String fn = makeTempFilename();
|
||||
new org.hl7.fhir.dstu2016may.formats.XmlParser().setOutputStyle(OutputStyle.PRETTY)
|
||||
.compose(new FileOutputStream(fn), r);
|
||||
.compose(ManagedFileAccess.outStream(fn), r);
|
||||
String msg = TestingUtilities.checkXMLIsSame(filename, fn);
|
||||
Assertions.assertNull(msg, name + ": " + msg);
|
||||
String j1 = makeTempFilename();
|
||||
new org.hl7.fhir.dstu2016may.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY)
|
||||
.compose(new FileOutputStream(j1), r);
|
||||
.compose(ManagedFileAccess.outStream(j1), r);
|
||||
|
||||
if (TestingUtilities.context == null) {
|
||||
TestingUtilities.context = SimpleWorkerContext.fromPack(Utilities.path(root, "validation-min.xml.zip"));
|
||||
}
|
||||
|
||||
Element re = Manager.parse(TestingUtilities.context, new FileInputStream(filename), FhirFormat.XML);
|
||||
Element re = Manager.parse(TestingUtilities.context, ManagedFileAccess.inStream(filename), FhirFormat.XML);
|
||||
fn = makeTempFilename();
|
||||
Manager.compose(TestingUtilities.context, re, new FileOutputStream(fn), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
Manager.compose(TestingUtilities.context, re, ManagedFileAccess.outStream(fn), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
msg = TestingUtilities.checkXMLIsSame(filename, fn);
|
||||
Assertions.assertNull(msg, name + ": " + msg);
|
||||
String j2 = makeTempFilename();
|
||||
Manager.compose(TestingUtilities.context, re, new FileOutputStream(j2), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
||||
Manager.compose(TestingUtilities.context, re, ManagedFileAccess.outStream(j2), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
||||
|
||||
msg = TestingUtilities.checkJsonIsSame(j1, j2);
|
||||
Assertions.assertNull(msg, name + ": " + msg);
|
||||
|
||||
// ok, we've produced equivalent JSON by both methods.
|
||||
// now, we're going to reverse the process
|
||||
r = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new FileInputStream(j2)); // crossover too
|
||||
r = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(ManagedFileAccess.inStream(j2)); // crossover too
|
||||
fn = makeTempFilename();
|
||||
new org.hl7.fhir.dstu2016may.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY)
|
||||
.compose(new FileOutputStream(fn), r);
|
||||
.compose(ManagedFileAccess.outStream(fn), r);
|
||||
msg = TestingUtilities.checkJsonIsSame(j2, fn);
|
||||
Assertions.assertNull(msg, name + ": " + msg);
|
||||
String x1 = makeTempFilename();
|
||||
new org.hl7.fhir.dstu2016may.formats.XmlParser().setOutputStyle(OutputStyle.PRETTY)
|
||||
.compose(new FileOutputStream(x1), r);
|
||||
.compose(ManagedFileAccess.outStream(x1), r);
|
||||
|
||||
re = Manager.parse(TestingUtilities.context, new FileInputStream(j1), FhirFormat.JSON);
|
||||
re = Manager.parse(TestingUtilities.context, ManagedFileAccess.inStream(j1), FhirFormat.JSON);
|
||||
fn = makeTempFilename();
|
||||
Manager.compose(TestingUtilities.context, re, new FileOutputStream(fn), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
||||
Manager.compose(TestingUtilities.context, re, ManagedFileAccess.outStream(fn), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
||||
msg = TestingUtilities.checkJsonIsSame(j1, fn);
|
||||
Assertions.assertNull(msg, name + ": " + msg);
|
||||
String x2 = makeTempFilename();
|
||||
Manager.compose(TestingUtilities.context, re, new FileOutputStream(x2), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
Manager.compose(TestingUtilities.context, re, ManagedFileAccess.outStream(x2), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
|
||||
msg = TestingUtilities.checkXMLIsSame(x1, x2);
|
||||
Assertions.assertNull(msg, name + ": " + msg);
|
||||
|
|
|
@ -2,27 +2,29 @@ package org.hl7.fhir.dstu2016may.test;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.dstu2016may.formats.XmlParser;
|
||||
import org.hl7.fhir.dstu2016may.model.StructureDefinition;
|
||||
import org.hl7.fhir.dstu2016may.utils.QuestionnaireBuilder;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class QuestionnaireBuilderTester {
|
||||
|
||||
private static final String TEST_PROFILE_DIR = "C:\\work\\org.hl7.fhir\\build\\publish";
|
||||
// private static final String TEST_DEST = Utilities.path("[tmp]", "questionnaires\\");
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws IOException {
|
||||
QuestionnaireBuilder b = new QuestionnaireBuilder(null);
|
||||
for (String f : new File(TEST_PROFILE_DIR).list()) {
|
||||
for (String f : ManagedFileAccess.file(TEST_PROFILE_DIR).list()) {
|
||||
if (f.endsWith(".profile.xml") && !f.contains("type-")) {
|
||||
System.out.println("process " + f);
|
||||
try {
|
||||
StructureDefinition p = (StructureDefinition) new XmlParser()
|
||||
.parse(new FileInputStream(TEST_PROFILE_DIR + "\\" + f));
|
||||
.parse(ManagedFileAccess.inStream(TEST_PROFILE_DIR + "\\" + f));
|
||||
// Questionnaire q = b.buildQuestionnaire(p);
|
||||
// new XmlComposer().compose(new FileOutputStream(TEST_DEST+f), q, true);
|
||||
// new XmlComposer().compose(ManagedFileAccess.outStream(TEST_DEST+f), q, true);
|
||||
throw new FHIRException("test");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.hl7.fhir.dstu2016may.formats.JsonParser;
|
|||
import org.hl7.fhir.dstu2016may.formats.XmlParser;
|
||||
import org.hl7.fhir.dstu2016may.model.Resource;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class ResourceTest {
|
||||
|
||||
|
@ -61,18 +62,18 @@ public class ResourceTest {
|
|||
p = new JsonParser();
|
||||
else
|
||||
p = new XmlParser(false);
|
||||
Resource rf = p.parse(new FileInputStream(source));
|
||||
Resource rf = p.parse(ManagedFileAccess.inStream(source));
|
||||
|
||||
FileOutputStream out = new FileOutputStream(source.getAbsoluteFile() + ".out.json");
|
||||
FileOutputStream out = ManagedFileAccess.outStream(source.getAbsoluteFile() + ".out.json");
|
||||
JsonParser json1 = new JsonParser();
|
||||
json1.setOutputStyle(OutputStyle.PRETTY);
|
||||
json1.compose(out, rf);
|
||||
out.close();
|
||||
|
||||
JsonParser json = new JsonParser();
|
||||
rf = json.parse(new FileInputStream(source.getAbsoluteFile() + ".out.json"));
|
||||
rf = json.parse(ManagedFileAccess.inStream(source.getAbsoluteFile() + ".out.json"));
|
||||
|
||||
out = new FileOutputStream(source.getAbsoluteFile() + ".out.xml");
|
||||
out = ManagedFileAccess.outStream(source.getAbsoluteFile() + ".out.xml");
|
||||
XmlParser atom = new XmlParser();
|
||||
atom.setOutputStyle(OutputStyle.PRETTY);
|
||||
atom.compose(out, rf, true);
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.hl7.fhir.dstu2016may.metamodel.Manager.FhirFormat;
|
|||
import org.hl7.fhir.dstu2016may.model.Resource;
|
||||
import org.hl7.fhir.dstu2016may.utils.SimpleWorkerContext;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
@ -29,7 +30,7 @@ public class RoundTripTest {
|
|||
public static Stream<Arguments> getFiles() throws IOException {
|
||||
List<Arguments> params = new ArrayList();
|
||||
String examples = Utilities.path(root, "examples");
|
||||
for (File f : new File(examples).listFiles()) {
|
||||
for (File f : ManagedFileAccess.file(examples).listFiles()) {
|
||||
if (f.getName().endsWith(".xml")) {
|
||||
params.add(Arguments.of(f));
|
||||
}
|
||||
|
@ -48,50 +49,50 @@ public class RoundTripTest {
|
|||
@SuppressWarnings("deprecation")
|
||||
public void test(File file) throws Exception {
|
||||
System.out.println(file.getName());
|
||||
Resource r = new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(new FileInputStream(file));
|
||||
Resource r = new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(ManagedFileAccess.inStream(file));
|
||||
String fn = makeTempFilename();
|
||||
new org.hl7.fhir.dstu2016may.formats.XmlParser().setOutputStyle(OutputStyle.PRETTY)
|
||||
.compose(new FileOutputStream(fn), r);
|
||||
.compose(ManagedFileAccess.outStream(fn), r);
|
||||
String msg = TestingUtilities.checkXMLIsSame(file.getAbsolutePath(), fn);
|
||||
Assertions.assertTrue(msg == null, file.getName() + ": " + msg);
|
||||
String j1 = makeTempFilename();
|
||||
new org.hl7.fhir.dstu2016may.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY)
|
||||
.compose(new FileOutputStream(j1), r);
|
||||
.compose(ManagedFileAccess.outStream(j1), r);
|
||||
|
||||
if (TestingUtilities.context == null) {
|
||||
TestingUtilities.context = SimpleWorkerContext.fromPack(Utilities.path(root, "validation-min.xml.zip"));
|
||||
}
|
||||
|
||||
Element re = Manager.parse(TestingUtilities.context, new FileInputStream(file), FhirFormat.XML);
|
||||
Element re = Manager.parse(TestingUtilities.context, ManagedFileAccess.inStream(file), FhirFormat.XML);
|
||||
fn = makeTempFilename();
|
||||
Manager.compose(TestingUtilities.context, re, new FileOutputStream(fn), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
Manager.compose(TestingUtilities.context, re, ManagedFileAccess.outStream(fn), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
msg = TestingUtilities.checkXMLIsSame(file.getAbsolutePath(), fn);
|
||||
Assertions.assertTrue(msg == null, file.getName() + ": " + msg);
|
||||
String j2 = makeTempFilename();
|
||||
Manager.compose(TestingUtilities.context, re, new FileOutputStream(j2), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
||||
Manager.compose(TestingUtilities.context, re, ManagedFileAccess.outStream(j2), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
||||
|
||||
msg = TestingUtilities.checkJsonIsSame(j1, j2);
|
||||
Assertions.assertTrue(msg == null, file.getName() + ": " + msg);
|
||||
|
||||
// ok, we've produced equivalent JSON by both methods.
|
||||
// now, we're going to reverse the process
|
||||
r = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new FileInputStream(j2)); // crossover too
|
||||
r = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(ManagedFileAccess.inStream(j2)); // crossover too
|
||||
fn = makeTempFilename();
|
||||
new org.hl7.fhir.dstu2016may.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY)
|
||||
.compose(new FileOutputStream(fn), r);
|
||||
.compose(ManagedFileAccess.outStream(fn), r);
|
||||
msg = TestingUtilities.checkJsonIsSame(j2, fn);
|
||||
Assertions.assertTrue(msg == null, file.getName() + ": " + msg);
|
||||
String x1 = makeTempFilename();
|
||||
new org.hl7.fhir.dstu2016may.formats.XmlParser().setOutputStyle(OutputStyle.PRETTY)
|
||||
.compose(new FileOutputStream(x1), r);
|
||||
.compose(ManagedFileAccess.outStream(x1), r);
|
||||
|
||||
re = Manager.parse(TestingUtilities.context, new FileInputStream(j1), FhirFormat.JSON);
|
||||
re = Manager.parse(TestingUtilities.context, ManagedFileAccess.inStream(j1), FhirFormat.JSON);
|
||||
fn = makeTempFilename();
|
||||
Manager.compose(TestingUtilities.context, re, new FileOutputStream(fn), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
||||
Manager.compose(TestingUtilities.context, re, ManagedFileAccess.outStream(fn), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
||||
msg = TestingUtilities.checkJsonIsSame(j1, fn);
|
||||
Assertions.assertTrue(msg == null, file.getName() + ": " + msg);
|
||||
String x2 = makeTempFilename();
|
||||
Manager.compose(TestingUtilities.context, re, new FileOutputStream(x2), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
Manager.compose(TestingUtilities.context, re, ManagedFileAccess.outStream(x2), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
|
||||
msg = TestingUtilities.checkXMLIsSame(x1, x2);
|
||||
Assertions.assertTrue(msg == null, file.getName() + ": " + msg);
|
||||
|
|
|
@ -30,6 +30,8 @@ package org.hl7.fhir.dstu2016may.test;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class SingleTest {
|
||||
|
||||
/**
|
||||
|
@ -38,7 +40,7 @@ public class SingleTest {
|
|||
public static void main(String[] args) {
|
||||
try {
|
||||
ResourceTest r = new ResourceTest();
|
||||
r.setSource(new File("C:\\work\\org.hl7.fhir\\build\\publish\\patient-example.xml"));
|
||||
r.setSource(ManagedFileAccess.file("C:\\work\\org.hl7.fhir\\build\\publish\\patient-example.xml"));
|
||||
r.test();
|
||||
System.out.println("Completed OK");
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.hl7.fhir.dstu2016may.utils.StructureMapUtilities;
|
|||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -86,16 +87,16 @@ public class StructureMapTests {
|
|||
|
||||
StructureMapUtilities scu = new StructureMapUtilities(TestingUtilities.context, maps, null);
|
||||
|
||||
for (String f : new File("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\CDA").list()) {
|
||||
for (String f : ManagedFileAccess.file("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\CDA").list()) {
|
||||
try {
|
||||
StructureDefinition sd = (StructureDefinition) new XmlParser()
|
||||
.parse(new FileInputStream("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\CDA\\" + f));
|
||||
.parse(ManagedFileAccess.inStream("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\CDA\\" + f));
|
||||
((SimpleWorkerContext) TestingUtilities.context).seeResource(sd.getUrl(), sd);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
for (String f : new File("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\maps").list()) {
|
||||
for (String f : ManagedFileAccess.file("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\maps").list()) {
|
||||
try {
|
||||
StructureMap map = scu.parse(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\maps\\" + f));
|
||||
maps.put(map.getUrl(), map);
|
||||
|
@ -104,17 +105,17 @@ public class StructureMapTests {
|
|||
}
|
||||
|
||||
Element cda = Manager.parse(TestingUtilities.context,
|
||||
new FileInputStream("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\Example\\ccd.xml"), FhirFormat.XML);
|
||||
ManagedFileAccess.inStream("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\Example\\ccd.xml"), FhirFormat.XML);
|
||||
Manager.compose(TestingUtilities.context, cda,
|
||||
new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\Example\\ccd.out.json"), FhirFormat.JSON,
|
||||
ManagedFileAccess.outStream("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\Example\\ccd.out.json"), FhirFormat.JSON,
|
||||
OutputStyle.PRETTY, null);
|
||||
Manager.compose(TestingUtilities.context, cda,
|
||||
new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\Example\\ccd.out.xml"), FhirFormat.XML,
|
||||
ManagedFileAccess.outStream("C:\\work\\org.hl7.fhir\\build\\guides\\ccda\\Example\\ccd.out.xml"), FhirFormat.XML,
|
||||
OutputStyle.PRETTY, null);
|
||||
Bundle bundle = new Bundle();
|
||||
scu.transform(null, cda, maps.get("http://hl7.org/fhir/StructureMap/cda"), bundle);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY)
|
||||
.compose(new FileOutputStream(Utilities.path("[tmp]", "bundle.xml")), bundle);
|
||||
.compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "bundle.xml")), bundle);
|
||||
}
|
||||
|
||||
}
|
|
@ -13,9 +13,10 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
|||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.hl7.fhir.dstu2016may.utils.SimpleWorkerContext;
|
||||
import org.hl7.fhir.utilities.CSFile;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFile;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
|
@ -41,7 +42,7 @@ public class TestingUtilities {
|
|||
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
builder.directory(new CSFile(Utilities.path("[tmp]")));
|
||||
builder.directory(ManagedFileAccess.csfile(Utilities.path("[tmp]")));
|
||||
builder.start();
|
||||
|
||||
}
|
||||
|
@ -154,7 +155,7 @@ public class TestingUtilities {
|
|||
|
||||
factory.setNamespaceAware(true);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
return builder.parse(new FileInputStream(fn));
|
||||
return builder.parse(ManagedFileAccess.inStream(fn));
|
||||
}
|
||||
|
||||
public static String checkJsonIsSame(String f1, String f2)
|
||||
|
@ -166,7 +167,7 @@ public class TestingUtilities {
|
|||
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
builder.directory(new CSFile(Utilities.path("[tmp]")));
|
||||
builder.directory(ManagedFileAccess.csfile(Utilities.path("[tmp]")));
|
||||
builder.start();
|
||||
|
||||
}
|
||||
|
|
|
@ -57,10 +57,11 @@ import org.hl7.fhir.dstu2016may.model.Resource;
|
|||
import org.hl7.fhir.dstu2016may.utils.SimpleWorkerContext;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.CSFile;
|
||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFile;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
@ -105,7 +106,7 @@ public class ToolsHelper {
|
|||
private void executeExamples(String[] args) throws IOException {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> lines = FileUtils.readLines(new File(args[1]), "UTF-8");
|
||||
List<String> lines = FileUtils.readLines(ManagedFileAccess.file(args[1]), "UTF-8");
|
||||
String srcDir = lines.get(0);
|
||||
lines.remove(0);
|
||||
processExamples(srcDir, lines);
|
||||
|
@ -183,7 +184,7 @@ public class ToolsHelper {
|
|||
// } else
|
||||
if (definitions.startsWith("https:") || definitions.startsWith("http:")) {
|
||||
defn = loadFromUrl(definitions);
|
||||
} else if (new File(definitions).exists()) {
|
||||
} else if (ManagedFileAccess.file(definitions).exists()) {
|
||||
defn = loadFromFile(definitions);
|
||||
} else
|
||||
throw new FHIRException("Unable to find FHIR validation Pack (source = " + definitions + ")");
|
||||
|
@ -197,7 +198,7 @@ public class ToolsHelper {
|
|||
}
|
||||
|
||||
private byte[] loadFromFile(String src) throws IOException {
|
||||
FileInputStream in = new FileInputStream(src);
|
||||
FileInputStream in = ManagedFileAccess.inStream(src);
|
||||
byte[] b = new byte[in.available()];
|
||||
in.read(b);
|
||||
in.close();
|
||||
|
@ -224,10 +225,10 @@ public class ToolsHelper {
|
|||
|
||||
public void executeFragments(String[] args) throws IOException {
|
||||
try {
|
||||
File source = new CSFile(args[1]);
|
||||
File source = ManagedFileAccess.csfile(args[1]);
|
||||
if (!source.exists())
|
||||
throw new FHIRException("Source File \"" + source.getAbsolutePath() + "\" not found");
|
||||
XmlPullParser xpp = loadXml(new FileInputStream(source));
|
||||
XmlPullParser xpp = loadXml(ManagedFileAccess.inStream(source));
|
||||
nextNoWhitespace(xpp);
|
||||
if (!xpp.getName().equals("tests"))
|
||||
throw new FHIRFormatError("Unable to parse file - starts with " + xpp.getName());
|
||||
|
@ -273,8 +274,8 @@ public class ToolsHelper {
|
|||
|
||||
public void executeRoundTrip(String[] args) throws IOException, FHIRException {
|
||||
FileInputStream in;
|
||||
File source = new CSFile(args[1]);
|
||||
File dest = new CSFile(args[2]);
|
||||
File source = ManagedFileAccess.csfile(args[1]);
|
||||
File dest = ManagedFileAccess.csfile(args[2]);
|
||||
if (args.length >= 4) {
|
||||
Utilities.copyFile(args[1], args[3]);
|
||||
}
|
||||
|
@ -292,18 +293,18 @@ public class ToolsHelper {
|
|||
json.close();
|
||||
TextFile.stringToFile(new String(json.toByteArray()), Utilities.changeFileExt(dest.getAbsolutePath(), ".json"));
|
||||
rf = pj.parse(new ByteArrayInputStream(json.toByteArray()));
|
||||
FileOutputStream s = new FileOutputStream(dest);
|
||||
FileOutputStream s = ManagedFileAccess.outStream(dest);
|
||||
new XmlParser().compose(s, rf, true);
|
||||
s.close();
|
||||
}
|
||||
|
||||
public String executeJson(String[] args) throws IOException, FHIRException {
|
||||
FileInputStream in;
|
||||
File source = new CSFile(args[1]);
|
||||
File dest = new CSFile(args[2]);
|
||||
File destc = new CSFile(Utilities.changeFileExt(args[2], ".canonical.json"));
|
||||
File destt = new CSFile(args[2] + ".tmp");
|
||||
File destr = new CSFile(Utilities.changeFileExt(args[2], ".ttl"));
|
||||
File source = ManagedFileAccess.csfile(args[1]);
|
||||
File dest = ManagedFileAccess.csfile(args[2]);
|
||||
File destc = ManagedFileAccess.csfile(Utilities.changeFileExt(args[2], ".canonical.json"));
|
||||
File destt = ManagedFileAccess.csfile(args[2] + ".tmp");
|
||||
File destr = ManagedFileAccess.csfile(Utilities.changeFileExt(args[2], ".ttl"));
|
||||
|
||||
if (!source.exists())
|
||||
throw new FHIRException("Source File \"" + source.getAbsolutePath() + "\" not found");
|
||||
|
@ -312,21 +313,21 @@ public class ToolsHelper {
|
|||
Resource rf = p.parse(in);
|
||||
JsonParser json = new JsonParser();
|
||||
json.setOutputStyle(OutputStyle.PRETTY);
|
||||
FileOutputStream s = new FileOutputStream(dest);
|
||||
FileOutputStream s = ManagedFileAccess.outStream(dest);
|
||||
json.compose(s, rf);
|
||||
s.close();
|
||||
json.setOutputStyle(OutputStyle.CANONICAL);
|
||||
s = new FileOutputStream(destc);
|
||||
s = ManagedFileAccess.outStream(destc);
|
||||
json.compose(s, rf);
|
||||
s.close();
|
||||
json.setSuppressXhtml("Snipped for Brevity");
|
||||
json.setOutputStyle(OutputStyle.PRETTY);
|
||||
s = new FileOutputStream(destt);
|
||||
s = ManagedFileAccess.outStream(destt);
|
||||
json.compose(s, rf);
|
||||
s.close();
|
||||
|
||||
RdfParserBase rdf = new RdfParser();
|
||||
s = new FileOutputStream(destr);
|
||||
s = ManagedFileAccess.outStream(destr);
|
||||
rdf.compose(s, rf);
|
||||
s.close();
|
||||
|
||||
|
@ -335,8 +336,8 @@ public class ToolsHelper {
|
|||
|
||||
public void executeCanonicalXml(String[] args) throws FHIRException, IOException {
|
||||
FileInputStream in;
|
||||
File source = new CSFile(args[1]);
|
||||
File dest = new CSFile(args[2]);
|
||||
File source = ManagedFileAccess.csfile(args[1]);
|
||||
File dest = ManagedFileAccess.csfile(args[2]);
|
||||
|
||||
if (!source.exists())
|
||||
throw new FHIRException("Source File \"" + source.getAbsolutePath() + "\" not found");
|
||||
|
@ -345,7 +346,7 @@ public class ToolsHelper {
|
|||
Resource rf = p.parse(in);
|
||||
XmlParser cxml = new XmlParser();
|
||||
cxml.setOutputStyle(OutputStyle.NORMAL);
|
||||
cxml.compose(new FileOutputStream(dest), rf);
|
||||
cxml.compose(ManagedFileAccess.outStream(dest), rf);
|
||||
}
|
||||
|
||||
private void executeVersion(String[] args) throws IOException {
|
||||
|
@ -358,7 +359,7 @@ public class ToolsHelper {
|
|||
String filename = rootDir + n + ".xml";
|
||||
// 1. produce canonical XML
|
||||
CSFileInputStream source = new CSFileInputStream(filename);
|
||||
FileOutputStream dest = new FileOutputStream(Utilities.changeFileExt(filename, ".canonical.xml"));
|
||||
FileOutputStream dest = ManagedFileAccess.outStream(Utilities.changeFileExt(filename, ".canonical.xml"));
|
||||
XmlParser p = new XmlParser();
|
||||
Resource r = p.parse(source);
|
||||
XmlParser cxml = new XmlParser();
|
||||
|
@ -367,18 +368,18 @@ public class ToolsHelper {
|
|||
|
||||
// 2. produce JSON
|
||||
source = new CSFileInputStream(filename);
|
||||
dest = new FileOutputStream(Utilities.changeFileExt(filename, ".json"));
|
||||
dest = ManagedFileAccess.outStream(Utilities.changeFileExt(filename, ".json"));
|
||||
r = p.parse(source);
|
||||
JsonParser json = new JsonParser();
|
||||
json.setOutputStyle(OutputStyle.PRETTY);
|
||||
json.compose(dest, r);
|
||||
json = new JsonParser();
|
||||
json.setOutputStyle(OutputStyle.CANONICAL);
|
||||
dest = new FileOutputStream(Utilities.changeFileExt(filename, ".canonical.json"));
|
||||
dest = ManagedFileAccess.outStream(Utilities.changeFileExt(filename, ".canonical.json"));
|
||||
json.compose(dest, r);
|
||||
|
||||
// 2. produce JSON
|
||||
dest = new FileOutputStream(Utilities.changeFileExt(filename, ".ttl"));
|
||||
dest = ManagedFileAccess.outStream(Utilities.changeFileExt(filename, ".ttl"));
|
||||
RdfParserBase rdf = new RdfParser();
|
||||
rdf.compose(dest, r);
|
||||
} catch (Exception e) {
|
||||
|
@ -399,23 +400,23 @@ public class ToolsHelper {
|
|||
String tmp = tmpDir + n.replace(File.separator, "-") + ".tmp";
|
||||
String dest = tmpDir + n.replace(File.separator, "-") + ".java.xml";
|
||||
|
||||
FileInputStream in = new FileInputStream(source);
|
||||
FileInputStream in = ManagedFileAccess.inStream(source);
|
||||
XmlParser xp = new XmlParser();
|
||||
Resource r = xp.parse(in);
|
||||
System.err.print(".");
|
||||
JsonParser jp = new JsonParser();
|
||||
FileOutputStream out = new FileOutputStream(tmp);
|
||||
FileOutputStream out = ManagedFileAccess.outStream(tmp);
|
||||
jp.setOutputStyle(OutputStyle.PRETTY);
|
||||
jp.compose(out, r);
|
||||
out.close();
|
||||
r = null;
|
||||
System.err.print(".");
|
||||
|
||||
in = new FileInputStream(tmp);
|
||||
in = ManagedFileAccess.inStream(tmp);
|
||||
System.err.print(",");
|
||||
r = jp.parse(in);
|
||||
System.err.print(".");
|
||||
out = new FileOutputStream(dest);
|
||||
out = ManagedFileAccess.outStream(dest);
|
||||
new XmlParser().compose(out, r, true);
|
||||
System.err.println("!");
|
||||
out.close();
|
||||
|
@ -431,7 +432,7 @@ public class ToolsHelper {
|
|||
private void executeTest(String[] args) throws Throwable {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> lines = FileUtils.readLines(new File(args[1]), "UTF-8");
|
||||
List<String> lines = FileUtils.readLines(ManagedFileAccess.file(args[1]), "UTF-8");
|
||||
String srcDir = lines.get(0);
|
||||
lines.remove(0);
|
||||
String dstDir = lines.get(0).trim();
|
||||
|
|
|
@ -94,6 +94,7 @@ import org.hl7.fhir.exceptions.TerminologyServiceException;
|
|||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.i18n.I18nBase;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
|
@ -323,7 +324,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
String cacheFn = null;
|
||||
if (cache != null) {
|
||||
cacheFn = Utilities.path(cache, determineCacheId(vs, heirarchical) + ".json");
|
||||
if (new File(cacheFn).exists()) {
|
||||
if (ManagedFileAccess.file(cacheFn).exists()) {
|
||||
return loadFromCache(vs.copy(), cacheFn);
|
||||
}
|
||||
}
|
||||
|
@ -335,8 +336,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
.expand(vs, expProfile.setExcludeNested(!heirarchical));
|
||||
if (vse.getValueset() != null) {
|
||||
if (cache != null) {
|
||||
FileOutputStream s = new FileOutputStream(cacheFn);
|
||||
newJsonParser().compose(new FileOutputStream(cacheFn), vse.getValueset());
|
||||
FileOutputStream s = ManagedFileAccess.outStream(cacheFn);
|
||||
newJsonParser().compose(ManagedFileAccess.outStream(cacheFn), vse.getValueset());
|
||||
s.close();
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +369,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
private ValueSetExpansionOutcome loadFromCache(ValueSet vs, String cacheFn)
|
||||
throws FileNotFoundException, Exception {
|
||||
JsonParser parser = new JsonParser();
|
||||
Resource r = parser.parse(new FileInputStream(cacheFn));
|
||||
Resource r = parser.parse(ManagedFileAccess.inStream(cacheFn));
|
||||
if (r instanceof OperationOutcome) {
|
||||
return new ValueSetExpansionOutcome(
|
||||
((OperationOutcome) r).getIssue().get(0).getDetails().getText(),
|
||||
|
@ -382,7 +383,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
|
||||
private void saveToCache(Resource res, String cacheFn) throws FileNotFoundException, Exception {
|
||||
JsonParser parser = new JsonParser();
|
||||
parser.compose(new FileOutputStream(cacheFn), res);
|
||||
parser.compose(ManagedFileAccess.outStream(cacheFn), res);
|
||||
}
|
||||
|
||||
private String determineCacheId(ValueSet vs, boolean heirarchical) throws Exception {
|
||||
|
@ -715,7 +716,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
if (fn == null) {
|
||||
return null;
|
||||
}
|
||||
if (!(new File(fn).exists())) {
|
||||
if (!(ManagedFileAccess.file(fn).exists())) {
|
||||
return null;
|
||||
}
|
||||
String cnt = TextFile.fileToString(fn);
|
||||
|
|
|
@ -86,9 +86,10 @@ import org.hl7.fhir.dstu3.utils.validation.IResourceValidator;
|
|||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.OIDUtils;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
|
@ -676,7 +677,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
|
||||
|
||||
public void loadFromFolder(String folder) throws FileNotFoundException, Exception {
|
||||
for (String n : new File(folder).list()) {
|
||||
for (String n : ManagedFileAccess.file(folder).list()) {
|
||||
if (n.endsWith(".json"))
|
||||
loadFromFile(Utilities.path(folder, n), new JsonParser());
|
||||
else if (n.endsWith(".xml"))
|
||||
|
@ -687,7 +688,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
private void loadFromFile(String filename, IParser p) throws FileNotFoundException, Exception {
|
||||
Resource r;
|
||||
try {
|
||||
r = p.parse(new FileInputStream(filename));
|
||||
r = p.parse(ManagedFileAccess.inStream(filename));
|
||||
if (r.getResourceType() == ResourceType.Bundle) {
|
||||
for (BundleEntryComponent e : ((Bundle) r).getEntry()) {
|
||||
seeResource(null, e.getResource());
|
||||
|
|
|
@ -32,6 +32,7 @@ package org.hl7.fhir.dstu3.elementmodel;
|
|||
|
||||
|
||||
import java.io.File;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -53,17 +54,17 @@ public class Tester {
|
|||
IWorkerContext context = SimpleWorkerContext.fromPack(Utilities.path("C:\\work\\org.hl7.fhir\\build\\publish", "validation-min.xml.zip"));
|
||||
int t = 0;
|
||||
int ok = 0;
|
||||
for (String f : new File("C:\\work\\org.hl7.fhir\\build\\publish").list()) {
|
||||
if (f.endsWith(".xml") && !f.endsWith(".canonical.xml") && !f.contains("profile") && !f.contains("questionnaire") && new File("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".ttl")).exists()) {
|
||||
for (String f : ManagedFileAccess.file("C:\\work\\org.hl7.fhir\\build\\publish").list()) {
|
||||
if (f.endsWith(".xml") && !f.endsWith(".canonical.xml") && !f.contains("profile") && !f.contains("questionnaire") && ManagedFileAccess.file("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".ttl")).exists()) {
|
||||
// if (f.equals("account-questionnaire.xml")) {
|
||||
System.out.print("convert "+f);
|
||||
// Manager.convert(context, new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+f), FhirFormat.XML,
|
||||
// new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")), FhirFormat.JSON, OutputStyle.PRETTY);
|
||||
// Manager.convert(context, ManagedFileAccess.inStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+f), FhirFormat.XML,
|
||||
// ManagedFileAccess.outStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")), FhirFormat.JSON, OutputStyle.PRETTY);
|
||||
// String src = normalise(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")));
|
||||
// String tgt = normalise(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".json")));
|
||||
Element e = Manager.parse(context, new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+f), FhirFormat.XML);
|
||||
Manager.compose(context, e, new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.ttl")), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
|
||||
Manager.compose(context, e, new FileOutputStream(Utilities.path("[tmp]", "resource.xml")), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
Element e = Manager.parse(context, ManagedFileAccess.inStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+f), FhirFormat.XML);
|
||||
Manager.compose(context, e, ManagedFileAccess.outStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.ttl")), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
|
||||
Manager.compose(context, e, ManagedFileAccess.outStream(Utilities.path("[tmp]", "resource.xml")), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
String src = TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.ttl"));
|
||||
String tgt = TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".ttl"));
|
||||
t++;
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.hl7.fhir.dstu3.model.Meta;
|
|||
import org.hl7.fhir.dstu3.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -157,12 +158,12 @@ public class LoincToDEConvertor {
|
|||
factory.setNamespaceAware(true);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
xml = builder.parse(new FileInputStream(definitions));
|
||||
xml = builder.parse(ManagedFileAccess.inStream(definitions));
|
||||
}
|
||||
|
||||
private void saveBundle() throws FHIRFormatError, IOException, XmlPullParserException {
|
||||
XmlParser xml = new XmlParser();
|
||||
FileOutputStream s = new FileOutputStream(dest);
|
||||
FileOutputStream s = ManagedFileAccess.outStream(dest);
|
||||
xml.compose(s, bundle, true);
|
||||
s.close();
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ import org.hl7.fhir.dstu3.terminologies.ValueSetExpander.ValueSetExpansionOutcom
|
|||
import org.hl7.fhir.dstu3.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
|
||||
|
||||
public class ValueSetExpansionCache implements ValueSetExpanderFactory {
|
||||
|
@ -96,7 +97,7 @@ public class ValueSetExpansionCache implements ValueSetExpanderFactory {
|
|||
// well, we'll see if the designated server can expand it, and if it can, we'll cache it locally
|
||||
vso = context.expandVS(source, false, profile == null || !profile.getExcludeNested());
|
||||
if (cacheFolder != null) {
|
||||
FileOutputStream s = new FileOutputStream(Utilities.path(cacheFolder, makeFile(source.getUrl())));
|
||||
FileOutputStream s = ManagedFileAccess.outStream(Utilities.path(cacheFolder, makeFile(source.getUrl())));
|
||||
context.newXmlParser().setOutputStyle(OutputStyle.PRETTY).compose(s, vso.getValueset());
|
||||
s.close();
|
||||
}
|
||||
|
@ -136,10 +137,10 @@ public class ValueSetExpansionCache implements ValueSetExpanderFactory {
|
|||
}
|
||||
|
||||
private void loadCache() throws FHIRFormatError, IOException {
|
||||
File[] files = new File(cacheFolder).listFiles();
|
||||
File[] files = ManagedFileAccess.file(cacheFolder).listFiles();
|
||||
for (File f : files) {
|
||||
if (f.getName().endsWith(".xml")) {
|
||||
final FileInputStream is = new FileInputStream(f);
|
||||
final FileInputStream is = ManagedFileAccess.inStream(f);
|
||||
try {
|
||||
Resource r = context.newXmlParser().setOutputStyle(OutputStyle.PRETTY).parse(is);
|
||||
if (r instanceof OperationOutcome) {
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.IniFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class BatchLoader {
|
||||
|
||||
|
@ -68,7 +69,7 @@ public class BatchLoader {
|
|||
throw new FHIRException("Unimplemented file type "+file);
|
||||
// } else if (file.endsWith(".zip")) {
|
||||
// LoadZipFile(server, file, p, size, 0, -1);
|
||||
} else if (new File(file).isDirectory()) {
|
||||
} else if (ManagedFileAccess.file(file).isDirectory()) {
|
||||
LoadDirectory(server, file, size);
|
||||
} else
|
||||
throw new FHIRException("Unknown file type "+file);
|
||||
|
@ -81,7 +82,7 @@ public class BatchLoader {
|
|||
System.out.println("Done");
|
||||
|
||||
IniFile ini = new IniFile(Utilities.path(folder, "batch-load-progress.ini"));
|
||||
for (File f : new File(folder).listFiles()) {
|
||||
for (File f : ManagedFileAccess.file(folder).listFiles()) {
|
||||
if (f.getName().endsWith(".json") || f.getName().endsWith(".xml")) {
|
||||
if (!ini.getBooleanProperty("finished", f.getName())) {
|
||||
sendFile(client, f, size, ini);
|
||||
|
@ -145,7 +146,7 @@ public class BatchLoader {
|
|||
// Bundle b = new Bundle();
|
||||
// b.setType(BundleType.COLLECTION);
|
||||
// b.setId(UUID.randomUUID().toString().toLowerCase());
|
||||
// ZipInputStream zip = new ZipInputStream(new FileInputStream(file));
|
||||
// ZipInputStream zip = new ZipInputStream(ManagedFileAccess.inStream(file));
|
||||
// ZipEntry entry;
|
||||
// while((entry = zip.getNextEntry())!=null)
|
||||
// {
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.hl7.fhir.dstu3.model.DomainResource;
|
|||
import org.hl7.fhir.dstu3.model.Resource;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class R3TEchnicalCorrectionProcessor {
|
||||
|
||||
|
@ -31,10 +32,10 @@ public class R3TEchnicalCorrectionProcessor {
|
|||
System.out.println("Loading resources from "+src);
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
Map<String, Resource> definitions = new HashMap<>();
|
||||
for (File f : new File(src).listFiles()) {
|
||||
for (File f : ManagedFileAccess.file(src).listFiles()) {
|
||||
if (f.getName().endsWith(".xml") && !(f.getName().endsWith("warnings.xml") || f.getName().endsWith(".diff.xml"))) {
|
||||
try {
|
||||
Resource r = new XmlParser().parse(new FileInputStream(f));
|
||||
Resource r = new XmlParser().parse(ManagedFileAccess.inStream(f));
|
||||
if (f.getName().contains("canonical")) {
|
||||
resources.add(r);
|
||||
}
|
||||
|
@ -43,17 +44,17 @@ public class R3TEchnicalCorrectionProcessor {
|
|||
definitions.put(f.getName(), r);
|
||||
}
|
||||
r.setUserData("path", f.getName().substring(0, f.getName().indexOf(".")));
|
||||
// FileUtils.copyFile(f, new File(f.getAbsolutePath()+"1"));
|
||||
// FileUtils.copyFile(f, new File(f.getAbsolutePath()+"2"));
|
||||
// FileUtils.copyFile(f, ManagedFileAccess.file(f.getAbsolutePath()+"1"));
|
||||
// FileUtils.copyFile(f, ManagedFileAccess.file(f.getAbsolutePath()+"2"));
|
||||
} catch (Exception e) {
|
||||
System.out.println("Unable to load "+f.getName()+": "+e.getMessage());
|
||||
}
|
||||
}
|
||||
if (f.getName().endsWith(".json") && !(f.getName().endsWith("schema.json") || f.getName().endsWith(".diff.json"))) {
|
||||
try {
|
||||
// new JsonParser().parse(new FileInputStream(f));
|
||||
// FileUtils.copyFile(f, new File(f.getAbsolutePath()+"1"));
|
||||
// FileUtils.copyFile(f, new File(f.getAbsolutePath()+"2"));
|
||||
// new JsonParser().parse(ManagedFileAccess.inStream(f));
|
||||
// FileUtils.copyFile(f, ManagedFileAccess.file(f.getAbsolutePath()+"1"));
|
||||
// FileUtils.copyFile(f, ManagedFileAccess.file(f.getAbsolutePath()+"2"));
|
||||
} catch (Exception e) {
|
||||
System.out.println("Unable to load "+f.getName()+": "+e.getMessage());
|
||||
}
|
||||
|
@ -79,15 +80,15 @@ public class R3TEchnicalCorrectionProcessor {
|
|||
|
||||
private void produceDefinitionsXml(Map<String, Resource> definitions, String dest) throws IOException {
|
||||
for (String n : definitions.keySet()) {
|
||||
File f = new File(Utilities.path(dest, "definitions.xml", n));
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(f), definitions.get(n));
|
||||
File f = ManagedFileAccess.file(Utilities.path(dest, "definitions.xml", n));
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f), definitions.get(n));
|
||||
}
|
||||
}
|
||||
|
||||
private void produceDefinitionsJson(Map<String, Resource> definitions, String dest) throws IOException {
|
||||
for (String n : definitions.keySet()) {
|
||||
File f = new File(Utilities.path(dest, "definitions.json", Utilities.changeFileExt(n, ".json")));
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(f), definitions.get(n));
|
||||
File f = ManagedFileAccess.file(Utilities.path(dest, "definitions.json", Utilities.changeFileExt(n, ".json")));
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f), definitions.get(n));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,8 +98,8 @@ public class R3TEchnicalCorrectionProcessor {
|
|||
if (!r.getId().equals(r.getUserString("path"))) {
|
||||
n = n+"("+r.getId()+")";
|
||||
}
|
||||
File f = new File(Utilities.path(dest, "examples-json", n+".json"));
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(f), r);
|
||||
File f = ManagedFileAccess.file(Utilities.path(dest, "examples-json", n+".json"));
|
||||
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f), r);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -109,8 +110,8 @@ public class R3TEchnicalCorrectionProcessor {
|
|||
if (!r.getId().equals(r.getUserString("path"))) {
|
||||
n = n+"("+r.getId()+")";
|
||||
}
|
||||
File f = new File(Utilities.path(dest, "examples", n+".xml"));
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(f), r);
|
||||
File f = ManagedFileAccess.file(Utilities.path(dest, "examples", n+".xml"));
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f), r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,9 +120,9 @@ public class R3TEchnicalCorrectionProcessor {
|
|||
String corePath = Utilities.path(root, "hl7.fhir.r3.core", "package");
|
||||
String examplesPath = Utilities.path(root, "hl7.fhir.r3.examples", "package");
|
||||
String elementsPath = Utilities.path(root, "hl7.fhir.r3.elements", "package");
|
||||
int coreTotal = new File(corePath).list().length-1;
|
||||
int examplesTotal = new File(examplesPath).list().length-1;
|
||||
int elementsTotal = new File(elementsPath).list().length-1;
|
||||
int coreTotal = ManagedFileAccess.file(corePath).list().length-1;
|
||||
int examplesTotal = ManagedFileAccess.file(examplesPath).list().length-1;
|
||||
int elementsTotal = ManagedFileAccess.file(elementsPath).list().length-1;
|
||||
|
||||
int coreCount = 0;
|
||||
int examplesCount = 0;
|
||||
|
@ -131,17 +132,17 @@ public class R3TEchnicalCorrectionProcessor {
|
|||
FileOutputStream dst = null;
|
||||
if (n.startsWith("DataElement-")) {
|
||||
elementsCount++;
|
||||
dst = new FileOutputStream(Utilities.path(elementsPath, n));
|
||||
dst = ManagedFileAccess.outStream(Utilities.path(elementsPath, n));
|
||||
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(dst, r);
|
||||
} else {
|
||||
dst = new FileOutputStream(Utilities.path(examplesPath, n));
|
||||
dst = ManagedFileAccess.outStream(Utilities.path(examplesPath, n));
|
||||
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(dst, r);
|
||||
examplesCount++;
|
||||
if (isCoreResource(r.fhirType())) {
|
||||
coreCount++;
|
||||
DomainResource dr = (DomainResource) r;
|
||||
dr.setText(null);
|
||||
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(new FileOutputStream(Utilities.path(corePath, n)), r);
|
||||
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(ManagedFileAccess.outStream(Utilities.path(corePath, n)), r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import javax.xml.parsers.DocumentBuilder;
|
|||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
|
|||
import org.hl7.fhir.dstu3.model.Resource;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class Unbundler {
|
||||
|
||||
|
@ -51,12 +52,12 @@ public class Unbundler {
|
|||
|
||||
private static void unbundle(String src) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
String folder = Utilities.getDirectoryForFile(src);
|
||||
Bundle bnd = (Bundle) new JsonParser().parse(new FileInputStream(src));
|
||||
Bundle bnd = (Bundle) new JsonParser().parse(ManagedFileAccess.inStream(src));
|
||||
for (BundleEntryComponent be : bnd.getEntry()) {
|
||||
Resource r = be.getResource();
|
||||
if (r != null) {
|
||||
String tgt = Utilities.path(folder, r.fhirType()+"-"+r.getId()+".json");
|
||||
new JsonParser().compose(new FileOutputStream(tgt), r);
|
||||
new JsonParser().compose(ManagedFileAccess.outStream(tgt), r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.hl7.fhir.dstu3.model.Resource;
|
|||
import org.hl7.fhir.dstu3.test.support.TestingUtilities;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
@ -59,7 +60,7 @@ public class FluentPathTests {
|
|||
if (Utilities.noString(input))
|
||||
fp.check(null, null, node);
|
||||
else {
|
||||
res = new XmlParser().parse(new FileInputStream(Utilities.path("C:\\work\\org.hl7.fhir\\build\\publish", input)));
|
||||
res = new XmlParser().parse(ManagedFileAccess.inStream(Utilities.path("C:\\work\\org.hl7.fhir\\build\\publish", input)));
|
||||
fp.check(res, res.getResourceType().toString(), res.getResourceType().toString(), node);
|
||||
}
|
||||
outcome = fp.evaluate(res, node);
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.hl7.fhir.dstu3.utils.EOperationOutcome;
|
|||
import org.hl7.fhir.dstu3.utils.NarrativeGenerator;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
@ -41,9 +42,9 @@ public class NarrativeGeneratorTests {
|
|||
|
||||
private void process(String path) throws FileNotFoundException, IOException, XmlPullParserException, EOperationOutcome, FHIRException {
|
||||
XmlParser p = new XmlParser();
|
||||
DomainResource r = (DomainResource) p.parse(new FileInputStream(path));
|
||||
DomainResource r = (DomainResource) p.parse(ManagedFileAccess.inStream(path));
|
||||
gen.generate(r);
|
||||
FileOutputStream s = new FileOutputStream(Utilities.path("[tmp]", "gen.xml"));
|
||||
FileOutputStream s = ManagedFileAccess.outStream(Utilities.path("[tmp]", "gen.xml"));
|
||||
new XmlParser().compose(s, r, true);
|
||||
s.close();
|
||||
|
||||
|
|
|
@ -26,8 +26,9 @@ import org.hl7.fhir.dstu3.utils.EOperationOutcome;
|
|||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.CSFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.CSFile;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
|
||||
|
@ -45,8 +46,8 @@ public class ProfileUtilitiesTests {
|
|||
public static void main(String[] args) throws EOperationOutcome, Exception {
|
||||
// new ProfileUtilitiesTests().execute(args);
|
||||
new ProfileUtilitiesTests("C:\\work\\org.hl7.fhir\\build\\publish").testSnapshotGeneration();
|
||||
// StructureDefinition p = (StructureDefinition) new XmlParser().parse(new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\lipid-report-cholesterol.profile.xml"));
|
||||
// new ProfileUtilities(context, messages, null).generateSchematrons(new FileOutputStream(Utilities.path("[tmp]", "test.sch"), p);
|
||||
// StructureDefinition p = (StructureDefinition) new XmlParser().parse(ManagedFileAccess.inStream("C:\\work\\org.hl7.fhir\\build\\publish\\lipid-report-cholesterol.profile.xml"));
|
||||
// new ProfileUtilities(context, messages, null).generateSchematrons(ManagedFileAccess.outStream(Utilities.path("[tmp]", "test.sch"), p);
|
||||
}
|
||||
|
||||
public void execute(String[] args) throws FileNotFoundException, IOException, FHIRException {
|
||||
|
@ -76,9 +77,9 @@ public class ProfileUtilitiesTests {
|
|||
System.out.println("processing output");
|
||||
for (ProfileComparison outcome : comp.getComparisons()) {
|
||||
if (outcome.getSubset() != null)
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "intersection-"+outcome.getId()+".xml")), outcome.getSubset());
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "intersection-"+outcome.getId()+".xml")), outcome.getSubset());
|
||||
if (outcome.getSuperset() != null)
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "union-"+outcome.getId()+".xml")), outcome.getSuperset());
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path("[tmp]", "union-"+outcome.getId()+".xml")), outcome.getSuperset());
|
||||
|
||||
System.out.println("\r\n"+outcome.getId()+": Comparison of "+outcome.getLeft().getUrl()+" and "+outcome.getRight().getUrl());
|
||||
for (ValidationMessage vm : outcome.getMessages())
|
||||
|
@ -101,8 +102,8 @@ public class ProfileUtilitiesTests {
|
|||
private void compare(String fn1, String fn2) throws FHIRFormatError, FileNotFoundException, IOException, DefinitionException {
|
||||
System.out.println("Compare "+fn1+" to "+fn2);
|
||||
System.out.println(" .. load");
|
||||
StructureDefinition left = (StructureDefinition) new XmlParser().parse(new FileInputStream(Utilities.path(root, fn1)));
|
||||
StructureDefinition right = (StructureDefinition) new XmlParser().parse(new FileInputStream(Utilities.path(root, fn2)));
|
||||
StructureDefinition left = (StructureDefinition) new XmlParser().parse(ManagedFileAccess.inStream(Utilities.path(root, fn1)));
|
||||
StructureDefinition right = (StructureDefinition) new XmlParser().parse(ManagedFileAccess.inStream(Utilities.path(root, fn2)));
|
||||
System.out.println(" .. compare");
|
||||
comp.compareProfiles(left, right);
|
||||
|
||||
|
@ -893,14 +894,14 @@ public class ProfileUtilitiesTests {
|
|||
// focus.setDifferential(null);
|
||||
String f1 = Utilities.path("c:", "temp", "base.xml");
|
||||
String f2 = Utilities.path("c:", "temp", "derived.xml");
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(f1), base);;
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(f2), focus);;
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f1), base);;
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(f2), focus);;
|
||||
String diff = Utilities.path(System.getenv("ProgramFiles(X86)"), "WinMerge", "WinMergeU.exe");
|
||||
List<String> command = new ArrayList<String>();
|
||||
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
builder.directory(new CSFile(Utilities.path("[tmp]")));
|
||||
builder.directory(ManagedFileAccess.csfile(Utilities.path("[tmp]")));
|
||||
builder.start();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.hl7.fhir.dstu3.test;
|
||||
|
||||
import java.io.File;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.dstu3.formats.XmlParser;
|
||||
import org.hl7.fhir.dstu3.model.StructureDefinition;
|
||||
|
@ -13,15 +15,15 @@ public class QuestionnaireBuilderTester {
|
|||
private static final String TEST_PROFILE_DIR = "C:\\work\\org.hl7.fhir\\build\\publish";
|
||||
// private static final String TEST_DEST = Utilities.path("[tmp]", "questionnaires\\");
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws IOException {
|
||||
QuestionnaireBuilder b = new QuestionnaireBuilder(null);
|
||||
for (String f : new File(TEST_PROFILE_DIR).list()) {
|
||||
for (String f : ManagedFileAccess.file(TEST_PROFILE_DIR).list()) {
|
||||
if (f.endsWith(".profile.xml") && !f.contains("type-")) {
|
||||
System.out.println("process "+f);
|
||||
try {
|
||||
StructureDefinition p = (StructureDefinition) new XmlParser().parse(new FileInputStream(TEST_PROFILE_DIR+"\\"+f));
|
||||
StructureDefinition p = (StructureDefinition) new XmlParser().parse(ManagedFileAccess.inStream(TEST_PROFILE_DIR+"\\"+f));
|
||||
// Questionnaire q = b.buildQuestionnaire(p);
|
||||
// new XmlComposer().compose(new FileOutputStream(TEST_DEST+f), q, true);
|
||||
// new XmlComposer().compose(ManagedFileAccess.outStream(TEST_DEST+f), q, true);
|
||||
throw new FHIRException("test");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.hl7.fhir.dstu3.test.support.TestingUtilities;
|
|||
import org.hl7.fhir.dstu3.utils.EOperationOutcome;
|
||||
import org.hl7.fhir.dstu3.utils.NarrativeGenerator;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -24,9 +25,9 @@ public class ResourceRoundTripTests {
|
|||
public void test() throws FileNotFoundException, IOException, FHIRException, EOperationOutcome {
|
||||
if (TestingUtilities.context == null)
|
||||
TestingUtilities.context = SimpleWorkerContext.fromPack("C:\\work\\org.hl7.fhir\\build\\publish\\definitions.xml.zip");
|
||||
Resource res = new XmlParser().parse(new FileInputStream("C:\\work\\org.hl7.fhir\\build\\tests\\resources\\unicode.xml"));
|
||||
Resource res = new XmlParser().parse(ManagedFileAccess.inStream("C:\\work\\org.hl7.fhir\\build\\tests\\resources\\unicode.xml"));
|
||||
new NarrativeGenerator("", "", TestingUtilities.context).generate((DomainResource) res);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\tests\\resources\\unicode.out.xml"), res);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream("C:\\work\\org.hl7.fhir\\build\\tests\\resources\\unicode.out.xml"), res);
|
||||
}
|
||||
|
||||
}
|
|
@ -45,6 +45,7 @@ import org.hl7.fhir.dstu3.formats.XmlParser;
|
|||
import org.hl7.fhir.dstu3.model.Resource;
|
||||
import org.hl7.fhir.dstu3.test.support.TestingUtilities;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
|
||||
public class ResourceTest {
|
||||
|
||||
|
@ -66,18 +67,18 @@ public class ResourceTest {
|
|||
p = new JsonParser();
|
||||
else
|
||||
p = new XmlParser(false);
|
||||
Resource rf = p.parse(new FileInputStream(source));
|
||||
Resource rf = p.parse(ManagedFileAccess.inStream(source));
|
||||
|
||||
FileOutputStream out = new FileOutputStream(source.getAbsoluteFile()+".out.json");
|
||||
FileOutputStream out = ManagedFileAccess.outStream(source.getAbsoluteFile()+".out.json");
|
||||
JsonParser json1 = new JsonParser();
|
||||
json1.setOutputStyle(OutputStyle.PRETTY);
|
||||
json1.compose(out, rf);
|
||||
out.close();
|
||||
|
||||
JsonParser json = new JsonParser();
|
||||
rf = json.parse(new FileInputStream(source.getAbsoluteFile()+".out.json"));
|
||||
rf = json.parse(ManagedFileAccess.inStream(source.getAbsoluteFile()+".out.json"));
|
||||
|
||||
out = new FileOutputStream(source.getAbsoluteFile()+".out.xml");
|
||||
out = ManagedFileAccess.outStream(source.getAbsoluteFile()+".out.xml");
|
||||
XmlParser atom = new XmlParser();
|
||||
atom.setOutputStyle(OutputStyle.PRETTY);
|
||||
atom.compose(out, rf, true);
|
||||
|
@ -89,9 +90,9 @@ public class ResourceTest {
|
|||
public Element testEM() throws Exception {
|
||||
if (TestingUtilities.context == null)
|
||||
TestingUtilities.context = SimpleWorkerContext.fromPack("C:\\work\\org.hl7.fhir\\build\\publish\\definitions.xml.zip");
|
||||
Element resource = Manager.parse(TestingUtilities.context, new FileInputStream(source), isJson() ? FhirFormat.JSON : FhirFormat.XML);
|
||||
Manager.compose(TestingUtilities.context, resource, new FileOutputStream(source.getAbsoluteFile()+".out.json"), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
||||
Manager.compose(TestingUtilities.context, resource, new FileOutputStream(source.getAbsoluteFile()+".out.json"), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
Element resource = Manager.parse(TestingUtilities.context, ManagedFileAccess.inStream(source), isJson() ? FhirFormat.JSON : FhirFormat.XML);
|
||||
Manager.compose(TestingUtilities.context, resource, ManagedFileAccess.outStream(source.getAbsoluteFile()+".out.json"), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
||||
Manager.compose(TestingUtilities.context, resource, ManagedFileAccess.outStream(source.getAbsoluteFile()+".out.json"), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||
return resource;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ package org.hl7.fhir.dstu3.test;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
@Disabled
|
||||
|
@ -41,7 +42,7 @@ public class SingleTest {
|
|||
public static void main(String[] args) {
|
||||
try {
|
||||
ResourceTest r = new ResourceTest();
|
||||
r.setSource(new File("C:\\work\\org.hl7.fhir\\fhir-test-cases\\r3\\ActivityDefinition-referralPrimaryCareMentalHealth.json"));
|
||||
r.setSource(ManagedFileAccess.file("C:\\work\\org.hl7.fhir\\fhir-test-cases\\r3\\ActivityDefinition-referralPrimaryCareMentalHealth.json"));
|
||||
r.test();
|
||||
System.out.println("Completed OK");
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.exceptions.PathEngineException;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.filesystem.ManagedFileAccess;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
@ -89,7 +90,7 @@ public class SnapShotGenerationTests {
|
|||
context.fixtures.put(op.getResponseId(), output);
|
||||
context.snapshots.put(output.getUrl(), output);
|
||||
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(Utilities.path("[tmp]"), op.getResponseId() + ".xml")), output);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(ManagedFileAccess.outStream(Utilities.path(Utilities.path("[tmp]"), op.getResponseId() + ".xml")), output);
|
||||
//ok, now the asserts:
|
||||
for (int i = 1; i < test.getAction().size(); i++) {
|
||||
SetupActionAssertComponent a = test.getAction().get(i).getAssert();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue