From 434f1ec47816028095ae3c90f4bdc05e6c1afd4d Mon Sep 17 00:00:00 2001 From: Tetiana Hurova Date: Mon, 16 Jun 2025 23:03:44 -0400 Subject: [PATCH 1/5] #7059: Add resourceType support to MdmSubmitJobParameters --- .../jpa/mdm/svc/MdmControllerSvcImpl.java | 3 ++ .../batch2/submit/MdmSubmitJobParameters.java | 31 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImpl.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImpl.java index d65ed708cdee..cb023b150e3d 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImpl.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImpl.java @@ -361,6 +361,9 @@ public IBaseParameters submitMdmSubmitJob( if (hasBatchSize) { params.setBatchSize(theBatchSize.getValue().intValue()); } + if (theRequestDetails.getResourceName() != null) { + params.setResourceNames(List.of(theRequestDetails.getResourceName())); + } RequestPartitionId partitionId = RequestPartitionId.allPartitions(); theUrls.forEach( url -> params.addPartitionedUrl(new PartitionedUrl().setUrl(url).setRequestPartitionId(partitionId))); diff --git a/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmSubmitJobParameters.java b/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmSubmitJobParameters.java index fc907820b704..276d542ca660 100644 --- a/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmSubmitJobParameters.java +++ b/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmSubmitJobParameters.java @@ -20,5 +20,34 @@ package ca.uhn.fhir.mdm.batch2.submit; import ca.uhn.fhir.batch2.jobs.parameters.PartitionedUrlJobParameters; +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.annotation.Nonnull; +import jakarta.validation.constraints.Pattern; +import org.apache.commons.lang3.Validate; -public class MdmSubmitJobParameters extends PartitionedUrlJobParameters {} +import java.util.ArrayList; +import java.util.List; + +public class MdmSubmitJobParameters extends PartitionedUrlJobParameters { + @JsonProperty("resourceType") + @Nonnull + private List<@Pattern(regexp = "^[A-Z][A-Za-z]+$", message = "If populated, must be a valid resource type'") String> + myResourceNames; + + public List getResourceNames() { + if (myResourceNames == null) { + myResourceNames = new ArrayList<>(); + } + return myResourceNames; + } + + public MdmSubmitJobParameters addResourceType(@Nonnull String theResourceName) { + Validate.notNull(theResourceName); + getResourceNames().add(theResourceName); + return this; + } + + public void setResourceNames(@Nonnull List theResourceNames) { + myResourceNames = theResourceNames; + } +} From f8bf31a8a62de792afda810757072b695328ef68 Mon Sep 17 00:00:00 2001 From: Tetiana Hurova Date: Thu, 19 Jun 2025 13:45:14 -0400 Subject: [PATCH 2/5] #7059: Formatting fix --- .../ca/uhn/fhir/mdm/batch2/submit/MdmSubmitJobParameters.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmSubmitJobParameters.java b/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmSubmitJobParameters.java index 276d542ca660..c1fc57998d41 100644 --- a/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmSubmitJobParameters.java +++ b/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmSubmitJobParameters.java @@ -32,7 +32,7 @@ public class MdmSubmitJobParameters extends PartitionedUrlJobParameters { @JsonProperty("resourceType") @Nonnull private List<@Pattern(regexp = "^[A-Z][A-Za-z]+$", message = "If populated, must be a valid resource type'") String> - myResourceNames; + myResourceNames; public List getResourceNames() { if (myResourceNames == null) { From fce21dcca419fa6c7f668f09669781052533a2c5 Mon Sep 17 00:00:00 2001 From: Tetiana Hurova Date: Thu, 19 Jun 2025 19:53:42 -0400 Subject: [PATCH 3/5] #7059: Added test --- .../jpa/mdm/svc/MdmControllerSvcImplTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImplTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImplTest.java index 9b0736591e66..d7ce620a33c5 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImplTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImplTest.java @@ -1,5 +1,6 @@ package ca.uhn.fhir.jpa.mdm.svc; +import ca.uhn.fhir.batch2.model.JobInstance; import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.entity.MdmLink; @@ -14,6 +15,7 @@ import ca.uhn.fhir.mdm.api.paging.MdmPageRequest; import ca.uhn.fhir.mdm.api.params.MdmQuerySearchParameters; import ca.uhn.fhir.mdm.batch2.clear.MdmClearStep; +import ca.uhn.fhir.mdm.batch2.submit.MdmSubmitJobParameters; import ca.uhn.fhir.mdm.model.MdmTransactionContext; import ca.uhn.fhir.mdm.model.mdmevents.MdmLinkJson; import ca.uhn.fhir.mdm.rules.config.MdmSettings; @@ -21,6 +23,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException; import ca.uhn.fhir.rest.server.interceptor.partition.RequestTenantPartitionInterceptor; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; +import com.fasterxml.jackson.databind.ObjectMapper; import org.hl7.fhir.instance.model.api.IBaseParameters; import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.r4.model.DecimalType; @@ -224,4 +227,23 @@ public boolean matches(RequestPartitionId theRequestPartitionId) { } } + @Test + public void testSubmitMdmSubmitJobUsesResourceNameFromRequestDetails() throws Exception { + assertLinkCount(1); + + List urls = List.of("Patient?"); + IPrimitiveType batchSize = new DecimalType(new BigDecimal(50)); + ServletRequestDetails details = new ServletRequestDetails(); + details.setResourceName("Patient"); + + IBaseParameters result = myMdmControllerSvc.submitMdmSubmitJob(urls, batchSize, details); + String jobId = ((StringType) ((Parameters) result).getParameterValue("jobId")).getValueAsString(); + + JobInstance instance = myBatch2JobHelper.awaitJobCompletion(jobId); + + ObjectMapper mapper = new ObjectMapper(); + MdmSubmitJobParameters submitParams = mapper.readValue(instance.getParameters(), MdmSubmitJobParameters.class); + + assertThat(submitParams.getResourceNames()).containsExactly("Patient"); + } } From fabfe2ab4db22a90ed80d9d7d7bc47c544c75109 Mon Sep 17 00:00:00 2001 From: Tetiana Hurova Date: Thu, 19 Jun 2025 22:26:43 -0400 Subject: [PATCH 4/5] #7059: Fix --- .../java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImplTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImplTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImplTest.java index d7ce620a33c5..18d4816af9dc 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImplTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmControllerSvcImplTest.java @@ -231,7 +231,7 @@ public boolean matches(RequestPartitionId theRequestPartitionId) { public void testSubmitMdmSubmitJobUsesResourceNameFromRequestDetails() throws Exception { assertLinkCount(1); - List urls = List.of("Patient?"); + List urls = List.of("Patient?_id=*"); IPrimitiveType batchSize = new DecimalType(new BigDecimal(50)); ServletRequestDetails details = new ServletRequestDetails(); details.setResourceName("Patient"); From 6dece868f9215b4cd6f6e7df1f66fb8b6e910fb5 Mon Sep 17 00:00:00 2001 From: Tetiana Hurova Date: Fri, 20 Jun 2025 11:38:06 -0400 Subject: [PATCH 5/5] #7059: Added changelog --- .../8_4_0/7059-add-resourceType-to-MdmSubmitJobParameters.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/8_4_0/7059-add-resourceType-to-MdmSubmitJobParameters.yml diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/8_4_0/7059-add-resourceType-to-MdmSubmitJobParameters.yml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/8_4_0/7059-add-resourceType-to-MdmSubmitJobParameters.yml new file mode 100644 index 000000000000..3527f5abb0ee --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/8_4_0/7059-add-resourceType-to-MdmSubmitJobParameters.yml @@ -0,0 +1,4 @@ +--- +type: change +issue: 7059 +title: "Added support for optional resourceType scoping in MDM_SUBMIT job parameters."