Allow configuration of default page size in SimpleBundleProvider
This commit is contained in:
parent
d04db790a3
commit
f03d6b7c22
|
@ -19,13 +19,14 @@ cache:
|
|||
|
||||
install: /bin/true
|
||||
|
||||
# This seems to be required to get travis to set Xmx4g, per https://github.com/travis-ci/travis-ci/issues/3893
|
||||
before_script:
|
||||
# This seems to be required to get travis to set Xmx4g, per https://github.com/travis-ci/travis-ci/issues/3893
|
||||
- export MAVEN_SKIP_RC=true
|
||||
# Sometimes things get restored from the cache with bad permissions. See https://github.com/travis-ci/travis-ci/issues/9630
|
||||
- sudo chmod -R 777 "$HOME/.m2/repository";
|
||||
- sudo chown -R travis:travis "$HOME/.m2/repository";
|
||||
|
||||
script:
|
||||
# - mvn -e -B clean install && cd hapi-fhir-ra && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID clean test jacoco:report coveralls:report
|
||||
# - mvn -Dci=true -e -B -P ALLMODULES,NOPARALLEL,ERRORPRONE clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report
|
||||
- sudo chmod -R 777 "$HOME/.m2/repository";
|
||||
- sudo chown -R travis:travis "$HOME/.m2/repository";
|
||||
- mvn -Dci=true -e -B -P ALLMODULES,REDUCED_JPA_TESTS,ERRORPRONE,JACOCO clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report;
|
||||
|
|
|
@ -23,6 +23,9 @@ package ca.uhn.fhir.jpa.entity;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
|
||||
/**
|
||||
* @see ResourceHistoryTable#ENCODING_COL_LENGTH
|
||||
*/
|
||||
public enum ResourceEncodingEnum {
|
||||
|
||||
/*
|
||||
|
|
|
@ -43,6 +43,10 @@ public class ResourceHistoryTable extends BaseHasResource implements Serializabl
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String IDX_RESVER_ID_VER = "IDX_RESVER_ID_VER";
|
||||
/**
|
||||
* @see ResourceEncodingEnum
|
||||
*/
|
||||
public static final int ENCODING_COL_LENGTH = 5;
|
||||
|
||||
@Id
|
||||
@SequenceGenerator(name = "SEQ_RESOURCE_HISTORY_ID", sequenceName = "SEQ_RESOURCE_HISTORY_ID")
|
||||
|
@ -67,7 +71,7 @@ public class ResourceHistoryTable extends BaseHasResource implements Serializabl
|
|||
@OptimisticLock(excluded = true)
|
||||
private byte[] myResource;
|
||||
|
||||
@Column(name = "RES_ENCODING", nullable = false, length = 5)
|
||||
@Column(name = "RES_ENCODING", nullable = false, length = ENCODING_COL_LENGTH)
|
||||
@Enumerated(EnumType.STRING)
|
||||
@OptimisticLock(excluded = true)
|
||||
private ResourceEncodingEnum myEncoding;
|
||||
|
|
|
@ -61,6 +61,7 @@ import org.springframework.transaction.support.TransactionCallback;
|
|||
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
@ -408,7 +409,11 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
myManagedTxManager = theTxManager;
|
||||
}
|
||||
|
||||
static Pageable toPage(final int theFromIndex, int theToIndex) {
|
||||
/**
|
||||
* Creates a {@link Pageable} using a start and end index
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public static @Nullable Pageable toPage(final int theFromIndex, int theToIndex) {
|
||||
int pageSize = theToIndex - theFromIndex;
|
||||
if (pageSize < 1) {
|
||||
return null;
|
||||
|
|
|
@ -31,6 +31,7 @@ public class SimpleBundleProvider implements IBundleProvider {
|
|||
|
||||
private final List<IBaseResource> myList;
|
||||
private final String myUuid;
|
||||
private Integer myPreferredPageSize;
|
||||
|
||||
public SimpleBundleProvider(List<IBaseResource> theList) {
|
||||
this(theList, null);
|
||||
|
@ -69,9 +70,20 @@ public class SimpleBundleProvider implements IBundleProvider {
|
|||
return myUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defaults to null
|
||||
*/
|
||||
@Override
|
||||
public Integer preferredPageSize() {
|
||||
return null;
|
||||
return myPreferredPageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preferred page size to be returned by {@link #preferredPageSize()}.
|
||||
* Default is <code>null</code>.
|
||||
*/
|
||||
public void setPreferredPageSize(Integer thePreferredPageSize) {
|
||||
myPreferredPageSize = thePreferredPageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -65,8 +65,8 @@ public class HashMapResourceProvider<T extends IBaseResource> implements IResour
|
|||
private final Class<T> myResourceType;
|
||||
private final FhirContext myFhirContext;
|
||||
private final String myResourceName;
|
||||
protected Map<String, TreeMap<Long, T>> myIdToVersionToResourceMap = new HashMap<>();
|
||||
protected Map<String, LinkedList<T>> myIdToHistory = new HashMap<>();
|
||||
protected Map<String, TreeMap<Long, T>> myIdToVersionToResourceMap = new LinkedHashMap<>();
|
||||
protected Map<String, LinkedList<T>> myIdToHistory = new LinkedHashMap<>();
|
||||
protected LinkedList<T> myTypeHistory = new LinkedList<>();
|
||||
private long myNextId;
|
||||
private AtomicLong myDeleteCount = new AtomicLong(0);
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SimpleBundleProviderTest {
|
||||
|
||||
@Test
|
||||
public void testPreferredPageSize() {
|
||||
SimpleBundleProvider p = new SimpleBundleProvider();
|
||||
assertEquals(null, p.preferredPageSize());
|
||||
|
||||
p.setPreferredPageSize(100);
|
||||
assertEquals(100, p.preferredPageSize().intValue());
|
||||
}
|
||||
|
||||
}
|
|
@ -164,7 +164,9 @@
|
|||
<![CDATA[<code>_id</code>]]> search parameter now has the
|
||||
search parameter marked as "required". This means that additional
|
||||
search methods can be added in subclasses without their intended
|
||||
searches being routed to the searchById method.
|
||||
searches being routed to the searchById method. Also, the resource
|
||||
map now uses a LinkedHashMap, so searches return a predictable
|
||||
order for unit tests.
|
||||
</action>
|
||||
<action type="fix">
|
||||
Fixed a bug when creating a custom search parameter in the JPA
|
||||
|
@ -209,7 +211,8 @@
|
|||
</action>
|
||||
<action type="add">
|
||||
SimpleBundleProvider has been modified to optionally allow calling
|
||||
code to specify a search UUID
|
||||
code to specify a search UUID, and a field to allow the preferred
|
||||
page size to be configured.
|
||||
</action>
|
||||
</release>
|
||||
<release version="3.4.0" date="2018-05-28">
|
||||
|
|
Loading…
Reference in New Issue