diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/api/GroupBulkDataExportOptions.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/api/GroupBulkDataExportOptions.java index 7690845c31c..ee267f38043 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/api/GroupBulkDataExportOptions.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/api/GroupBulkDataExportOptions.java @@ -1,17 +1,19 @@ package ca.uhn.fhir.jpa.bulk.api; +import org.hl7.fhir.instance.model.api.IIdType; + import java.util.Date; import java.util.Set; public class GroupBulkDataExportOptions extends BulkDataExportOptions { - private final String myGroupId; + private final IIdType myGroupId; - public GroupBulkDataExportOptions(String theOutputFormat, Set theResourceTypes, Date theSince, Set theFilters, String theGroupId) { + public GroupBulkDataExportOptions(String theOutputFormat, Set theResourceTypes, Date theSince, Set theFilters, IIdType theGroupId) { super(theOutputFormat, theResourceTypes, theSince, theFilters); myGroupId = theGroupId; } - public String getGroupId() { + public IIdType getGroupId() { return myGroupId; } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/provider/BulkDataExportProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/provider/BulkDataExportProvider.java index 9c3fa464007..21ed3826114 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/provider/BulkDataExportProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/provider/BulkDataExportProvider.java @@ -26,6 +26,7 @@ import ca.uhn.fhir.jpa.bulk.api.GroupBulkDataExportOptions; import ca.uhn.fhir.jpa.bulk.api.IBulkDataExportSvc; import ca.uhn.fhir.jpa.bulk.model.BulkExportResponseJson; import ca.uhn.fhir.jpa.model.util.JpaConstants; +import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Operation; import ca.uhn.fhir.rest.annotation.OperationParam; import ca.uhn.fhir.rest.api.Constants; @@ -39,6 +40,7 @@ import ca.uhn.fhir.util.OperationOutcomeUtil; import com.google.common.annotations.VisibleForTesting; import org.apache.commons.lang3.StringUtils; import org.hl7.fhir.instance.model.api.IBaseOperationOutcome; +import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.r4.model.InstantType; import org.springframework.beans.factory.annotation.Autowired; @@ -184,6 +186,7 @@ public class BulkDataExportProvider { */ @Operation(name = JpaConstants.OPERATION_EXPORT, manualResponse = true, idempotent = true, typeName = "Group") public void groupExport( + @IdParam IIdType theIdParam, @OperationParam(name = JpaConstants.PARAM_EXPORT_OUTPUT_FORMAT, min = 0, max = 1, typeName = "string") IPrimitiveType theOutputFormat, @OperationParam(name = JpaConstants.PARAM_EXPORT_TYPE, min = 0, max = 1, typeName = "string") IPrimitiveType theType, @OperationParam(name = JpaConstants.PARAM_EXPORT_SINCE, min = 0, max = 1, typeName = "instant") IPrimitiveType theSince, @@ -213,9 +216,7 @@ public class BulkDataExportProvider { if (theTypeFilter != null) { filters = ArrayUtil.commaSeparatedListToCleanSet(theTypeFilter.getValueAsString()); } - // FIXME set this - String groupId = "FIXME"; - IBulkDataExportSvc.JobInfo outcome = myBulkDataExportSvc.submitJob(new GroupBulkDataExportOptions(outputFormat, resourceTypes, since, filters, groupId)); + IBulkDataExportSvc.JobInfo outcome = myBulkDataExportSvc.submitJob(new GroupBulkDataExportOptions(outputFormat, resourceTypes, since, filters, theIdParam)); String serverBase = getServerBase(theRequestDetails); String pollLocation = serverBase + "/" + JpaConstants.OPERATION_EXPORT_POLL_STATUS + "?" + JpaConstants.PARAM_EXPORT_POLL_STATUS_JOB_ID + "=" + outcome.getJobId(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java index 79ddbf3fdaf..136fdad7e95 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java @@ -61,7 +61,7 @@ public class BulkDataExportProviderTest { private static final String A_JOB_ID = "0000000-AAAAAA"; private static final Logger ourLog = LoggerFactory.getLogger(BulkDataExportProviderTest.class); - private static final String GROUP_ID = "G2401"; + private static final String GROUP_ID = "Group/G2401"; private static final String G_JOB_ID = "0000000-GGGGGG"; private Server myServer; private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); @@ -309,7 +309,7 @@ public class BulkDataExportProviderTest { ourLog.info(myCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); - HttpPost post = new HttpPost("http://localhost:" + myPort + "/Group/" + GROUP_ID + "/" + JpaConstants.OPERATION_EXPORT); + HttpPost post = new HttpPost("http://localhost:" + myPort + "/" + GROUP_ID + "/" + JpaConstants.OPERATION_EXPORT); post.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RESPOND_ASYNC); post.setEntity(new ResourceEntity(myCtx, input)); ourLog.info("Request: {}", post); @@ -326,6 +326,6 @@ public class BulkDataExportProviderTest { assertThat(options.getResourceTypes(), containsInAnyOrder("Observation", "DiagnosticReport")); assertThat(options.getSince(), notNullValue()); assertThat(options.getFilters(), containsInAnyOrder("Observation?code=OBSCODE", "DiagnosticReport?code=DRCODE")); - assertEquals(GROUP_ID, options.getGroupId()); + assertEquals(GROUP_ID, options.getGroupId().getValue()); } }