diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/Storage.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/Storage.java index 41740d108..b66975343 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/Storage.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/Storage.java @@ -3,16 +3,17 @@ package org.hl7.fhir.r5.utils.sql; import java.util.List; import org.hl7.fhir.r5.model.Base; +import org.hl7.fhir.r5.utils.sql.Validator.TrueFalseOrUnknown; public interface Storage { - boolean supportsArrays(); - boolean supportsComplexTypes(); + TrueFalseOrUnknown supportsArrays(); + TrueFalseOrUnknown supportsComplexTypes(); Store createStore(String name, List columns); void addRow(Store store, List cells); void finish(Store store); - boolean needsName(); + TrueFalseOrUnknown needsName(); String getKeyForSourceResource(Base res); String getKeyForTargetResource(Base res); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/StorageJson.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/StorageJson.java index d76404c03..9581118c3 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/StorageJson.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/StorageJson.java @@ -4,6 +4,7 @@ import java.util.List; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.model.Base; +import org.hl7.fhir.r5.utils.sql.Validator.TrueFalseOrUnknown; import org.hl7.fhir.utilities.json.model.JsonArray; import org.hl7.fhir.utilities.json.model.JsonBoolean; import org.hl7.fhir.utilities.json.model.JsonElement; @@ -18,8 +19,8 @@ public class StorageJson implements Storage { private JsonArray rows; @Override - public boolean supportsArrays() { - return true; + public TrueFalseOrUnknown supportsArrays() { + return TrueFalseOrUnknown.TRUE; } @Override @@ -77,13 +78,13 @@ public class StorageJson implements Storage { } @Override - public boolean supportsComplexTypes() { - return true; + public TrueFalseOrUnknown supportsComplexTypes() { + return TrueFalseOrUnknown.TRUE; } @Override - public boolean needsName() { - return false; + public TrueFalseOrUnknown needsName() { + return TrueFalseOrUnknown.FALSE; } @Override diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/StorageSqlite3.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/StorageSqlite3.java index 1a32d9c46..4fddf533d 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/StorageSqlite3.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/StorageSqlite3.java @@ -7,6 +7,7 @@ import java.util.List; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.model.Base; +import org.hl7.fhir.r5.utils.sql.Validator.TrueFalseOrUnknown; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; public class StorageSqlite3 implements Storage { @@ -119,18 +120,18 @@ public class StorageSqlite3 implements Storage { } @Override - public boolean supportsArrays() { - return false; + public TrueFalseOrUnknown supportsArrays() { + return TrueFalseOrUnknown.FALSE; } @Override - public boolean supportsComplexTypes() { - return false; + public TrueFalseOrUnknown supportsComplexTypes() { + return TrueFalseOrUnknown.FALSE; } @Override - public boolean needsName() { - return true; + public TrueFalseOrUnknown needsName() { + return TrueFalseOrUnknown.TRUE; } @Override diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/Validator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/Validator.java index 00c862b5d..13c132962 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/Validator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/sql/Validator.java @@ -32,6 +32,7 @@ import org.hl7.fhir.r5.model.UnsignedIntType; import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.UrlType; import org.hl7.fhir.r5.model.UuidType; +import org.hl7.fhir.r5.utils.sql.Validator.TrueFalseOrUnknown; import org.hl7.fhir.r5.fhirpath.ExpressionNode.CollectionStatus; import org.hl7.fhir.r5.fhirpath.FHIRPathEngine.IssueMessage; import org.hl7.fhir.utilities.Utilities; @@ -49,18 +50,22 @@ import org.hl7.fhir.utilities.validation.ValidationMessage.Source; public class Validator { + public enum TrueFalseOrUnknown { + TRUE, FALSE, UNKNOWN + } + private IWorkerContext context; private FHIRPathEngine fpe; private List prohibitedNames = new ArrayList(); private List issues = new ArrayList(); - private Boolean arrays; - private Boolean complexTypes; - private Boolean needsName; + private TrueFalseOrUnknown arrays; + private TrueFalseOrUnknown complexTypes; + private TrueFalseOrUnknown needsName; private String resourceName; private String name; - public Validator(IWorkerContext context, FHIRPathEngine fpe, List prohibitedNames, Boolean arrays, Boolean complexTypes, Boolean needsName) { + public Validator(IWorkerContext context, FHIRPathEngine fpe, List prohibitedNames, TrueFalseOrUnknown arrays, TrueFalseOrUnknown complexTypes, TrueFalseOrUnknown needsName) { super(); this.context = context; this.fpe = fpe; @@ -82,7 +87,7 @@ public class Validator { if (nameJ == null) { if (needsName == null) { hint(path, viewDefinition, "No name provided. A name is required in many contexts where a ViewDefinition is used"); - } else if (needsName) { + } else if (needsName == TrueFalseOrUnknown.TRUE) { error(path, viewDefinition, "No name provided", IssueType.REQUIRED); } } else if (!(nameJ instanceof JsonString)) { @@ -334,9 +339,9 @@ public class Validator { hint(path, column, "collection is true, but the path statement(s) can only return single values for the column '"+columnName+"'"); } } else { - if (arrays == null) { + if (arrays == TrueFalseOrUnknown.UNKNOWN) { warning(path, expression, "The column '"+columnName+"' appears to be a collection based on it's path. Collections are not supported in all execution contexts"); - } else if (!arrays) { + } else if (arrays == TrueFalseOrUnknown.FALSE) { warning(path, expression, "The column '"+columnName+"' appears to be a collection based on it's path, but this is not allowed in the current execution context"); } if (td.getCollectionStatus() != CollectionStatus.SINGLETON) { @@ -373,9 +378,9 @@ public class Validator { String type = types.iterator().next(); boolean ok = false; if (!isSimpleType(type) && !"null".equals(type)) { - if (complexTypes) { + if (complexTypes == TrueFalseOrUnknown.UNKNOWN) { warning(path, expression, "Column is a complex type. This is not supported in some Runners"); - } else if (!complexTypes) { + } else if (complexTypes == TrueFalseOrUnknown.FALSE) { error(path, expression, "Column is a complex type but this is not allowed in this context", IssueType.BUSINESSRULE); } else { ok = true;