use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class NpmPackageTests method testSave.
@Test
public void testSave() throws IOException {
NpmPackage npm = NpmPackage.fromPackage(TestingUtilities.loadTestResourceStream("npm", "test.format.old.tgz"));
ByteArrayOutputStream bs = new ByteArrayOutputStream();
npm.save(bs);
npm = NpmPackage.fromPackage(new ByteArrayInputStream(bs.toByteArray()));
checkNpm(npm);
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class NpmPackageTests method testNewFolder.
@Test
public void testNewFolder() throws IOException {
// extract the test
String dst = Utilities.path("[tmp]", "npm", "test.format.new");
Utilities.clearDirectory(dst);
unzip(TestingUtilities.loadTestResourceStream("npm", "test.format.new.zip"), new File(dst));
dst = Utilities.path(dst, "test.format.new");
NpmPackage npm = NpmPackage.fromFolder(dst);
checkNpm(npm);
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class NpmPackageTests method testOldFolder.
@Test
public void testOldFolder() throws IOException {
// extract the test
String dst = Utilities.path("[tmp]", "npm", "test.format.old");
Utilities.clearDirectory(dst);
unzip(TestingUtilities.loadTestResourceStream("npm", "test.format.old.zip"), new File(dst));
dst = Utilities.path(dst, "test.format.old");
NpmPackage npm = NpmPackage.fromFolder(dst);
checkNpm(npm);
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class SimpleWorkerContext method loadFromPackageAndDependenciesInt.
public int loadFromPackageAndDependenciesInt(NpmPackage pi, IContextResourceLoader loader, BasePackageCacheManager pcm, String path) throws FileNotFoundException, IOException, FHIRException {
int t = 0;
for (String e : pi.dependencies()) {
if (!loadedPackages.contains(e) && !VersionUtilities.isCorePackage(e)) {
NpmPackage npm = pcm.loadPackage(e);
if (!VersionUtilities.versionsMatch(version, npm.fhirVersion())) {
System.out.println(formatMessage(I18nConstants.PACKAGE_VERSION_MISMATCH, e, version, npm.fhirVersion(), path));
}
t = t + loadFromPackageAndDependenciesInt(npm, loader.getNewLoader(npm), pcm, path + " -> " + npm.name() + "#" + npm.version());
}
}
t = t + loadFromPackageInt(pi, loader, loader.getTypes());
return t;
}
use of org.hl7.fhir.utilities.npm.NpmPackage in project org.hl7.fhir.core by hapifhir.
the class PackageValidator method execute.
private void execute() throws IOException {
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
CachingPackageClient pc = new CachingPackageClient(PackageClient.PRIMARY_SERVER);
for (PackageInfo t : pc.search(null, null, null, false)) {
System.out.println("Check Package " + t.getId());
List<PackageInfo> vl = pc.getVersions(t.getId());
PackageInfo v = vl.get(vl.size() - 1);
System.out.println(" v" + v.getVersion());
try {
NpmPackage pi = pcm.loadPackage(v.getId(), v.getVersion());
if (VersionUtilities.isR4Ver(pi.fhirVersion()) || VersionUtilities.isR3Ver(pi.fhirVersion()) || VersionUtilities.isR2Ver(pi.fhirVersion())) {
for (String n : pi.list("package")) {
if (n.endsWith(".json") && !n.equals("ig-r4.json")) {
InputStream s = pi.load("package", n);
try {
parseResource(s, pi.fhirVersion());
} catch (Exception e) {
System.out.println(" error parsing " + n + " for " + pi.fhirVersion() + ": " + e.getMessage());
}
}
}
} else {
System.out.println(" Unsupported FHIR version " + pi.fhirVersion());
}
} catch (Exception e) {
System.out.println(" Error - no FHIR version");
}
}
}
Aggregations