Skip to content

Commit

Permalink
FM2-651: Allow DAOs access to all API load-able by the OpenMRS Class …
Browse files Browse the repository at this point in the history
…loader.
  • Loading branch information
Ruhanga committed Dec 11, 2024
1 parent 210dfa8 commit 3597294
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.openmrs.module.fhir2.api.dao.FhirDao;
import org.openmrs.module.fhir2.api.search.param.PropParam;
import org.openmrs.module.fhir2.api.search.param.SearchParameterMap;
import org.openmrs.util.OpenmrsClassLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -100,6 +101,7 @@ protected BaseFhirDao() {
@Override
@Transactional(readOnly = true)
public T get(@Nonnull String uuid) {
Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance());
@SuppressWarnings("unchecked")
T result = (T) sessionFactory.getCurrentSession().createCriteria(typeToken.getRawType()).add(eq("uuid", uuid))
.uniqueResult();
Expand All @@ -115,6 +117,7 @@ public T get(@Nonnull String uuid) {
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
public List<T> get(@Nonnull Collection<String> uuids) {
Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance());
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(typeToken.getRawType());
criteria.add(in("uuid", uuids));

Expand Down Expand Up @@ -210,6 +213,7 @@ protected void applyExactTotal(SearchParameterMap theParams, Criteria criteria)
@SuppressWarnings("unchecked")
@Override
public List<T> getSearchResults(@Nonnull SearchParameterMap theParams) {
Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance());
Criteria criteria = getSearchResultCriteria(theParams);

handleSort(criteria, theParams.getSortSpec());
Expand Down

0 comments on commit 3597294

Please sign in to comment.