fix to package infrastructure
This commit is contained in:
parent
0e1674d712
commit
e5986a31fb
|
@ -374,14 +374,14 @@ 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");
|
||||
if (dep != null) {
|
||||
for (Entry<String, JsonElement> 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() {
|
||||
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<String, List<String>> getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public Map<String, String> getUrls() {
|
||||
return urls;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<String, byte[]> 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<String, byte[]> 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<String, byte[]> content) {
|
||||
List<String> 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<String, byte[]> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue