Fix issue with collection status of resolve() being wrong
This commit is contained in:
parent
8cc698af5d
commit
45b5631e62
|
@ -668,7 +668,7 @@ public class FHIRPathEngine {
|
||||||
if (sd == null) {
|
if (sd == null) {
|
||||||
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONTEXT, t);
|
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONTEXT, t);
|
||||||
}
|
}
|
||||||
types = new TypeDetails(CollectionStatus.SINGLETON, sd.getUrl());
|
types.addType(sd.getUrl());
|
||||||
} else {
|
} else {
|
||||||
String ctxt = t.substring(0, t.indexOf('.'));
|
String ctxt = t.substring(0, t.indexOf('.'));
|
||||||
StructureDefinition sd = cu.findType(ctxt);
|
StructureDefinition sd = cu.findType(ctxt);
|
||||||
|
@ -680,11 +680,10 @@ public class FHIRPathEngine {
|
||||||
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONTEXT_ELEMENT, t);
|
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONTEXT_ELEMENT, t);
|
||||||
}
|
}
|
||||||
if (ed.fixedType != null) {
|
if (ed.fixedType != null) {
|
||||||
types = new TypeDetails(CollectionStatus.SINGLETON, ed.fixedType);
|
types.addType(ed.fixedType);
|
||||||
} else if (ed.getDefinition().getType().isEmpty() || isAbstractType(ed.getDefinition().getType())) {
|
} else if (ed.getDefinition().getType().isEmpty() || isAbstractType(ed.getDefinition().getType())) {
|
||||||
types = new TypeDetails(CollectionStatus.SINGLETON, sd.getType()+"#"+t);
|
types.addType(sd.getType()+"#"+t);
|
||||||
} else {
|
} else {
|
||||||
types = new TypeDetails(CollectionStatus.SINGLETON);
|
|
||||||
for (TypeRefComponent tt : ed.getDefinition().getType()) {
|
for (TypeRefComponent tt : ed.getDefinition().getType()) {
|
||||||
types.addType(tt.getCode());
|
types.addType(tt.getCode());
|
||||||
}
|
}
|
||||||
|
@ -3545,7 +3544,7 @@ public class FHIRPathEngine {
|
||||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_DateTime);
|
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_DateTime);
|
||||||
case Resolve : {
|
case Resolve : {
|
||||||
checkContextReference(focus, "resolve", exp);
|
checkContextReference(focus, "resolve", exp);
|
||||||
return new TypeDetails(CollectionStatus.ORDERED, "DomainResource");
|
return new TypeDetails(focus.getCollectionStatus(), "Resource");
|
||||||
}
|
}
|
||||||
case Extension : {
|
case Extension : {
|
||||||
checkParamTypes(exp, exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
checkParamTypes(exp, exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||||
|
|
|
@ -865,8 +865,12 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
|
||||||
if (other.location != null) {
|
if (other.location != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (!location.equals(other.location)) {
|
} else {
|
||||||
return false;
|
String l1 = preprocessLocation(location);
|
||||||
|
String l2 = preprocessLocation(other.location);
|
||||||
|
if (!l1.equals(l2)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
if (other.message != null) {
|
if (other.message != null) {
|
||||||
|
@ -890,6 +894,14 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String preprocessLocation(String loc) {
|
||||||
|
// some locations are prefixes with a location but they're not different since the location is fixed where .match is called from
|
||||||
|
if (loc.contains(": ")) {
|
||||||
|
return loc.substring(loc.indexOf(": ")+2);
|
||||||
|
}
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5969,7 +5969,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
if (ed.hasSlicing()) {
|
if (ed.hasSlicing()) {
|
||||||
if (slicer != null && slicer.getPath().equals(ed.getPath())) {
|
if (slicer != null && slicer.getPath().equals(ed.getPath())) {
|
||||||
String errorContext = "profile " + profile.getVersionedUrl();
|
String errorContext = "profile " + profile.getVersionedUrl();
|
||||||
if (!resource.getChildValue(ID).isEmpty()) {
|
if (resource.hasChild(ID) && !resource.getChildValue(ID).isEmpty()) {
|
||||||
errorContext += "; instance " + resource.getChildValue("id");
|
errorContext += "; instance " + resource.getChildValue("id");
|
||||||
}
|
}
|
||||||
throw new DefinitionException(context.formatMessage(I18nConstants.SLICE_ENCOUNTERED_MIDWAY_THROUGH_SET_PATH___ID___, slicer.getPath(), slicer.getId(), errorContext));
|
throw new DefinitionException(context.formatMessage(I18nConstants.SLICE_ENCOUNTERED_MIDWAY_THROUGH_SET_PATH___ID___, slicer.getPath(), slicer.getId(), errorContext));
|
||||||
|
|
|
@ -103,8 +103,8 @@ public class StructureDefinitionValidator extends BaseValidator {
|
||||||
for (ValidationMessage msg : msgs) {
|
for (ValidationMessage msg : msgs) {
|
||||||
// we need to set the location for the context
|
// we need to set the location for the context
|
||||||
String loc = msg.getLocation();
|
String loc = msg.getLocation();
|
||||||
if (loc.contains("#")) {
|
if (loc.startsWith("StructureDefinition.")) {
|
||||||
msg.setLocation(stack.getLiteralPath()+".differential.element.where(path = '"+loc.substring(loc.indexOf("#")+1)+"')");
|
msg.setLocation(stack.getLiteralPath()+loc.substring(loc.indexOf(".")));
|
||||||
} else {
|
} else {
|
||||||
msg.setLocation(stack.getLiteralPath());
|
msg.setLocation(stack.getLiteralPath());
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class SnapShotGenerationXTests {
|
||||||
sort = "true".equals(test.getAttribute("sort"));
|
sort = "true".equals(test.getAttribute("sort"));
|
||||||
fail = "true".equals(test.getAttribute("fail"));
|
fail = "true".equals(test.getAttribute("fail"));
|
||||||
newSliceProcessing = !"false".equals(test.getAttribute("new-slice-processing"));
|
newSliceProcessing = !"false".equals(test.getAttribute("new-slice-processing"));
|
||||||
debug = false; // "true".equals(test.getAttribute("debug"));
|
debug = "true".equals(test.getAttribute("debug"));
|
||||||
|
|
||||||
id = test.getAttribute("id");
|
id = test.getAttribute("id");
|
||||||
include = test.getAttribute("include");
|
include = test.getAttribute("include");
|
||||||
|
@ -510,7 +510,7 @@ public class SnapShotGenerationXTests {
|
||||||
pu.setAllowUnknownProfile(AllowUnknownProfile.ALL_TYPES);
|
pu.setAllowUnknownProfile(AllowUnknownProfile.ALL_TYPES);
|
||||||
if (test.isSort()) {
|
if (test.isSort()) {
|
||||||
List<String> errors = new ArrayList<String>();
|
List<String> errors = new ArrayList<String>();
|
||||||
int lastCount = output.getDifferential().getElement().size();
|
// int lastCount = output.getDifferential().getElement().size();
|
||||||
pu.sortDifferential(base, output, test.getSource().getName(), errors, false);
|
pu.sortDifferential(base, output, test.getSource().getName(), errors, false);
|
||||||
if (errors.size() > 0)
|
if (errors.size() > 0)
|
||||||
throw new FHIRException("Sort failed: " + errors.toString());
|
throw new FHIRException("Sort failed: " + errors.toString());
|
||||||
|
|
Loading…
Reference in New Issue