Add checks for illegal constratins on elements
This commit is contained in:
parent
ae2a44ccb2
commit
0f0d19cd94
|
@ -898,6 +898,9 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
baseCursor++;
|
baseCursor++;
|
||||||
} else if (diffMatches.size() == 1 && (slicingDone || (!isImplicitSlicing(diffMatches.get(0), cpath) && !(diffMatches.get(0).hasSlicing() || (isExtension(diffMatches.get(0)) && diffMatches.get(0).hasSliceName()))))) {// one matching element in the differential
|
} else if (diffMatches.size() == 1 && (slicingDone || (!isImplicitSlicing(diffMatches.get(0), cpath) && !(diffMatches.get(0).hasSlicing() || (isExtension(diffMatches.get(0)) && diffMatches.get(0).hasSliceName()))))) {// one matching element in the differential
|
||||||
ElementDefinition template = null;
|
ElementDefinition template = null;
|
||||||
|
if (diffMatches.get(0).hasType() && "Reference".equals(diffMatches.get(0).getType().get(0).getWorkingCode()) && !isValidType(diffMatches.get(0).getType().get(0), currentBase)) {
|
||||||
|
throw new DefinitionException(context.formatMessage(I18nConstants.VALIDATION_VAL_ILLEGAL_TYPE_CONSTRAINT, url, diffMatches.get(0).getPath(), diffMatches.get(0).getType().get(0), currentBase.typeSummary()));
|
||||||
|
}
|
||||||
if (diffMatches.get(0).hasType() && diffMatches.get(0).getType().size() == 1 && diffMatches.get(0).getType().get(0).hasProfile() && !"Reference".equals(diffMatches.get(0).getType().get(0).getWorkingCode())) {
|
if (diffMatches.get(0).hasType() && diffMatches.get(0).getType().size() == 1 && diffMatches.get(0).getType().get(0).hasProfile() && !"Reference".equals(diffMatches.get(0).getType().get(0).getWorkingCode())) {
|
||||||
CanonicalType p = diffMatches.get(0).getType().get(0).getProfile().get(0);
|
CanonicalType p = diffMatches.get(0).getType().get(0).getProfile().get(0);
|
||||||
StructureDefinition sd = context.fetchResource(StructureDefinition.class, p.getValue());
|
StructureDefinition sd = context.fetchResource(StructureDefinition.class, p.getValue());
|
||||||
|
@ -912,6 +915,9 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sd != null) {
|
if (sd != null) {
|
||||||
|
if (!isMatchingType(sd, diffMatches.get(0).getType())) {
|
||||||
|
throw new DefinitionException(context.formatMessage(I18nConstants.VALIDATION_VAL_PROFILE_WRONGTYPE2, sd.getUrl(), diffMatches.get(0).getPath(), sd.getType(), p.getValue(), diffMatches.get(0).getType().get(0).getWorkingCode()));
|
||||||
|
}
|
||||||
if (isGenerating(sd)) {
|
if (isGenerating(sd)) {
|
||||||
// this is a special case, because we're only going to access the first element, and we can rely on the fact that it's already populated.
|
// this is a special case, because we're only going to access the first element, and we can rely on the fact that it's already populated.
|
||||||
// but we check anyway
|
// but we check anyway
|
||||||
|
@ -1605,6 +1611,31 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isMatchingType(StructureDefinition sd, List<TypeRefComponent> types) {
|
||||||
|
while (sd != null) {
|
||||||
|
for (TypeRefComponent tr : types) {
|
||||||
|
if (sd.getType().equals(tr.getCode())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sd = context.fetchResource(StructureDefinition.class, sd.getBaseDefinition());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidType(TypeRefComponent t, ElementDefinition base) {
|
||||||
|
for (TypeRefComponent tr : base.getType()) {
|
||||||
|
if (tr.getCode().equals(t.getCode())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (tr.getWorkingCode().equals(t.getCode())) {
|
||||||
|
System.out.println("Type error: use of a simple type \""+t.getCode()+"\" wrongly constraining "+base.getPath());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isGenerating(StructureDefinition sd) {
|
private boolean isGenerating(StructureDefinition sd) {
|
||||||
return sd.hasUserData("profileutils.snapshot.generating");
|
return sd.hasUserData("profileutils.snapshot.generating");
|
||||||
}
|
}
|
||||||
|
|
|
@ -491,30 +491,10 @@ public class I18nConstants {
|
||||||
public static final String MEASURE_M_CRITERIA_CQL_NO_ELM = "MEASURE_M_CRITERIA_CQL_NO_ELM";
|
public static final String MEASURE_M_CRITERIA_CQL_NO_ELM = "MEASURE_M_CRITERIA_CQL_NO_ELM";
|
||||||
public static final String MEASURE_M_CRITERIA_CQL_ELM_NOT_VALID = "MEASURE_M_CRITERIA_CQL_ELM_NOT_VALID";
|
public static final String MEASURE_M_CRITERIA_CQL_ELM_NOT_VALID = "MEASURE_M_CRITERIA_CQL_ELM_NOT_VALID";
|
||||||
public static final String MEASURE_M_CRITERIA_CQL_NOT_FOUND = "MEASURE_M_CRITERIA_CQL_NOT_FOUND";
|
public static final String MEASURE_M_CRITERIA_CQL_NOT_FOUND = "MEASURE_M_CRITERIA_CQL_NOT_FOUND";
|
||||||
//public static final String
|
public static final String VALIDATION_VAL_PROFILE_WRONGTYPE2 = "Validation_VAL_Profile_WrongType2";
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
//public static final String
|
|
||||||
public static final String XHTML_URL_EMPTY = "XHTML_URL_EMPTY";
|
public static final String XHTML_URL_EMPTY = "XHTML_URL_EMPTY";
|
||||||
public static final String XHTML_URL_INVALID_CHARS = "XHTML_URL_INVALID_CHARS";
|
public static final String XHTML_URL_INVALID_CHARS = "XHTML_URL_INVALID_CHARS";
|
||||||
public static final String TERMINOLOGY_TX_SYSTEM_HTTPS = "TERMINOLOGY_TX_SYSTEM_HTTPS";
|
public static final String TERMINOLOGY_TX_SYSTEM_HTTPS = "TERMINOLOGY_TX_SYSTEM_HTTPS";
|
||||||
public static final String CODESYSTEM_CS_NO_VS_NOTCOMPLETE = "CODESYSTEM_CS_NO_VS_NOTCOMPLETE";
|
public static final String CODESYSTEM_CS_NO_VS_NOTCOMPLETE = "CODESYSTEM_CS_NO_VS_NOTCOMPLETE";
|
||||||
|
public static final String VALIDATION_VAL_ILLEGAL_TYPE_CONSTRAINT = "VALIDATION_VAL_ILLEGAL_TYPE_CONSTRAINT";
|
||||||
}
|
}
|
|
@ -495,3 +495,6 @@ TYPE_SPECIFIC_CHECKS_DT_ATT_TOO_LONG = Attachment size is {0} bytes which exceed
|
||||||
TYPE_SPECIFIC_CHECKS_DT_ATT_NO_CONTENT = Attachments have data and/or url, or else must have either contentType and/oor language
|
TYPE_SPECIFIC_CHECKS_DT_ATT_NO_CONTENT = Attachments have data and/or url, or else must have either contentType and/oor language
|
||||||
TYPE_SPECIFIC_CHECKS_DT_BASE64_TOO_LONG = Base64 size is {0} bytes which exceeds the stated limit of {1} bytes
|
TYPE_SPECIFIC_CHECKS_DT_BASE64_TOO_LONG = Base64 size is {0} bytes which exceeds the stated limit of {1} bytes
|
||||||
TYPE_SPECIFIC_CHECKS_DT_DECIMAL_CHARS = Found {0} decimal places which exceeds the stated limit of {1} digits
|
TYPE_SPECIFIC_CHECKS_DT_DECIMAL_CHARS = Found {0} decimal places which exceeds the stated limit of {1} digits
|
||||||
|
Validation_VAL_Profile_WrongType = Specified profile type was "{0}", but found type "{1}"
|
||||||
|
Validation_VAL_Profile_WrongType2 = Type mismatch processing profile {0} at path {1}: The element type is {4}, but the profile {3} is for a different type {2}
|
||||||
|
VALIDATION_VAL_ILLEGAL_TYPE_CONSTRAINT = Illegal constraint in profile {0} at path {1} - cannot constrain to type {2} from base types {3}
|
Loading…
Reference in New Issue