Jpaserver changes (#3632)

* Make FulltextSearchSvcImpl optional bean for ValuesetOperationProvider

* wip

* wip

* wip fix test

* move to override in test class

* Test fixes

* Add failsafe to other projects which have ITs

* Fix test

* Fix test to use transaction

* Move subscription loading

Co-authored-by: Ken Stevens <khstevens@gmail.com>
This commit is contained in:
Tadgh 2022-05-25 22:52:05 -04:00 committed by GitHub
parent 66b3fa680b
commit 6f5eea81b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 5 deletions

View File

@ -25,7 +25,7 @@ public final class Msg {
/**
* IMPORTANT: Please update the following comment after you add a new code
* Last code value: 2082
* Last code value: 2083
*/
private Msg() {}

View File

@ -73,7 +73,7 @@ public class ValueSetOperationProvider extends BaseJpaProvider {
private ValidationSupportChain myValidationSupportChain;
@Autowired
private IValidationSupport myValidationSupport;
@Autowired
@Autowired(required = false)
private IFulltextSearchSvc myFulltextSearch;
public void setValidationSupport(IValidationSupport theValidationSupport) {
@ -125,8 +125,11 @@ public class ValueSetOperationProvider extends BaseJpaProvider {
ValueSetAutocompleteOptions options = ValueSetAutocompleteOptions.validateAndParseOptions(myDaoConfig, theContext, theFilter, theCount, theId, theUrl, theValueSet);
startRequest(theServletRequest);
try {
return myFulltextSearch.tokenAutocompleteValueSetSearch(options);
if (myFulltextSearch == null || myFulltextSearch.isDisabled()) {
throw new InvalidRequestException(Msg.code(2083) + " Autocomplete is not supported on this server, as the fulltext search service is not configured.");
} else {
return myFulltextSearch.tokenAutocompleteValueSetSearch(options);
}
} finally {
endRequest(theServletRequest);
}

View File

@ -29,6 +29,7 @@ import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
import ca.uhn.fhir.jpa.dao.index.IJpaIdHelperService;
import ca.uhn.fhir.jpa.subscription.channel.api.ChannelProducerSettings;
import ca.uhn.fhir.jpa.subscription.channel.subscription.IChannelNamer;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionLoader;
import ca.uhn.fhir.mdm.api.IMdmSettings;
import ca.uhn.fhir.mdm.api.MdmConstants;
import ca.uhn.fhir.mdm.log.Logs;
@ -59,6 +60,8 @@ public class MdmSubscriptionLoader {
@Autowired
IChannelNamer myChannelNamer;
@Autowired
private SubscriptionLoader mySubscriptionLoader;
@Autowired
private IMdmSettings myMdmSettings;
private IFhirResourceDao<IBaseResource> mySubscriptionDao;
@ -87,6 +90,10 @@ public class MdmSubscriptionLoader {
for (IBaseResource subscription : subscriptions) {
updateIfNotPresent(subscription);
}
//After loading all the subscriptions, sync the subscriptions to the registry.
if (subscriptions != null && subscriptions.size() > 0) {
mySubscriptionLoader.syncSubscriptions();
}
}
synchronized void updateIfNotPresent(IBaseResource theSubscription) {

View File

@ -4,6 +4,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.subscription.channel.subscription.IChannelNamer;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionLoader;
import ca.uhn.fhir.mdm.api.IMdmSettings;
import ca.uhn.fhir.mdm.rules.json.MdmRulesJson;
import ca.uhn.fhir.model.api.IFhirVersion;
@ -57,6 +58,9 @@ class MdmSubscriptionLoaderTest {
@Mock
IChannelNamer myChannelNamer;
@Mock
SubscriptionLoader mySubscriptionLoader;
@InjectMocks
MdmSubscriptionLoader mySvc = new MdmSubscriptionLoader();

View File

@ -88,7 +88,6 @@ public abstract class BaseMdmHelper implements BeforeEachCallback, AfterEachCall
// We need to call this because subscriptions will get deleted in @After cleanup
waitForActivatedSubscriptionCount(0);
myMdmSubscriptionLoader.daoUpdateMdmSubscriptions();
mySubscriptionLoader.syncSubscriptions();
waitForActivatedSubscriptionCount(2);
}