fix package subsystem for challenge with hl7.fhir.au.base setup
This commit is contained in:
parent
550aeffb9a
commit
da2a59cf1a
|
@ -175,6 +175,7 @@ public class PackageCacheManager {
|
|||
|
||||
private static final String PRIMARY_SERVER = "http://packages.fhir.org";
|
||||
private static final String SECONDARY_SERVER = "http://test.fhir.org/packages";
|
||||
// private static final String SECONDARY_SERVER = "http://local.fhir.org:960/packages";
|
||||
public static final String PACKAGE_REGEX = "^[a-z][a-z0-9\\_\\-]*(\\.[a-z0-9\\_\\-]+)+$";
|
||||
public static final String PACKAGE_VERSION_REGEX = "^[a-z][a-z0-9\\_\\-]*(\\.[a-z0-9\\_\\-]+)+\\#[a-z0-9\\-\\_]+(\\.[a-z0-9\\-\\_]+)*$";
|
||||
private static final String CACHE_VERSION = "3"; // second version - see wiki page
|
||||
|
@ -281,6 +282,12 @@ public class PackageCacheManager {
|
|||
if (res.size() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
// this is driven by HL7 Australia (http://hl7.org.au/fhir/ is the canonical url for the base package, and the root for all the others)
|
||||
for (PackageInfo pi : res) {
|
||||
if (canonical.equals(pi.getCanonical())) {
|
||||
return pi.getId();
|
||||
}
|
||||
}
|
||||
return res.get(0).getId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,16 @@ public class PackageClient {
|
|||
private String fhirVersion;
|
||||
private String description;
|
||||
private String url;
|
||||
public PackageInfo(String id, String version, String fhirVersion, String description, String url) {
|
||||
private String canonical;
|
||||
|
||||
public PackageInfo(String id, String version, String fhirVersion, String description, String url, String canonical) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.version = version;
|
||||
this.fhirVersion = fhirVersion;
|
||||
this.description = description;
|
||||
this.url = url;
|
||||
this.canonical = canonical;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
|
@ -52,9 +55,13 @@ public class PackageClient {
|
|||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getCanonical() {
|
||||
return canonical;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return id+"#"+(version == null ? "??" : version)+(fhirVersion == null ? "": "for FHIR "+fhirVersion)+(url == null ? "" : " @"+url)+(description == null ? "" : " '"+description+"'");
|
||||
return id+"#"+(version == null ? "??" : version)+(fhirVersion == null ? "": " ("+canonical+") for FHIR "+fhirVersion)+(url == null ? "" : " @"+url)+(description == null ? "" : " '"+description+"'");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +104,7 @@ public class PackageClient {
|
|||
if (versions != null) {
|
||||
for (String v : sorted(versions.keySet())) {
|
||||
JsonObject obj = versions.getAsJsonObject(v);
|
||||
res.add(new PackageInfo(JSONUtil.str(obj, "name"), JSONUtil.str(obj, "version"), JSONUtil.str(obj, "FhirVersion"), JSONUtil.str(obj, "description"), JSONUtil.str(obj, "url")));
|
||||
res.add(new PackageInfo(JSONUtil.str(obj, "name"), JSONUtil.str(obj, "version"), JSONUtil.str(obj, "FhirVersion"), JSONUtil.str(obj, "description"), JSONUtil.str(obj, "url"), JSONUtil.str(obj, "canonical")));
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
|
@ -131,7 +138,7 @@ public class PackageClient {
|
|||
JsonArray json = fetchJsonArray(Utilities.pathURL(address, "catalog?")+params.toString());
|
||||
for (JsonElement e : json) {
|
||||
JsonObject obj = (JsonObject) e;
|
||||
res.add(new PackageInfo(JSONUtil.str(obj, "Name"), null, JSONUtil.str(obj, "FhirVersion"), JSONUtil.str(obj, "Description"), null));
|
||||
res.add(new PackageInfo(JSONUtil.str(obj, "Name", "name"), JSONUtil.str(obj, "Version", "version"), JSONUtil.str(obj, "FhirVersion", "fhirVersion"), JSONUtil.str(obj, "Description", "description"), JSONUtil.str(obj, "url"), JSONUtil.str(obj, "canonical")));
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue