revert back to Boolean

This commit is contained in:
Bashir Sadjad 2024-09-11 17:36:34 +00:00
parent 875e9e06da
commit f04082119c
2 changed files with 7 additions and 10 deletions

View File

@ -85,9 +85,9 @@ public class Validator {
JsonElement nameJ = viewDefinition.get("name"); JsonElement nameJ = viewDefinition.get("name");
if (nameJ == null) { if (nameJ == null) {
if (!needsName) { if (needsName == null) {
hint(path, viewDefinition, "No name provided. A name is required in many contexts where a ViewDefinition is used"); hint(path, viewDefinition, "No name provided. A name is required in many contexts where a ViewDefinition is used");
} else { } else if (needsName) {
error(path, viewDefinition, "No name provided", IssueType.REQUIRED); error(path, viewDefinition, "No name provided", IssueType.REQUIRED);
} }
} else if (!(nameJ instanceof JsonString)) { } else if (!(nameJ instanceof JsonString)) {
@ -324,9 +324,7 @@ public class Validator {
// ok, name is sorted! // ok, name is sorted!
if (columnName != null) { if (columnName != null) {
column.setUserData("name", columnName); column.setUserData("name", columnName);
// TODO: Fix this collection testing logic as it does not seem to take into account // TODO: Fix this collection testing; it mis-categorizes many singletons as collections.
// the `forEach` context.
//boolean isColl = (td.getCollectionStatus() != CollectionStatus.SINGLETON);
boolean isColl = false; boolean isColl = false;
if (column.has("collection")) { if (column.has("collection")) {
JsonElement collectionJ = column.get("collection"); JsonElement collectionJ = column.get("collection");
@ -340,14 +338,13 @@ public class Validator {
} }
} }
if (isColl) { if (isColl) {
//if (acceptArrays) {
if (td.getCollectionStatus() == CollectionStatus.SINGLETON) { if (td.getCollectionStatus() == CollectionStatus.SINGLETON) {
hint(path, column, "collection is true, but the path statement(s) can only return single values for the column '"+columnName+"'"); hint(path, column, "collection is true, but the path statement(s) can only return single values for the column '"+columnName+"'");
} }
} else { } else {
if (acceptArrays == null) { if (acceptArrays == null) {
warning(path, expression, "The column '"+columnName+"' appears to be a collection based on it's path. Collections are not supported in all execution contexts"); 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 { } else if (!acceptArrays) {
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"); 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) { if (td.getCollectionStatus() != CollectionStatus.SINGLETON) {
@ -384,10 +381,10 @@ public class Validator {
String type = types.iterator().next(); String type = types.iterator().next();
boolean ok = false; boolean ok = false;
if (!isSimpleType(type) && !"null".equals(type)) { if (!isSimpleType(type) && !"null".equals(type)) {
if (acceptComplexTypes) { if (acceptComplexTypes == null) {
warning(path, expression, "The column '"+columnName+"' is a complex type. This is not supported in some Runners"); warning(path, expression, "The column '"+columnName+"' is a complex type. This is not supported in some Runners");
ok = true; ok = true;
} else { } else if (!acceptComplexTypes) {
error(path, expression, "The column '"+columnName+"' is a complex type but this is not allowed in this context", IssueType.BUSINESSRULE); error(path, expression, "The column '"+columnName+"' is a complex type but this is not allowed in this context", IssueType.BUSINESSRULE);
} }
} else { } else {

View File

@ -5754,7 +5754,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} else if ("http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition".equals(element.getProperty().getStructure().getUrl())) { } else if ("http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition".equals(element.getProperty().getStructure().getUrl())) {
if (element.getNativeObject() != null && element.getNativeObject() instanceof JsonObject) { if (element.getNativeObject() != null && element.getNativeObject() instanceof JsonObject) {
JsonObject json = (JsonObject) element.getNativeObject(); JsonObject json = (JsonObject) element.getNativeObject();
Validator sqlv = new Validator(context, fpe, new ArrayList<>(), true, true, false); Validator sqlv = new Validator(context, fpe, new ArrayList<>(), null, null, null);
sqlv.checkViewDefinition(stack.getLiteralPath(), json); sqlv.checkViewDefinition(stack.getLiteralPath(), json);
errors.addAll(sqlv.getIssues()); errors.addAll(sqlv.getIssues());
ok = sqlv.isOk() && ok; ok = sqlv.isOk() && ok;