rename package cache operations for clarity + upgrade for version release

This commit is contained in:
Grahame Grieve 2019-02-01 06:09:03 +11:00
parent 742dac277a
commit 364ed14c2a
13 changed files with 49 additions and 29 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>3.7.1-SNAPSHOT</version> <version>3.7.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -383,7 +383,7 @@ public class ExtensionDefinitionGenerator {
private List<StructureDefinition> loadSource() throws IOException, FHIRException { private List<StructureDefinition> loadSource() throws IOException, FHIRException {
List<StructureDefinition> list = new ArrayList<>(); List<StructureDefinition> list = new ArrayList<>();
PackageCacheManager pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION); PackageCacheManager pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
NpmPackage npm = pcm.loadPackageCache("hl7.fhir.core", sourceVersion.toCode()); NpmPackage npm = pcm.loadPackage("hl7.fhir.core", sourceVersion.toCode());
if (sourceVersion == FHIRVersion._4_0_0) if (sourceVersion == FHIRVersion._4_0_0)
context = SimpleWorkerContext.fromPackage(npm); context = SimpleWorkerContext.fromPackage(npm);
else if (sourceVersion == FHIRVersion._3_0_1) else if (sourceVersion == FHIRVersion._3_0_1)

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>3.7.1-SNAPSHOT</version> <version>3.7.2-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>3.7.1-SNAPSHOT</version> <version>3.7.2-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>3.7.1-SNAPSHOT</version> <version>3.7.2-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>3.7.1-SNAPSHOT</version> <version>3.7.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -66,7 +66,7 @@ public class TestingUtilities {
PackageCacheManager pcm; PackageCacheManager pcm;
try { try {
pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION); pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackageCache("hl7.fhir.core", "4.0.0")); fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.core", "4.0.0"));
fcontext.setUcumService(new UcumEssenceService(TestingUtilities.resourceNameToFile("ucum", "ucum-essence.xml"))); fcontext.setUcumService(new UcumEssenceService(TestingUtilities.resourceNameToFile("ucum", "ucum-essence.xml")));
fcontext.setExpansionProfile(new Parameters()); fcontext.setExpansionProfile(new Parameters());
} catch (Exception e) { } catch (Exception e) {

View File

@ -26,8 +26,8 @@ public class CDARoundTripTests {
public void setUp() throws Exception { public void setUp() throws Exception {
context = new SimpleWorkerContext(); context = new SimpleWorkerContext();
PackageCacheManager pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION); PackageCacheManager pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
context.loadFromPackage(pcm.loadPackageCacheLatest("hl7.fhir.core"), null, "StructureDefinition"); context.loadFromPackage(pcm.loadPackage("hl7.fhir.core"), null, "StructureDefinition");
context.loadFromPackage(pcm.loadPackageCacheLatest("hl7.fhir.cda"), null, "StructureDefinition"); context.loadFromPackage(pcm.loadPackage("hl7.fhir.cda"), null, "StructureDefinition");
} }
@Test @Test

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>3.7.1-SNAPSHOT</version> <version>3.7.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -162,7 +162,7 @@ public class PackageCacheManager {
boolean del = true; boolean del = true;
NpmPackage pck; NpmPackage pck;
try { try {
pck = resolvePackage(id, ver, "xx"); pck = loadPackageFromCacheOnly(id, ver);
if (pck.getNpm().has("tools-version")) { if (pck.getNpm().has("tools-version")) {
del = pck.getNpm().get("tools-version").getAsInt() < minVer; del = pck.getNpm().get("tools-version").getAsInt() < minVer;
} }
@ -247,7 +247,13 @@ public class PackageCacheManager {
return names; return names;
} }
public NpmPackage loadPackageCacheLatest(String id) throws IOException { /**
* get the latest version of the package from what is in the cache
* @param id
* @return
* @throws IOException
*/
public NpmPackage loadPackageFromCacheOnly(String id) throws IOException {
String match = null; String match = null;
List<String> l = sorted(new File(cacheFolder).list()); List<String> l = sorted(new File(cacheFolder).list());
for (int i = l.size()-1; i >= 0; i--) { for (int i = l.size()-1; i >= 0; i--) {
@ -259,7 +265,17 @@ public class PackageCacheManager {
return null; return null;
} }
public NpmPackage loadPackageCache(String id, String version) throws IOException { /**
* Load the identified package from the cache - it it exists
*
* This is for special purpose only. Generally, use the loadPackage method
*
* @param id
* @param version
* @return
* @throws IOException
*/
public NpmPackage loadPackageFromCacheOnly(String id, String version) throws IOException {
for (NpmPackage p : temporaryPackages) { for (NpmPackage p : temporaryPackages) {
if (p.name().equals(id) && ("current".equals(version) || "dev".equals(version) || p.version().equals(version))) if (p.name().equals(id) && ("current".equals(version) || "dev".equals(version) || p.version().equals(version)))
return p; return p;
@ -271,7 +287,7 @@ public class PackageCacheManager {
} }
} }
if ("dev".equals(version)) if ("dev".equals(version))
return loadPackageCache(id, "current"); return loadPackageFromCacheOnly(id, "current");
else else
return null; return null;
} }
@ -515,13 +531,17 @@ public class PackageCacheManager {
return false; return false;
} }
public NpmPackage resolvePackage(String id, String v, String currentVersion) throws FHIRException, IOException { public NpmPackage loadPackage(String id) throws FHIRException, IOException {
NpmPackage p = loadPackageCache(id, v); throw new Error("Not done yet");
}
public NpmPackage loadPackage(String id, String v) throws FHIRException, IOException {
NpmPackage p = loadPackageFromCacheOnly(id, v);
if (p != null) if (p != null)
return p; return p;
if ("dev".equals(v)) { if ("dev".equals(v)) {
p = loadPackageCache(id, "current"); p = loadPackageFromCacheOnly(id, "current");
if (p != null) if (p != null)
return p; return p;
v = "current"; v = "current";
@ -560,13 +580,13 @@ public class PackageCacheManager {
return addPackageToCache(id, v, stream); return addPackageToCache(id, v, stream);
} }
} }
// special case: current version // // special case: current version
if (id.equals("hl7.fhir.core") && v.equals(currentVersion)) { // if (id.equals("hl7.fhir.core") && v.equals(currentVersion)) {
InputStream stream = fetchFromUrlSpecific(Utilities.pathURL("http://build.fhir.org", "package.tgz"), true); // InputStream stream = fetchFromUrlSpecific(Utilities.pathURL("http://build.fhir.org", "package.tgz"), true);
if (stream == null) // if (stream == null)
throw new FHIRException("Unable to find the package source for '"+id+"#"+v+"' at "+Utilities.pathURL("http://build.fhir.org", "package.tgz")); // throw new FHIRException("Unable to find the package source for '"+id+"#"+v+"' at "+Utilities.pathURL("http://build.fhir.org", "package.tgz"));
return addPackageToCache(id, v, stream); // return addPackageToCache(id, v, stream);
} // }
throw new FHIRException("Unable to resolve version "+v+" for package "+id); throw new FHIRException("Unable to resolve version "+v+" for package "+id);
} }
} }

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>3.7.1-SNAPSHOT</version> <version>3.7.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -540,11 +540,11 @@ public class ValidationEngine {
} }
NpmPackage pi = null; NpmPackage pi = null;
if (version == null) { if (version == null) {
pi = pcm.loadPackageCacheLatest(id); pi = pcm.loadPackageFromCacheOnly(id);
if (pi != null) if (pi != null)
log(" ... Using version "+pi.version()); log(" ... Using version "+pi.version());
} else } else
pi = pcm.loadPackageCache(id, version); pi = pcm.loadPackageFromCacheOnly(id, version);
if (pi == null) { if (pi == null) {
return resolvePackage(id, version); return resolvePackage(id, version);
} else } else
@ -557,7 +557,7 @@ public class ValidationEngine {
} catch (IOException e) { } catch (IOException e) {
log("Unable to connect to build.fhir.org to check on packages"); log("Unable to connect to build.fhir.org to check on packages");
} }
NpmPackage pi = pcm.resolvePackage(id, v, Constants.VERSION); NpmPackage pi = pcm.loadPackage(id, v);
if (pi != null && v == null) if (pi != null && v == null)
log(" ... Using version "+pi.version()); log(" ... Using version "+pi.version());
return loadPackage(pi); return loadPackage(pi);

View File

@ -13,7 +13,7 @@
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>3.7.1-SNAPSHOT</version> <version>3.7.2-SNAPSHOT</version>
<properties> <properties>
<hapi_fhir_version>3.7.0-SNAPSHOT</hapi_fhir_version> <hapi_fhir_version>3.7.0-SNAPSHOT</hapi_fhir_version>