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());
|
||||
Slice<Long> historicalIds = txTemplate.execute(t -> {
|
||||
if (theResourceId != null && theVersion != null) {
|
||||
if (theResourceId != null) {
|
||||
if (theVersion != null) {
|
||||
return toSlice(myResourceHistoryTableDao.findForIdAndVersion(theResourceId, theVersion));
|
||||
} else {
|
||||
return myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResourceId(page, theResourceId);
|
||||
}
|
||||
} else {
|
||||
if (theResourceName != null) {
|
||||
return myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResources(page, theResourceName);
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package ca.uhn.fhir.jpa.dao.data;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
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.repository.query.Param;
|
||||
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
|
||||
import javax.persistence.TemporalType;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
/*
|
||||
* #%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")
|
||||
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("" +
|
||||
"SELECT v.myId FROM ResourceHistoryTable v " +
|
||||
"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.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class ResourceProviderExpungeDstu3Test extends BaseResourceProviderDstu3Test {
|
||||
|
||||
|
@ -326,6 +327,26 @@ public class ResourceProviderExpungeDstu3Test extends BaseResourceProviderDstu3T
|
|||
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
|
||||
public void testParameters() {
|
||||
Parameters p = new Parameters();
|
||||
|
|
Loading…
Reference in New Issue