Merge branch 'philips-3.6.0'

This commit is contained in:
James Agnew 2018-11-01 09:15:27 -04:00
commit 4315900ac0
6 changed files with 117 additions and 23 deletions

View File

@ -65,6 +65,15 @@ public class PersistedJpaSearchFirstPageBundleProvider extends PersistedJpaBundl
txTemplate.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRED); txTemplate.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRED);
List<IBaseResource> retVal = txTemplate.execute(theStatus -> toResourceList(mySearchBuilder, pids)); List<IBaseResource> retVal = txTemplate.execute(theStatus -> toResourceList(mySearchBuilder, pids));
int totalCountWanted = theToIndex - theFromIndex;
if (retVal.size() < totalCountWanted) {
if (mySearch.getStatus() == SearchStatusEnum.PASSCMPLET) {
int remainingWanted = totalCountWanted - retVal.size();
int fromIndex = theToIndex - remainingWanted;
List<IBaseResource> remaining = super.getResources(fromIndex, theToIndex);
retVal.addAll(remaining);
}
}
ourLog.trace("Loaded resources to return"); ourLog.trace("Loaded resources to return");
return retVal; return retVal;

View File

@ -229,17 +229,19 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
txTemplate.afterPropertiesSet(); txTemplate.afterPropertiesSet();
return txTemplate.execute(t -> { return txTemplate.execute(t -> {
myEntityManager.refresh(theSearch); Search search = mySearchDao.findById(theSearch.getId()).orElse(theSearch);
if (theSearch.getStatus() != SearchStatusEnum.PASSCMPLET) {
if (search.getStatus() != SearchStatusEnum.PASSCMPLET) {
throw new IllegalStateException("Can't change to LOADING because state is " + theSearch.getStatus()); throw new IllegalStateException("Can't change to LOADING because state is " + theSearch.getStatus());
} }
theSearch.setStatus(SearchStatusEnum.LOADING); search.setStatus(SearchStatusEnum.LOADING);
Search newSearch = mySearchDao.save(theSearch); Search newSearch = mySearchDao.save(search);
return Optional.of(newSearch); return Optional.of(newSearch);
}); });
} catch (Exception e) { } catch (Exception e) {
ourLog.warn("Failed to activate search: {}", e.toString()); ourLog.warn("Failed to activate search: {}", e.toString());
ourLog.trace("Failed to activate search", e); // FIXME: aaaaa
ourLog.info("Failed to activate search", e);
return Optional.empty(); return Optional.empty();
} }
} }
@ -511,9 +513,10 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
* user has requested resources 0-60, then they would get 0-50 back but the search * user has requested resources 0-60, then they would get 0-50 back but the search
* coordinator would then stop searching.SearchCoordinatorSvcImplTest * coordinator would then stop searching.SearchCoordinatorSvcImplTest
*/ */
List<Long> remainingResources = SearchCoordinatorSvcImpl.this.getResources(mySearch.getUuid(), mySyncedPids.size(), theToIndex); // FIXME: aaaaaaaa
ourLog.debug("Adding {} resources to the existing {} synced resource IDs", remainingResources.size(), mySyncedPids.size()); // List<Long> remainingResources = SearchCoordinatorSvcImpl.this.getResources(mySearch.getUuid(), mySyncedPids.size(), theToIndex);
mySyncedPids.addAll(remainingResources); // ourLog.debug("Adding {} resources to the existing {} synced resource IDs", remainingResources.size(), mySyncedPids.size());
// mySyncedPids.addAll(remainingResources);
keepWaiting = false; keepWaiting = false;
break; break;
case FAILED: case FAILED:

View File

