fixed second expunge bug reported by FMCNA
This commit is contained in:
parent
de4cc89568
commit
1d5f648070
|
@ -310,8 +310,12 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao,
|
||||||
*/
|
*/
|
||||||
Pageable page = PageRequest.of(0, remainingCount.get());
|
Pageable page = PageRequest.of(0, remainingCount.get());
|
||||||
Slice<Long> historicalIds = txTemplate.execute(t -> {
|
Slice<Long> historicalIds = txTemplate.execute(t -> {
|
||||||
if (theResourceId != null && theVersion != null) {
|
if (theResourceId != null) {
|
||||||
return toSlice(myResourceHistoryTableDao.findForIdAndVersion(theResourceId, theVersion));
|
if (theVersion != null) {
|
||||||
|
return toSlice(myResourceHistoryTableDao.findForIdAndVersion(theResourceId, theVersion));
|
||||||
|
} else {
|
||||||
|
return myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResourceId(page, theResourceId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (theResourceName != null) {
|
if (theResourceName != null) {
|
||||||
return myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResources(page, theResourceName);
|
return myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResources(page, theResourceName);
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
package ca.uhn.fhir.jpa.dao.data;
|
package ca.uhn.fhir.jpa.dao.data;
|
||||||
|
|
||||||
import java.util.Collection;
|
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import javax.persistence.TemporalType;
|
|
||||||
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
@ -13,7 +9,9 @@ import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.jpa.repository.Temporal;
|
import org.springframework.data.jpa.repository.Temporal;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
|
import javax.persistence.TemporalType;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
|
@ -74,6 +72,13 @@ public interface IResourceHistoryTableDao extends JpaRepository<ResourceHistoryT
|
||||||
@Query("SELECT t.myId FROM ResourceHistoryTable t WHERE t.myResourceId = :resId AND t.myResourceVersion != :dontWantVersion")
|
@Query("SELECT t.myId FROM ResourceHistoryTable t WHERE t.myResourceId = :resId AND t.myResourceVersion != :dontWantVersion")
|
||||||
Slice<Long> findForResourceId(Pageable thePage, @Param("resId") Long theId, @Param("dontWantVersion") Long theDontWantVersion);
|
Slice<Long> findForResourceId(Pageable thePage, @Param("resId") Long theId, @Param("dontWantVersion") Long theDontWantVersion);
|
||||||
|
|
||||||
|
@Query("" +
|
||||||
|
"SELECT v.myId FROM ResourceHistoryTable v " +
|
||||||
|
"LEFT OUTER JOIN ResourceTable t ON (v.myResourceId = t.myId) " +
|
||||||
|
"WHERE v.myResourceVersion != t.myVersion AND " +
|
||||||
|
"t.myId = :resId")
|
||||||
|
Slice<Long> findIdsOfPreviousVersionsOfResourceId(Pageable thePage, @Param("resId") Long theResourceId);
|
||||||
|
|
||||||
@Query("" +
|
@Query("" +
|
||||||
"SELECT v.myId FROM ResourceHistoryTable v " +
|
"SELECT v.myId FROM ResourceHistoryTable v " +
|
||||||
"LEFT OUTER JOIN ResourceTable t ON (v.myResourceId = t.myId) " +
|
"LEFT OUTER JOIN ResourceTable t ON (v.myResourceId = t.myId) " +
|
||||||
|
|
|
@ -18,7 +18,8 @@ import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class ResourceProviderExpungeDstu3Test extends BaseResourceProviderDstu3Test {
|
public class ResourceProviderExpungeDstu3Test extends BaseResourceProviderDstu3Test {
|
||||||
|
|
||||||
|
@ -326,6 +327,26 @@ public class ResourceProviderExpungeDstu3Test extends BaseResourceProviderDstu3T
|
||||||
assertGone(myDeletedObservationId);
|
assertGone(myDeletedObservationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExpungeNothing() {
|
||||||
|
|
||||||
|
myPatientDao.expunge(myOneVersionPatientId.toUnqualifiedVersionless(), new ExpungeOptions()
|
||||||
|
.setExpungeDeletedResources(true)
|
||||||
|
.setExpungeOldVersions(true));
|
||||||
|
|
||||||
|
// Patients
|
||||||
|
assertStillThere(myOneVersionPatientId);
|
||||||
|
assertStillThere(myTwoVersionPatientId.withVersion("1"));
|
||||||
|
assertStillThere(myTwoVersionPatientId.withVersion("2"));
|
||||||
|
assertGone(myDeletedPatientId);
|
||||||
|
|
||||||
|
// No observations deleted
|
||||||
|
assertStillThere(myOneVersionObservationId);
|
||||||
|
assertStillThere(myTwoVersionObservationId.withVersion("1"));
|
||||||
|
assertStillThere(myTwoVersionObservationId.withVersion("2"));
|
||||||
|
assertGone(myDeletedObservationId);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParameters() {
|
public void testParameters() {
|
||||||
Parameters p = new Parameters();
|
Parameters p = new Parameters();
|
||||||
|
|
Loading…
Reference in New Issue