From e5ba5a535e1ed38b0d1dfc5a132334da086d6894 Mon Sep 17 00:00:00 2001 From: leif stawnyczy Date: Fri, 27 Sep 2024 16:07:33 -0400 Subject: [PATCH] review points --- .../fhir/jpa/dao/BaseHapiFhirResourceDao.java | 3 +- ...FhirResourceDaoR4ComboUniqueParamTest.java | 3 +- ...esourceDaoR4IndexStorageOptimizedTest.java | 3 +- .../r4/FhirResourceDaoR4QueryCountTest.java | 2 +- ...ourceDaoR4SearchCustomSearchParamTest.java | 7 +- .../fhir/jpa/dao/tx/ReindexStepV1Test.java | 2 +- ...sourceProviderCustomSearchParamR4Test.java | 9 +- .../fhir/jpa/reindex/ReindexStepV1Test.java | 2 +- .../uhn/fhir/jpa/reindex/ReindexTaskTest.java | 32 ++--- .../ReindexTaskWithPartitioningTest.java | 4 +- .../jpa/term/ValueSetExpansionR4Test.java | 4 +- .../jpa/test/PatientReindexTestHelper.java | 3 +- .../term/TermDeferredStorageSvcImplTest.java | 15 ++- .../batch2/jobs/reindex/BaseReindexStep.java | 66 ----------- .../batch2/jobs/reindex/ReindexAppCtx.java | 99 +--------------- .../batch2/jobs/reindex/ReindexProvider.java | 3 +- .../batch2/jobs/reindex/ReindexUtils.java | 7 ++ .../v1/ReindexJobParametersValidatorV1.java | 57 +++++++++ .../jobs/reindex/{ => v1}/ReindexStepV1.java | 57 ++++++++- .../jobs/reindex/v1/ReindexV1Config.java | 100 ++++++++++++++++ .../{ => v2}/CheckPendingReindexWorkStep.java | 4 +- .../ReindexJobParametersValidatorV2.java} | 7 +- .../jobs/reindex/{ => v2}/ReindexStepV2.java | 54 ++++++++- .../jobs/reindex/v2/ReindexV2Config.java | 109 ++++++++++++++++++ .../ReindexTaskParametersValidatorTest.java | 3 +- 25 files changed, 444 insertions(+), 211 deletions(-) delete mode 100644 hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/BaseReindexStep.java create mode 100644 hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v1/ReindexJobParametersValidatorV1.java rename hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/{ => v1}/ReindexStepV1.java (52%) create mode 100644 hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v1/ReindexV1Config.java rename hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/{ => v2}/CheckPendingReindexWorkStep.java (90%) rename hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/{ReindexJobParametersValidator.java => v2/ReindexJobParametersValidatorV2.java} (85%) rename hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/{ => v2}/ReindexStepV2.java (57%) create mode 100644 hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/ReindexV2Config.java diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java index fbd583d0090..6f90316c768 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java @@ -158,6 +158,7 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; import static java.util.Objects.isNull; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; @@ -1315,7 +1316,7 @@ public abstract class BaseHapiFhirResourceDao extends B myJobPartitionProvider.getPartitionedUrls(theRequestDetails, urls).forEach(params::addPartitionedUrl); JobInstanceStartRequest request = new JobInstanceStartRequest(); - request.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + request.setJobDefinitionId(JOB_REINDEX); request.setParameters(params); myJobCoordinator.startInstance(theRequestDetails, request); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamTest.java index baf3e756028..8b6ea38e450 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamTest.java @@ -54,6 +54,7 @@ import java.util.List; import java.util.UUID; import java.util.stream.Collectors; +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; import static ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.INDEX_STATUS_INDEXED; import static ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.INDEX_STATUS_INDEXING_FAILED; import static org.assertj.core.api.Assertions.assertThat; @@ -990,7 +991,7 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test parameters.addUrl(url); } JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(parameters); Batch2JobStartResponse res = myJobCoordinator.startInstance(mySrd, startRequest); ourLog.info("Started reindex job with id {}", res.getInstanceId()); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4IndexStorageOptimizedTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4IndexStorageOptimizedTest.java index 6523bdd1373..98eeb191a21 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4IndexStorageOptimizedTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4IndexStorageOptimizedTest.java @@ -57,6 +57,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -312,7 +313,7 @@ public class FhirResourceDaoR4IndexStorageOptimizedTest extends BaseJpaR4Test { parameters.addUrl(url); } JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(parameters); Batch2JobStartResponse res = myJobCoordinator.startInstance(mySrd, startRequest); ourLog.info("Started reindex job with id {}", res.getInstanceId()); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java index 0ff0fbe6ca0..9f5ed69f7a9 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java @@ -7,7 +7,7 @@ import ca.uhn.fhir.batch2.api.VoidModel; import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson; import ca.uhn.fhir.batch2.jobs.chunk.TypedPidJson; import ca.uhn.fhir.batch2.jobs.expunge.DeleteExpungeStep; -import ca.uhn.fhir.batch2.jobs.reindex.ReindexStepV1; +import ca.uhn.fhir.batch2.jobs.reindex.v1.ReindexStepV1; import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; import ca.uhn.fhir.batch2.model.JobInstance; import ca.uhn.fhir.batch2.model.WorkChunk; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java index bff403a5ea4..a9f3cc57519 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java @@ -1,6 +1,5 @@ package ca.uhn.fhir.jpa.dao.r4; -import ca.uhn.fhir.batch2.jobs.reindex.ReindexAppCtx; import ca.uhn.fhir.batch2.model.JobInstance; import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.context.phonetic.PhoneticEncoderEnum; @@ -22,7 +21,6 @@ import ca.uhn.fhir.rest.param.NumberParam; import ca.uhn.fhir.rest.param.ReferenceOrListParam; import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.param.StringParam; -import ca.uhn.fhir.rest.param.TokenOrListParam; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; @@ -70,6 +68,7 @@ import org.springframework.transaction.support.TransactionTemplate; import java.util.List; import java.util.stream.Collectors; +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; import static org.apache.commons.lang3.StringUtils.countMatches; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -441,11 +440,11 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test fooSp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL); fooSp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); - List initialJobs = myBatch2JobHelper.findJobsByDefinition(ReindexAppCtx.JOB_REINDEX); + List initialJobs = myBatch2JobHelper.findJobsByDefinition(JOB_REINDEX); mySearchParameterDao.create(fooSp, mySrd); - List finalJobs = myBatch2JobHelper.findJobsByDefinition(ReindexAppCtx.JOB_REINDEX); + List finalJobs = myBatch2JobHelper.findJobsByDefinition(JOB_REINDEX); List newJobs = finalJobs.stream().filter(t -> !initialJobs.contains(t)).collect(Collectors.toList()); assertThat(newJobs.size()).as("number of jobs created").isEqualTo(1); } diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/tx/ReindexStepV1Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/tx/ReindexStepV1Test.java index 95d2920706b..539c4590a4c 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/tx/ReindexStepV1Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/tx/ReindexStepV1Test.java @@ -6,7 +6,7 @@ import ca.uhn.fhir.batch2.api.VoidModel; import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson; import ca.uhn.fhir.batch2.jobs.parameters.PartitionedUrl; import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; -import ca.uhn.fhir.batch2.jobs.reindex.ReindexStepV1; +import ca.uhn.fhir.batch2.jobs.reindex.v1.ReindexStepV1; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderCustomSearchParamR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderCustomSearchParamR4Test.java index 987f3430873..0bee635ccc0 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderCustomSearchParamR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderCustomSearchParamR4Test.java @@ -1,8 +1,5 @@ package ca.uhn.fhir.jpa.provider.r4; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import ca.uhn.fhir.batch2.jobs.reindex.ReindexAppCtx; import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; import ca.uhn.fhir.batch2.model.JobInstance; import ca.uhn.fhir.i18n.Msg; @@ -60,9 +57,11 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.fail; @@ -244,7 +243,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide runInTransaction(() -> { myBatch2JobHelper.forceRunMaintenancePass(); - List allJobs = myBatch2JobHelper.findJobsByDefinition(ReindexAppCtx.JOB_REINDEX); + List allJobs = myBatch2JobHelper.findJobsByDefinition(JOB_REINDEX); assertEquals(1, allJobs.size()); assertEquals(1, allJobs.get(0).getParameters(ReindexJobParameters.class).getPartitionedUrls().size()); assertEquals("Patient?", allJobs.get(0).getParameters(ReindexJobParameters.class).getPartitionedUrls().get(0).getUrl()); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexStepV1Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexStepV1Test.java index 13e58a760da..8075789db8d 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexStepV1Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexStepV1Test.java @@ -6,7 +6,7 @@ import ca.uhn.fhir.batch2.api.StepExecutionDetails; import ca.uhn.fhir.batch2.api.VoidModel; import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson; import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; -import ca.uhn.fhir.batch2.jobs.reindex.ReindexStepV1; +import ca.uhn.fhir.batch2.jobs.reindex.v1.ReindexStepV1; import ca.uhn.fhir.batch2.model.JobInstance; import ca.uhn.fhir.batch2.model.WorkChunk; import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexTaskTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexTaskTest.java index d78e456092c..c04a40f1ac7 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexTaskTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexTaskTest.java @@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.reindex; import ca.uhn.fhir.batch2.api.IJobCoordinator; import ca.uhn.fhir.batch2.api.IJobPersistence; -import ca.uhn.fhir.batch2.jobs.reindex.ReindexAppCtx; import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; import ca.uhn.fhir.batch2.model.JobInstance; import ca.uhn.fhir.batch2.model.JobInstanceStartRequest; @@ -39,6 +38,7 @@ import java.util.Date; import java.util.List; import java.util.stream.Stream; +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -101,7 +101,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { // execute JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters( new ReindexJobParameters() .setOptimizeStorage(ReindexParameters.OptimizeStorageModeEnum.CURRENT_VERSION) @@ -158,7 +158,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { // execute JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters( new ReindexJobParameters() .setOptimizeStorage(ReindexParameters.OptimizeStorageModeEnum.ALL_VERSIONS) @@ -217,7 +217,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { // execute JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters( new ReindexJobParameters() .setOptimizeStorage(ReindexParameters.OptimizeStorageModeEnum.ALL_VERSIONS) @@ -252,7 +252,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { // execute JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters( new ReindexJobParameters() .setOptimizeStorage(ReindexParameters.OptimizeStorageModeEnum.CURRENT_VERSION) @@ -294,7 +294,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { // execute JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(parameters); Batch2JobStartResponse res = myJobCoordinator.startInstance(mySrd, startRequest); myBatch2JobHelper.awaitJobCompletion(res); @@ -325,7 +325,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { // execute JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(parameters); Batch2JobStartResponse res = myJobCoordinator.startInstance(startRequest); JobInstance jobInstance = myBatch2JobHelper.awaitJobCompletion(res); @@ -356,7 +356,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { parameters.addUrl("Observation?status=final"); JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(parameters); Batch2JobStartResponse res = myJobCoordinator.startInstance(mySrd, startRequest); myBatch2JobHelper.awaitJobCompletion(res); @@ -387,7 +387,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { // execute JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(new ReindexJobParameters()); Batch2JobStartResponse startResponse = myJobCoordinator.startInstance(mySrd, startRequest); myBatch2JobHelper.awaitJobCompletion(startResponse); @@ -406,7 +406,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { DaoMethodOutcome searchParameter = myReindexTestHelper.createUniqueCodeSearchParameter(); JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(new ReindexJobParameters()); Batch2JobStartResponse startResponse = myJobCoordinator.startInstance(new SystemRequestDetails(), startRequest); JobInstance myJob = myBatch2JobHelper.awaitJobCompletion(startResponse); @@ -436,7 +436,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { // Run a reindex JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(new ReindexJobParameters()); Batch2JobStartResponse startResponse = myJobCoordinator.startInstance(new SystemRequestDetails(), startRequest); JobInstance myJob = myBatch2JobHelper.awaitJobCompletion(startResponse.getInstanceId(), 999); @@ -469,7 +469,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { // Run a reindex JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(new ReindexJobParameters()); Batch2JobStartResponse startResponse = myJobCoordinator.startInstance(new SystemRequestDetails(), startRequest); JobInstance myJob = myBatch2JobHelper.awaitJobCompletion(startResponse.getInstanceId(), 999); @@ -500,7 +500,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { // execute JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(new ReindexJobParameters()); Batch2JobStartResponse startResponse = myJobCoordinator.startInstance(mySrd, startRequest); JobInstance outcome = myBatch2JobHelper.awaitJobCompletion(startResponse); @@ -528,7 +528,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { // execute JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(new ReindexJobParameters()); Batch2JobStartResponse startResponse = myJobCoordinator.startInstance(new SystemRequestDetails(), startRequest); JobInstance outcome = myBatch2JobHelper.awaitJobFailure(startResponse); @@ -541,7 +541,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { @Test public void testReindex_withReindexingUponSearchParameterChangeEnabled_reindexJobCompleted() { - List jobInstances = myJobPersistence.fetchInstancesByJobDefinitionId(ReindexAppCtx.JOB_REINDEX, 10, 0); + List jobInstances = myJobPersistence.fetchInstancesByJobDefinitionId(JOB_REINDEX, 10, 0); assertThat(jobInstances).isEmpty(); // make sure the resources auto-reindex after the search parameter update is enabled @@ -552,7 +552,7 @@ public class ReindexTaskTest extends BaseJpaR4Test { myReindexTestHelper.createCodeSearchParameter(); // check that reindex job was created - jobInstances = myJobPersistence.fetchInstancesByJobDefinitionId(ReindexAppCtx.JOB_REINDEX, 10, 0); + jobInstances = myJobPersistence.fetchInstancesByJobDefinitionId(JOB_REINDEX, 10, 0); assertThat(jobInstances).hasSize(1); // check that the job is completed (not stuck in QUEUED status) diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexTaskWithPartitioningTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexTaskWithPartitioningTest.java index 6ab5bec996f..35657c3ab47 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexTaskWithPartitioningTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/reindex/ReindexTaskWithPartitioningTest.java @@ -3,7 +3,6 @@ package ca.uhn.fhir.jpa.reindex; import ca.uhn.fhir.batch2.api.IJobCoordinator; import ca.uhn.fhir.batch2.jobs.parameters.PartitionedUrl; import ca.uhn.fhir.batch2.jobs.parameters.PartitionedUrlJobParameters; -import ca.uhn.fhir.batch2.jobs.reindex.ReindexAppCtx; import ca.uhn.fhir.batch2.model.JobInstance; import ca.uhn.fhir.batch2.model.JobInstanceStartRequest; import ca.uhn.fhir.interceptor.model.RequestPartitionId; @@ -25,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import java.util.List; import java.util.stream.Stream; +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; import static org.assertj.core.api.Assertions.assertThat; @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ReindexTaskWithPartitioningTest extends BaseJpaR4Test { @@ -133,7 +133,7 @@ public class ReindexTaskWithPartitioningTest extends BaseJpaR4Test { // execute JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(parameters); Batch2JobStartResponse res = myJobCoordinator.startInstance(new SystemRequestDetails(), startRequest); JobInstance jobInstance = myBatch2JobHelper.awaitJobCompletion(res); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4Test.java index a0a1862f3b3..d6f5039d129 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4Test.java @@ -1,6 +1,5 @@ package ca.uhn.fhir.jpa.term; -import ca.uhn.fhir.batch2.jobs.reindex.ReindexAppCtx; import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; import ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils; import ca.uhn.fhir.batch2.model.JobInstanceStartRequest; @@ -68,6 +67,7 @@ import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; import static ca.uhn.fhir.util.HapiExtensions.EXT_VALUESET_EXPANSION_MESSAGE; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -2229,7 +2229,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test implements IValueSet ReindexJobParameters params = new ReindexJobParameters(); params.addUrl("CodeSystem?"); JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); startRequest.setParameters(params); // and wait for it to complete diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/PatientReindexTestHelper.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/PatientReindexTestHelper.java index 346ecfc519f..bb063387b89 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/PatientReindexTestHelper.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/PatientReindexTestHelper.java @@ -38,6 +38,7 @@ import org.junit.jupiter.params.provider.Arguments; import java.util.List; import java.util.stream.Stream; +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; @@ -170,7 +171,7 @@ public class PatientReindexTestHelper { private JobInstanceStartRequest createPatientReindexRequest(int theBatchSize) { JobInstanceStartRequest startRequest = new JobInstanceStartRequest(); - startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + startRequest.setJobDefinitionId(JOB_REINDEX); ReindexJobParameters reindexJobParameters = new ReindexJobParameters(); reindexJobParameters.setBatchSize(Math.max(theBatchSize,1)); diff --git a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/TermDeferredStorageSvcImplTest.java b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/TermDeferredStorageSvcImplTest.java index eed255e7842..2365300b65a 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/TermDeferredStorageSvcImplTest.java +++ b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/TermDeferredStorageSvcImplTest.java @@ -17,11 +17,15 @@ import org.springframework.test.util.ReflectionTestUtils; import org.springframework.transaction.PlatformTransactionManager; import java.util.ArrayList; +import java.util.List; import java.util.Optional; +import static ca.uhn.fhir.batch2.jobs.termcodesystem.TermCodeSystemJobConfig.TERM_CODE_SYSTEM_DELETE_JOB_NAME; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.same; import static org.mockito.Mockito.times; @@ -67,8 +71,15 @@ public class TermDeferredStorageSvcImplTest { ReflectionTestUtils.setField(mySvc, "myJobExecutions", mockExecutions); - when(myJobCoordinator.getInstance(eq(jobId))) - .thenReturn(instance); + when(myJobCoordinator.getInstancesbyJobDefinitionIdAndEndedStatus( + eq(TERM_CODE_SYSTEM_DELETE_JOB_NAME), + eq(true), + anyInt(), + eq(0) + )) + .thenReturn(List.of()) // first nothing + .thenReturn(List.of(instance)); // then the list with the instance + assertFalse(mySvc.isStorageQueueEmpty(true)); instance.setStatus(StatusEnum.COMPLETED); assertTrue(mySvc.isStorageQueueEmpty(true)); diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/BaseReindexStep.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/BaseReindexStep.java deleted file mode 100644 index 95e5f5be163..00000000000 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/BaseReindexStep.java +++ /dev/null @@ -1,66 +0,0 @@ -package ca.uhn.fhir.batch2.jobs.reindex; - -import ca.uhn.fhir.batch2.api.IJobDataSink; -import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson; -import ca.uhn.fhir.batch2.jobs.reindex.models.ReindexResults; -import ca.uhn.fhir.jpa.api.dao.DaoRegistry; -import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; -import ca.uhn.fhir.jpa.api.svc.IIdHelperService; -import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; -import ca.uhn.fhir.rest.api.server.RequestDetails; -import ca.uhn.fhir.rest.api.server.SystemRequestDetails; -import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; -import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; - -public abstract class BaseReindexStep { - - public static final int REINDEX_MAX_RETRIES = 10; - - protected final HapiTransactionService myHapiTransactionService; - - protected final IFhirSystemDao mySystemDao; - - protected final DaoRegistry myDaoRegistry; - - protected final IIdHelperService> myIdHelperService; - - public BaseReindexStep( - HapiTransactionService theHapiTransactionService, - IFhirSystemDao theSystemDao, - DaoRegistry theRegistry, - IIdHelperService> theIdHelperService) { - myHapiTransactionService = theHapiTransactionService; - mySystemDao = theSystemDao; - myDaoRegistry = theRegistry; - myIdHelperService = theIdHelperService; - } - - public ReindexResults doReindex( - ResourceIdListWorkChunkJson data, - IJobDataSink theDataSink, - String theInstanceId, - String theChunkId, - ReindexJobParameters theJobParameters) { - RequestDetails requestDetails = new SystemRequestDetails(); - requestDetails.setRetry(true); - requestDetails.setMaxRetries(REINDEX_MAX_RETRIES); - - TransactionDetails transactionDetails = new TransactionDetails(); - ReindexTask.JobParameters jp = new ReindexTask.JobParameters(); - jp.setData(data) - .setRequestDetails(requestDetails) - .setTransactionDetails(transactionDetails) - .setDataSink(theDataSink) - .setInstanceId(theInstanceId) - .setChunkId(theChunkId) - .setJobParameters(theJobParameters); - - ReindexTask reindexJob = new ReindexTask(jp, myDaoRegistry, mySystemDao, myIdHelperService); - - return myHapiTransactionService - .withRequest(requestDetails) - .withTransactionDetails(transactionDetails) - .withRequestPartitionId(data.getRequestPartitionId()) - .execute(reindexJob); - } -} diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexAppCtx.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexAppCtx.java index 816b5044cc2..ba335b1f60b 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexAppCtx.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexAppCtx.java @@ -21,33 +21,24 @@ package ca.uhn.fhir.batch2.jobs.reindex; import ca.uhn.fhir.batch2.api.IJobCoordinator; import ca.uhn.fhir.batch2.api.IJobPartitionProvider; -import ca.uhn.fhir.batch2.api.IJobStepWorker; -import ca.uhn.fhir.batch2.api.VoidModel; -import ca.uhn.fhir.batch2.jobs.chunk.ChunkRangeJson; -import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson; -import ca.uhn.fhir.batch2.jobs.parameters.UrlListValidator; -import ca.uhn.fhir.batch2.jobs.reindex.models.ReindexResults; import ca.uhn.fhir.batch2.jobs.reindex.svcs.ReindexJobService; -import ca.uhn.fhir.batch2.jobs.step.GenerateRangeChunksStep; -import ca.uhn.fhir.batch2.jobs.step.LoadIdsStep; -import ca.uhn.fhir.batch2.model.JobDefinition; +import ca.uhn.fhir.batch2.jobs.reindex.v1.ReindexV1Config; +import ca.uhn.fhir.batch2.jobs.reindex.v2.ReindexV2Config; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; -import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; -import ca.uhn.fhir.rest.server.provider.ProviderConstants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; @Configuration +@Import({ReindexV1Config.class, ReindexV2Config.class}) public class ReindexAppCtx { - public static final String JOB_REINDEX = "REINDEX"; - @Autowired private HapiTransactionService myHapiTransactionService; @@ -60,87 +51,7 @@ public class ReindexAppCtx { @Autowired private IIdHelperService> myIdHelperService; - // Version 2 - @Bean - public JobDefinition reindexJobDefinitionV2(IBatch2DaoSvc theBatch2DaoSvc) { - return JobDefinition.newBuilder() - .setJobDefinitionId(JOB_REINDEX) - .setJobDescription("Reindex resources") - .setJobDefinitionVersion(2) - .setParametersType(ReindexJobParameters.class) - .setParametersValidator(reindexJobParametersValidator(theBatch2DaoSvc)) - .gatedExecution() - .addFirstStep( - "generate-ranges", - "Generate data ranges to reindex", - ChunkRangeJson.class, - reindexGenerateRangeChunksStep()) - .addIntermediateStep( - "load-ids", - "Load IDs of resources to reindex", - ResourceIdListWorkChunkJson.class, - reindexLoadIdsStep(theBatch2DaoSvc)) - .addIntermediateStep( - "reindex-start", "Perform the resource reindex", ReindexResults.class, reindexStepV2()) - .addLastStep("reindex-pending-work", "Waits for reindex work to complete.", pendingWorkStep()) - .build(); - } - - // Version 1 - @Bean - public JobDefinition reindexJobDefinitionV1(IBatch2DaoSvc theBatch2DaoSvc) { - return JobDefinition.newBuilder() - .setJobDefinitionId(JOB_REINDEX) - .setJobDescription("Reindex resources") - .setJobDefinitionVersion(1) - .setParametersType(ReindexJobParameters.class) - .setParametersValidator(reindexJobParametersValidator(theBatch2DaoSvc)) - .gatedExecution() - .addFirstStep( - "generate-ranges", - "Generate data ranges to reindex", - ChunkRangeJson.class, - reindexGenerateRangeChunksStep()) - .addIntermediateStep( - "load-ids", - "Load IDs of resources to reindex", - ResourceIdListWorkChunkJson.class, - reindexLoadIdsStep(theBatch2DaoSvc)) - .addLastStep("reindex-start", "Start the resource reindex", reindexStepV1()) - .build(); - } - - @Bean - public IJobStepWorker reindexGenerateRangeChunksStep() { - return new GenerateRangeChunksStep<>(); - } - - @Bean - public IJobStepWorker reindexLoadIdsStep( - IBatch2DaoSvc theBatch2DaoSvc) { - return new LoadIdsStep<>(theBatch2DaoSvc); - } - - @Bean - public ReindexJobParametersValidator reindexJobParametersValidator(IBatch2DaoSvc theBatch2DaoSvc) { - return new ReindexJobParametersValidator( - new UrlListValidator(ProviderConstants.OPERATION_REINDEX, theBatch2DaoSvc)); - } - - @Bean - public ReindexStepV1 reindexStepV1() { - return new ReindexStepV1(myHapiTransactionService, mySystemDao, myRegistry, myIdHelperService); - } - - @Bean - public ReindexStepV2 reindexStepV2() { - return new ReindexStepV2(jobService(), myHapiTransactionService, mySystemDao, myRegistry, myIdHelperService); - } - - @Bean - public CheckPendingReindexWorkStep pendingWorkStep() { - return new CheckPendingReindexWorkStep(jobService()); - } + /* Shared services */ @Bean public ReindexProvider reindexProvider( diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexProvider.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexProvider.java index 5889a75d4e9..a8f8e08707c 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexProvider.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexProvider.java @@ -44,6 +44,7 @@ import java.util.stream.Collectors; import static ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters.OPTIMIZE_STORAGE; import static ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters.REINDEX_SEARCH_PARAMETERS; +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; public class ReindexProvider { @@ -127,7 +128,7 @@ public class ReindexProvider { myJobPartitionProvider.getPartitionedUrls(theRequestDetails, urls).forEach(params::addPartitionedUrl); JobInstanceStartRequest request = new JobInstanceStartRequest(); - request.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX); + request.setJobDefinitionId(JOB_REINDEX); request.setParameters(params); Batch2JobStartResponse response = myJobCoordinator.startInstance(theRequestDetails, request); diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexUtils.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexUtils.java index d102dbc2341..e54b32a90cc 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexUtils.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexUtils.java @@ -7,6 +7,13 @@ import java.time.temporal.ChronoUnit; public class ReindexUtils { + /** + * The reindex job definition id + */ + public static final String JOB_REINDEX = "REINDEX"; + + public static final int REINDEX_MAX_RETRIES = 10; + private static final Duration RETRY_DELAY = Duration.of(30, ChronoUnit.SECONDS); private static Duration myDelay; diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v1/ReindexJobParametersValidatorV1.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v1/ReindexJobParametersValidatorV1.java new file mode 100644 index 00000000000..a54ef49f9eb --- /dev/null +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v1/ReindexJobParametersValidatorV1.java @@ -0,0 +1,57 @@ +/*- + * #%L + * hapi-fhir-storage-batch2-jobs + * %% + * Copyright (C) 2014 - 2024 Smile CDR, Inc. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package ca.uhn.fhir.batch2.jobs.reindex.v1; + +import ca.uhn.fhir.batch2.api.IJobParametersValidator; +import ca.uhn.fhir.batch2.jobs.parameters.IUrlListValidator; +import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; +import ca.uhn.fhir.rest.api.server.RequestDetails; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; + +import java.util.ArrayList; +import java.util.List; + +@Deprecated(forRemoval = true, since = "7.6.0") +public class ReindexJobParametersValidatorV1 implements IJobParametersValidator { + + private final IUrlListValidator myUrlListValidator; + + public ReindexJobParametersValidatorV1(IUrlListValidator theUrlListValidator) { + myUrlListValidator = theUrlListValidator; + } + + @Nullable + @Override + public List validate(RequestDetails theRequestDetails, @Nonnull ReindexJobParameters theParameters) { + List errors = myUrlListValidator.validateUrls(theParameters.getUrls()); + + if (errors == null || errors.isEmpty()) { + // only check if there's no other errors (new list to fix immutable issues) + errors = new ArrayList<>(); + for (String url : theParameters.getUrls()) { + if (url.contains(" ") || url.contains("\n") || url.contains("\t")) { + errors.add("Invalid URL. URL cannot contain spaces : " + url); + } + } + } + return errors; + } +} diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexStepV1.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v1/ReindexStepV1.java similarity index 52% rename from hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexStepV1.java rename to hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v1/ReindexStepV1.java index 77db5d78455..6d539be0214 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexStepV1.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v1/ReindexStepV1.java @@ -17,7 +17,7 @@ * limitations under the License. * #L% */ -package ca.uhn.fhir.batch2.jobs.reindex; +package ca.uhn.fhir.batch2.jobs.reindex.v1; import ca.uhn.fhir.batch2.api.IJobDataSink; import ca.uhn.fhir.batch2.api.IJobStepWorker; @@ -26,26 +26,46 @@ import ca.uhn.fhir.batch2.api.RunOutcome; import ca.uhn.fhir.batch2.api.StepExecutionDetails; import ca.uhn.fhir.batch2.api.VoidModel; import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson; +import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; +import ca.uhn.fhir.batch2.jobs.reindex.ReindexTask; +import ca.uhn.fhir.batch2.jobs.reindex.models.ReindexResults; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; +import ca.uhn.fhir.rest.api.server.RequestDetails; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import jakarta.annotation.Nonnull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ReindexStepV1 extends BaseReindexStep - implements IJobStepWorker { +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.REINDEX_MAX_RETRIES; + +@Deprecated(forRemoval = true, since = "7.6.0") +public class ReindexStepV1 implements IJobStepWorker { private static final Logger ourLog = LoggerFactory.getLogger(ReindexStepV1.class); + private final HapiTransactionService myHapiTransactionService; + + private final IFhirSystemDao mySystemDao; + + private final DaoRegistry myDaoRegistry; + + private final IIdHelperService> myIdHelperService; + + public ReindexStepV1( HapiTransactionService theHapiTransactionService, IFhirSystemDao theSystemDao, DaoRegistry theRegistry, IIdHelperService> theIdHelperService) { - super(theHapiTransactionService, theSystemDao, theRegistry, theIdHelperService); + myDaoRegistry = theRegistry; + myHapiTransactionService = theHapiTransactionService; + mySystemDao = theSystemDao; + myIdHelperService = theIdHelperService; } @Nonnull @@ -67,4 +87,33 @@ public class ReindexStepV1 extends BaseReindexStep return new RunOutcome(data.size()); } + + public ReindexResults doReindex( + ResourceIdListWorkChunkJson data, + IJobDataSink theDataSink, + String theInstanceId, + String theChunkId, + ReindexJobParameters theJobParameters) { + RequestDetails requestDetails = new SystemRequestDetails(); + requestDetails.setRetry(true); + requestDetails.setMaxRetries(REINDEX_MAX_RETRIES); + + TransactionDetails transactionDetails = new TransactionDetails(); + ReindexTask.JobParameters jp = new ReindexTask.JobParameters(); + jp.setData(data) + .setRequestDetails(requestDetails) + .setTransactionDetails(transactionDetails) + .setDataSink(theDataSink) + .setInstanceId(theInstanceId) + .setChunkId(theChunkId) + .setJobParameters(theJobParameters); + + ReindexTask reindexJob = new ReindexTask(jp, myDaoRegistry, mySystemDao, myIdHelperService); + + return myHapiTransactionService + .withRequest(requestDetails) + .withTransactionDetails(transactionDetails) + .withRequestPartitionId(data.getRequestPartitionId()) + .execute(reindexJob); + } } diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v1/ReindexV1Config.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v1/ReindexV1Config.java new file mode 100644 index 00000000000..2fddd0b4a4a --- /dev/null +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v1/ReindexV1Config.java @@ -0,0 +1,100 @@ +package ca.uhn.fhir.batch2.jobs.reindex.v1; + +import ca.uhn.fhir.batch2.api.IJobStepWorker; +import ca.uhn.fhir.batch2.api.VoidModel; +import ca.uhn.fhir.batch2.jobs.chunk.ChunkRangeJson; +import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson; +import ca.uhn.fhir.batch2.jobs.parameters.UrlListValidator; +import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; +import ca.uhn.fhir.batch2.jobs.reindex.svcs.ReindexJobService; +import ca.uhn.fhir.batch2.jobs.step.GenerateRangeChunksStep; +import ca.uhn.fhir.batch2.jobs.step.LoadIdsStep; +import ca.uhn.fhir.batch2.model.JobDefinition; +import ca.uhn.fhir.jpa.api.dao.DaoRegistry; +import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; +import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc; +import ca.uhn.fhir.jpa.api.svc.IIdHelperService; +import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; +import ca.uhn.fhir.rest.server.provider.ProviderConstants; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; + +@Deprecated(forRemoval = true, since = "7.6.0") +@Configuration +public class ReindexV1Config { + @Autowired + private ReindexJobService myReindexJobService; + @Autowired + private HapiTransactionService myHapiTransactionService; + + @Autowired + private IFhirSystemDao mySystemDao; + + @Autowired + private DaoRegistry myRegistry; + + @Autowired + private IIdHelperService> myIdHelperService; + + @Autowired + @Qualifier("reindexGenerateRangeChunkStepV1") + private IJobStepWorker myReindexGenerateRangeChunkStep; + + @Autowired + @Qualifier("reindexLoadIdsStepV1") + private IJobStepWorker myReindexLoadIdsStep; + + @Autowired + private ReindexJobParametersValidatorV1 myReindexJobParametersValidatorV1; + + // Version 1 + @Bean + public JobDefinition reindexJobDefinitionV1() { + return JobDefinition.newBuilder() + .setJobDefinitionId(JOB_REINDEX) + .setJobDescription("Reindex resources") + .setJobDefinitionVersion(1) + .setParametersType(ReindexJobParameters.class) + .setParametersValidator(myReindexJobParametersValidatorV1) + .gatedExecution() + .addFirstStep( + "generate-ranges", + "Generate data ranges to reindex", + ChunkRangeJson.class, + myReindexGenerateRangeChunkStep) + .addIntermediateStep( + "load-ids", + "Load IDs of resources to reindex", + ResourceIdListWorkChunkJson.class, + myReindexLoadIdsStep) + .addLastStep("reindex-start", "Start the resource reindex", reindexStepV1()) + .build(); + } + + @Bean + public ReindexStepV1 reindexStepV1() { + return new ReindexStepV1(myHapiTransactionService, mySystemDao, myRegistry, myIdHelperService); + } + + @Bean("reindexGenerateRangeChunkStepV1") + public IJobStepWorker reindexGenerateRangeChunksStep() { + return new GenerateRangeChunksStep<>(); + } + + @Bean("reindexLoadIdsStepV1") + public IJobStepWorker reindexLoadIdsStep( + IBatch2DaoSvc theBatch2DaoSvc) { + return new LoadIdsStep<>(theBatch2DaoSvc); + } + + @Bean + public ReindexJobParametersValidatorV1 reindexJobParametersValidatorV1(IBatch2DaoSvc theBatch2DaoSvc) { + return new ReindexJobParametersValidatorV1( + new UrlListValidator(ProviderConstants.OPERATION_REINDEX, theBatch2DaoSvc)); + } +} diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/CheckPendingReindexWorkStep.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/CheckPendingReindexWorkStep.java similarity index 90% rename from hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/CheckPendingReindexWorkStep.java rename to hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/CheckPendingReindexWorkStep.java index f412b8fa6ae..9a9dfd294f9 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/CheckPendingReindexWorkStep.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/CheckPendingReindexWorkStep.java @@ -1,4 +1,4 @@ -package ca.uhn.fhir.batch2.jobs.reindex; +package ca.uhn.fhir.batch2.jobs.reindex.v2; import ca.uhn.fhir.batch2.api.IJobDataSink; import ca.uhn.fhir.batch2.api.IJobStepWorker; @@ -7,6 +7,8 @@ import ca.uhn.fhir.batch2.api.RetryChunkLaterException; import ca.uhn.fhir.batch2.api.RunOutcome; import ca.uhn.fhir.batch2.api.StepExecutionDetails; import ca.uhn.fhir.batch2.api.VoidModel; +import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; +import ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils; import ca.uhn.fhir.batch2.jobs.reindex.models.ReindexResults; import ca.uhn.fhir.batch2.jobs.reindex.svcs.ReindexJobService; import ca.uhn.fhir.i18n.Msg; diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexJobParametersValidator.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/ReindexJobParametersValidatorV2.java similarity index 85% rename from hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexJobParametersValidator.java rename to hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/ReindexJobParametersValidatorV2.java index b7560a8ef57..9bfbbfe6564 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexJobParametersValidator.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/ReindexJobParametersValidatorV2.java @@ -17,10 +17,11 @@ * limitations under the License. * #L% */ -package ca.uhn.fhir.batch2.jobs.reindex; +package ca.uhn.fhir.batch2.jobs.reindex.v2; import ca.uhn.fhir.batch2.api.IJobParametersValidator; import ca.uhn.fhir.batch2.jobs.parameters.IUrlListValidator; +import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; import ca.uhn.fhir.rest.api.server.RequestDetails; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; @@ -28,11 +29,11 @@ import jakarta.annotation.Nullable; import java.util.ArrayList; import java.util.List; -public class ReindexJobParametersValidator implements IJobParametersValidator { +public class ReindexJobParametersValidatorV2 implements IJobParametersValidator { private final IUrlListValidator myUrlListValidator; - public ReindexJobParametersValidator(IUrlListValidator theUrlListValidator) { + public ReindexJobParametersValidatorV2(IUrlListValidator theUrlListValidator) { myUrlListValidator = theUrlListValidator; } diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexStepV2.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/ReindexStepV2.java similarity index 57% rename from hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexStepV2.java rename to hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/ReindexStepV2.java index d58dc855e6f..1f1c0e83f72 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexStepV2.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/ReindexStepV2.java @@ -1,4 +1,4 @@ -package ca.uhn.fhir.batch2.jobs.reindex; +package ca.uhn.fhir.batch2.jobs.reindex.v2; import ca.uhn.fhir.batch2.api.IJobDataSink; import ca.uhn.fhir.batch2.api.IJobStepWorker; @@ -7,6 +7,9 @@ import ca.uhn.fhir.batch2.api.RetryChunkLaterException; import ca.uhn.fhir.batch2.api.RunOutcome; import ca.uhn.fhir.batch2.api.StepExecutionDetails; import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson; +import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; +import ca.uhn.fhir.batch2.jobs.reindex.ReindexTask; +import ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils; import ca.uhn.fhir.batch2.jobs.reindex.models.ReindexResults; import ca.uhn.fhir.batch2.jobs.reindex.svcs.ReindexJobService; import ca.uhn.fhir.i18n.Msg; @@ -14,16 +17,29 @@ import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; +import ca.uhn.fhir.rest.api.server.RequestDetails; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import jakarta.annotation.Nonnull; import java.util.HashMap; import java.util.Map; -public class ReindexStepV2 extends BaseReindexStep +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.REINDEX_MAX_RETRIES; + +public class ReindexStepV2 implements IJobStepWorker { private final ReindexJobService myReindexJobService; + private final HapiTransactionService myHapiTransactionService; + + private final IFhirSystemDao mySystemDao; + + private final DaoRegistry myDaoRegistry; + + private final IIdHelperService> myIdHelperService; + public ReindexStepV2( ReindexJobService theJobService, @@ -31,7 +47,10 @@ public class ReindexStepV2 extends BaseReindexStep IFhirSystemDao theSystemDao, DaoRegistry theRegistry, IIdHelperService> theIdHelperService) { - super(theHapiTransactionService, theSystemDao, theRegistry, theIdHelperService); + myDaoRegistry = theRegistry; + myHapiTransactionService = theHapiTransactionService; + mySystemDao = theSystemDao; + myIdHelperService = theIdHelperService; myReindexJobService = theJobService; } @@ -69,4 +88,33 @@ public class ReindexStepV2 extends BaseReindexStep return new RunOutcome(data.size()); } + + public ReindexResults doReindex( + ResourceIdListWorkChunkJson data, + IJobDataSink theDataSink, + String theInstanceId, + String theChunkId, + ReindexJobParameters theJobParameters) { + RequestDetails requestDetails = new SystemRequestDetails(); + requestDetails.setRetry(true); + requestDetails.setMaxRetries(REINDEX_MAX_RETRIES); + + TransactionDetails transactionDetails = new TransactionDetails(); + ReindexTask.JobParameters jp = new ReindexTask.JobParameters(); + jp.setData(data) + .setRequestDetails(requestDetails) + .setTransactionDetails(transactionDetails) + .setDataSink(theDataSink) + .setInstanceId(theInstanceId) + .setChunkId(theChunkId) + .setJobParameters(theJobParameters); + + ReindexTask reindexJob = new ReindexTask(jp, myDaoRegistry, mySystemDao, myIdHelperService); + + return myHapiTransactionService + .withRequest(requestDetails) + .withTransactionDetails(transactionDetails) + .withRequestPartitionId(data.getRequestPartitionId()) + .execute(reindexJob); + } } diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/ReindexV2Config.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/ReindexV2Config.java new file mode 100644 index 00000000000..a402df42e85 --- /dev/null +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/v2/ReindexV2Config.java @@ -0,0 +1,109 @@ +package ca.uhn.fhir.batch2.jobs.reindex.v2; + +import ca.uhn.fhir.batch2.api.IJobStepWorker; +import ca.uhn.fhir.batch2.api.VoidModel; +import ca.uhn.fhir.batch2.jobs.chunk.ChunkRangeJson; +import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson; +import ca.uhn.fhir.batch2.jobs.parameters.UrlListValidator; +import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters; +import ca.uhn.fhir.batch2.jobs.reindex.models.ReindexResults; +import ca.uhn.fhir.batch2.jobs.reindex.svcs.ReindexJobService; +import ca.uhn.fhir.batch2.jobs.step.GenerateRangeChunksStep; +import ca.uhn.fhir.batch2.jobs.step.LoadIdsStep; +import ca.uhn.fhir.batch2.model.JobDefinition; +import ca.uhn.fhir.jpa.api.dao.DaoRegistry; +import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; +import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc; +import ca.uhn.fhir.jpa.api.svc.IIdHelperService; +import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; +import ca.uhn.fhir.rest.server.provider.ProviderConstants; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import static ca.uhn.fhir.batch2.jobs.reindex.ReindexUtils.JOB_REINDEX; + +@Configuration +public class ReindexV2Config { + + @Autowired + private ReindexJobService myReindexJobService; + @Autowired + private HapiTransactionService myHapiTransactionService; + + @Autowired + private IFhirSystemDao mySystemDao; + + @Autowired + private DaoRegistry myRegistry; + + @Autowired + private IIdHelperService> myIdHelperService; + + @Autowired + @Qualifier("reindexGenerateRangeChunkStepV2") + private IJobStepWorker myReindexGenerateRangeChunkStep; + + @Autowired + @Qualifier("reindexLoadIdsStepV2") + private IJobStepWorker myReindexLoadIdsStep; + + @Autowired + private ReindexJobParametersValidatorV2 myReindexJobParametersValidator; + + + // Version 2 + @Bean + public JobDefinition reindexJobDefinitionV2() { + return JobDefinition.newBuilder() + .setJobDefinitionId(JOB_REINDEX) + .setJobDescription("Reindex resources") + .setJobDefinitionVersion(2) + .setParametersType(ReindexJobParameters.class) + .setParametersValidator(myReindexJobParametersValidator) + .gatedExecution() + .addFirstStep( + "generate-ranges", + "Generate data ranges to reindex", + ChunkRangeJson.class, + myReindexGenerateRangeChunkStep) + .addIntermediateStep( + "load-ids", + "Load IDs of resources to reindex", + ResourceIdListWorkChunkJson.class, + myReindexLoadIdsStep) + .addIntermediateStep( + "reindex-start", "Perform the resource reindex", ReindexResults.class, reindexStepV2()) + .addLastStep("reindex-pending-work", "Waits for reindex work to complete.", pendingWorkStep()) + .build(); + } + + @Bean + public CheckPendingReindexWorkStep pendingWorkStep() { + return new CheckPendingReindexWorkStep(myReindexJobService); + } + + @Bean + public ReindexStepV2 reindexStepV2() { + return new ReindexStepV2(myReindexJobService, myHapiTransactionService, mySystemDao, myRegistry, myIdHelperService); + } + + @Bean("reindexGenerateRangeChunkStepV2") + public IJobStepWorker reindexGenerateRangeChunksStep() { + return new GenerateRangeChunksStep<>(); + } + + @Bean("reindexLoadIdsStepV2") + public IJobStepWorker reindexLoadIdsStep( + IBatch2DaoSvc theBatch2DaoSvc) { + return new LoadIdsStep<>(theBatch2DaoSvc); + } + + @Bean + public ReindexJobParametersValidatorV2 reindexJobParametersValidatorV2(IBatch2DaoSvc theBatch2DaoSvc) { + return new ReindexJobParametersValidatorV2( + new UrlListValidator(ProviderConstants.OPERATION_REINDEX, theBatch2DaoSvc)); + } +} diff --git a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexTaskParametersValidatorTest.java b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexTaskParametersValidatorTest.java index 5f3b62f91c5..f03db306889 100644 --- a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexTaskParametersValidatorTest.java +++ b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexTaskParametersValidatorTest.java @@ -1,6 +1,7 @@ package ca.uhn.fhir.batch2.jobs.reindex; import ca.uhn.fhir.batch2.jobs.parameters.UrlListValidator; +import ca.uhn.fhir.batch2.jobs.reindex.v1.ReindexJobParametersValidatorV1; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -19,7 +20,7 @@ public class ReindexTaskParametersValidatorTest { private UrlListValidator myListValidator; @InjectMocks - private ReindexJobParametersValidator myValidator; + private ReindexJobParametersValidatorV1 myValidator; @ParameterizedTest @ValueSource(strings = { "\n", " ", "\t" })