Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
type: change
issue: 7059
title: "Added support for optional resourceType scoping in MDM_SUBMIT job parameters."
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ public IBaseParameters submitMdmSubmitJob(
if (hasBatchSize) {
params.setBatchSize(theBatchSize.getValue().intValue());
}
if (theRequestDetails.getResourceName() != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest using isNotBlank(theRequestDetails.getResourceName()) in case it's an empty string and not a null (for whatever reason)

params.setResourceNames(List.of(theRequestDetails.getResourceName()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Do the urls not define the resourcetypes being submitted? ie, can't you have a bunch of different URLs that are per resource type (as in MdmOperationPointcutsIT.mdmSubmit_interceptor_differentPaths)

}
RequestPartitionId partitionId = RequestPartitionId.allPartitions();
theUrls.forEach(
url -> params.addPartitionedUrl(new PartitionedUrl().setUrl(url).setRequestPartitionId(partitionId)));
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -14,13 +15,15 @@
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;
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
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;
Expand Down Expand Up @@ -224,4 +227,23 @@ public boolean matches(RequestPartitionId theRequestPartitionId) {
}
}

@Test
public void testSubmitMdmSubmitJobUsesResourceNameFromRequestDetails() throws Exception {
assertLinkCount(1);

List<String> urls = List.of("Patient?_id=*");
IPrimitiveType<BigDecimal> 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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> theResourceNames) {
myResourceNames = theResourceNames;
}
}
Loading