Some configs don't publish and FullText service at all. Make it optional.

This commit is contained in:
Michael Buckley 2021-09-24 14:29:18 -04:00
parent 79e2800f3e
commit 11c5f7ee87
5 changed files with 18 additions and 33 deletions

View File

@ -63,7 +63,9 @@ import org.hibernate.SessionFactory;
import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings; import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings;
import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings;
import org.hibernate.search.engine.cfg.BackendSettings; import org.hibernate.search.engine.cfg.BackendSettings;
import org.hibernate.search.mapper.orm.Search;
import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings;
import org.hibernate.search.mapper.orm.session.SearchSession;
import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator;
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu3.model.Resource; import org.hl7.fhir.dstu3.model.Resource;
@ -90,6 +92,7 @@ import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate; import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.persistence.EntityManager;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -185,10 +188,9 @@ public abstract class BaseJpaTest extends BaseTest {
private IResourceHistoryTableDao myResourceHistoryTableDao; private IResourceHistoryTableDao myResourceHistoryTableDao;
@Autowired @Autowired
private IForcedIdDao myForcedIdDao; private IForcedIdDao myForcedIdDao;
@Autowired @Autowired(required = false)
protected IFulltextSearchSvc myFulltestSearchSvc; protected IFulltextSearchSvc myFulltestSearchSvc;
@AfterEach @AfterEach
public void afterPerformCleanup() { public void afterPerformCleanup() {
BaseHapiFhirDao.setDisableIncrementOnUpdateForUnitTest(false); BaseHapiFhirDao.setDisableIncrementOnUpdateForUnitTest(false);
@ -259,6 +261,16 @@ public abstract class BaseJpaTest extends BaseTest {
return deliveryLatch; return deliveryLatch;
} }
protected void purgeHibernateSearch(EntityManager theEntityManager) {
runInTransaction(() -> {
if (myFulltestSearchSvc != null && !myFulltestSearchSvc.isDisabled()) {
SearchSession searchSession = Search.session(theEntityManager);
searchSession.workspace(ResourceTable.class).purge();
searchSession.indexingPlan().execute();
}
});
}
protected abstract FhirContext getContext(); protected abstract FhirContext getContext();
protected abstract PlatformTransactionManager getTxManager(); protected abstract PlatformTransactionManager getTxManager();

View File

@ -226,15 +226,7 @@ public abstract class BaseJpaDstu2Test extends BaseJpaTest {
@BeforeEach @BeforeEach
public void beforeFlushFT() { public void beforeFlushFT() {
if (!myFulltestSearchSvc.isDisabled()) { purgeHibernateSearch(myEntityManager);
runInTransaction(() -> {
SearchSession searchSession = Search.session(myEntityManager);
searchSession.workspace(ResourceTable.class).purge();
// searchSession.workspace(ResourceIndexedSearchParamString.class).purge();
searchSession.indexingPlan().execute();
});
}
myDaoConfig.setSchedulingDisabled(true); myDaoConfig.setSchedulingDisabled(true);
myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED); myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);

View File

@ -386,14 +386,7 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
@BeforeEach @BeforeEach
public void beforeFlushFT() { public void beforeFlushFT() {
if (!myFulltestSearchSvc.isDisabled()) { purgeHibernateSearch(myEntityManager);
runInTransaction(() -> {
SearchSession searchSession = Search.session(myEntityManager);
searchSession.workspace(ResourceTable.class).purge();
// searchSession.workspace(ResourceIndexedSearchParamString.class).purge();
searchSession.indexingPlan().execute();
});
}
myDaoConfig.setSchedulingDisabled(true); myDaoConfig.setSchedulingDisabled(true);
myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED); myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);

View File

@ -550,13 +550,7 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil
@BeforeEach @BeforeEach
public void beforeFlushFT() { public void beforeFlushFT() {
runInTransaction(() -> { purgeHibernateSearch(this.myEntityManager);
if (!myFulltestSearchSvc.isDisabled()) {
SearchSession searchSession = Search.session(myEntityManager);
searchSession.workspace(ResourceTable.class).purge();
searchSession.indexingPlan().execute();
}
});
myDaoConfig.setSchedulingDisabled(true); myDaoConfig.setSchedulingDisabled(true);
myDaoConfig.setIndexMissingFields(new DaoConfig().getIndexMissingFields()); myDaoConfig.setIndexMissingFields(new DaoConfig().getIndexMissingFields());

View File

@ -477,13 +477,7 @@ public abstract class BaseJpaR5Test extends BaseJpaTest implements ITestDataBuil
@BeforeEach @BeforeEach
public void beforeFlushFT() { public void beforeFlushFT() {
runInTransaction(() -> { purgeHibernateSearch(myEntityManager);
if (!myFulltestSearchSvc.isDisabled()) {
SearchSession searchSession = Search.session(myEntityManager);
searchSession.workspace(ResourceTable.class).purge();
searchSession.indexingPlan().execute();
}
});
myDaoConfig.setSchedulingDisabled(true); myDaoConfig.setSchedulingDisabled(true);
myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED); myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);