@ -176,6 +176,70 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest {
return null; return null;
} }
@Test
public void testTransactionReSavesPreviouslyDeletedResources() {
{
Bundle input = new Bundle();
input.setType(BundleType.TRANSACTION);
Patient pt = new Patient();
pt.setId("pt");
pt.setActive(true);
input
.addEntry()
.setResource(pt)
.getRequest()
.setUrl("Patient/pt")
.setMethod(HTTPVerb.PUT);
Observation obs = new Observation();
obs.setId("obs");
obs.getSubject().setReference("Patient/pt");
input
.addEntry()
.setResource(obs)
.getRequest()
.setUrl("Observation/obs")
.setMethod(HTTPVerb.PUT);
mySystemDao.transaction(null, input);
}
myObservationDao.delete(new IdType("Observation/obs"));
myPatientDao.delete(new IdType("Patient/pt"));
{
Bundle input = new Bundle();
input.setType(BundleType.TRANSACTION);
Patient pt = new Patient();
pt.setId("pt");
pt.setActive(true);
input
.addEntry()
.setResource(pt)
.getRequest()
.setUrl("Patient/pt")
.setMethod(HTTPVerb.PUT);
Observation obs = new Observation();
obs.setId("obs");
obs.getSubject().setReference("Patient/pt");
input
.addEntry()
.setResource(obs)
.getRequest()
.setUrl("Observation/obs")
.setMethod(HTTPVerb.PUT);
mySystemDao.transaction(null, input);
}
myPatientDao.read(new IdType("Patient/pt"));
}
@Test @Test
public void testResourceCounts() { public void testResourceCounts() {
Patient p = new Patient(); Patient p = new Patient();

View File

@ -34,7 +34,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
@ -52,6 +51,7 @@ import static org.mockito.Mockito.*;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class SearchCoordinatorSvcImplTest { public class SearchCoordinatorSvcImplTest {
private static final Logger ourLog = LoggerFactory.getLogger(SearchCoordinatorSvcImplTest.class);
private static FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
@Captor @Captor
ArgumentCaptor<Iterable<SearchResult>> mySearchResultIterCaptor; ArgumentCaptor<Iterable<SearchResult>> mySearchResultIterCaptor;
@ -69,7 +69,6 @@ public class SearchCoordinatorSvcImplTest {
@Mock @Mock
private ISearchResultDao mySearchResultDao; private ISearchResultDao mySearchResultDao;
private SearchCoordinatorSvcImpl mySvc; private SearchCoordinatorSvcImpl mySvc;
@Mock @Mock
private PlatformTransactionManager myTxManager; private PlatformTransactionManager myTxManager;
private DaoConfig myDaoConfig; private DaoConfig myDaoConfig;
@ -159,7 +158,7 @@ public class SearchCoordinatorSvcImplTest {
} }
} }
private static final Logger ourLog = LoggerFactory.getLogger(SearchCoordinatorSvcImplTest.class);
@Test @Test
public void testAsyncSearchLargeResultSetBigCountSameCoordinator() { public void testAsyncSearchLargeResultSetBigCountSameCoordinator() {
SearchParameterMap params = new SearchParameterMap(); SearchParameterMap params = new SearchParameterMap();
@ -174,7 +173,7 @@ private static final Logger ourLog = LoggerFactory.getLogger(SearchCoordinatorSv
List<Long> returnedValues = iter.getReturnedValues(); List<Long> returnedValues = iter.getReturnedValues();
Pageable page = (Pageable) t.getArguments()[1]; Pageable page = (Pageable) t.getArguments()[1];
int offset = (int) page.getOffset(); int offset = (int) page.getOffset();
int end = (int)(page.getOffset() + page.getPageSize()); int end = (int) (page.getOffset() + page.getPageSize());
end = Math.min(end, returnedValues.size()); end = Math.min(end, returnedValues.size());
offset = Math.min(offset, returnedValues.size()); offset = Math.min(offset, returnedValues.size());
ourLog.info("findWithSearchUuid {} - {} out of {} values", offset, end, returnedValues.size()); ourLog.info("findWithSearchUuid {} - {} out of {} values", offset, end, returnedValues.size());
@ -214,7 +213,7 @@ private static final Logger ourLog = LoggerFactory.getLogger(SearchCoordinatorSv
assertEquals(10, allResults.get(0).getResourcePid().longValue()); assertEquals(10, allResults.get(0).getResourcePid().longValue());
assertEquals(799, allResults.get(789).getResourcePid().longValue()); assertEquals(799, allResults.get(789).getResourcePid().longValue());
myExpectedNumberOfSearchBuildersCreated = 3; myExpectedNumberOfSearchBuildersCreated = 4;
} }
@Test @Test

View File

@ -223,16 +223,6 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
int start = Math.max(0, theOffset - theLimit); int start = Math.max(0, theOffset - theLimit);
linkPrev = RestfulServerUtils.createPagingLink(theIncludes, serverBase, searchId, start, theLimit, theRequest.getParameters(), prettyPrint, theBundleType); linkPrev = RestfulServerUtils.createPagingLink(theIncludes, serverBase, searchId, start, theLimit, theRequest.getParameters(), prettyPrint, theBundleType);
} }
// int offset = theOffset + resourceList.size();
//
// // We're doing offset pages
// if (numTotalResults == null || offset < numTotalResults) {
// linkNext = (RestfulServerUtils.createPagingLink(theIncludes, serverBase, searchId, offset, numToReturn, theRequest.getParameters(), prettyPrint, theBundleType));
// }
// if (theOffset > 0) {
// int start = Math.max(0, theOffset - theLimit);
// linkPrev = RestfulServerUtils.createPagingLink(theIncludes, serverBase, searchId, start, theLimit, theRequest.getParameters(), prettyPrint, theBundleType);
// }
} }
bundleFactory.addRootPropertiesToBundle(theResult.getUuid(), serverBase, theLinkSelf, linkPrev, linkNext, theResult.size(), theBundleType, theResult.getPublished()); bundleFactory.addRootPropertiesToBundle(theResult.getUuid(), serverBase, theLinkSelf, linkPrev, linkNext, theResult.size(), theBundleType, theResult.getPublished());

View File

@ -27,6 +27,35 @@ public class FhirTerserDstu3Test {
private static FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
@Test
public void testCloneIntoBundle() {
Bundle input = new Bundle();
input.setType(Bundle.BundleType.TRANSACTION);
Patient pt = new Patient();
pt.setId("pt");
pt.setActive(true);
input
.addEntry()
.setResource(pt)
.getRequest()
.setUrl("Patient/pt")
.setMethod(Bundle.HTTPVerb.PUT);
Observation obs = new Observation();
obs.setId("obs");
obs.getSubject().setReference("Patient/pt");
input
.addEntry()
.setResource(obs)
.getRequest()
.setUrl("Observation/obs")
.setMethod(Bundle.HTTPVerb.PUT);
Bundle ionputClone = new Bundle();
ourCtx.newTerser().cloneInto(input, ionputClone, false);
}
@Test @Test
public void testCloneIntoComposite() { public void testCloneIntoComposite() {
Quantity source = new Quantity(); Quantity source = new Quantity();