Fix test failure in boot
This commit is contained in:
parent
5d5ee78873
commit
6ce9120132
|
@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.config;
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -22,6 +22,7 @@ package ca.uhn.fhir.jpa.config;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.i18n.HapiLocalizer;
|
||||
import ca.uhn.fhir.jpa.dao.DaoRegistry;
|
||||
import ca.uhn.fhir.jpa.provider.SubscriptionRetriggeringProvider;
|
||||
import ca.uhn.fhir.jpa.search.*;
|
||||
import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc;
|
||||
|
@ -63,6 +64,11 @@ public abstract class BaseConfig implements SchedulingConfigurer {
|
|||
@Autowired
|
||||
protected Environment myEnv;
|
||||
|
||||
@Bean
|
||||
public DaoRegistry daoRegistry() {
|
||||
return new DaoRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureTasks(@Nonnull ScheduledTaskRegistrar theTaskRegistrar) {
|
||||
theTaskRegistrar.setTaskScheduler(taskScheduler());
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DaoRegistry implements ApplicationContextAware {
|
||||
private ApplicationContext myAppCtx;
|
||||
|
||||
@Autowired
|
||||
private FhirContext myCtx;
|
||||
private Map<String, IFhirResourceDao<?>> myResourceNameToResourceDao = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext theApplicationContext) throws BeansException {
|
||||
myAppCtx = theApplicationContext;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void start() {
|
||||
Map<String, IFhirResourceDao> resourceDaos = myAppCtx.getBeansOfType(IFhirResourceDao.class);
|
||||
for (IFhirResourceDao nextResourceDao : resourceDaos.values()) {
|
||||
RuntimeResourceDefinition nextResourceDef = myCtx.getResourceDefinition(nextResourceDao.getResourceType());
|
||||
myResourceNameToResourceDao.put(nextResourceDef.getName(), nextResourceDao);
|
||||
}
|
||||
}
|
||||
|
||||
public IFhirResourceDao<?> getResourceDao(String theResourceName) {
|
||||
IFhirResourceDao<?> retVal = myResourceNameToResourceDao.get(theResourceName);
|
||||
Validate.notNull(retVal, "No DAO exists for resource type %s", theResourceName);
|
||||
return retVal;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -89,7 +89,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
@Autowired
|
||||
private PlatformTransactionManager myManagedTxManager;
|
||||
@Autowired
|
||||
private IFhirSystemDao<?, ?> mySystemDao;
|
||||
private DaoRegistry myDaoRegistry;
|
||||
@Autowired
|
||||
private IPagingProvider myPagingProvider;
|
||||
|
||||
|
@ -170,9 +170,8 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
if (newSearch.isPresent()) {
|
||||
search = newSearch.get();
|
||||
String resourceType = search.getResourceType();
|
||||
Class<? extends IBaseResource> type = myContext.getResourceDefinition(resourceType).getImplementingClass();
|
||||
SearchParameterMap params = search.getSearchParameterMap();
|
||||
SearchContinuationTask task = new SearchContinuationTask(search, mySystemDao.getDao(type), params, resourceType);
|
||||
SearchContinuationTask task = new SearchContinuationTask(search, myDaoRegistry.getResourceDao(resourceType), params, resourceType);
|
||||
myIdToSearchTask.put(search.getUuid(), task);
|
||||
myExecutor.submit(task);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue