remove getDao() from Dao

This commit is contained in:
Ken Stevens 2020-01-24 13:01:58 -05:00
parent 9b0f850cf4
commit 4ba91e0797
5 changed files with 6 additions and 13 deletions

View File

@ -159,7 +159,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
@Autowired @Autowired
private ISearchParamPresenceSvc mySearchParamPresenceSvc; private ISearchParamPresenceSvc mySearchParamPresenceSvc;
@Autowired @Autowired
private DaoRegistry myDaoRegistry; protected DaoRegistry myDaoRegistry;
@Autowired @Autowired
private SearchParamWithInlineReferencesExtractor mySearchParamWithInlineReferencesExtractor; private SearchParamWithInlineReferencesExtractor mySearchParamWithInlineReferencesExtractor;
@Autowired @Autowired
@ -327,11 +327,6 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
} }
} }
// FIXME KHS remove this method
public <R extends IBaseResource> IFhirResourceDao<R> getDao(Class<R> theType) {
return myDaoRegistry.getResourceDaoOrNull(theType);
}
protected TagDefinition getTagOrNull(TagTypeEnum theTagType, String theScheme, String theTerm, String theLabel) { protected TagDefinition getTagOrNull(TagTypeEnum theTagType, String theScheme, String theTerm, String theLabel) {
if (isBlank(theScheme) && isBlank(theTerm) && isBlank(theLabel)) { if (isBlank(theScheme) && isBlank(theTerm) && isBlank(theLabel)) {
return null; return null;

View File

@ -25,6 +25,7 @@ import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.interceptor.api.HookParams; import ca.uhn.fhir.interceptor.api.HookParams;
import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.api.IDaoRegistry;
import ca.uhn.fhir.jpa.delete.DeleteConflictList; import ca.uhn.fhir.jpa.delete.DeleteConflictList;
import ca.uhn.fhir.jpa.delete.DeleteConflictService; import ca.uhn.fhir.jpa.delete.DeleteConflictService;
import ca.uhn.fhir.jpa.model.cross.ResourcePersistentId; import ca.uhn.fhir.jpa.model.cross.ResourcePersistentId;
@ -1338,7 +1339,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
IBaseResource resourceToValidateById = null; IBaseResource resourceToValidateById = null;
if (theId != null && theId.hasResourceType() && theId.hasIdPart()) { if (theId != null && theId.hasResourceType() && theId.hasIdPart()) {
Class<? extends IBaseResource> type = getContext().getResourceDefinition(theId.getResourceType()).getImplementingClass(); Class<? extends IBaseResource> type = getContext().getResourceDefinition(theId.getResourceType()).getImplementingClass();
IFhirResourceDao<? extends IBaseResource> dao = getDao(type); IFhirResourceDao<? extends IBaseResource> dao = myDaoRegistry.getResourceDaoOrNull(type);
resourceToValidateById = dao.read(theId, theRequest); resourceToValidateById = dao.read(theId, theRequest);
} }

View File

@ -582,7 +582,7 @@ public class FhirSystemDaoDstu2 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
} }
IFhirResourceDao<? extends IBaseResource> dao = null; IFhirResourceDao<? extends IBaseResource> dao = null;
if (resType != null) { if (resType != null) {
dao = getDao(resType.getImplementingClass()); dao = this.myDaoRegistry.getResourceDaoOrNull(resType.getImplementingClass());
} }
if (dao == null) { if (dao == null) {
String msg = getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionInvalidUrl", theVerb, theUrl); String msg = getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionInvalidUrl", theVerb, theUrl);

View File

@ -43,9 +43,6 @@ public interface IFhirSystemDao<T, MT> extends IDao {
ExpungeOutcome expunge(ExpungeOptions theExpungeOptions, RequestDetails theRequestDetails); ExpungeOutcome expunge(ExpungeOptions theExpungeOptions, RequestDetails theRequestDetails);
@SuppressWarnings("unchecked")
<R extends IBaseResource> IFhirResourceDao<R> getDao(Class<R> theType);
Map<String, Long> getResourceCounts(); Map<String, Long> getResourceCounts();
/** /**

View File

@ -51,7 +51,7 @@ public class JpaStorageServices extends BaseHapiFhirDao<IBaseResource> implement
private IFhirResourceDao<? extends IBaseResource> getDao(String theResourceType) { private IFhirResourceDao<? extends IBaseResource> getDao(String theResourceType) {
RuntimeResourceDefinition typeDef = getContext().getResourceDefinition(theResourceType); RuntimeResourceDefinition typeDef = getContext().getResourceDefinition(theResourceType);
return getDao(typeDef.getImplementingClass()); return myDaoRegistry.getResourceDaoOrNull(typeDef.getImplementingClass());
} }
@Transactional(propagation = Propagation.NEVER) @Transactional(propagation = Propagation.NEVER)
@ -59,7 +59,7 @@ public class JpaStorageServices extends BaseHapiFhirDao<IBaseResource> implement
public void listResources(Object theAppInfo, String theType, List<Argument> theSearchParams, List<IBaseResource> theMatches) throws FHIRException { public void listResources(Object theAppInfo, String theType, List<Argument> theSearchParams, List<IBaseResource> theMatches) throws FHIRException {
RuntimeResourceDefinition typeDef = getContext().getResourceDefinition(theType); RuntimeResourceDefinition typeDef = getContext().getResourceDefinition(theType);
IFhirResourceDao<? extends IBaseResource> dao = getDao(typeDef.getImplementingClass()); IFhirResourceDao<? extends IBaseResource> dao = myDaoRegistry.getResourceDaoOrNull(typeDef.getImplementingClass());
SearchParameterMap params = new SearchParameterMap(); SearchParameterMap params = new SearchParameterMap();
params.setLoadSynchronousUpTo(MAX_SEARCH_SIZE); params.setLoadSynchronousUpTo(MAX_SEARCH_SIZE);