From f008d6050f24d5d2b5d66e4428fa7c83740dcfcf Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 5 Dec 2019 16:59:09 +1100 Subject: [PATCH] Add debugging code --- .../hl7/fhir/utilities/cache/NpmPackage.java | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java index 4648ca4dd..0bd76d978 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java @@ -157,6 +157,10 @@ public class NpmPackage { } + public String dump() { + return name + " ("+ (folder == null ? "null" : folder.toString())+") | "+Boolean.toString(index != null)+" | "+content.size()+" | "+types.size(); + } + } private String path; @@ -484,13 +488,15 @@ public class NpmPackage { if (npm.has("fhirVersions")) { return npm.getAsJsonArray("fhirVersions").get(0).getAsString(); } - // legacy simplifier support: - if (dep.has("simplifier.core.r4")) - return "4.0"; - if (dep.has("simplifier.core.r3")) - return "3.0"; - if (dep.has("simplifier.core.r2")) - return "2.0"; + if (dep != null) { + // legacy simplifier support: + if (dep.has("simplifier.core.r4")) + return "4.0"; + if (dep.has("simplifier.core.r3")) + return "3.0"; + if (dep.has("simplifier.core.r2")) + return "2.0"; + } throw new FHIRException("no core dependency or FHIR Version found in the Package definition"); } } @@ -731,5 +737,22 @@ public class NpmPackage { // FileUtils.copyDirectory(new File(path), new File(dir)); } } + + public void debugDump(String purpose) { + System.out.println("Debug Dump of Package for '"+purpose+"'. Path = "+path); + System.out.println(" npm = "+name()+"#"+version()+", canonical = "+canonical()); + System.out.println(" folders = "+folders.size()); + for (String s : sorted(folders.keySet())) { + NpmPackageFolder folder = folders.get(s); + System.out.println(" "+folder.dump()); + } + } + + private List sorted(Set keys) { + List res = new ArrayList(); + res.addAll(keys); + Collections.sort(res); + return res ; + } }