Merge pull request #779 from hapifhir/gg-202203-urls

Gg 202203 urls
This commit is contained in:
Grahame Grieve 2022-03-31 09:34:47 +11:00 committed by GitHub
commit 7c8f5a3d8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 32 deletions

View File

@ -10290,9 +10290,9 @@ The primary difference between a medication statement and a medication administr
return FHIRVersion._4_0_1;
if ("4.1.0".equals(codeString))
return FHIRVersion._4_1_0;
if ("4.3.0-snapshot1".equals(codeString))
if ("4.3.0-snapshot1".equalsIgnoreCase(codeString))
return FHIRVersion._4_3_0_SNAPSHOT1;
if ("4.3.0-cibuild".equals(codeString))
if ("4.3.0-cibuild".equalsIgnoreCase(codeString))
return FHIRVersion._4_3_0_CIBUILD;
throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'");
}

View File

@ -2511,19 +2511,19 @@ public class ProfileUtilities extends TranslatingUtilities {
if (webUrl != null) {
// also, must touch up the markdown
if (element.hasDefinition())
element.setDefinition(processRelativeUrls(element.getDefinition(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
element.setDefinition(processRelativeUrls(element.getDefinition(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, null, false));
if (element.hasComment())
element.setComment(processRelativeUrls(element.getComment(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
element.setComment(processRelativeUrls(element.getComment(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, null, false));
if (element.hasRequirements())
element.setRequirements(processRelativeUrls(element.getRequirements(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
element.setRequirements(processRelativeUrls(element.getRequirements(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, null, false));
if (element.hasMeaningWhenMissing())
element.setMeaningWhenMissing(processRelativeUrls(element.getMeaningWhenMissing(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
element.setMeaningWhenMissing(processRelativeUrls(element.getMeaningWhenMissing(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, null, false));
}
}
return element;
}
public static String processRelativeUrls(String markdown, String webUrl, String basePath, List<String> resourceNames, Set<String> filenames, boolean processRelatives) {
public static String processRelativeUrls(String markdown, String webUrl, String basePath, List<String> resourceNames, Set<String> baseFilenames, Set<String> localFilenames, boolean processRelatives) {
if (markdown == null) {
return "";
}
@ -2547,7 +2547,7 @@ public class ProfileUtilities extends TranslatingUtilities {
// This code is trying to guess which relative references are actually to the
// base specification.
//
if (isLikelySourceURLReference(url, resourceNames, filenames)) {
if (isLikelySourceURLReference(url, resourceNames, baseFilenames, localFilenames)) {
b.append("](");
b.append(basePath);
i = i + 1;
@ -2556,7 +2556,7 @@ public class ProfileUtilities extends TranslatingUtilities {
// disabled 7-Dec 2021 GDG - we don't want to fool with relative URLs at all?
// re-enabled 11-Feb 2022 GDG - we do want to do this. At least, $assemble in davinci-dtr, where the markdown comes from the SDC IG, and an SDC local reference must be changed to point to SDC. in this case, it's called when generating snapshots
// added processRelatives parameter to deal with this (well, to try)
if (processRelatives && webUrl != null) {
if (processRelatives && webUrl != null && !issLocalFileName(url, localFilenames)) {
// System.out.println("Making "+url+" relative to '"+webUrl+"'");
b.append(webUrl);
} else {
@ -2577,7 +2577,19 @@ public class ProfileUtilities extends TranslatingUtilities {
}
public static boolean isLikelySourceURLReference(String url, List<String> resourceNames, Set<String> filenames) {
public static boolean issLocalFileName(String url, Set<String> localFilenames) {
if (localFilenames != null) {
for (String n : localFilenames) {
if (url.startsWith(n.toLowerCase())) {
return true;
}
}
}
return false;
}
public static boolean isLikelySourceURLReference(String url, List<String> resourceNames, Set<String> baseFilenames, Set<String> localFilenames) {
if (resourceNames != null) {
for (String n : resourceNames) {
if (url.startsWith(n.toLowerCase()+".html")) {
@ -2588,8 +2600,15 @@ public class ProfileUtilities extends TranslatingUtilities {
}
}
}
if (filenames != null) {
for (String n : filenames) {
if (localFilenames != null) {
for (String n : localFilenames) {
if (url.startsWith(n.toLowerCase())) {
return false;
}
}
}
if (baseFilenames != null) {
for (String n : baseFilenames) {
if (url.startsWith(n.toLowerCase())) {
return true;
}
@ -2822,7 +2841,7 @@ public class ProfileUtilities extends TranslatingUtilities {
String webroot = profile.getUserString("webroot");
if (e.hasDefinition()) {
base.setDefinition(processRelativeUrls(e.getDefinition(), webroot, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
base.setDefinition(processRelativeUrls(e.getDefinition(), webroot, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, null, true));
}
base.setShort(e.getShort());
if (e.hasCommentElement())

View File

@ -307,14 +307,17 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
public void registerResourceFromPackage(CanonicalResourceProxy r, PackageVersion packageInfo) throws FHIRException {
synchronized (lock) {
Map<String, ResourceProxy> map = allResourcesById.get(r.getType());
if (map == null) {
map = new HashMap<String, ResourceProxy>();
allResourcesById.put(r.getType(), map);
}
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
map.put(r.getId(), new ResourceProxy(r));
if (r.getId() != null) {
Map<String, ResourceProxy> map = allResourcesById.get(r.getType());
if (map == null) {
map = new HashMap<String, ResourceProxy>();
allResourcesById.put(r.getType(), map);
}
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
map.put(r.getId(), new ResourceProxy(r));
}
}
String url = r.getUrl();
@ -377,16 +380,19 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
}
public void cacheResourceFromPackage(Resource r, PackageVersion packageInfo) throws FHIRException {
synchronized (lock) {
Map<String, ResourceProxy> map = allResourcesById.get(r.fhirType());
if (map == null) {
map = new HashMap<String, ResourceProxy>();
allResourcesById.put(r.fhirType(), map);
}
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
map.put(r.getId(), new ResourceProxy(r));
} else {
logger.logDebugMessage(LogCategory.PROGRESS,"Ignore "+r.fhirType()+"/"+r.getId()+" from package "+packageInfo.toString());
synchronized (lock) {
if (r.getId() != null) {
Map<String, ResourceProxy> map = allResourcesById.get(r.fhirType());
if (map == null) {
map = new HashMap<String, ResourceProxy>();
allResourcesById.put(r.fhirType(), map);
}
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
map.put(r.getId(), new ResourceProxy(r));
} else {
logger.logDebugMessage(LogCategory.PROGRESS,"Ignore "+r.fhirType()+"/"+r.getId()+" from package "+packageInfo.toString());
}
}
if (r instanceof CodeSystem || r instanceof NamingSystem) {

View File

@ -258,7 +258,11 @@ public class NPMPackageGenerator {
packageManifest = new JsonObject();
packageManifest.addProperty("version", ig.getVersion());
packageManifest.addProperty("fhirVersion", fhirVersion.toString());
JsonArray fv = new JsonArray();
for (String v : fhirVersion) {
fv.add(v);
}
packageManifest.add("fhirVersion", fv);
packageManifest.addProperty("date", dt);
packageManifest.addProperty("name", ig.getPackageId());

View File

@ -706,5 +706,5 @@ TYPE_SPECIFIC_CHECKS_DT_QTY_MAX_VALUE_WRONG_UCUM = The value in the instance ({0
TYPE_SPECIFIC_CHECKS_DT_BASE64_NO_WS_ERROR = Base64 encoded values are not allowed to contain any whitespace (per RFC 4648). Note that non-validating readers are encouraged to accept whitespace anyway
TYPE_SPECIFIC_CHECKS_DT_BASE64_NO_WS_WARNING = Base64 encoded values SHOULD not contain any whitespace (per RFC 4648). Note that non-validating readers are encouraged to accept whitespace anyway
SD_DERIVATION_KIND_MISMATCH = The structure definition constrains a kind of {0}, but has a different kind ({1})
VALUESET_IMPORT_UNION_INTERSECTION = This value set has an include with multiple imported value sets. Per issue https://jira.hl7.org/browse/FHIR-25179, there has been confusion in the past whether these value sets are unioned or intersectioned. If this value set is contained in a package published prior to March 31 2022, it will be treated as a union, otherwise it will be treated as an intersection
VALUESET_IMPORT_UNION_INTERSECTION = This value set has a single include with multiple imported value sets. Per issue https://jira.hl7.org/browse/FHIR-25179, there has been confusion in the past whether these value sets are unioned or intersectioned. If this value set is contained in a package published prior to March 31 2022, it will be treated as a union, otherwise it will be treated as an intersection. If want a union, split the value set imports across multiple includes