Add sort support
This commit is contained in:
parent
fbb281f39f
commit
7c156e844b
|
@ -361,6 +361,12 @@ public class SearchQueryBuilder {
|
||||||
public ComboCondition createOnCondition(DbColumn theSourceColumn, DbColumn theTargetColumn) {
|
public ComboCondition createOnCondition(DbColumn theSourceColumn, DbColumn theTargetColumn) {
|
||||||
ComboCondition onCondition = ComboCondition.and();
|
ComboCondition onCondition = ComboCondition.and();
|
||||||
onCondition.addCondition(BinaryCondition.equalTo(theSourceColumn, theTargetColumn));
|
onCondition.addCondition(BinaryCondition.equalTo(theSourceColumn, theTargetColumn));
|
||||||
|
// fixme cosmos hack
|
||||||
|
if (true) {
|
||||||
|
DbColumn sourcePartId = theSourceColumn.getTable().findColumn("PARTITION_ID");
|
||||||
|
DbColumn targetPartId = theTargetColumn.getTable().findColumn("PARTITION_ID");
|
||||||
|
onCondition.addCondition(BinaryCondition.equalTo(sourcePartId, targetPartId));
|
||||||
|
}
|
||||||
|
|
||||||
return onCondition;
|
return onCondition;
|
||||||
}
|
}
|
||||||
|
@ -459,18 +465,18 @@ public class SearchQueryBuilder {
|
||||||
DbColumn theToColumn,
|
DbColumn theToColumn,
|
||||||
SelectQuery.JoinType theJoinType) {
|
SelectQuery.JoinType theJoinType) {
|
||||||
DbColumn[] fromColumns;
|
DbColumn[] fromColumns;
|
||||||
DbColumn[] toColumns;
|
DbColumn[] toColumns;
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
// fixme cosmos hack
|
// fixme cosmos hack
|
||||||
fromColumns = new DbColumn[]{theFromColumn, theFromTable.findColumn("PARTITION_ID")};
|
fromColumns = new DbColumn[] {theFromColumn, theFromTable.findColumn("PARTITION_ID")};
|
||||||
toColumns = new DbColumn[]{theToColumn, theToTable.findColumn("PARTITION_ID")};
|
toColumns = new DbColumn[] {theToColumn, theToTable.findColumn("PARTITION_ID")};
|
||||||
} else {
|
} else {
|
||||||
fromColumns = new DbColumn[]{theFromColumn};
|
fromColumns = new DbColumn[] {theFromColumn};
|
||||||
toColumns = new DbColumn[]{theToColumn};
|
toColumns = new DbColumn[] {theToColumn};
|
||||||
}
|
}
|
||||||
|
|
||||||
Join join = new DbJoin(mySpec, theFromTable, theToTable, fromColumns, toColumns);
|
Join join = new DbJoin(mySpec, theFromTable, theToTable, fromColumns, toColumns);
|
||||||
mySelect.addJoins(theJoinType, join);
|
mySelect.addJoins(theJoinType, join);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoPatient;
|
||||||
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
||||||
import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc;
|
import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc;
|
||||||
import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportJobSchedulingHelper;
|
import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportJobSchedulingHelper;
|
||||||
|
import ca.uhn.fhir.jpa.dao.TestDaoSearch;
|
||||||
import ca.uhn.fhir.jpa.entity.PartitionEntity;
|
import ca.uhn.fhir.jpa.entity.PartitionEntity;
|
||||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||||
import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc;
|
import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc;
|
||||||
|
@ -18,9 +19,7 @@ import ca.uhn.fhir.rest.param.TokenParam;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||||
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
|
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
|
||||||
import ca.uhn.fhir.util.BundleBuilder;
|
import ca.uhn.fhir.util.BundleBuilder;
|
||||||
import org.hamcrest.Matchers;
|
|
||||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
|
||||||
import org.hl7.fhir.r4.model.Bundle;
|
import org.hl7.fhir.r4.model.Bundle;
|
||||||
import org.hl7.fhir.r4.model.Enumerations;
|
import org.hl7.fhir.r4.model.Enumerations;
|
||||||
import org.hl7.fhir.r4.model.IdType;
|
import org.hl7.fhir.r4.model.IdType;
|
||||||
|
@ -32,6 +31,8 @@ import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.CsvSource;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
@ -72,6 +73,8 @@ public class CosmosDbTest extends BaseJpaTest {
|
||||||
private ISearchParamRegistry mySearchParamRegistry;
|
private ISearchParamRegistry mySearchParamRegistry;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IBulkDataExportJobSchedulingHelper myBulkDataScheduleHelper;
|
private IBulkDataExportJobSchedulingHelper myBulkDataScheduleHelper;
|
||||||
|
@Autowired
|
||||||
|
private TestDaoSearch myDaoSearch;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FhirContext getFhirContext() {
|
protected FhirContext getFhirContext() {
|
||||||
|
@ -142,6 +145,26 @@ public class CosmosDbTest extends BaseJpaTest {
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(outcome), contains(OBSERVATION_O0));
|
assertThat(toUnqualifiedVersionlessIdValues(outcome), contains(OBSERVATION_O0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@CsvSource(textBlock = """
|
||||||
|
string, Patient?_sort=name
|
||||||
|
date, Observation?_sort=date
|
||||||
|
_id, Patient?_sort=_id
|
||||||
|
_lastUpdated, Patient?_sort=_lastUpdated
|
||||||
|
_pid, Patient?_sort=_pid
|
||||||
|
""")
|
||||||
|
void testSort(String theComment, String theQuery) {
|
||||||
|
// Create resource
|
||||||
|
createPatientAndObservation();
|
||||||
|
|
||||||
|
// when
|
||||||
|
addReadPartition(1);
|
||||||
|
List<String> ids = myDaoSearch.searchForIds(theQuery);
|
||||||
|
|
||||||
|
assertEquals(1, ids.size(), theComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIncludes() {
|
public void testIncludes() {
|
||||||
// Setup
|
// Setup
|
||||||
|
@ -222,6 +245,7 @@ public class CosmosDbTest extends BaseJpaTest {
|
||||||
patient.setId(PATIENT_P0);
|
patient.setId(PATIENT_P0);
|
||||||
patient.addIdentifier().setSystem("http://foo").setValue("123");
|
patient.addIdentifier().setSystem("http://foo").setValue("123");
|
||||||
patient.setGender(Enumerations.AdministrativeGender.MALE);
|
patient.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
|
patient.addName().setFamily("Smith");
|
||||||
myPatientDao.update(patient, mySrd).getId().toUnqualifiedVersionless();
|
myPatientDao.update(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
addCreatePartition1();
|
addCreatePartition1();
|
||||||
|
|
Loading…
Reference in New Issue