use of org.hl7.fhir.utilities.npm.PackageInfo 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");
}
}
}
use of org.hl7.fhir.utilities.npm.PackageInfo in project org.hl7.fhir.core by hapifhir.
the class PackageVisitor method getAllPackages.
private Set<String> getAllPackages() throws IOException, ParserConfigurationException, SAXException {
Set<String> list = new HashSet<>();
for (PackageInfo i : pc.search(null, null, null, false)) {
list.add(i.getId());
}
JsonObject json = JsonTrackingParser.fetchJson("https://raw.githubusercontent.com/FHIR/ig-registry/master/fhir-ig-list.json");
for (JsonObject ig : JSONUtil.objects(json, "guides")) {
list.add(JSONUtil.str(ig, "npm-name"));
}
json = JsonTrackingParser.fetchJson("https://raw.githubusercontent.com/FHIR/ig-registry/master/package-feeds.json");
for (JsonObject feed : JSONUtil.objects(json, "feeds")) {
processFeed(list, JSONUtil.str(feed, "url"));
}
return list;
}
use of org.hl7.fhir.utilities.npm.PackageInfo in project org.hl7.fhir.core by hapifhir.
the class PackageClient method search.
public List<PackageInfo> search(String name, String canonical, String fhirVersion, boolean preRelease) throws IOException {
CommaSeparatedStringBuilder params = new CommaSeparatedStringBuilder("&");
if (!Utilities.noString(name)) {
params.append("name=" + name);
}
if (!Utilities.noString(canonical)) {
params.append("canonical=" + canonical);
}
if (!Utilities.noString(fhirVersion)) {
params.append("fhirversion=" + fhirVersion);
}
if (preRelease) {
params.append("prerelease=" + preRelease);
}
List<PackageInfo> res = new ArrayList<>();
try {
JsonArray json = fetchJsonArray(Utilities.pathURL(address, "catalog?") + params.toString());
for (JsonElement e : json) {
JsonObject obj = (JsonObject) e;
res.add(new PackageInfo(JSONUtil.str(obj, "Name", "name"), JSONUtil.str(obj, "Version", "version"), JSONUtil.str(obj, "FhirVersion", "fhirVersion"), JSONUtil.str(obj, "Description", "description"), JSONUtil.str(obj, "url"), JSONUtil.str(obj, "canonical"), address));
}
} catch (IOException e1) {
}
return res;
}
use of org.hl7.fhir.utilities.npm.PackageInfo in project org.hl7.fhir.core by hapifhir.
the class CachingPackageClientTests method testVersionsNone.
@Test
public void testVersionsNone() throws IOException {
CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER1);
List<PackageInfo> matches = client.getVersions("Simplifier.Core.STU3X");
Assertions.assertTrue(matches.size() == 0);
}
use of org.hl7.fhir.utilities.npm.PackageInfo in project org.hl7.fhir.core by hapifhir.
the class CachingPackageClientTests method testVersions2.
@Test
public void testVersions2() throws IOException {
CachingPackageClient client = new CachingPackageClient(CachingPackageClientTests.SERVER2);
List<PackageInfo> matches = client.getVersions("Simplifier.Core.STU3");
for (PackageInfo pi : matches) {
System.out.println(pi.toString());
}
Assertions.assertTrue(matches.size() == 0);
}
Aggregations