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 9122ad261..195dd1b0b 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 @@ -374,13 +374,13 @@ public class NpmPackage { return npm.get("version").getAsString(); else { JsonObject dep = npm.getAsJsonObject("dependencies"); - if (dep == null) - throw new FHIRException("no dependencies found in the Package definition"); - for (Entry e : dep.entrySet()) { - if (Utilities.existsInList(e.getKey(), "hl7.fhir.r2.core", "hl7.fhir.r2b.core", "hl7.fhir.r3.core", "hl7.fhir.r4.core")) - return e.getValue().getAsString(); - if (Utilities.existsInList(e.getKey(), "hl7.fhir.core")) // while all packages are updated - return e.getValue().getAsString(); + if (dep != null) { + for (Entry e : dep.entrySet()) { + if (Utilities.existsInList(e.getKey(), "hl7.fhir.r2.core", "hl7.fhir.r2b.core", "hl7.fhir.r3.core", "hl7.fhir.r4.core")) + return e.getValue().getAsString(); + if (Utilities.existsInList(e.getKey(), "hl7.fhir.core")) // while all packages are updated + return e.getValue().getAsString(); + } } if (npm.has("fhirVersions")) { return npm.getAsJsonArray("fhirVersions").get(0).getAsString(); @@ -408,7 +408,10 @@ public class NpmPackage { } public String type() { - return npm.get("type").getAsString(); + if (npm.has("type")) + return npm.get("type").getAsString(); + else + return null; } public String description() { @@ -563,5 +566,51 @@ public class NpmPackage { } return res; } + + public String homepage() { + if (npm.has("homepage")) + return npm.get("homepage").getAsString(); + else + return null; + } + + public String url() { + if (npm.has("url")) + return npm.get("url").getAsString(); + else + return null; + } + + + public String title() { + if (npm.has("title")) + return npm.get("title").getAsString(); + else + return null; + } + + public String toolsVersion() { + if (npm.has("tools-version")) + return npm.get("tools-version").getAsString(); + else + return null; + } + + public String license() { + if (npm.has("license")) + return npm.get("license").getAsString(); + else + return null; + } + + public Map> getTypes() { + return types; + } + + public Map getUrls() { + return urls; + } + + } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java index 2fba3ece0..8a0e2686e 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java @@ -327,6 +327,8 @@ public class PackageCacheManager { save = checkIniHasMapping("hl7.fhir.uv.phd", "http://hl7.org/fhir/devices", ini) || save; save = checkIniHasMapping("hl7.fhir.uv.vhdir", "http://hl7.org/fhir/ig/vhdir", ini) || save; save = checkIniHasMapping("hl7.fhir.vn.base", "http://hl7.org/fhir/ig/vietnam", ini) || save; + save = checkIniHasMapping("hl7.fhir.uv.bulkdata", "http://hl7.org/fhir/uv/bulkdata", ini) || save; + save = checkIniHasMapping("hl7.fhir.us.bulkdata", "http://hl7.org/fhir/uv/bulkdata", ini) || save; save = checkIniHasMapping("hl7.fhir.vocabpoc", "http://hl7.org/fhir/ig/vocab-poc", ini) || save; return save; } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageHacker.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageHacker.java index c0cbb24d2..7dcf5849b 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageHacker.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageHacker.java @@ -5,8 +5,11 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.Map; +import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; import com.google.gson.GsonBuilder; @@ -22,7 +25,7 @@ import com.google.gson.JsonObject; public class PackageHacker { public static void main(String[] args) throws FileNotFoundException, IOException { - new PackageHacker().edit("C:\\work\\fhir.org\\web-source\\source\\guides\\argonaut\\questionnaire\\package.tgz"); + new PackageHacker().edit("C:\\web\\hl7.org\\fhir\\uv\\pocd\\2018Jan\\package.tgz"); } private void edit(String name) throws FileNotFoundException, IOException { @@ -53,16 +56,39 @@ public class PackageHacker { return new GsonBuilder().setPrettyPrinting().create().toJson(json); } - private void change(JsonObject npm, Map content) { - npm.remove("name"); - npm.addProperty("name", "fhir.argonaut.questionnaire"); -// JsonArray fhirVersions = new JsonArray(); -// fhirVersions.add("1.9.0"); -// npm.add("fhirVersions", fhirVersions); -// JsonObject dependencies = new JsonObject(); -// dependencies.addProperty("hl7.fhir.r3.core", "3.0.2"); -// npm.remove("dependencies"); -// npm.add("dependencies", dependencies); + private void change(JsonObject npm, Map content) throws FileNotFoundException, IOException { +// addContentFrom("C:\\web\\hl7.org\\fhir\\us\\meds", content); + fixNames(content); +// setProperty(npm, "homepage", "http://hl7.org/fhir"); + + } + + private void setProperty(JsonObject npm, String name, String value) { + npm.remove("homepage"); + npm.addProperty("homepage", "http://hl7.org/fhir"); + } + + private void fixNames(Map content) { + List names = new ArrayList<>(); + names.addAll(content.keySet()); + for (String s : names) { + if (s.endsWith("json") && !s.endsWith(".json")) { + String n = s.substring(0, s.length()-4)+".json"; + content.put(n, content.get(s)); + content.remove(s); + } + } + } + + private void addContentFrom(String folder, Map content) throws FileNotFoundException, IOException { + for (File f : new File(folder).listFiles()) { + if (f.getName().endsWith(".json") && !f.getName().endsWith(".canonical.json")) { + String cnt = TextFile.fileToString(f); + if (cnt.contains("\"resourceType\"")) { + content.put("package/"+f.getName(), TextFile.fileToBytes(f)); + } + } + } } }