rework xig into 3 steps

This commit is contained in:
Grahame Grieve 2023-10-04 03:16:07 +03:00
parent fb7ad19218
commit 64403db109
2 changed files with 81 additions and 65 deletions

View File

@ -72,6 +72,7 @@ public class PackageVisitor {
private FilesystemPackageCacheManager pcm; private FilesystemPackageCacheManager pcm;
private PackageClient pc; private PackageClient pc;
private String cache; private String cache;
private int step;
public List<String> getResourceTypes() { public List<String> getResourceTypes() {
return resourceTypes; return resourceTypes;
@ -164,6 +165,7 @@ public class PackageVisitor {
if (pid != null) { if (pid != null) {
if (!cpidSet.contains(pid)) { if (!cpidSet.contains(pid)) {
cpidSet.add(pid); cpidSet.add(pid);
if (step == 0 || step == 3) {
List<String> vList = listVersions(pid); List<String> vList = listVersions(pid);
if (oldVersions) { if (oldVersions) {
for (String v : vList) { for (String v : vList) {
@ -174,12 +176,15 @@ public class PackageVisitor {
} else { } else {
processPackage(pid, vList.get(vList.size() - 1), i, pidList.size()); processPackage(pid, vList.get(vList.size() - 1), i, pidList.size());
} }
}
} else { } else {
processor.alreadyVisited(pid); processor.alreadyVisited(pid);
} }
i++; i++;
} }
} }
if (step == 0 || step == 3) {
JsonObject json = JsonParser.parseObjectFromUrl("https://raw.githubusercontent.com/FHIR/ig-registry/master/fhir-ig-list.json"); JsonObject json = JsonParser.parseObjectFromUrl("https://raw.githubusercontent.com/FHIR/ig-registry/master/fhir-ig-list.json");
i = 0; i = 0;
List<JsonObject> objects = json.getJsonObjects("guides"); List<JsonObject> objects = json.getJsonObjects("guides");
@ -201,9 +206,12 @@ public class PackageVisitor {
i++; i++;
} }
} }
}
private void processCurrentPackage(String url, String pid, Set<String> cpidSet, int i, int t) { private void processCurrentPackage(String url, String pid, Set<String> cpidSet, int i, int t) {
try { try {
cpidSet.add(pid);
if (step == 0 || (step == 1 && i < t/2) || (step == 2 && i >= t/2)) {
long ms1 = System.currentTimeMillis(); long ms1 = System.currentTimeMillis();
String[] p = url.split("\\/"); String[] p = url.split("\\/");
String repo = "https://build.fhir.org/ig/"+p[0]+"/"+p[1]; String repo = "https://build.fhir.org/ig/"+p[0]+"/"+p[1];
@ -217,7 +225,6 @@ public class PackageVisitor {
} }
NpmPackage npm = NpmPackage.fromPackage(new FileInputStream(co)); NpmPackage npm = NpmPackage.fromPackage(new FileInputStream(co));
String fv = npm.fhirVersion(); String fv = npm.fhirVersion();
cpidSet.add(pid);
long ms2 = System.currentTimeMillis(); long ms2 = System.currentTimeMillis();
if (corePackages || !corePackage(npm)) { if (corePackages || !corePackage(npm)) {
@ -252,6 +259,7 @@ public class PackageVisitor {
System.out.println("Ignored: "+pid+"#current: no version"); System.out.println("Ignored: "+pid+"#current: no version");
} }
} }
}
} catch (Exception e) { } catch (Exception e) {
System.out.println("Unable to process: "+pid+"#current: "+e.getMessage()); System.out.println("Unable to process: "+pid+"#current: "+e.getMessage());
} }
@ -370,4 +378,12 @@ public class PackageVisitor {
npm.name().startsWith("hl7.fhir.r5.")); npm.name().startsWith("hl7.fhir.r5."));
} }
public int getStep() {
return step;
}
public void setStep(int step) {
this.step = step;
}
} }

View File

@ -4507,7 +4507,7 @@ public class ProfileUtilities extends TranslatingUtilities {
public static boolean isModifierExtension(StructureDefinition sd) { public static boolean isModifierExtension(StructureDefinition sd) {
ElementDefinition defn = sd.getSnapshot().getElementByPath("Extension"); ElementDefinition defn = sd.getSnapshot().getElementByPath("Extension");
return defn.getIsModifier(); return defn != null && defn.getIsModifier();
} }
public boolean isForPublication() { public boolean isForPublication() {