diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_0_0/3529-move-expunge-to-storage.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_0_0/3529-move-expunge-to-storage.yaml new file mode 100644 index 00000000000..5c55380d65b --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_0_0/3529-move-expunge-to-storage.yaml @@ -0,0 +1,4 @@ +type: change +issue: 3529 +title: "Several classes and interfaces related to the `$expunge` operation have moved from the hapi-fhir-jpaserver-base +project to the hapi-fhir-storage project." diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/mdm/job/MdmLinkDeleter.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/mdm/job/MdmLinkDeleter.java index 262f9e2bc8a..8cbc47eb5ad 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/mdm/job/MdmLinkDeleter.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/mdm/job/MdmLinkDeleter.java @@ -58,7 +58,7 @@ public class MdmLinkDeleter implements ItemProcessor, List> { public List process(List thePidList) throws Exception { ConcurrentLinkedQueue goldenPidAggregator = new ConcurrentLinkedQueue<>(); PartitionRunner partitionRunner = new PartitionRunner(PROCESS_NAME, THREAD_PREFIX, myDaoConfig.getReindexBatchSize(), myDaoConfig.getReindexThreadCount()); - partitionRunner.runInPartitionedThreads(new SliceImpl<>(thePidList), pids -> removeLinks(pids, goldenPidAggregator)); + partitionRunner.runInPartitionedThreads(thePidList, pids -> removeLinks(pids, goldenPidAggregator)); return new ArrayList<>(goldenPidAggregator); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java index 2e744fcbc7d..1935de39a83 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java @@ -16,8 +16,8 @@ import ca.uhn.fhir.jpa.batch.config.BatchConstants; import ca.uhn.fhir.jpa.batch.job.PartitionedUrlValidator; import ca.uhn.fhir.jpa.batch.mdm.MdmClearJobSubmitterImpl; import ca.uhn.fhir.jpa.batch.reader.BatchResourceSearcher; -import ca.uhn.fhir.jpa.binary.provider.BinaryAccessProvider; import ca.uhn.fhir.jpa.binary.interceptor.BinaryStorageInterceptor; +import ca.uhn.fhir.jpa.binary.provider.BinaryAccessProvider; import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportJobSchedulingHelper; import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportSvc; import ca.uhn.fhir.jpa.bulk.export.provider.BulkDataExportProvider; @@ -38,6 +38,7 @@ import ca.uhn.fhir.jpa.dao.TransactionProcessor; import ca.uhn.fhir.jpa.dao.expunge.ExpungeEverythingService; import ca.uhn.fhir.jpa.dao.expunge.ExpungeOperation; import ca.uhn.fhir.jpa.dao.expunge.ExpungeService; +import ca.uhn.fhir.jpa.dao.expunge.IExpungeEverythingService; import ca.uhn.fhir.jpa.dao.expunge.IResourceExpungeService; import ca.uhn.fhir.jpa.dao.expunge.ResourceExpungeService; import ca.uhn.fhir.jpa.dao.expunge.ResourceTableFKProvider; @@ -758,7 +759,7 @@ public class JpaConfig { } @Bean - public ExpungeEverythingService expungeEverythingService() { + public IExpungeEverythingService expungeEverythingService() { return new ExpungeEverythingService(); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeEverythingService.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeEverythingService.java index f3522b86af0..73d89c88325 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeEverythingService.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeEverythingService.java @@ -92,7 +92,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @Service -public class ExpungeEverythingService { +public class ExpungeEverythingService implements IExpungeEverythingService { private static final Logger ourLog = LoggerFactory.getLogger(ExpungeEverythingService.class); @PersistenceContext(type = PersistenceContextType.TRANSACTION) protected EntityManager myEntityManager; @@ -111,6 +111,7 @@ public class ExpungeEverythingService { myTxTemplate = new TransactionTemplate(myPlatformTransactionManager); } + @Override public void expungeEverything(@Nullable RequestDetails theRequest) { final AtomicInteger counter = new AtomicInteger(); @@ -224,6 +225,7 @@ public class ExpungeEverythingService { return outcome; } + @Override public int expungeEverythingByType(Class theEntityType) { int result = expungeEverythingByTypeWithoutPurging(theEntityType); purgeAllCaches(); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ResourceExpungeService.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ResourceExpungeService.java index 1e444b7a0f4..5a1c0b09208 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ResourceExpungeService.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ResourceExpungeService.java @@ -45,7 +45,6 @@ import ca.uhn.fhir.jpa.dao.data.IResourceProvenanceDao; import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; import ca.uhn.fhir.jpa.dao.data.IResourceTagDao; import ca.uhn.fhir.jpa.dao.data.ISearchParamPresentDao; -import ca.uhn.fhir.jpa.dao.index.IdHelperService; import ca.uhn.fhir.jpa.model.entity.ForcedId; import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable; import ca.uhn.fhir.jpa.model.entity.ResourceTable; @@ -126,42 +125,45 @@ public class ResourceExpungeService implements IResourceExpungeService { @Override @Transactional - public Slice findHistoricalVersionsOfNonDeletedResources(String theResourceName, Long theResourceId, Long theVersion, int theRemainingCount) { + public List findHistoricalVersionsOfNonDeletedResources(String theResourceName, Long theResourceId, Long theVersion, int theRemainingCount) { Pageable page = PageRequest.of(0, theRemainingCount); + + Slice ids; if (theResourceId != null) { if (theVersion != null) { - return toSlice(myResourceHistoryTableDao.findForIdAndVersionAndFetchProvenance(theResourceId, theVersion)); + ids = toSlice(myResourceHistoryTableDao.findForIdAndVersionAndFetchProvenance(theResourceId, theVersion)); } else { - return myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResourceId(page, theResourceId); + ids = myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResourceId(page, theResourceId); } } else { if (theResourceName != null) { - return myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResources(page, theResourceName); + ids = myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResources(page, theResourceName); } else { - return myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResources(page); + ids = myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResources(page); } } + + return ids.getContent(); } @Override @Transactional - public Slice findHistoricalVersionsOfDeletedResources(String theResourceName, Long theResourceId, int theRemainingCount) { + public List findHistoricalVersionsOfDeletedResources(String theResourceName, Long theResourceId, int theRemainingCount) { Pageable page = PageRequest.of(0, theRemainingCount); + Slice ids; if (theResourceId != null) { - Slice ids = myResourceTableDao.findIdsOfDeletedResourcesOfType(page, theResourceId, theResourceName); + ids = myResourceTableDao.findIdsOfDeletedResourcesOfType(page, theResourceId, theResourceName); ourLog.info("Expunging {} deleted resources of type[{}] and ID[{}]", ids.getNumberOfElements(), theResourceName, theResourceId); - return ids; } else { if (theResourceName != null) { - Slice ids = myResourceTableDao.findIdsOfDeletedResourcesOfType(page, theResourceName); + ids = myResourceTableDao.findIdsOfDeletedResourcesOfType(page, theResourceName); ourLog.info("Expunging {} deleted resources of type[{}]", ids.getNumberOfElements(), theResourceName); - return ids; } else { - Slice ids = myResourceTableDao.findIdsOfDeletedResources(page); + ids = myResourceTableDao.findIdsOfDeletedResources(page); ourLog.info("Expunging {} deleted resources (all types)", ids.getNumberOfElements()); - return ids; } } + return ids.getContent(); } @Override diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/job/DeleteExpungeProcessor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/job/DeleteExpungeProcessor.java index 7df1eef61b8..bffee9b7d9a 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/job/DeleteExpungeProcessor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/job/DeleteExpungeProcessor.java @@ -33,8 +33,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.item.ItemProcessor; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Slice; -import org.springframework.data.domain.SliceImpl; import java.util.ArrayList; import java.util.Collections; @@ -62,7 +60,7 @@ public class DeleteExpungeProcessor implements ItemProcessor, List process(List thePids) throws Exception { - validateOkToDeleteAndExpunge(new SliceImpl<>(thePids)); + validateOkToDeleteAndExpunge(thePids); List retval = new ArrayList<>(); @@ -79,7 +77,7 @@ public class DeleteExpungeProcessor implements ItemProcessor, List thePids) { + public void validateOkToDeleteAndExpunge(List thePids) { if (!myDaoConfig.isEnforceReferentialIntegrityOnDelete()) { ourLog.info("Referential integrity on delete disabled. Skipping referential integrity check."); return; @@ -87,7 +85,7 @@ public class DeleteExpungeProcessor implements ItemProcessor, List conflictResourceLinks = Collections.synchronizedList(new ArrayList<>()); PartitionRunner partitionRunner = new PartitionRunner(PROCESS_NAME, THREAD_PREFIX, myDaoConfig.getExpungeBatchSize(), myDaoConfig.getExpungeThreadCount()); - partitionRunner.runInPartitionedThreads(thePids, someTargetPids -> findResourceLinksWithTargetPidIn(thePids.getContent(), someTargetPids, conflictResourceLinks)); + partitionRunner.runInPartitionedThreads(thePids, someTargetPids -> findResourceLinksWithTargetPidIn(thePids, someTargetPids, conflictResourceLinks)); if (conflictResourceLinks.isEmpty()) { return; diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmStorageInterceptor.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmStorageInterceptor.java index 2d30467ed8c..1cfac44c5dc 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmStorageInterceptor.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmStorageInterceptor.java @@ -22,30 +22,26 @@ package ca.uhn.fhir.jpa.mdm.interceptor; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.dao.expunge.IExpungeEverythingService; import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import ca.uhn.fhir.mdm.api.MdmConstants; import ca.uhn.fhir.mdm.api.IMdmSettings; import ca.uhn.fhir.mdm.model.CanonicalEID; import ca.uhn.fhir.mdm.util.EIDHelper; import ca.uhn.fhir.mdm.util.MdmResourceUtil; -import ca.uhn.fhir.mdm.util.GoldenResourceHelper; import ca.uhn.fhir.interceptor.api.Hook; import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.jpa.dao.mdm.MdmLinkDeleteSvc; -import ca.uhn.fhir.jpa.dao.expunge.ExpungeEverythingService; import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.r4.model.Extension; -import org.hl7.fhir.r4.model.Patient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -56,7 +52,7 @@ public class MdmStorageInterceptor implements IMdmStorageInterceptor { private static final Logger ourLog = LoggerFactory.getLogger(MdmStorageInterceptor.class); @Autowired - private ExpungeEverythingService myExpungeEverythingService; + private IExpungeEverythingService myExpungeEverythingService; @Autowired private MdmLinkDeleteSvc myMdmLinkDeleteSvc; @Autowired diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java index 3c3c63e3d0d..7412526d951 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java @@ -2,7 +2,7 @@ package ca.uhn.fhir.jpa.mdm.svc; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.i18n.Msg; -import ca.uhn.fhir.jpa.dao.expunge.ExpungeEverythingService; +import ca.uhn.fhir.jpa.dao.expunge.IExpungeEverythingService; import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; import ca.uhn.fhir.mdm.api.IMdmLinkSvc; @@ -35,7 +35,7 @@ public class MdmLinkSvcTest extends BaseMdmR4Test { @Autowired IMdmLinkSvc myMdmLinkSvc; @Autowired - ExpungeEverythingService myExpungeEverythingService; + IExpungeEverythingService myExpungeEverythingService; @Override @AfterEach diff --git a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunnerTest.java b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunnerTest.java index 4518cfc9a2a..e92d43b95ee 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunnerTest.java +++ b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunnerTest.java @@ -9,8 +9,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.data.domain.Slice; -import org.springframework.data.domain.SliceImpl; import java.util.ArrayList; import java.util.List; @@ -36,7 +34,7 @@ public class PartitionRunnerTest { @Test public void emptyList() { - Slice resourceIds = buildSlice(0); + List resourceIds = buildPidList(0); Consumer> partitionConsumer = buildPartitionConsumer(myLatch); myLatch.setExpectedCount(0); @@ -56,17 +54,17 @@ public class PartitionRunnerTest { return new PartitionRunner("TEST", "test", theBatchSize, theThreadCount); } - private Slice buildSlice(int size) { + private List buildPidList(int size) { List list = new ArrayList<>(); for (long i = 0; i < size; ++i) { list.add(i + 1); } - return new SliceImpl(list); + return list; } @Test public void oneItem() throws InterruptedException { - Slice resourceIds = buildSlice(1); + List resourceIds = buildPidList(1); Consumer> partitionConsumer = buildPartitionConsumer(myLatch); myLatch.setExpectedCount(1); @@ -79,7 +77,7 @@ public class PartitionRunnerTest { @Test public void twoItems() throws InterruptedException { - Slice resourceIds = buildSlice(2); + List resourceIds = buildPidList(2); Consumer> partitionConsumer = buildPartitionConsumer(myLatch); myLatch.setExpectedCount(1); @@ -91,7 +89,7 @@ public class PartitionRunnerTest { @Test public void tenItemsBatch5() throws InterruptedException { - Slice resourceIds = buildSlice(10); + List resourceIds = buildPidList(10); Consumer> partitionConsumer = buildPartitionConsumer(myLatch); myLatch.setExpectedCount(2); @@ -108,7 +106,7 @@ public class PartitionRunnerTest { @Test public void nineItemsBatch5() throws InterruptedException { - Slice resourceIds = buildSlice(9); + List resourceIds = buildPidList(9); // We don't care in which order, but one partition size should be // 5 and one should be 4 @@ -129,7 +127,7 @@ public class PartitionRunnerTest { @Test public void tenItemsOneThread() throws InterruptedException { - Slice resourceIds = buildSlice(10); + List resourceIds = buildPidList(10); Consumer> partitionConsumer = buildPartitionConsumer(myLatch); myLatch.setExpectedCount(2); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeOperation.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeOperation.java similarity index 85% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeOperation.java rename to hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeOperation.java index 297cfbfd95f..fbe97ccdb2a 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeOperation.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeOperation.java @@ -28,9 +28,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; -import org.springframework.data.domain.Slice; import org.springframework.stereotype.Component; +import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; @@ -82,7 +82,7 @@ public class ExpungeOperation implements Callable { } private void expungeDeletedResources() { - Slice resourceIds = findHistoricalVersionsOfDeletedResources(); + List resourceIds = findHistoricalVersionsOfDeletedResources(); deleteHistoricalVersions(resourceIds); if (expungeLimitReached()) { @@ -92,13 +92,13 @@ public class ExpungeOperation implements Callable { deleteCurrentVersionsOfDeletedResources(resourceIds); } - private Slice findHistoricalVersionsOfDeletedResources() { - Slice retVal = myExpungeDaoService.findHistoricalVersionsOfDeletedResources(myResourceName, myResourceId, myRemainingCount.get()); - ourLog.debug("Found {} historical versions", retVal.getSize()); + private List findHistoricalVersionsOfDeletedResources() { + List retVal = myExpungeDaoService.findHistoricalVersionsOfDeletedResources(myResourceName, myResourceId, myRemainingCount.get()); + ourLog.debug("Found {} historical versions", retVal.size()); return retVal; } - private Slice findHistoricalVersionsOfNonDeletedResources() { + private List findHistoricalVersionsOfNonDeletedResources() { return myExpungeDaoService.findHistoricalVersionsOfNonDeletedResources(myResourceName, myResourceId, myVersion, myRemainingCount.get()); } @@ -111,7 +111,7 @@ public class ExpungeOperation implements Callable { } private void expungeOldVersions() { - Slice historicalIds = findHistoricalVersionsOfNonDeletedResources(); + List historicalIds = findHistoricalVersionsOfNonDeletedResources(); getPartitionRunner().runInPartitionedThreads(historicalIds, partition -> myExpungeDaoService.expungeHistoricalVersions(myRequestDetails, partition, myRemainingCount)); } @@ -120,11 +120,11 @@ public class ExpungeOperation implements Callable { return new PartitionRunner(PROCESS_NAME, THREAD_PREFIX, myDaoConfig.getExpungeBatchSize(), myDaoConfig.getExpungeThreadCount()); } - private void deleteCurrentVersionsOfDeletedResources(Slice theResourceIds) { + private void deleteCurrentVersionsOfDeletedResources(List theResourceIds) { getPartitionRunner().runInPartitionedThreads(theResourceIds, partition -> myExpungeDaoService.expungeCurrentVersionOfResources(myRequestDetails, partition, myRemainingCount)); } - private void deleteHistoricalVersions(Slice theResourceIds) { + private void deleteHistoricalVersions(List theResourceIds) { getPartitionRunner().runInPartitionedThreads(theResourceIds, partition -> myExpungeDaoService.expungeHistoricalVersionsOfIds(myRequestDetails, partition, myRemainingCount)); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeService.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeService.java similarity index 97% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeService.java rename to hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeService.java index ea2c3296db6..1d473b2c927 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeService.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeService.java @@ -36,7 +36,7 @@ public class ExpungeService { private static final Logger ourLog = LoggerFactory.getLogger(ExpungeService.class); @Autowired - private ExpungeEverythingService myExpungeEverythingService; + private IExpungeEverythingService myExpungeEverythingService; @Autowired private IResourceExpungeService myExpungeDaoService; @Autowired diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IExpungeEverythingService.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IExpungeEverythingService.java new file mode 100644 index 00000000000..4d74f08fde9 --- /dev/null +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IExpungeEverythingService.java @@ -0,0 +1,11 @@ +package ca.uhn.fhir.jpa.dao.expunge; + +import ca.uhn.fhir.rest.api.server.RequestDetails; + +import javax.annotation.Nullable; + +public interface IExpungeEverythingService { + void expungeEverything(@Nullable RequestDetails theRequest); + + int expungeEverythingByType(Class theEntityType); +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IResourceExpungeService.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IResourceExpungeService.java similarity index 82% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IResourceExpungeService.java rename to hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IResourceExpungeService.java index 19701c4fdbf..d8d8a6b4213 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IResourceExpungeService.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IResourceExpungeService.java @@ -21,15 +21,14 @@ package ca.uhn.fhir.jpa.dao.expunge; */ import ca.uhn.fhir.rest.api.server.RequestDetails; -import org.springframework.data.domain.Slice; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; public interface IResourceExpungeService { - Slice findHistoricalVersionsOfDeletedResources(String theResourceName, Long theResourceId, int theI); + List findHistoricalVersionsOfDeletedResources(String theResourceName, Long theResourceId, int theI); - Slice findHistoricalVersionsOfNonDeletedResources(String theResourceName, Long theResourceId, Long theVersion, int theI); + List findHistoricalVersionsOfNonDeletedResources(String theResourceName, Long theResourceId, Long theVersion, int theI); void expungeHistoricalVersions(RequestDetails theRequestDetails, List thePartition, AtomicInteger theRemainingCount); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunner.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunner.java similarity index 90% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunner.java rename to hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunner.java index 4dcf477ad69..5cca08bb326 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunner.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunner.java @@ -27,7 +27,6 @@ import com.google.common.collect.Lists; import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.data.domain.Slice; import java.util.ArrayList; import java.util.List; @@ -58,7 +57,7 @@ public class PartitionRunner { myThreadCount = theThreadCount; } - public void runInPartitionedThreads(Slice theResourceIds, Consumer> partitionConsumer) { + public void runInPartitionedThreads(List theResourceIds, Consumer> partitionConsumer) { List> callableTasks = buildCallableTasks(theResourceIds, partitionConsumer); if (callableTasks.size() == 0) { @@ -93,15 +92,15 @@ public class PartitionRunner { } } - private List> buildCallableTasks(Slice theResourceIds, Consumer> partitionConsumer) { + private List> buildCallableTasks(List theResourceIds, Consumer> partitionConsumer) { List> retval = new ArrayList<>(); - if (myBatchSize > theResourceIds.getContent().size()) { - ourLog.info("Splitting batch job of {} entries into chunks of {}", theResourceIds.getContent().size(), myBatchSize); + if (myBatchSize > theResourceIds.size()) { + ourLog.info("Splitting batch job of {} entries into chunks of {}", theResourceIds.size(), myBatchSize); } else { - ourLog.info("Creating batch job of {} entries", theResourceIds.getContent().size()); + ourLog.info("Creating batch job of {} entries", theResourceIds.size()); } - List> partitions = Lists.partition(theResourceIds.getContent(), myBatchSize); + List> partitions = Lists.partition(theResourceIds, myBatchSize); for (List nextPartition : partitions) { if (nextPartition.size() > 0) {