diff --git a/org.hl7.fhir.core.generator/configuration/Bundle.java b/org.hl7.fhir.core.generator/configuration/Bundle.java index 04c8fb791..c5a58f609 100644 --- a/org.hl7.fhir.core.generator/configuration/Bundle.java +++ b/org.hl7.fhir.core.generator/configuration/Bundle.java @@ -13,7 +13,7 @@ public BundleLinkComponent getLink(String theRelation) { org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty"); for (BundleLinkComponent next : getLink()) { - if (theRelation.equals(next.getRelation())) { + if (theRelation.equals(next.getRelation().toCode())) { return next; } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Bundle.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Bundle.java index f0deecff1..17de529a9 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Bundle.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Bundle.java @@ -2798,9 +2798,9 @@ public class Bundle extends Resource implements IBaseBundle { protected List link; /** - * The Absolute URL for the resource. Except for transactions and batches, each entry in a Bundle must have a fullUrl. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. Even when not required, fullUrl MAY be set to a urn:uuid to allow referencing entries in a transaction. The fullUrl can be an arbitrary URI and is not limited to urn:uuid, urn:oid, http, and https. The fullUrl element SHALL have a value except when: -* invoking a create -* invoking or responding to an operation where the body is not a single identified resource + * The Absolute URL for the resource. Except for transactions and batches, each entry in a Bundle must have a fullUrl. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. Even when not required, fullUrl MAY be set to a urn:uuid to allow referencing entries in a transaction. The fullUrl can be an arbitrary URI and is not limited to urn:uuid, urn:oid, http, and https. The fullUrl element SHALL have a value except when: +* invoking a create +* invoking or responding to an operation where the body is not a single identified resource * invoking or returning the results of a search or history operation. */ @Child(name = "fullUrl", type = {UriType.class}, order=2, min=0, max=1, modifier=false, summary=true) @@ -2898,9 +2898,9 @@ public class Bundle extends Resource implements IBaseBundle { } /** - * @return {@link #fullUrl} (The Absolute URL for the resource. Except for transactions and batches, each entry in a Bundle must have a fullUrl. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. Even when not required, fullUrl MAY be set to a urn:uuid to allow referencing entries in a transaction. The fullUrl can be an arbitrary URI and is not limited to urn:uuid, urn:oid, http, and https. The fullUrl element SHALL have a value except when: -* invoking a create -* invoking or responding to an operation where the body is not a single identified resource + * @return {@link #fullUrl} (The Absolute URL for the resource. Except for transactions and batches, each entry in a Bundle must have a fullUrl. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. Even when not required, fullUrl MAY be set to a urn:uuid to allow referencing entries in a transaction. The fullUrl can be an arbitrary URI and is not limited to urn:uuid, urn:oid, http, and https. The fullUrl element SHALL have a value except when: +* invoking a create +* invoking or responding to an operation where the body is not a single identified resource * invoking or returning the results of a search or history operation.). This is the underlying object with id, value and extensions. The accessor "getFullUrl" gives direct access to the value */ public UriType getFullUrlElement() { @@ -2921,9 +2921,9 @@ public class Bundle extends Resource implements IBaseBundle { } /** - * @param value {@link #fullUrl} (The Absolute URL for the resource. Except for transactions and batches, each entry in a Bundle must have a fullUrl. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. Even when not required, fullUrl MAY be set to a urn:uuid to allow referencing entries in a transaction. The fullUrl can be an arbitrary URI and is not limited to urn:uuid, urn:oid, http, and https. The fullUrl element SHALL have a value except when: -* invoking a create -* invoking or responding to an operation where the body is not a single identified resource + * @param value {@link #fullUrl} (The Absolute URL for the resource. Except for transactions and batches, each entry in a Bundle must have a fullUrl. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. Even when not required, fullUrl MAY be set to a urn:uuid to allow referencing entries in a transaction. The fullUrl can be an arbitrary URI and is not limited to urn:uuid, urn:oid, http, and https. The fullUrl element SHALL have a value except when: +* invoking a create +* invoking or responding to an operation where the body is not a single identified resource * invoking or returning the results of a search or history operation.). This is the underlying object with id, value and extensions. The accessor "getFullUrl" gives direct access to the value */ public BundleEntryComponent setFullUrlElement(UriType value) { @@ -2932,9 +2932,9 @@ public class Bundle extends Resource implements IBaseBundle { } /** - * @return The Absolute URL for the resource. Except for transactions and batches, each entry in a Bundle must have a fullUrl. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. Even when not required, fullUrl MAY be set to a urn:uuid to allow referencing entries in a transaction. The fullUrl can be an arbitrary URI and is not limited to urn:uuid, urn:oid, http, and https. The fullUrl element SHALL have a value except when: -* invoking a create -* invoking or responding to an operation where the body is not a single identified resource + * @return The Absolute URL for the resource. Except for transactions and batches, each entry in a Bundle must have a fullUrl. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. Even when not required, fullUrl MAY be set to a urn:uuid to allow referencing entries in a transaction. The fullUrl can be an arbitrary URI and is not limited to urn:uuid, urn:oid, http, and https. The fullUrl element SHALL have a value except when: +* invoking a create +* invoking or responding to an operation where the body is not a single identified resource * invoking or returning the results of a search or history operation. */ public String getFullUrl() { @@ -2942,9 +2942,9 @@ public class Bundle extends Resource implements IBaseBundle { } /** - * @param value The Absolute URL for the resource. Except for transactions and batches, each entry in a Bundle must have a fullUrl. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. Even when not required, fullUrl MAY be set to a urn:uuid to allow referencing entries in a transaction. The fullUrl can be an arbitrary URI and is not limited to urn:uuid, urn:oid, http, and https. The fullUrl element SHALL have a value except when: -* invoking a create -* invoking or responding to an operation where the body is not a single identified resource + * @param value The Absolute URL for the resource. Except for transactions and batches, each entry in a Bundle must have a fullUrl. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. Even when not required, fullUrl MAY be set to a urn:uuid to allow referencing entries in a transaction. The fullUrl can be an arbitrary URI and is not limited to urn:uuid, urn:oid, http, and https. The fullUrl element SHALL have a value except when: +* invoking a create +* invoking or responding to an operation where the body is not a single identified resource * invoking or returning the results of a search or history operation. */ public BundleEntryComponent setFullUrl(String value) { @@ -5307,7 +5307,7 @@ public class Bundle extends Resource implements IBaseBundle { public BundleLinkComponent getLink(String theRelation) { org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty"); for (BundleLinkComponent next : getLink()) { - if (theRelation.equals(next.getRelation())) { + if (theRelation.equals(next.getRelation().toCode())) { return next; } } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BundleTypeTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BundleTypeTest.java new file mode 100644 index 000000000..d439ec9d8 --- /dev/null +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BundleTypeTest.java @@ -0,0 +1,31 @@ +package org.hl7.fhir.r5.model; + +import org.hl7.fhir.instance.model.api.IBaseBundle; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class BundleTypeTest { + + @Test + @DisplayName("Test getLink by string when present") + public void getLinkShouldFindWhenPresent() { + Bundle bundle = new Bundle(); + Bundle.BundleLinkComponent link = new Bundle.BundleLinkComponent(); + link.setRelation(Bundle.LinkRelationTypes.NEXT); + bundle.getLink().add(link); + Bundle.BundleLinkComponent returnedLink = bundle.getLink(IBaseBundle.LINK_NEXT); + Assertions.assertNotNull(returnedLink); + } + + @Test + @DisplayName("Test getLink by string when not present") + public void getLinkStringShouldReturnNullWhenNoLinksMatch() { + Bundle bundle = new Bundle(); + Bundle.BundleLinkComponent previousLink = new Bundle.BundleLinkComponent(); + previousLink.setRelation(Bundle.LinkRelationTypes.PREV); + bundle.getLink().add(previousLink); + Bundle.BundleLinkComponent returnedLink = bundle.getLink(IBaseBundle.LINK_NEXT); + Assertions.assertNull(returnedLink); + } +}