fix for profile comparison issues
This commit is contained in:
parent
1f0419b822
commit
c6d667db04
|
@ -35,6 +35,7 @@ public class ComparisonSession {
|
|||
this.context = context;
|
||||
this.sessiondId = UUID.randomUUID().toString().toLowerCase();
|
||||
this.title = title;
|
||||
// debug = true;
|
||||
}
|
||||
|
||||
public IWorkerContext getContext() {
|
||||
|
|
|
@ -545,9 +545,14 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
}
|
||||
|
||||
private boolean derivesFrom(StructureDefinition left, StructureDefinition right) {
|
||||
// left derives from right if it's base is the same as right
|
||||
// todo: recursive...
|
||||
return left.hasBaseDefinition() && left.getBaseDefinition().equals(right.getUrl());
|
||||
StructureDefinition sd = left;
|
||||
while (sd != null) {
|
||||
if (right.getUrl().equals(sd.getBaseDefinition())) {
|
||||
return true;
|
||||
}
|
||||
sd = sd.hasBaseDefinition() ? session.getContext().fetchResource(StructureDefinition.class, sd.getBaseDefinition()) : null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Collection<? extends TypeRefComponent> intersectTypes(ProfileComparison comp, StructuralMatch<ElementDefinition> res, ElementDefinition ed, String path, List<TypeRefComponent> left, List<TypeRefComponent> right) throws DefinitionException, IOException, FHIRFormatError {
|
||||
|
|
|
@ -1158,7 +1158,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (!unbounded(currentBase) && !isSlicedToOneOnly(diffMatches.get(0)))
|
||||
// you can only slice an element that doesn't repeat if the sum total of your slices is limited to 1
|
||||
// (but you might do that in order to split up constraints by type)
|
||||
throw new DefinitionException(context.formatMessage(I18nConstants.ATTEMPT_TO_A_SLICE_AN_ELEMENT_THAT_DOES_NOT_REPEAT__FROM__IN_, currentBase.getPath(), currentBase.getPath(), contextName, url));
|
||||
throw new DefinitionException(context.formatMessage(I18nConstants.ATTEMPT_TO_A_SLICE_AN_ELEMENT_THAT_DOES_NOT_REPEAT__FROM__IN_, currentBase.getPath(), currentBase.getPath(), contextName, url, diffMatches.get(0).getId(), sliceNames(diffMatches)));
|
||||
if (!diffMatches.get(0).hasSlicing() && !isExtension(currentBase)) // well, the diff has set up a slice, but hasn't defined it. this is an error
|
||||
throw new DefinitionException(context.formatMessage(I18nConstants.DIFFERENTIAL_DOES_NOT_HAVE_A_SLICE__B_OF_____IN_PROFILE_, currentBase.getPath(), baseCursor, baseLimit, diffCursor, diffLimit, url));
|
||||
|
||||
|
@ -1611,6 +1611,16 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
return res;
|
||||
}
|
||||
|
||||
private String sliceNames(List<ElementDefinition> diffMatches) {
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
||||
for (ElementDefinition ed : diffMatches) {
|
||||
if (ed.hasSliceName()) {
|
||||
b.append(ed.getSliceName());
|
||||
}
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
private boolean isMatchingType(StructureDefinition sd, List<TypeRefComponent> types) {
|
||||
while (sd != null) {
|
||||
for (TypeRefComponent tr : types) {
|
||||
|
|
Loading…
Reference in New Issue