Bugfix on #1772
This commit is contained in:
parent
08c1c28f67
commit
c2e00bb73b
|
@ -328,9 +328,12 @@ class PredicateBuilderReference extends BasePredicateBuilder {
|
||||||
throw newInvalidTargetTypeForChainException(theResourceName, theParamName, typeValue);
|
throw newInvalidTargetTypeForChainException(theResourceName, theParamName, typeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Predicate sourceTypeParameter = myCriteriaBuilder.equal(theJoin.get("mySourceResourceType"), myResourceName);
|
||||||
Predicate targetTypeParameter = myCriteriaBuilder.equal(theJoin.get("myTargetResourceType"), typeValue);
|
Predicate targetTypeParameter = myCriteriaBuilder.equal(theJoin.get("myTargetResourceType"), typeValue);
|
||||||
myQueryRoot.addPredicate(targetTypeParameter);
|
|
||||||
return targetTypeParameter;
|
Predicate composite = myCriteriaBuilder.and(sourceTypeParameter, targetTypeParameter);
|
||||||
|
myQueryRoot.addPredicate(composite);
|
||||||
|
return composite;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean foundChainMatch = false;
|
boolean foundChainMatch = false;
|
||||||
|
|
|
@ -3,7 +3,14 @@ package ca.uhn.fhir.jpa.dao.r4;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||||
import ca.uhn.fhir.jpa.entity.Search;
|
import ca.uhn.fhir.jpa.entity.Search;
|
||||||
import ca.uhn.fhir.jpa.model.entity.*;
|
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamNumber;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamQuantity;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamToken;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamUri;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.ResourceLink;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||||
import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
|
import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap.EverythingModeEnum;
|
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap.EverythingModeEnum;
|
||||||
|
@ -33,7 +40,11 @@ import org.hl7.fhir.r4.model.Enumerations.AdministrativeGender;
|
||||||
import org.hl7.fhir.r4.model.Observation.ObservationStatus;
|
import org.hl7.fhir.r4.model.Observation.ObservationStatus;
|
||||||
import org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType;
|
import org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType;
|
||||||
import org.hl7.fhir.r4.model.Subscription.SubscriptionStatus;
|
import org.hl7.fhir.r4.model.Subscription.SubscriptionStatus;
|
||||||
import org.junit.*;
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.TransactionStatus;
|
import org.springframework.transaction.TransactionStatus;
|
||||||
import org.springframework.transaction.support.TransactionCallback;
|
import org.springframework.transaction.support.TransactionCallback;
|
||||||
|
@ -44,11 +55,30 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.*;
|
import static ca.uhn.fhir.rest.api.Constants.PARAM_TYPE;
|
||||||
import static org.junit.Assert.*;
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.hamcrest.Matchers.empty;
|
||||||
|
import static org.hamcrest.Matchers.endsWith;
|
||||||
|
import static org.hamcrest.Matchers.hasItem;
|
||||||
|
import static org.hamcrest.Matchers.hasItems;
|
||||||
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
|
import static org.hamcrest.Matchers.not;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "Duplicates"})
|
@SuppressWarnings({"unchecked", "Duplicates"})
|
||||||
|
@ -337,27 +367,36 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
||||||
enc2.getSubject().setReference(sub2Id);
|
enc2.getSubject().setReference(sub2Id);
|
||||||
String enc2Id = myEncounterDao.create(enc2).getId().toUnqualifiedVersionless().getValue();
|
String enc2Id = myEncounterDao.create(enc2).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
Observation obs = new Observation();
|
||||||
|
obs.getSubject().setReference(sub1Id);
|
||||||
|
myObservationDao.create(obs);
|
||||||
|
|
||||||
|
// Log the link rows
|
||||||
|
runInTransaction(() -> myResourceLinkDao.findAll().forEach(t -> ourLog.info("ResLink: {}", t.toString())));
|
||||||
|
|
||||||
List<String> ids;
|
List<String> ids;
|
||||||
SearchParameterMap map;
|
SearchParameterMap map;
|
||||||
IBundleProvider results;
|
IBundleProvider results;
|
||||||
|
|
||||||
|
myCaptureQueriesListener.clear();
|
||||||
map = new SearchParameterMap();
|
map = new SearchParameterMap();
|
||||||
map.setLoadSynchronous(true);
|
map.setLoadSynchronous(true);
|
||||||
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "Patient").setChain("_type"));
|
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "Patient").setChain(PARAM_TYPE));
|
||||||
results = myEncounterDao.search(map);
|
results = myEncounterDao.search(map);
|
||||||
ids = toUnqualifiedVersionlessIdValues(results);
|
ids = toUnqualifiedVersionlessIdValues(results);
|
||||||
assertThat(ids, hasItems(enc1Id));
|
assertThat(ids, contains(enc1Id));
|
||||||
|
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
|
||||||
|
|
||||||
map = new SearchParameterMap();
|
map = new SearchParameterMap();
|
||||||
map.setLoadSynchronous(true);
|
map.setLoadSynchronous(true);
|
||||||
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "Group").setChain("_type"));
|
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "Group").setChain(PARAM_TYPE));
|
||||||
results = myEncounterDao.search(map);
|
results = myEncounterDao.search(map);
|
||||||
ids = toUnqualifiedVersionlessIdValues(results);
|
ids = toUnqualifiedVersionlessIdValues(results);
|
||||||
assertThat(ids, hasItems(enc2Id));
|
assertThat(ids, contains(enc2Id));
|
||||||
|
|
||||||
map = new SearchParameterMap();
|
map = new SearchParameterMap();
|
||||||
map.setLoadSynchronous(true);
|
map.setLoadSynchronous(true);
|
||||||
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "Organization").setChain("_type"));
|
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "Organization").setChain(PARAM_TYPE));
|
||||||
try {
|
try {
|
||||||
myEncounterDao.search(map);
|
myEncounterDao.search(map);
|
||||||
fail();
|
fail();
|
||||||
|
@ -367,7 +406,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
||||||
|
|
||||||
map = new SearchParameterMap();
|
map = new SearchParameterMap();
|
||||||
map.setLoadSynchronous(true);
|
map.setLoadSynchronous(true);
|
||||||
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "HelpImABug").setChain("_type"));
|
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "HelpImABug").setChain(PARAM_TYPE));
|
||||||
try {
|
try {
|
||||||
myEncounterDao.search(map);
|
myEncounterDao.search(map);
|
||||||
fail();
|
fail();
|
||||||
|
@ -3532,7 +3571,6 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchWithFetchSizeDefaultMaximum() {
|
public void testSearchWithFetchSizeDefaultMaximum() {
|
||||||
myDaoConfig.setFetchSizeDefaultMaximum(5);
|
myDaoConfig.setFetchSizeDefaultMaximum(5);
|
||||||
|
|
|
@ -210,6 +210,7 @@ public class ResourceLink extends BaseResourceIndex {
|
||||||
b.append("path=").append(mySourcePath);
|
b.append("path=").append(mySourcePath);
|
||||||
b.append(", src=").append(mySourceResourcePid);
|
b.append(", src=").append(mySourceResourcePid);
|
||||||
b.append(", target=").append(myTargetResourcePid);
|
b.append(", target=").append(myTargetResourcePid);
|
||||||
|
b.append(", targetType=").append(myTargetResourceType);
|
||||||
b.append(", targetUrl=").append(myTargetResourceUrl);
|
b.append(", targetUrl=").append(myTargetResourceUrl);
|
||||||
|
|
||||||
b.append("]");
|
b.append("]");
|
||||||
|
|
Loading…
Reference in New Issue