Improved handling of profiles with no derivation
This commit is contained in:
parent
60085522f7
commit
46e1e5edd4
|
@ -444,20 +444,29 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
* @throws Exception
|
||||
*/
|
||||
public void generateSnapshot(StructureDefinition base, StructureDefinition derived, String url, String webUrl, String profileName) throws DefinitionException, FHIRException {
|
||||
if (base == null)
|
||||
if (base == null) {
|
||||
throw new DefinitionException("no base profile provided");
|
||||
if (derived == null)
|
||||
}
|
||||
if (derived == null) {
|
||||
throw new DefinitionException("no derived structure provided");
|
||||
}
|
||||
|
||||
if (!base.hasType())
|
||||
if (!base.hasType()) {
|
||||
throw new DefinitionException("Base profile "+base.getUrl()+" has no type");
|
||||
if (!derived.hasType())
|
||||
}
|
||||
if (!derived.hasType()) {
|
||||
throw new DefinitionException("Derived profile "+derived.getUrl()+" has no type");
|
||||
if (!base.getType().equals(derived.getType()) && derived.getDerivation().equals(TypeDerivationRule.CONSTRAINT))
|
||||
}
|
||||
if (!derived.hasDerivation()) {
|
||||
throw new DefinitionException("Derived profile "+derived.getUrl()+" has no derivation value and so can't be processed");
|
||||
}
|
||||
if (!base.getType().equals(derived.getType()) && derived.getDerivation() == TypeDerivationRule.CONSTRAINT) {
|
||||
throw new DefinitionException("Base & Derived profiles have different types ("+base.getUrl()+" = "+base.getType()+" vs "+derived.getUrl()+" = "+derived.getType()+")");
|
||||
|
||||
if (snapshotStack.contains(derived.getUrl()))
|
||||
}
|
||||
|
||||
if (snapshotStack.contains(derived.getUrl())) {
|
||||
throw new DefinitionException("Circular snapshot references detected; cannot generate snapshot (stack = "+snapshotStack.toString()+")");
|
||||
}
|
||||
snapshotStack.add(derived.getUrl());
|
||||
|
||||
if (!Utilities.noString(webUrl) && !webUrl.endsWith("/"))
|
||||
|
@ -486,7 +495,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
// we actually delegate the work to a subroutine so we can re-enter it with a different cursors
|
||||
StructureDefinitionDifferentialComponent diff = cloneDiff(derived.getDifferential()); // we make a copy here because we're sometimes going to hack the differential while processing it. Have to migrate user data back afterwards
|
||||
StructureDefinitionSnapshotComponent baseSnapshot = base.getSnapshot();
|
||||
if (derived.getDerivation().equals(TypeDerivationRule.SPECIALIZATION)) {
|
||||
if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) {
|
||||
String derivedType = derived.getType();
|
||||
if (StructureDefinitionKind.LOGICAL.equals(derived.getKind()) && derived.getType().contains("/")) {
|
||||
derivedType = derivedType.substring(derivedType.lastIndexOf("/")+1);
|
||||
|
@ -498,7 +507,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
processPaths("", derived.getSnapshot(), baseSnapshot, diff, baseCursor, diffCursor, baseSnapshot.getElement().size()-1,
|
||||
derived.getDifferential().hasElement() ? derived.getDifferential().getElement().size()-1 : -1, url, webUrl, derived.present(), null, null, false, base.getUrl(), null, false, null, new ArrayList<ElementRedirection>(), base);
|
||||
if (derived.getDerivation().equals(TypeDerivationRule.SPECIALIZATION)) {
|
||||
if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) {
|
||||
for (ElementDefinition e : diff.getElement()) {
|
||||
if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) {
|
||||
ElementDefinition outcome = updateURLs(url, webUrl, e.copy());
|
||||
|
|
Loading…
Reference in New Issue