clean up bug checking data types in ContextUtilities
This commit is contained in:
parent
f1c56ca0d6
commit
c13f24ef4c
|
@ -439,6 +439,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
public String url;
|
||||
}
|
||||
boolean isDatatype(String typeSimple);
|
||||
boolean isPrimitiveType(String typeSimple);
|
||||
boolean isResource(String typeSimple);
|
||||
boolean hasLinkFor(String typeSimple);
|
||||
String getLinkFor(String corePath, String typeSimple);
|
||||
|
@ -3291,10 +3292,10 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
}
|
||||
if (dest.hasFixed()) {
|
||||
checkTypeOk(dest, dest.getFixed().fhirType(), srcSD);
|
||||
checkTypeOk(dest, dest.getFixed().fhirType(), srcSD, "fixed");
|
||||
}
|
||||
if (dest.hasPattern()) {
|
||||
checkTypeOk(dest, dest.getPattern().fhirType(), srcSD);
|
||||
checkTypeOk(dest, dest.getPattern().fhirType(), srcSD, "pattern");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3359,7 +3360,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
|
||||
|
||||
public void checkTypeOk(ElementDefinition dest, String ft, StructureDefinition sd) {
|
||||
public void checkTypeOk(ElementDefinition dest, String ft, StructureDefinition sd, String fieldName) {
|
||||
boolean ok = false;
|
||||
Set<String> types = new HashSet<>();
|
||||
if (dest.getPath().contains(".")) {
|
||||
|
@ -3375,7 +3376,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
|
||||
}
|
||||
if (!ok) {
|
||||
messages.add(new ValidationMessage(Source.InstanceValidator, IssueType.CONFLICT, dest.getId(), "The fixed value has type '"+ft+"' which is not valid (valid "+Utilities.pluralize("type", dest.getType().size())+": "+types.toString()+")", IssueSeverity.ERROR));
|
||||
messages.add(new ValidationMessage(Source.InstanceValidator, IssueType.CONFLICT, dest.getId(), "The "+fieldName+" value has type '"+ft+"' which is not valid (valid "+Utilities.pluralize("type", dest.getType().size())+": "+types.toString()+")", IssueSeverity.ERROR));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -282,11 +282,17 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isDatatype(String type) {
|
||||
public boolean isPrimitiveType(String type) {
|
||||
StructureDefinition sd = context.fetchTypeDefinition(type);
|
||||
return sd != null && sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDatatype(String type) {
|
||||
StructureDefinition sd = context.fetchTypeDefinition(type);
|
||||
return sd != null && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE || sd.getKind() == StructureDefinitionKind.COMPLEXTYPE) && sd.getDerivation() == TypeDerivationRule.SPECIALIZATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResource(String t) {
|
||||
StructureDefinition sd;
|
||||
|
|
|
@ -59,6 +59,10 @@ public class NarrativeGenerationTests {
|
|||
public boolean isDatatype(String typeSimple) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@Override
|
||||
public boolean isPrimitiveType(String typeSimple) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResource(String typeSimple) {
|
||||
|
|
|
@ -215,6 +215,13 @@ public class SnapShotGenerationTests {
|
|||
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE || sd.getKind() == StructureDefinitionKind.COMPLEXTYPE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPrimitiveType(String name) {
|
||||
StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchTypeDefinition(name);
|
||||
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResource(String typeSimple) {
|
||||
StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchTypeDefinition(typeSimple);
|
||||
|
|
|
@ -207,6 +207,13 @@ public class SnapShotGenerationXTests {
|
|||
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE || sd.getKind() == StructureDefinitionKind.COMPLEXTYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrimitiveType(String name) {
|
||||
StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchTypeDefinition(name);
|
||||
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isResource(String typeSimple) {
|
||||
StructureDefinition sd = UtilitiesXTests.context(version).fetchTypeDefinition(typeSimple);
|
||||
|
|
Loading…
Reference in New Issue