From b47edc0109abf5251eeb4ee9b6b53f92e0a880bf Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 23 Sep 2022 09:32:39 -0400 Subject: [PATCH] xig publisher improvements --- .../convertors/analytics/PackageVisitor.java | 41 +++++++++++++++---- .../CapabilityStatementRenderer.java | 4 +- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/analytics/PackageVisitor.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/analytics/PackageVisitor.java index ad445ccf2..9036ce044 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/analytics/PackageVisitor.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/analytics/PackageVisitor.java @@ -116,28 +116,53 @@ public class PackageVisitor { Map cpidMap = getAllCIPackages(); Set cpidSet = new HashSet<>(); System.out.println("Go: "+cpidMap.size()+" current packages"); + int i = 0; for (String s : cpidMap.keySet()) { - processCurrentPackage(s, cpidMap.get(s), cpidSet); + processCurrentPackage(s, cpidMap.get(s), cpidSet, i, cpidMap.size()); + i++; } Set pidList = getAllPackages(); System.out.println("Go: "+pidList.size()+" published packages"); + i = 0; for (String pid : pidList) { if (!cpidSet.contains(pid)) { + cpidSet.add(pid); List vList = listVersions(pid); if (oldVersions) { for (String v : vList) { - processPackage(pid, v); + processPackage(pid, v, i, pidList.size()); } } else if (vList.isEmpty()) { System.out.println("No Packages for "+pid); } else { - processPackage(pid, vList.get(vList.size() - 1)); + processPackage(pid, vList.get(vList.size() - 1), i, pidList.size()); } } - } + i++; + } + JsonObject json = JsonTrackingParser.fetchJson("https://raw.githubusercontent.com/FHIR/ig-registry/master/fhir-ig-list.json"); + i = 0; + List objects = JsonUtilities.objects(json, "guides"); + for (JsonObject o : objects) { + String pid = JsonUtilities.str(o, "npm-name"); + if (pid != null && !cpidSet.contains(pid)) { + cpidSet.add(pid); + List vList = listVersions(pid); + if (oldVersions) { + for (String v : vList) { + processPackage(pid, v, i, objects.size()); + } + } else if (vList.isEmpty()) { + System.out.println("No Packages for "+pid); + } else { + processPackage(pid, vList.get(vList.size() - 1), i, objects.size()); + } + } + i++; + } } - private void processCurrentPackage(String url, String pid, Set cpidSet) { + private void processCurrentPackage(String url, String pid, Set cpidSet, int i, int t) { try { String[] p = url.split("\\/"); String repo = "https://build.fhir.org/ig/"+p[0]+"/"+p[1]; @@ -160,7 +185,7 @@ public class PackageVisitor { } } } - System.out.println("Processed: "+pid+"#current: "+c+" resources"); + System.out.println("Processed: "+pid+"#current: "+c+" resources ("+i+" of "+t+")"); } } catch (Exception e) { System.out.println("Unable to process: "+pid+"#current: "+e.getMessage()); @@ -228,7 +253,7 @@ public class PackageVisitor { } - private void processPackage(String pid, String v) throws IOException { + private void processPackage(String pid, String v, int i, int t) throws IOException { NpmPackage npm = null; String fv = null; try { @@ -252,7 +277,7 @@ public class PackageVisitor { } } } - System.out.println("Processed: "+pid+"#"+v+": "+c+" resources"); + System.out.println("Processed: "+pid+"#"+v+": "+c+" resources ("+i+" of "+t+")"); } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CapabilityStatementRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CapabilityStatementRenderer.java index a197b14f8..1e6b64456 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CapabilityStatementRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CapabilityStatementRenderer.java @@ -41,7 +41,9 @@ public class CapabilityStatementRenderer extends ResourceRenderer { if (conf.getRest().size() > 0) { CapabilityStatementRestComponent rest = conf.getRest().get(0); XhtmlNode t = x.table(null); - addTableRow(t, "Mode", rest.getMode().toString()); + if (rest.hasMode()) { + addTableRow(t, "Mode", rest.getMode().toString()); + } addMarkdown(addTableRow(t, "Description"), rest.getDocumentation()); addTableRow(t, "Transaction", showOp(rest, SystemRestfulInteraction.TRANSACTION));