Allow suppressing snapshot errors for XIG

This commit is contained in:
Grahame Grieve 2023-09-07 17:05:23 +10:00
parent 8bb908ef5c
commit c270f1761f
4 changed files with 23 additions and 14 deletions

View File

@ -32,7 +32,7 @@ import lombok.With;
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class ProfilePathProcessor {
@Getter
protected final ProfileUtilities profileUtilities;
@ -96,6 +96,7 @@ public class ProfilePathProcessor {
@With
final PathSlicingParams slicing;
private ProfilePathProcessor(
ProfileUtilities profileUtilities
) {
@ -558,7 +559,9 @@ public class ProfilePathProcessor {
ElementDefinition res;
ElementDefinition template = null;
if (diffMatches.get(0).hasType() && "Reference".equals(diffMatches.get(0).getType().get(0).getWorkingCode()) && !profileUtilities.isValidType(diffMatches.get(0).getType().get(0), currentBase)) {
throw new DefinitionException(profileUtilities.getContext().formatMessage(I18nConstants.VALIDATION_VAL_ILLEGAL_TYPE_CONSTRAINT, getUrl(), diffMatches.get(0).getPath(), diffMatches.get(0).getType().get(0), currentBase.typeSummary()));
if (!ProfileUtilities.isSuppressIgnorableExceptions()) {
throw new DefinitionException(profileUtilities.getContext().formatMessage(I18nConstants.VALIDATION_VAL_ILLEGAL_TYPE_CONSTRAINT, getUrl(), diffMatches.get(0).getPath(), diffMatches.get(0).getType().get(0), currentBase.typeSummary()));
}
}
String id = diffMatches.get(0).getId();
String lid = profileUtilities.tail(id);

View File

@ -136,6 +136,9 @@ import org.hl7.fhir.utilities.xml.SchematronWriter.Section;
*/
public class ProfileUtilities extends TranslatingUtilities {
private static boolean suppressIgnorableExceptions;
public class ElementDefinitionCounter {
int countMin = 0;
int countMax = 0;
@ -2886,7 +2889,7 @@ public class ProfileUtilities extends TranslatingUtilities {
}
}
}
if (!ok) {
if (!ok && !isSuppressIgnorableExceptions()) {
throw new DefinitionException(context.formatMessage(I18nConstants.STRUCTUREDEFINITION__AT__ILLEGAL_CONSTRAINED_TYPE__FROM__IN_, purl, derived.getPath(), tDesc, b.toString(), srcSD.getUrl()));
}
}
@ -4467,4 +4470,12 @@ public class ProfileUtilities extends TranslatingUtilities {
return ed.getType().size() == 1 && "Resource".equals(ed.getTypeFirstRep().getCode());
}
public static boolean isSuppressIgnorableExceptions() {
return suppressIgnorableExceptions;
}
public static void setSuppressIgnorableExceptions(boolean suppressIgnorableExceptions) {
ProfileUtilities.suppressIgnorableExceptions = suppressIgnorableExceptions;
}
}

View File

@ -42,7 +42,6 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
private IWorkerContext context;
private boolean suppressDebugMessages;
private boolean ignoreProfileErrors;
private XVerExtensionManager xverManager;
private Map<String, String> oidCache = new HashMap<>();
private List<StructureDefinition> allStructuresList = new ArrayList<StructureDefinition>();
@ -61,14 +60,7 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
public void setSuppressDebugMessages(boolean suppressDebugMessages) {
this.suppressDebugMessages = suppressDebugMessages;
}
public boolean isIgnoreProfileErrors() {
return ignoreProfileErrors;
}
public void setIgnoreProfileErrors(boolean ignoreProfileErrors) {
this.ignoreProfileErrors = ignoreProfileErrors;
}
public String oid2Uri(String oid) {
if (oid != null && oid.startsWith("urn:oid:")) {
oid = oid.substring(8);
@ -291,7 +283,7 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
}
pu.generateSnapshot(sd, p, p.getUrl(), sd.getUserString("webroot"), p.getName());
for (ValidationMessage msg : msgs) {
if ((!ignoreProfileErrors && msg.getLevel() == ValidationMessage.IssueSeverity.ERROR) || msg.getLevel() == ValidationMessage.IssueSeverity.FATAL) {
if ((!ProfileUtilities.isSuppressIgnorableExceptions() && msg.getLevel() == ValidationMessage.IssueSeverity.ERROR) || msg.getLevel() == ValidationMessage.IssueSeverity.FATAL) {
if (!msg.isIgnorableError()) {
throw new DefinitionException(context.formatMessage(I18nConstants.PROFILE___ELEMENT__ERROR_GENERATING_SNAPSHOT_, p.getName(), p.getUrl(), msg.getLocation(), msg.getMessage()));
} else {

View File

@ -14,6 +14,7 @@ import org.apache.commons.lang3.NotImplementedException;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.conformance.profile.ProfileUtilities;
import org.hl7.fhir.r5.context.ContextUtilities;
import org.hl7.fhir.r5.model.Address;
import org.hl7.fhir.r5.model.Annotation;
@ -1054,7 +1055,9 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
if (pe == null) {
if (ed == null) {
if (url != null && url.startsWith("http://hl7.org/fhir") && !url.startsWith("http://hl7.org/fhir/us")) {
throw new DefinitionException("unknown extension "+url);
if (!ProfileUtilities.isSuppressIgnorableExceptions()) {
throw new DefinitionException("unknown extension "+url);
}
}
// System.out.println("unknown extension "+url);
pe = new PropertyWrapperDirect(this.context, new Property(p.getName()+"["+url+"]", p.getTypeCode(), p.getDefinition(), p.getMinCardinality(), p.getMaxCardinality(), ex), null);