Release new version

This commit is contained in:
Grahame Grieve 2019-11-29 18:14:33 +11:00
parent 4a282a3d66
commit fe9dc1919b
13 changed files with 105 additions and 19 deletions

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>4.1.8-SNAPSHOT</version> <version>4.1.9-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>4.1.8-SNAPSHOT</version> <version>4.1.9-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>4.1.8-SNAPSHOT</version> <version>4.1.9-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>4.1.8-SNAPSHOT</version> <version>4.1.9-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>4.1.8-SNAPSHOT</version> <version>4.1.9-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>4.1.8-SNAPSHOT</version> <version>4.1.9-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>4.1.8-SNAPSHOT</version> <version>4.1.9-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -337,7 +337,7 @@ public class NpmPackage {
if (content.containsKey(folder+"/"+file)) { if (content.containsKey(folder+"/"+file)) {
return new ByteArrayInputStream(content.get(folder+"/"+file)); return new ByteArrayInputStream(content.get(folder+"/"+file));
} else if (content.containsKey("package/"+folder+"/"+file)) { } else if (content.containsKey("package/"+folder+"/"+file)) {
return new ByteArrayInputStream(content.get(folder+"/"+file)); return new ByteArrayInputStream(content.get("package/"+folder+"/"+file));
} else { } else {
File f = new File(Utilities.path(path, folder, file)); File f = new File(Utilities.path(path, folder, file));
if (f.exists()) if (f.exists())
@ -463,7 +463,7 @@ public class NpmPackage {
public boolean hasFile(String folder, String name) throws IOException { public boolean hasFile(String folder, String name) throws IOException {
String file = folder+"/"+name; String file = folder+"/"+name;
return content.containsKey(file); return content.containsKey(file) || content.containsKey("package/"+file) ;
} }
public InputStream loadResource(String type, String id) throws IOException { public InputStream loadResource(String type, String id) throws IOException {

View File

@ -12,12 +12,27 @@ import java.util.Map.Entry;
import org.hl7.fhir.utilities.CSVWriter; import org.hl7.fhir.utilities.CSVWriter;
import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.cache.PackageScanner.ResourceInfo;
import org.hl7.fhir.utilities.json.JsonTrackingParser;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
public class PackageScanner { public class PackageScanner {
public class ResourceInfo {
private String filenameRoot;
private String htmlName;
private String id;
public ResourceInfo(String filename, String id) {
this.filenameRoot = Utilities.changeFileExt(filename, "");
this.id = id;
}
}
public static void main(String[] args) throws FileNotFoundException, IOException { public static void main(String[] args) throws FileNotFoundException, IOException {
new PackageScanner().scan(new File("C:\\web\\hl7.org\\fhir"), "c:\\temp\\package-scan.csv", "http://hl7.org/fhir"); new PackageScanner().scan(new File("C:\\web\\hl7.org\\fhir"), "c:\\temp\\package-scan.csv", "http://hl7.org/fhir");
} }
@ -25,7 +40,7 @@ public class PackageScanner {
private void scan(File folder, String dest, String url) throws IOException { private void scan(File folder, String dest, String url) throws IOException {
CSVWriter csv = new CSVWriter(new FileOutputStream(dest)); CSVWriter csv = new CSVWriter(new FileOutputStream(dest));
csv.line("path", "error", "name", "version", "fhir-version", "fhir-version-explicit", "canonical", "homepage", csv.line("path", "error", "name", "version", "fhir-version", "fhir-version-explicit", "canonical", "homepage",
"url", "type", "#types", "#urls", "dependencies"); "url", "type", "#types", "#urls", "dependencies", "spec.internals");
scanFolders(folder, csv, folder.getAbsolutePath(), url); scanFolders(folder, csv, folder.getAbsolutePath(), url);
csv.close(); csv.close();
System.out.println("done"); System.out.println("done");
@ -47,7 +62,7 @@ public class PackageScanner {
NpmPackage npm = NpmPackage.fromPackage(new FileInputStream(file)); NpmPackage npm = NpmPackage.fromPackage(new FileInputStream(file));
fix(npm, file, root, url); fix(npm, file, root, url);
csv.line(file.getAbsolutePath(), "", npm.name(), npm.version(), npm.fhirVersion(), npm.fhirVersionList(), npm.canonical(), npm.homepage(), csv.line(file.getAbsolutePath(), "", npm.name(), npm.version(), npm.fhirVersion(), npm.fhirVersionList(), npm.canonical(), npm.homepage(),
npm.url(), npm.type(), Integer.toString(npm.getTypes().size()), Integer.toString(npm.getUrls().size()), npm.dependencySummary()); npm.url(), npm.type(), Integer.toString(npm.getTypes().size()), Integer.toString(npm.getUrls().size()), npm.dependencySummary(), Boolean.toString(npm.hasFile("other", "spec.internals")));
} catch (Exception e) { } catch (Exception e) {
try { try {
csv.line(file.getAbsolutePath(), e.getMessage() == null ? "NPE" : e.getMessage()); csv.line(file.getAbsolutePath(), e.getMessage() == null ? "NPE" : e.getMessage());
@ -55,8 +70,6 @@ public class PackageScanner {
e1.printStackTrace(); e1.printStackTrace();
} }
} }
} }
private void fix(NpmPackage npm, File file, String root, String url) throws FileNotFoundException, IOException { private void fix(NpmPackage npm, File file, String root, String url) throws FileNotFoundException, IOException {
@ -109,6 +122,10 @@ public class PackageScanner {
} }
} }
} }
if (!npm.hasFile("other", "spec.internals") && !file.getName().startsWith("hl7.fhir.r")) {
save = true;
npm.getContent().put("package/other/spec.internals", buildSpecInternals(npm.canonical(), Utilities.getDirectoryForFile(file.getAbsolutePath())));
}
// if (npm.url() == null || !npm.url().equals(u)) { // if (npm.url() == null || !npm.url().equals(u)) {
// npm.getNpm().remove("url"); // npm.getNpm().remove("url");
// npm.getNpm().addProperty("url", u); // npm.getNpm().addProperty("url", u);
@ -129,5 +146,74 @@ public class PackageScanner {
npm.save(new FileOutputStream(file)); npm.save(new FileOutputStream(file));
} }
} }
private byte[] buildSpecInternals(String canonical, String dir) throws FileNotFoundException, IOException {
// the spec internals file contains 2 important things: a map from canonical URL to html path
// and a list of html target files
List<ResourceInfo> rl = makeResList(dir);
List<String> targets = new ArrayList<>();
for (File f : new File(dir).listFiles()) {
if (f.getName().endsWith(".html")) {
targets.add(f.getName());
String src = TextFile.fileToString(f);
for (ResourceInfo r : rl) {
if (r.htmlName == null) {
if (src.contains(r.filenameRoot+".json")) {
r.htmlName = f.getName();
}
}
}
}
}
StringBuilder b = new StringBuilder();
b.append("{\r\n");
b.append(" \"paths\": {");
boolean first = true;
for (ResourceInfo r : rl) {
String link = r.htmlName;
if (link == null) {
System.out.println("No link found for "+r.id);
} else {
if (first) first = false; else b.append(",");
b.append("\r\n \"");
b.append(Utilities.pathURL(canonical, r.id));
b.append("\": \"");
if (link.contains(".json.html") && new File(Utilities.path(dir,link. replace(".json", ""))).exists()) {
link = link.replace(".json", "");
}
b.append(link);
b.append("\"");
}
}
b.append("\r\n },\r\n");
b.append(" \"targets\": [");
first = true;
for (String s : targets) {
if (first) first = false; else b.append(",");
b.append("\r\n \"");
b.append(s);
b.append("\"");
}
b.append(" ]\r\n");
b.append("}\r\n");
return TextFile.stringToBytes(b.toString(), false);
}
private List<ResourceInfo> makeResList(String dir) {
List<ResourceInfo> rl = new ArrayList<>();
for (File f : new File(dir).listFiles()) {
if (f.getName().endsWith(".json") && !f.getName().endsWith(".canonical.json")) {
try {
JsonObject obj = JsonTrackingParser.parseJson(f);
if (obj.has("resourceType") && obj.has("id")) {
rl.add(new ResourceInfo(f.getName(), obj.get("resourceType").getAsString() +"/"+ obj.get("id").getAsString()));
}
} catch (IOException e) {
}
}
}
return rl;
}
} }

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>4.1.8-SNAPSHOT</version> <version>4.1.9-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>4.1.8-SNAPSHOT</version> <version>4.1.9-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -13,11 +13,11 @@
each other. It is fine to bump the point version of this POM without affecting each other. It is fine to bump the point version of this POM without affecting
HAPI FHIR. HAPI FHIR.
--> -->
<version>4.1.8-SNAPSHOT</version> <version>4.1.9-SNAPSHOT</version>
<properties> <properties>
<hapi_fhir_version>4.1.0</hapi_fhir_version> <hapi_fhir_version>4.1.0</hapi_fhir_version>
<validator_test_case_version>1.0.7-SNAPSHOT</validator_test_case_version> <validator_test_case_version>1.0.8-SNAPSHOT</validator_test_case_version>
</properties> </properties>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>

View File

@ -1,7 +1,7 @@
@echo off @echo off
set oldver=4.1.7 set oldver=4.1.8
set newver=4.1.8 set newver=4.1.9
echo .. echo ..
echo ===================================================================== echo =====================================================================