Merge branch 'master' of https://github.com/hapifhir/org.hl7.fhir.core
This commit is contained in:
commit
93d5adc9da
|
@ -387,7 +387,7 @@ public class ExtensionDefinitionGenerator {
|
|||
|
||||
private List<StructureDefinition> loadSource() throws IOException, FHIRException {
|
||||
List<StructureDefinition> list = new ArrayList<>();
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
NpmPackage npm = pcm.loadPackage("hl7.fhir.core", sourceVersion.toCode());
|
||||
if (sourceVersion == FHIRVersion._4_0_0)
|
||||
context = SimpleWorkerContext.fromPackage(npm);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.convertors.analytics;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -34,6 +33,16 @@ import org.xml.sax.SAXException;
|
|||
|
||||
public class PackageVisitor {
|
||||
|
||||
private PackageServer clientPackageServer = null;
|
||||
|
||||
public void setClientPackageServer(PackageServer packageServer) {
|
||||
this.clientPackageServer = packageServer;
|
||||
}
|
||||
private List<PackageServer> cachePackageServers = null;
|
||||
public void setCachePackageServers(List<PackageServer> packageServers) {
|
||||
this.cachePackageServers = packageServers;
|
||||
}
|
||||
|
||||
public static class PackageContext {
|
||||
private String pid;
|
||||
private NpmPackage npm;
|
||||
|
@ -145,8 +154,13 @@ public class PackageVisitor {
|
|||
|
||||
public void visitPackages() throws IOException, ParserConfigurationException, SAXException, FHIRException, EOperationOutcome {
|
||||
System.out.println("Finding packages");
|
||||
pc = new PackageClient(PackageServer.primaryServer());
|
||||
pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
pc = clientPackageServer == null
|
||||
? new PackageClient(PackageServer.primaryServer())
|
||||
: new PackageClient(clientPackageServer);
|
||||
|
||||
pcm = cachePackageServers == null
|
||||
? new FilesystemPackageCacheManager.Builder().build()
|
||||
: new FilesystemPackageCacheManager.Builder().withPackageServers(cachePackageServers).build();
|
||||
|
||||
Set<String> pidList = getAllPackages();
|
||||
|
||||
|
@ -338,9 +352,14 @@ public class PackageVisitor {
|
|||
String fv = null;
|
||||
try {
|
||||
npm = pcm.loadPackage(pid, v);
|
||||
} catch (Throwable e) {
|
||||
System.out.println("Unable to load package: "+pid+"#"+v+": "+e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
fv = npm.fhirVersion();
|
||||
} catch (Throwable e) {
|
||||
System.out.println("Unable to process: "+pid+"#"+v+": "+e.getMessage());
|
||||
System.out.println("Unable to identify package FHIR version:: "+pid+"#"+v+": "+e.getMessage());
|
||||
}
|
||||
if (corePackages || !corePackage(npm)) {
|
||||
PackageContext ctxt = new PackageContext(pid+"#"+v, npm, fv);
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ExtensionExtractor {
|
|||
|
||||
private void process(String dst) throws IOException {
|
||||
Set<String> ids = new HashSet<>();
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
NpmPackage r5 = pcm.loadPackage("hl7.fhir.r5.core", "current");
|
||||
CanonicalResourceManager<CodeSystem> cslist = new CanonicalResourceManager<CodeSystem>(true, false);
|
||||
for (String r : r5.listResources("CodeSystem")) {
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ExtensionStatusUpgrader implements IResourceObserver {
|
|||
Map<String, CanonicalResource> r5 = new HashMap<>();
|
||||
|
||||
private void execute(String folder) throws IOException {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
|
||||
// load R4
|
||||
NpmPackage npm = pcm.loadPackage("hl7.fhir.r4.core");
|
||||
|
|
|
@ -15,7 +15,7 @@ public class OIDBasedValueSetImporter {
|
|||
protected IWorkerContext context;
|
||||
|
||||
protected void init() throws FHIRException, IOException {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
NpmPackage npm = pcm.loadPackage("hl7.fhir.r5.core", "5.0.0");
|
||||
SimpleWorkerContext context = new SimpleWorkerContext.SimpleWorkerContextBuilder().withAllowLoadingDuplicates(true).fromPackage(npm);
|
||||
context.loadFromPackage(pcm.loadPackage("hl7.terminology"), null);
|
||||
|
|
|
@ -18,7 +18,7 @@ public class PackageMinifier {
|
|||
}
|
||||
|
||||
private void process(String source, String target) throws FileNotFoundException, IOException {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
NpmPackage src = pcm.loadPackage(source);
|
||||
NpmPackage tgt = NpmPackage.empty();
|
||||
tgt.setNpm(src.getNpm().deepCopy());
|
||||
|
|
|
@ -35,7 +35,7 @@ public class ResourceDependencyPackageBuilder {
|
|||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
System.out.println("Load Core");
|
||||
NpmPackage src = pcm.loadPackage(VersionUtilities.packageForVersion(args[0]));
|
||||
SimpleWorkerContext ctxt = new SimpleWorkerContextBuilder().withAllowLoadingDuplicates(true).fromPackage(src);
|
||||
|
|
|
@ -89,7 +89,7 @@ public class UTGVersionSorter {
|
|||
private Map<String, CanonicalResource> loadPackageR2(String id) throws IOException {
|
||||
Map<String, CanonicalResource> res = new HashMap<>();
|
||||
if (pcm == null) {
|
||||
pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
}
|
||||
System.out.println("Load " + id);
|
||||
NpmPackage npm = pcm.loadPackage(id);
|
||||
|
@ -103,7 +103,7 @@ public class UTGVersionSorter {
|
|||
private Map<String, CanonicalResource> loadPackageR3(String id) throws IOException {
|
||||
Map<String, CanonicalResource> res = new HashMap<>();
|
||||
if (pcm == null) {
|
||||
pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
}
|
||||
System.out.println("Load " + id);
|
||||
NpmPackage npm = pcm.loadPackage(id);
|
||||
|
@ -117,7 +117,7 @@ public class UTGVersionSorter {
|
|||
private Map<String, CanonicalResource> loadPackageR4(String id) throws IOException {
|
||||
Map<String, CanonicalResource> res = new HashMap<>();
|
||||
if (pcm == null) {
|
||||
pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
}
|
||||
System.out.println("Load " + id);
|
||||
NpmPackage npm = pcm.loadPackage(id);
|
||||
|
|
|
@ -25,7 +25,7 @@ class Convertor_Factory_40_50Test {
|
|||
|
||||
@BeforeAll
|
||||
static public void setUp() throws Exception {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
context = TestingUtilities.getWorkerContext(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public class JavaCoreGenerator {
|
|||
Date ddate = new Date();
|
||||
String date = config.DATE_FORMAT().format(ddate);
|
||||
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheManagerBuilder().build();
|
||||
System.out.println("Cache: "+pcm.getFolder());
|
||||
System.out.println("Load hl7.fhir."+pid+".core");
|
||||
NpmPackage npm = pcm.loadPackage("hl7.fhir."+pid+".core", version);
|
||||
|
|
|
@ -79,8 +79,7 @@ public class TestingUtilities {
|
|||
if (fcontext == null) {
|
||||
FilesystemPackageCacheManager pcm;
|
||||
try {
|
||||
pcm = new FilesystemPackageCacheManager(
|
||||
org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
|
||||
fcontext
|
||||
.setUcumService(new UcumEssenceService(TestingUtilities.resourceNameToFile("ucum", "ucum-essence.xml")));
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.hl7.fhir.r4.context.SimpleWorkerContext;
|
|||
import org.hl7.fhir.r4.fhirpath.FHIRPathEngine;
|
||||
import org.hl7.fhir.r4.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r4.formats.JsonParser;
|
||||
import org.hl7.fhir.r4.formats.XmlParser;
|
||||
import org.hl7.fhir.r4.model.Base;
|
||||
import org.hl7.fhir.r4.model.BooleanType;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
|
@ -27,8 +26,6 @@ import org.hl7.fhir.r4.model.HumanName;
|
|||
import org.hl7.fhir.r4.model.Immunization;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent;
|
||||
import org.hl7.fhir.r4.model.HumanName;
|
||||
import org.hl7.fhir.r4.model.Immunization;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.hl7.fhir.r4.model.Period;
|
||||
import org.hl7.fhir.r4.model.Procedure;
|
||||
|
@ -55,7 +52,7 @@ public class CmdLineApp {
|
|||
|
||||
private void execute() throws IOException {
|
||||
System.out.print("Loading...");
|
||||
NpmPackage npm = new FilesystemPackageCacheManager(true).loadPackage("hl7.fhir.r4.core");
|
||||
NpmPackage npm = new FilesystemPackageCacheManager.Builder().build().loadPackage("hl7.fhir.r4.core");
|
||||
context = SimpleWorkerContext.fromPackage(npm);
|
||||
fpe = new FHIRPathEngine(context);
|
||||
System.out.println(" Done");
|
||||
|
|
|
@ -29,8 +29,7 @@ public class CDARoundTripTests {
|
|||
@BeforeAll
|
||||
public void setUp() throws Exception {
|
||||
context = new SimpleWorkerContext();
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(
|
||||
org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
context.loadFromPackage(pcm.loadPackage("hl7.fhir.core", "current"), null, "StructureDefinition");
|
||||
context.loadFromPackage(pcm.loadPackage("hl7.fhir.cda", "current"), null, "StructureDefinition");
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@ import org.hl7.fhir.utilities.TextFile;
|
|||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
|
||||
import org.hl7.fhir.utilities.tests.BaseTestingUtilities;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -85,8 +84,7 @@ public class TestingUtilities extends BaseTestingUtilities {
|
|||
if (!fcontexts.containsKey(v)) {
|
||||
FilesystemPackageCacheManager pcm;
|
||||
try {
|
||||
pcm = new FilesystemPackageCacheManager(
|
||||
org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
IWorkerContext fcontext = SimpleWorkerContext
|
||||
.fromPackage(pcm.loadPackage(VersionUtilities.packageForVersion(version), version));
|
||||
fcontext.setUcumService(
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.hl7.fhir.r4b.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
@ -18,7 +17,6 @@ import org.hl7.fhir.utilities.TextFile;
|
|||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
@ -36,8 +34,7 @@ public class ParsingTests {
|
|||
|
||||
public static Stream<Arguments> data()
|
||||
throws ParserConfigurationException, IOException, FHIRFormatError, SAXException {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(
|
||||
org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
npm = pcm.loadPackage("hl7.fhir.r4b.examples", "4.3.0");
|
||||
List<Arguments> objects = new ArrayList<>();
|
||||
List<String> names = npm.list("package");
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.hl7.fhir.utilities.Utilities;
|
|||
import org.hl7.fhir.utilities.npm.CommonPackages;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
|
@ -581,8 +580,7 @@ public class SnapShotGenerationTests {
|
|||
pu.setDebug(test.isDebug());
|
||||
pu.setIds(test.getSource(), false);
|
||||
if (!TestingUtilities.context().hasPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER)) {
|
||||
NpmPackage npm = new FilesystemPackageCacheManager(
|
||||
org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER)
|
||||
NpmPackage npm = new FilesystemPackageCacheManager.Builder().build()
|
||||
.loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER);
|
||||
TestingUtilities.context().loadFromPackage(npm, new TestLoader(new String[] { "StructureDefinition" }),
|
||||
new String[] { "StructureDefinition" });
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.hl7.fhir.r4b.test.utils.TestingUtilities;
|
|||
import org.hl7.fhir.r4b.utils.structuremap.StructureMapUtilities;
|
||||
import org.hl7.fhir.r4b.utils.structuremap.ITransformerServices;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -24,8 +23,7 @@ public class StructureMapUtilitiesTest implements ITransformerServices {
|
|||
|
||||
@BeforeAll
|
||||
static public void setUp() throws Exception {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(
|
||||
org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
package org.hl7.fhir.r4b.test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.r4b.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r4b.elementmodel.Element;
|
||||
import org.hl7.fhir.r4b.elementmodel.Manager;
|
||||
import org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat;
|
||||
import org.hl7.fhir.r4b.fhirpath.FHIRPathEngine;
|
||||
import org.hl7.fhir.r4b.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r4b.model.StructureDefinition;
|
||||
import org.hl7.fhir.r4b.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class XmlParserTests {
|
||||
|
||||
|
@ -24,8 +14,7 @@ public class XmlParserTests {
|
|||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(
|
||||
org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
|
||||
fp = new FHIRPathEngine(context);
|
||||
|
||||
|
|
|
@ -13,15 +13,12 @@ import org.hl7.fhir.r5.context.IWorkerContext;
|
|||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r5.model.Parameters;
|
||||
import org.hl7.fhir.r5.terminologies.utilities.TerminologyCache;
|
||||
import org.hl7.fhir.r5.utils.R5Hacker;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.npm.BasePackageCacheManager.InputStreamWithSrc;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.IPackageProvider;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
import org.hl7.fhir.utilities.tests.BaseTestingUtilities;
|
||||
import org.hl7.fhir.utilities.tests.TestConfig;
|
||||
|
||||
|
@ -80,7 +77,7 @@ public class TestingUtilities extends BaseTestingUtilities {
|
|||
|
||||
FilesystemPackageCacheManager pcm;
|
||||
try {
|
||||
pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
IWorkerContext fcontext = null;
|
||||
if (VersionUtilities.isR5Ver(version)) {
|
||||
// for purposes of stability, the R5 core package comes from the test case repository
|
||||
|
|
|
@ -3,23 +3,13 @@ package org.hl7.fhir.r5.profiles;
|
|||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.model.CodeableConcept;
|
||||
import org.hl7.fhir.r5.model.Identifier;
|
||||
import org.hl7.fhir.r5.model.Observation;
|
||||
import org.hl7.fhir.r5.model.Patient;
|
||||
import org.hl7.fhir.r5.model.Reference;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.formats.XmlParser;
|
||||
import org.hl7.fhir.r5.profilemodel.PEBuilder;
|
||||
import org.hl7.fhir.r5.test.utils.CompareUtilities;
|
||||
import org.hl7.fhir.r5.test.utils.TestPackageLoader;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
|
@ -36,7 +26,7 @@ public class GeneratedPEModelTest {
|
|||
public void load() throws Exception {
|
||||
if (ctxt == null) {
|
||||
ctxt = TestingUtilities.getSharedWorkerContext();
|
||||
FilesystemPackageCacheManager pc = new FilesystemPackageCacheManager(true);
|
||||
FilesystemPackageCacheManager pc = new FilesystemPackageCacheManager.Builder().build();
|
||||
NpmPackage npm = pc.loadPackage("hl7.fhir.us.core", "5.0.0");
|
||||
ctxt.loadFromPackage(npm, new TestPackageLoader(Utilities.strings("StructureDefinition" )));
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.hl7.fhir.r5.profiles;
|
||||
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.model.Patient;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
|
@ -22,7 +21,7 @@ public class PEModelTest1343 {
|
|||
public void Load() throws Exception {
|
||||
if (ctxt == null) {
|
||||
ctxt = TestingUtilities.getSharedWorkerContext("4.0.1");
|
||||
FilesystemPackageCacheManager pc = new FilesystemPackageCacheManager(true);
|
||||
FilesystemPackageCacheManager pc = new FilesystemPackageCacheManager.Builder().build();
|
||||
NpmPackage npm = pc.loadPackage("hl7.fhir.fr.core", "1.1.0");
|
||||
ctxt.loadFromPackage(npm, new TestPackageLoader(Utilities.strings(SimpleWorkerContext.defaultTypesToLoad().stream().toArray(String[]::new))));
|
||||
}
|
||||
|
|
|
@ -28,20 +28,14 @@ package org.hl7.fhir.r5.profiles;
|
|||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.model.Coding;
|
||||
import org.hl7.fhir.r5.model.Comparison;
|
||||
import org.hl7.fhir.r5.model.Enumerations.ObservationStatus;
|
||||
import org.hl7.fhir.r5.model.Observation;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.profilemodel.PEDefinition;
|
||||
|
@ -71,7 +65,7 @@ public class PETests {
|
|||
public void load() throws IOException {
|
||||
if (ctxt == null) {
|
||||
ctxt = TestingUtilities.getSharedWorkerContext();
|
||||
FilesystemPackageCacheManager pc = new FilesystemPackageCacheManager(true);
|
||||
FilesystemPackageCacheManager pc = new FilesystemPackageCacheManager.Builder().build();
|
||||
NpmPackage npm = pc.loadPackage("hl7.fhir.us.core", "5.0.0");
|
||||
ctxt.loadFromPackage(npm, new TestPackageLoader(Utilities.strings("StructureDefinition" )));
|
||||
|
||||
|
|
|
@ -5,20 +5,15 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.r5.context.ContextUtilities;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Element;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
|
||||
import org.hl7.fhir.r5.fhirpath.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -30,11 +25,11 @@ public class CDARoundTripTests {
|
|||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
context = TestingUtilities.getWorkerContext(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
|
||||
fp = new FHIRPathEngine(context);
|
||||
|
||||
NpmPackage npm = new FilesystemPackageCacheManager(true).loadPackage("hl7.cda.uv.core", "current");
|
||||
NpmPackage npm = new FilesystemPackageCacheManager.Builder().build().loadPackage("hl7.cda.uv.core", "current");
|
||||
context.loadFromPackage(npm, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.xml.sax.SAXException;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class FHIRPathTests {
|
||||
|
||||
|
@ -111,7 +110,7 @@ public class FHIRPathTests {
|
|||
@BeforeAll
|
||||
public static void setUp() throws FileNotFoundException, FHIRException, IOException {
|
||||
if (!TestingUtilities.getSharedWorkerContext().hasPackage("hl7.cda.us.ccda", null)) {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
NpmPackage npm = pcm.loadPackage("hl7.cda.uv.core", "2.0.0");
|
||||
TestingUtilities.getSharedWorkerContext().loadFromPackage(npm, null);
|
||||
npm = pcm.loadPackage("hl7.cda.us.ccda", "current");
|
||||
|
|
|
@ -213,7 +213,7 @@ public class NarrativeGenerationTests {
|
|||
@BeforeAll
|
||||
public static void setUp() throws IOException {
|
||||
context = TestingUtilities.getSharedWorkerContext("5.0.0");
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
NpmPackage ips = pcm.loadPackage("hl7.fhir.uv.ips#1.1.0");
|
||||
context.loadFromPackage(ips, new TestPackageLoader(Utilities.strings("StructureDefinition", "ValueSet" )));
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
|||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
@ -35,7 +33,7 @@ public class ParsingTests {
|
|||
}
|
||||
|
||||
public static Stream<Arguments> data() throws ParserConfigurationException, IOException, FHIRFormatError, SAXException {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
// npm = pcm.loadPackage("hl7.fhir.r5.examples", "5.0.0");
|
||||
npm = NpmPackage.fromPackage(TestingUtilities.loadTestResourceStream("r5", "packages", "hl7.fhir.r5.examples.tgz"));
|
||||
List<Arguments> objects = new ArrayList<>();
|
||||
|
|
|
@ -540,7 +540,7 @@ public class SnapShotGenerationTests {
|
|||
pu.setIds(test.getSource(), false);
|
||||
pu.setAllowUnknownProfile(test.allow);
|
||||
if (!TestingUtilities.getSharedWorkerContext().hasPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER)) {
|
||||
NpmPackage npm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER).loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER);
|
||||
NpmPackage npm = new FilesystemPackageCacheManager.Builder().build().loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER);
|
||||
TestingUtilities.getSharedWorkerContext().loadFromPackage(npm, new TestPackageLoader(Utilities.strings("StructureDefinition")), Utilities.strings("StructureDefinition"));
|
||||
}
|
||||
pu.setXver(new XVerExtensionManager(TestingUtilities.getSharedWorkerContext()));
|
||||
|
|
|
@ -17,8 +17,6 @@ import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
|||
import org.hl7.fhir.r5.utils.structuremap.ITransformerServices;
|
||||
import org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -29,7 +27,7 @@ public class StructureMapUtilitiesTest implements ITransformerServices {
|
|||
|
||||
@BeforeAll
|
||||
static public void setUp() throws Exception {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
context = TestingUtilities.getWorkerContext(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@ import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
|||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -26,7 +24,7 @@ public class XmlParserTests {
|
|||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
context = TestingUtilities.getWorkerContext(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
|
||||
|
||||
fp = new FHIRPathEngine(context);
|
||||
|
|
|
@ -16,7 +16,7 @@ class FHIRPathHostServicesTest {
|
|||
|
||||
@BeforeAll
|
||||
static public void setUp() throws Exception {
|
||||
FilesystemPackageCacheManager pcm = new org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager(true);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
context = TestingUtilities.getWorkerContext(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,29 @@ public class SimpleHTTPClient {
|
|||
private static final int MAX_REDIRECTS = 5;
|
||||
private static int counter = 1;
|
||||
|
||||
public static class HTTPResultException extends Exception{
|
||||
public final int httpCode;
|
||||
|
||||
public final String message;
|
||||
|
||||
public final String url;
|
||||
public final String logPath;
|
||||
|
||||
public HTTPResultException(int httpCode, String message, String url, String logPath) {
|
||||
this.httpCode = httpCode;
|
||||
this.message = message;
|
||||
this.url = url;
|
||||
this.logPath = logPath;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return "Invalid HTTP response "+httpCode+" from "+url+" ("+message+") (" + (
|
||||
logPath != null ? "Response in " + logPath : "No response content")
|
||||
+ ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class HTTPResult {
|
||||
private int code;
|
||||
private String contentType;
|
||||
|
@ -79,11 +102,13 @@ public class SimpleHTTPClient {
|
|||
if (code >= 300) {
|
||||
String filename = Utilities.path("[tmp]", "http-log", "fhir-http-"+(++counter)+".log");
|
||||
if (content == null || content.length == 0) {
|
||||
throw new IOException("Invalid HTTP response "+code+" from "+source+" ("+message+") (no content)");
|
||||
HTTPResultException exception = new HTTPResultException(code, message, source, null);
|
||||
throw new IOException(exception.message, exception);
|
||||
} else {
|
||||
Utilities.createDirectory(Utilities.path("[tmp]", "http-log"));
|
||||
TextFile.bytesToFile(content, filename);
|
||||
throw new IOException("Invalid HTTP response "+code+" from "+source+" ("+message+") (content in "+filename+")");
|
||||
HTTPResultException exception = new HTTPResultException(code, message, source, filename);
|
||||
throw new IOException(exception.message, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.UUID;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.With;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.IniFile;
|
||||
|
@ -84,13 +86,8 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class FilesystemPackageCacheManager extends BasePackageCacheManager implements IPackageCacheManager {
|
||||
|
||||
|
||||
public static final String INI_TIMESTAMP_FORMAT = "yyyyMMddHHmmss";
|
||||
|
||||
public enum FilesystemPackageCacheMode {
|
||||
USER, SYSTEM, TESTING, CUSTOM
|
||||
}
|
||||
|
||||
// When running in testing mode, some packages are provided from the test case repository rather than by the normal means
|
||||
// the PackageProvider is responsible for this. if no package provider is defined, or it declines to handle the package,
|
||||
// then the normal means will be used
|
||||
|
@ -99,8 +96,6 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
InputStreamWithSrc provide(String id, String version) throws IOException;
|
||||
}
|
||||
private static IPackageProvider packageProvider;
|
||||
|
||||
// private static final String SECONDARY_SERVER = "http://local.fhir.org:8080/packages";
|
||||
public static final String PACKAGE_REGEX = "^[a-zA-Z][A-Za-z0-9\\_\\-]*(\\.[A-Za-z0-9\\_\\-]+)+$";
|
||||
public static final String PACKAGE_VERSION_REGEX = "^[A-Za-z][A-Za-z0-9\\_\\-]*(\\.[A-Za-z0-9\\_\\-]+)+\\#[A-Za-z0-9\\-\\_\\$]+(\\.[A-Za-z0-9\\-\\_\\$]+)*$";
|
||||
public static final String PACKAGE_VERSION_REGEX_OPT = "^[A-Za-z][A-Za-z0-9\\_\\-]*(\\.[A-Za-z0-9\\_\\-]+)+(\\#[A-Za-z0-9\\-\\_]+(\\.[A-Za-z0-9\\-\\_]+)*)?$";
|
||||
|
@ -115,52 +110,78 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
private boolean suppressErrors;
|
||||
private boolean minimalMemory;
|
||||
|
||||
public FilesystemPackageCacheManager(boolean userMode) throws IOException {
|
||||
init(userMode ? FilesystemPackageCacheMode.USER : FilesystemPackageCacheMode.SYSTEM);
|
||||
public static class Builder {
|
||||
|
||||
@Getter
|
||||
private final File cacheFolder;
|
||||
|
||||
@With @Getter
|
||||
private final List<PackageServer> packageServers;
|
||||
|
||||
public Builder() throws IOException {
|
||||
this.cacheFolder = getUserCacheFolder();
|
||||
this.packageServers = getPackageServersFromFHIRSettings();
|
||||
}
|
||||
|
||||
public FilesystemPackageCacheManager(FilesystemPackageCacheMode mode) throws IOException {
|
||||
init(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined for use on Android
|
||||
*
|
||||
* @param customFolder
|
||||
* @throws IOException
|
||||
*/
|
||||
public FilesystemPackageCacheManager(String customFolder) throws IOException {
|
||||
this.cacheFolder = new File(customFolder);
|
||||
init(FilesystemPackageCacheMode.CUSTOM);
|
||||
}
|
||||
|
||||
protected void init(FilesystemPackageCacheMode mode) throws IOException {
|
||||
initPackageServers();
|
||||
|
||||
if (mode == FilesystemPackageCacheMode.CUSTOM) {
|
||||
if (!this.cacheFolder.exists()) {
|
||||
throw new FHIRException("The folder ''"+cacheFolder+"' could not be found");
|
||||
}
|
||||
} else {
|
||||
this.cacheFolder = getCacheFolder(mode);
|
||||
}
|
||||
initCacheFolder();
|
||||
}
|
||||
|
||||
public static File getCacheFolder(FilesystemPackageCacheMode mode) throws IOException {
|
||||
switch (mode) {
|
||||
case SYSTEM:
|
||||
if (Utilities.isWindows()) {
|
||||
return new File(Utilities.path(System.getenv("ProgramData"), ".fhir", "packages"));
|
||||
} else {
|
||||
return new File(Utilities.path("/var", "lib", ".fhir", "packages"));
|
||||
}
|
||||
case USER:
|
||||
private File getUserCacheFolder() throws IOException {
|
||||
return new File(Utilities.path(System.getProperty("user.home"), ".fhir", "packages"));
|
||||
case TESTING:
|
||||
return new File(Utilities.path("[tmp]", ".fhir", "packages"));
|
||||
}
|
||||
return null;
|
||||
private List<PackageServer> getPackageServersFromFHIRSettings() {
|
||||
List<PackageServer> packageServers = new ArrayList<>(getConfiguredServers());
|
||||
if (!isIgnoreDefaultPackageServers()) {
|
||||
packageServers.addAll(getDefaultServers());
|
||||
}
|
||||
return packageServers;
|
||||
}
|
||||
|
||||
protected boolean isIgnoreDefaultPackageServers() {
|
||||
return FhirSettings.isIgnoreDefaultPackageServers();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected List<PackageServer> getDefaultServers() {
|
||||
return PackageServer.defaultServers();
|
||||
}
|
||||
|
||||
protected List<PackageServer> getConfiguredServers() {
|
||||
return PackageServer.getConfiguredServers();
|
||||
}
|
||||
private Builder(File cacheFolder, List<PackageServer> packageServers) {
|
||||
this.cacheFolder = cacheFolder;
|
||||
this.packageServers = packageServers;
|
||||
}
|
||||
|
||||
public Builder withCacheFolder (String cacheFolderPath) throws IOException {
|
||||
File cacheFolder = new File(cacheFolderPath);
|
||||
if (!cacheFolder.exists()) {
|
||||
throw new FHIRException("The folder '"+cacheFolder+"' could not be found");
|
||||
}
|
||||
return new Builder(cacheFolder, this.packageServers);
|
||||
}
|
||||
|
||||
public Builder withSystemCacheFolder() throws IOException {
|
||||
final File systemCacheFolder;
|
||||
if (Utilities.isWindows()) {
|
||||
systemCacheFolder = new File(Utilities.path(System.getenv("ProgramData"), ".fhir", "packages"));
|
||||
} else {
|
||||
systemCacheFolder = new File(Utilities.path("/var", "lib", ".fhir", "packages"));
|
||||
}
|
||||
return new Builder(systemCacheFolder, this.packageServers);
|
||||
}
|
||||
|
||||
public Builder withTestingCacheFolder() throws IOException {
|
||||
return new Builder(new File(Utilities.path("[tmp]", ".fhir", "packages")), this.packageServers);
|
||||
}
|
||||
|
||||
public FilesystemPackageCacheManager build() throws IOException {
|
||||
return new FilesystemPackageCacheManager(cacheFolder, packageServers);
|
||||
}
|
||||
}
|
||||
|
||||
private FilesystemPackageCacheManager(File cacheFolder, List<PackageServer> packageServers) throws IOException {
|
||||
this.cacheFolder = cacheFolder;
|
||||
this.myPackageServers = packageServers;
|
||||
initCacheFolder();
|
||||
}
|
||||
|
||||
protected void initCacheFolder() throws IOException {
|
||||
|
|
|
@ -56,7 +56,8 @@ public class FilesystemPackageManagerTests {
|
|||
|
||||
@Nonnull
|
||||
private FilesystemPackageCacheManager getFilesystemPackageCacheManager(final boolean ignoreDefaultPackageServers) throws IOException {
|
||||
return new FilesystemPackageCacheManager(FilesystemPackageCacheManager.FilesystemPackageCacheMode.TESTING) {
|
||||
|
||||
FilesystemPackageCacheManager.Builder builder = new FilesystemPackageCacheManager.Builder() {
|
||||
protected boolean isIgnoreDefaultPackageServers() {
|
||||
return ignoreDefaultPackageServers;
|
||||
}
|
||||
|
@ -70,14 +71,14 @@ public class FilesystemPackageManagerTests {
|
|||
return dummyPrivateServers;
|
||||
}
|
||||
};
|
||||
|
||||
return builder.build();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUserCacheDirectory() throws IOException {
|
||||
FilesystemPackageCacheManager filesystemPackageCacheManager = new FilesystemPackageCacheManager(true) {
|
||||
protected void initCacheFolder() throws IOException {
|
||||
}
|
||||
};
|
||||
FilesystemPackageCacheManager filesystemPackageCacheManager = new FilesystemPackageCacheManager.Builder().build();
|
||||
assertEquals(System.getProperty("user.home") + File.separator + ".fhir" + File.separator + "packages", filesystemPackageCacheManager.getFolder());
|
||||
}
|
||||
|
||||
|
@ -87,27 +88,22 @@ public class FilesystemPackageManagerTests {
|
|||
@Test
|
||||
@DisabledOnOs(OS.WINDOWS)
|
||||
public void testSystemCacheDirectory() throws IOException {
|
||||
FilesystemPackageCacheManager filesystemPackageCacheManager = new FilesystemPackageCacheManager(false) {
|
||||
protected void initCacheFolder() throws IOException {
|
||||
}
|
||||
};
|
||||
assertEquals( "/var/lib/.fhir/packages", filesystemPackageCacheManager.getFolder());
|
||||
File folder = new FilesystemPackageCacheManager.Builder().withSystemCacheFolder().getCacheFolder();
|
||||
|
||||
assertEquals( "/var/lib/.fhir/packages", folder.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(OS.WINDOWS)
|
||||
public void testSystemCacheDirectoryWin() throws IOException {
|
||||
FilesystemPackageCacheManager filesystemPackageCacheManager = new FilesystemPackageCacheManager(false) {
|
||||
protected void initCacheFolder() throws IOException {
|
||||
}
|
||||
};
|
||||
assertEquals( System.getenv("ProgramData") + "\\.fhir\\packages", filesystemPackageCacheManager.getFolder());
|
||||
File folder = new FilesystemPackageCacheManager.Builder().withSystemCacheFolder().getCacheFolder();
|
||||
assertEquals( System.getenv("ProgramData") + "\\.fhir\\packages", folder.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multithreadingTest() throws IOException {
|
||||
String pcmPath = Files.createTempDirectory("fpcm-multithreadingTest").toFile().getAbsolutePath();
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(pcmPath);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().withCacheFolder(pcmPath).build();
|
||||
|
||||
final AtomicInteger totalSuccessful = new AtomicInteger();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public class MinimalMemoryTests {
|
|||
} else {
|
||||
Utilities.createDirectory(folder.getAbsolutePath());
|
||||
}
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(folder.getAbsolutePath());
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().withCacheFolder(folder.getAbsolutePath()).build();
|
||||
pcm.setMinimalMemory(true);
|
||||
NpmPackage npm = pcm.loadPackage("hl7.fhir.us.core", "5.0.0");
|
||||
Assertions.assertTrue(npm.isMinimalMemory());
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.hl7.fhir.utilities.TextFile;
|
|||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.npm.CommonPackages;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -17,7 +16,7 @@ public class PackageCacheTests {
|
|||
|
||||
@Test
|
||||
public void testPath() throws IOException {
|
||||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(FilesystemPackageCacheMode.TESTING);
|
||||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager.Builder().withTestingCacheFolder().build();
|
||||
NpmPackage npm = cache.loadPackage(CommonPackages.ID_PUBPACK, CommonPackages.VER_PUBPACK);
|
||||
cache.clear();
|
||||
List<String> list = cache.listPackages();
|
||||
|
@ -43,7 +42,7 @@ public class PackageCacheTests {
|
|||
|
||||
@Test
|
||||
public void testPatchWildCard() throws IOException {
|
||||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(FilesystemPackageCacheMode.TESTING);
|
||||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager.Builder().withTestingCacheFolder().build();
|
||||
cache.clear();
|
||||
Assertions.assertEquals(cache.loadPackage("hl7.fhir.us.core", "3.1.0").version(), "3.1.0");
|
||||
Assertions.assertEquals(cache.loadPackage("hl7.fhir.us.core", "3.1.1").version(), "3.1.1");
|
||||
|
@ -53,7 +52,7 @@ public class PackageCacheTests {
|
|||
|
||||
@Test
|
||||
public void testNotCaseSensitive() throws IOException {
|
||||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(FilesystemPackageCacheMode.TESTING);
|
||||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager.Builder().withTestingCacheFolder().build();
|
||||
cache.clear();
|
||||
Assertions.assertEquals(cache.loadPackage("KBV.Basis", "1.1.3").version(), "1.1.3");
|
||||
Assertions.assertEquals(cache.loadPackage("kbv.basis", "1.1.3").version(), "1.1.3");
|
||||
|
@ -61,7 +60,7 @@ public class PackageCacheTests {
|
|||
|
||||
@Test
|
||||
public void testLastReleasedVersion() throws IOException {
|
||||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(FilesystemPackageCacheMode.TESTING);
|
||||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager.Builder().withTestingCacheFolder().build();
|
||||
cache.clear();
|
||||
Assertions.assertEquals("0.0.8", cache.loadPackage(CommonPackages.ID_PUBPACK, "0.0.8").version());
|
||||
Assertions.assertEquals(CommonPackages.VER_PUBPACK, cache.loadPackage(CommonPackages.ID_PUBPACK).version());
|
||||
|
@ -69,7 +68,7 @@ public class PackageCacheTests {
|
|||
|
||||
@Test
|
||||
public void testMinimal() throws IOException {
|
||||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(FilesystemPackageCacheMode.TESTING);
|
||||
FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager.Builder().withTestingCacheFolder().build();
|
||||
cache.clear();
|
||||
NpmPackage uscore = cache.loadPackage("hl7.fhir.us.core", "3.1.0");
|
||||
cache.setMinimalMemory(true);
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.r5.conformance.profile.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.context.ContextUtilities;
|
||||
import org.hl7.fhir.r5.context.ILoggingService;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.context.IWorkerContextManager;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r5.context.SystemOutLoggingService;
|
||||
|
@ -1055,7 +1054,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IValidationP
|
|||
public FilesystemPackageCacheManager getPcm() throws IOException {
|
||||
if (pcm == null) {
|
||||
//System.out.println("Creating Package manager?");
|
||||
pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
}
|
||||
return pcm;
|
||||
}
|
||||
|
|
|
@ -74,25 +74,7 @@ import org.hl7.fhir.utilities.VersionUtilities;
|
|||
import org.hl7.fhir.utilities.settings.FhirSettings;
|
||||
import org.hl7.fhir.validation.cli.model.CliContext;
|
||||
import org.hl7.fhir.validation.cli.services.ValidationService;
|
||||
import org.hl7.fhir.validation.cli.tasks.CliTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.CompareTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.CompileTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.ConvertTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.FhirpathTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.InstallTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.LangTransformTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.NarrativeTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.ScanTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.SnapshotTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.SpecialTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.SpreadsheetTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.StandaloneTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.TestsTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.TransformTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.TxTestsTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.ValidateTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.ValidationEngineTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.VersionTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.*;
|
||||
import org.hl7.fhir.validation.cli.utils.Display;
|
||||
import org.hl7.fhir.validation.cli.utils.Params;
|
||||
|
||||
|
@ -144,6 +126,7 @@ public class ValidatorCli {
|
|||
new InstallTask(),
|
||||
new LangTransformTask(),
|
||||
new NarrativeTask(),
|
||||
new PreloadCacheTask(),
|
||||
new ScanTask(),
|
||||
new SnapshotTask(),
|
||||
new SpecialTask(),
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.hl7.fhir.r5.model.ConceptMap;
|
|||
import org.hl7.fhir.r5.model.OperationOutcome;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
||||
import org.hl7.fhir.r5.model.StructureMap;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.renderers.spreadsheets.CodeSystemSpreadsheetGenerator;
|
||||
|
@ -154,7 +153,7 @@ public class ValidationService {
|
|||
public VersionSourceInformation scanForVersions(CliContext cliContext) throws Exception {
|
||||
VersionSourceInformation versions = new VersionSourceInformation();
|
||||
IgLoader igLoader = new IgLoader(
|
||||
new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER),
|
||||
new FilesystemPackageCacheManager.Builder().build(),
|
||||
new SimpleWorkerContext.SimpleWorkerContextBuilder().fromNothing(),
|
||||
null);
|
||||
for (String src : cliContext.getIgs()) {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package org.hl7.fhir.validation.cli.tasks;
|
||||
|
||||
import org.hl7.fhir.convertors.analytics.PackageVisitor;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.utils.EOperationOutcome;
|
||||
import org.hl7.fhir.utilities.SystemExitManager;
|
||||
import org.hl7.fhir.utilities.TimeTracker;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.json.JsonException;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.PackageServer;
|
||||
import org.hl7.fhir.utilities.settings.FhirSettings;
|
||||
import org.hl7.fhir.validation.cli.model.CliContext;
|
||||
import org.hl7.fhir.validation.cli.utils.Params;
|
||||
import org.hl7.fhir.validation.packages.PackageCacheDownloader;
|
||||
import org.hl7.fhir.validation.special.TxTester;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
|
||||
public class PreloadCacheTask extends StandaloneTask {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "preloadCache";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Pre-load Package Cache";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecuteTask(CliContext cliContext, String[] args) {
|
||||
return Params.hasParam(args, Params.PRELOAD_CACHE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHelp(PrintStream out) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask(CliContext cliContext, String[] args, TimeTracker tt, TimeTracker.Session tts) throws Exception {
|
||||
PackageVisitor pv = new PackageCacheDownloader();
|
||||
pv.visitPackages();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@ public class Display {
|
|||
}
|
||||
|
||||
public static void printCliParamsAndInfo(String[] args) throws IOException {
|
||||
System.out.println(" Paths: Current = " + System.getProperty("user.dir") + ", Package Cache = " + new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER).getFolder());
|
||||
System.out.println(" Paths: Current = " + System.getProperty("user.dir") + ", Package Cache = " + new FilesystemPackageCacheManager.Builder().build().getFolder());
|
||||
System.out.print(" Params:");
|
||||
for (String s : args) {
|
||||
System.out.print(s.contains(" ") ? " \"" + s + "\"" : " " + s);
|
||||
|
|
|
@ -69,6 +69,8 @@ public class Params {
|
|||
public static final String LEFT = "-left";
|
||||
public static final String RIGHT = "-right";
|
||||
public static final String NO_INTERNAL_CACHING = "-no-internal-caching";
|
||||
|
||||
public static final String PRELOAD_CACHE = "-preload-cache";
|
||||
public static final String NO_EXTENSIBLE_BINDING_WARNINGS = "-no-extensible-binding-warnings";
|
||||
public static final String NO_UNICODE_BIDI_CONTROL_CHARS = "-no_unicode_bidi_control_chars";
|
||||
public static final String NO_INVARIANTS = "-no-invariants";
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package org.hl7.fhir.validation.packages;
|
||||
|
||||
import org.hl7.fhir.convertors.analytics.PackageVisitor;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.utils.EOperationOutcome;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.npm.PackageServer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A PackageVisitor that is intended to visit each available package from
|
||||
* https://packages2.fhir.org/packages aka PackageServer.secondaryServer()
|
||||
* <p/>
|
||||
* A useful side effect of this is that it fills the package cache on the disk
|
||||
* with all available packages. Aside from this, it does nothing but write to
|
||||
* console out.
|
||||
* <p/>
|
||||
* It targets the secondary server to avoid loading the primary server.
|
||||
*
|
||||
*/
|
||||
public class PackageCacheDownloader extends PackageVisitor implements PackageVisitor.IPackageVisitorProcessor{
|
||||
|
||||
public PackageCacheDownloader() throws IOException {
|
||||
super();
|
||||
setClientPackageServer(PackageServer.secondaryServer());
|
||||
setCachePackageServers(List.of(PackageServer.secondaryServer()));
|
||||
|
||||
String taskCache = Utilities.path("[tmp]", "package-cache-task");
|
||||
|
||||
setProcessor(this);
|
||||
setCache(taskCache);
|
||||
setOldVersions(true);
|
||||
setCorePackages(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object startPackage(PackageVisitor.PackageContext context) throws FHIRException {
|
||||
System.out.println("Currently loading " + context.getPid());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processResource(PackageVisitor.PackageContext context, Object clientContext, String type, String id, byte[] content) throws FHIRException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishPackage(PackageVisitor.PackageContext context) throws FHIRException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void alreadyVisited(String pid) throws FHIRException {
|
||||
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ public class PackageValidator {
|
|||
}
|
||||
|
||||
private void execute() throws IOException {
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
|
||||
PackageClient pc = new PackageClient(PackageServer.primaryServer());
|
||||
for (PackageInfo t : pc.search(null, null, null, false)) {
|
||||
|
|
|
@ -167,7 +167,7 @@ public class R4R5MapTester implements IValidatorResourceFetcher {
|
|||
log("Load Test Outcomes");
|
||||
JsonObject json = JsonParser.parseObjectFromFile(Utilities.path(src, "input", "_data", "conversions.json"));
|
||||
log("Load R5");
|
||||
pcm = new FilesystemPackageCacheManager(true);
|
||||
pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
context = new SimpleWorkerContextBuilder().withAllowLoadingDuplicates(true).fromPackage(pcm.loadPackage("hl7.fhir.r5.core#current"));
|
||||
log("Load Maps");
|
||||
// context.loadFromPackage(pcm.loadPackage(), null);
|
||||
|
|
|
@ -64,7 +64,6 @@ import org.hl7.fhir.utilities.TextFile;
|
|||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.json.model.*;
|
||||
import org.hl7.fhir.utilities.json.parser.*;
|
||||
import org.hl7.fhir.utilities.npm.CommonPackages;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
|
@ -127,7 +126,7 @@ public class ComparisonTests {
|
|||
if (context == null) {
|
||||
System.out.println("---- Load R5 ----------------------------------------------------------------");
|
||||
context = TestingUtilities.getSharedWorkerContext();
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
NpmPackage npm = pcm.loadPackage("hl7.fhir.us.core#3.1.0");
|
||||
BaseWorkerContext bc = (BaseWorkerContext) context;
|
||||
boolean dupl = bc.isAllowLoadingDuplicates();
|
||||
|
@ -140,7 +139,7 @@ public class ComparisonTests {
|
|||
if (!new File(Utilities.path("[tmp]", "comparison")).exists()) {
|
||||
System.out.println("---- Set up Output ----------------------------------------------------------");
|
||||
Utilities.createDirectory(Utilities.path("[tmp]", "comparison"));
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
NpmPackage npm = pcm.loadPackage(CommonPackages.ID_PUBPACK, CommonPackages.VER_PUBPACK);
|
||||
for (String f : npm.list("other")) {
|
||||
TextFile.streamToFile(npm.load("other", f), Utilities.path("[tmp]", "comparison", f));
|
||||
|
|
|
@ -308,7 +308,7 @@ public class R3R4ConversionTests implements ITransformerServices, IValidatorReso
|
|||
if (contextR3 != null)
|
||||
return;
|
||||
|
||||
pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
R3ToR4Loader ldr = (R3ToR4Loader) new R3ToR4Loader().setPatchUrls(true).setKillPrimitives(true);
|
||||
|
||||
System.out.println("loading R3");
|
||||
|
|
|
@ -87,7 +87,7 @@ public class UtilitiesXTests {
|
|||
if (!fcontexts.containsKey(version)) {
|
||||
FilesystemPackageCacheManager pcm;
|
||||
try {
|
||||
pcm = new FilesystemPackageCacheManager(org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager.FilesystemPackageCacheMode.USER);
|
||||
pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
IWorkerContext fcontext = TestingUtilities.getWorkerContext(pcm.loadPackage(VersionUtilities.packageForVersion(version), version), loaderForVersion(version));
|
||||
fcontext.setUcumService(new UcumEssenceService(UtilitiesXTests.loadTestResourceStream("ucum", "ucum-essence.xml")));
|
||||
fcontext.setExpansionProfile(new Parameters());
|
||||
|
|
|
@ -16,23 +16,7 @@ import org.hl7.fhir.utilities.TimeTracker;
|
|||
import org.hl7.fhir.validation.cli.model.CliContext;
|
||||
import org.hl7.fhir.validation.cli.services.ValidationService;
|
||||
import org.hl7.fhir.validation.cli.services.ValidatorWatchMode;
|
||||
import org.hl7.fhir.validation.cli.tasks.CliTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.CompareTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.CompileTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.ConvertTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.FhirpathTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.InstallTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.LangTransformTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.NarrativeTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.ScanTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.SnapshotTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.SpecialTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.SpreadsheetTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.TestsTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.TransformTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.TxTestsTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.ValidateTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.VersionTask;
|
||||
import org.hl7.fhir.validation.cli.tasks.*;
|
||||
import org.hl7.fhir.validation.cli.utils.Params;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
@ -74,6 +58,12 @@ public class ValidatorCliTests {
|
|||
@Spy
|
||||
SpreadsheetTask spreadsheetTask;
|
||||
|
||||
@Spy
|
||||
PreloadCacheTask preloadCacheTask = new PreloadCacheTask() {
|
||||
@Override
|
||||
public void executeTask(CliContext cliContext, String[] args, TimeTracker tt, TimeTracker.Session tts) {}
|
||||
};
|
||||
|
||||
@Spy
|
||||
TestsTask testsTask = new TestsTask() {
|
||||
@Override
|
||||
|
@ -119,6 +109,7 @@ public class ValidatorCliTests {
|
|||
installTask,
|
||||
langTransformTask,
|
||||
narrativeTask,
|
||||
preloadCacheTask,
|
||||
scanTask,
|
||||
snapshotTask,
|
||||
specialTask,
|
||||
|
@ -304,6 +295,16 @@ public class ValidatorCliTests {
|
|||
Mockito.verify(compareTask).executeTask(same(validationService), same(validationEngine), same(cliContext), eq(args), any(TimeTracker.class), any(TimeTracker.Session.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void preloadCacheTest() throws Exception {
|
||||
final String[] args = new String[]{"-preload-cache"};
|
||||
CliContext cliContext = Params.loadCliContext(args);
|
||||
ValidatorCli cli = mockValidatorCli();
|
||||
cli.readParamsAndExecuteTask(cliContext, args);
|
||||
|
||||
Mockito.verify(preloadCacheTask).executeTask(same(cliContext), eq(args), any(TimeTracker.class), any(TimeTracker.Session.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void txTestsTest() throws Exception {
|
||||
final String[] args = new String[]{"-txTests"};
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
|
|||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||
import org.hl7.fhir.convertors.loaders.loaderR5.R4ToR5Loader;
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
|
@ -39,7 +38,6 @@ import org.hl7.fhir.r5.fhirpath.TypeDetails;
|
|||
import org.hl7.fhir.r5.fhirpath.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r5.fhirpath.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r5.elementmodel.ObjectConverter;
|
||||
import org.hl7.fhir.r5.elementmodel.SHLParser;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.formats.XmlParser;
|
||||
|
@ -445,7 +443,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||
|
||||
|
||||
private NpmPackage loadPackage(String idAndVer) throws IOException {
|
||||
var pcm = new FilesystemPackageCacheManager(true);
|
||||
var pcm = new FilesystemPackageCacheManager.Builder().build();
|
||||
return pcm.loadPackage(idAndVer);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue