Jm improve test server helper (#6281)
* Improve docs as indexing is not the only function using extraction * Add providers map which to be able to add any kind of provider dynamically --------- Co-authored-by: juan.marchionatto <juan.marchionatto@smilecdr.com>
This commit is contained in:
parent
ab2ba05fb5
commit
699f863fe2
|
@ -44,13 +44,13 @@ public interface ISearchParamExtractor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant for the {@literal theSearchParamFilter} parameters on this interface
|
* Constant for the {@literal theSearchParamFilter} parameters on this interface
|
||||||
* indicating that all search parameters should be indexed.
|
* indicating that all search parameters should be extracted.
|
||||||
*/
|
*/
|
||||||
ISearchParamFilter ALL_PARAMS = t -> t;
|
ISearchParamFilter ALL_PARAMS = t -> t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant for the {@literal theSearchParamFilter} parameters on this interface
|
* Constant for the {@literal theSearchParamFilter} parameters on this interface
|
||||||
* indicating that no search parameters should be indexed.
|
* indicating that no search parameters should be extracted.
|
||||||
*/
|
*/
|
||||||
ISearchParamFilter NO_PARAMS = t -> Collections.emptyList();
|
ISearchParamFilter NO_PARAMS = t -> Collections.emptyList();
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ public interface ISearchParamExtractor {
|
||||||
interface ISearchParamFilter {
|
interface ISearchParamFilter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given the list of search parameters for indexing, an implementation of this
|
* Given the list of search parameters for extracting, an implementation of this
|
||||||
* interface may selectively remove any that it wants to remove (or can add if desired).
|
* interface may selectively remove any that it wants to remove (or can add if desired).
|
||||||
* <p>
|
* <p>
|
||||||
* Implementations must not modify the list that is passed in. If changes are
|
* Implementations must not modify the list that is passed in. If changes are
|
||||||
|
|
|
@ -221,6 +221,28 @@ public class RestServerR4Helper extends BaseRestServerHelper implements BeforeEa
|
||||||
myRestServer.setConceptMapResourceProvider(theResourceProvider);
|
myRestServer.setConceptMapResourceProvider(theResourceProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T extends IBaseResource> HashMapResourceProvider<T> getResourceProvider(Class<T> theResourceType) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
HashMapResourceProvider<T> resourceProvider = (HashMapResourceProvider<T>) myRestServer.myResourceProvidersMap.get(theResourceType);
|
||||||
|
assert resourceProvider != null : "No resource provider defined for resource type: '" + theResourceType + "'" ;
|
||||||
|
return resourceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends IBaseResource> void setResourceProvider(HashMapResourceProvider<T> theResourceProvider) {
|
||||||
|
assert theResourceProvider.getResourceType() != null : "resourceProvider doesn't have a resourceType";
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
HashMapResourceProvider<T> resourceProvider = (HashMapResourceProvider<T>) myRestServer.myResourceProvidersMap.get(theResourceProvider.getResourceType());
|
||||||
|
|
||||||
|
if (resourceProvider != null) {
|
||||||
|
resourceProvider.getStoredResources().forEach(theResourceProvider::store);
|
||||||
|
myRestServer.unregisterProvider(resourceProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
registerProvider(theResourceProvider);
|
||||||
|
myRestServer.myResourceProvidersMap.put(theResourceProvider.getResourceType(), theResourceProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setPagingProvider(IPagingProvider thePagingProvider) {
|
public void setPagingProvider(IPagingProvider thePagingProvider) {
|
||||||
myPagingProvider = thePagingProvider;
|
myPagingProvider = thePagingProvider;
|
||||||
}
|
}
|
||||||
|
@ -295,6 +317,8 @@ public class RestServerR4Helper extends BaseRestServerHelper implements BeforeEa
|
||||||
private HashMapResourceProvider<ConceptMap> myConceptMapResourceProvider;
|
private HashMapResourceProvider<ConceptMap> myConceptMapResourceProvider;
|
||||||
private RestServerDstu3Helper.MyPlainProvider myPlainProvider;
|
private RestServerDstu3Helper.MyPlainProvider myPlainProvider;
|
||||||
|
|
||||||
|
private final Map<Class<?>, HashMapResourceProvider<?>> myResourceProvidersMap = new HashMap<>();
|
||||||
|
|
||||||
private final boolean myInitialTransactionLatchEnabled;
|
private final boolean myInitialTransactionLatchEnabled;
|
||||||
|
|
||||||
private PagingHttpMethodEnum myPagingHttpMethod = PagingHttpMethodEnum.GET;
|
private PagingHttpMethodEnum myPagingHttpMethod = PagingHttpMethodEnum.GET;
|
||||||
|
|
Loading…
Reference in New Issue