More perf work
This commit is contained in:
parent
bf0f1421b3
commit
e32d6bb56e
|
@ -35,6 +35,7 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -1276,6 +1277,13 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, RuntimeSearchParam>> activeSearchParams = mySearchParamRegistry.getActiveSearchParams(theEntity.getResourceType()).entrySet();
|
||||
findMissingSearchParams(theEntity, activeSearchParams, RestSearchParameterTypeEnum.STRING, stringParams);
|
||||
findMissingSearchParams(theEntity, activeSearchParams, RestSearchParameterTypeEnum.NUMBER, numberParams);
|
||||
findMissingSearchParams(theEntity, activeSearchParams, RestSearchParameterTypeEnum.QUANTITY, quantityParams);
|
||||
findMissingSearchParams(theEntity, activeSearchParams, RestSearchParameterTypeEnum.DATE, dateParams);
|
||||
findMissingSearchParams(theEntity, activeSearchParams, RestSearchParameterTypeEnum.URI, uriParams);
|
||||
|
||||
setUpdatedTime(stringParams, theUpdateTime);
|
||||
setUpdatedTime(numberParams, theUpdateTime);
|
||||
setUpdatedTime(quantityParams, theUpdateTime);
|
||||
|
@ -1520,6 +1528,56 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
return theEntity;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends BaseResourceIndexedSearchParam> void findMissingSearchParams(ResourceTable theEntity, Set<Entry<String, RuntimeSearchParam>> activeSearchParams, RestSearchParameterTypeEnum type,
|
||||
Set<T> paramCollection) {
|
||||
for (Entry<String, RuntimeSearchParam> nextEntry : activeSearchParams) {
|
||||
String nextParamName = nextEntry.getKey();
|
||||
if (nextEntry.getValue().getParamType() == type) {
|
||||
boolean haveParam = false;
|
||||
for (BaseResourceIndexedSearchParam nextParam : paramCollection) {
|
||||
if (nextParam.getParamName().equals(nextParamName)) {
|
||||
haveParam = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!haveParam) {
|
||||
BaseResourceIndexedSearchParam param;
|
||||
switch (type) {
|
||||
case DATE:
|
||||
param = new ResourceIndexedSearchParamDate();
|
||||
break;
|
||||
case NUMBER:
|
||||
param = new ResourceIndexedSearchParamNumber();
|
||||
break;
|
||||
case QUANTITY:
|
||||
param = new ResourceIndexedSearchParamQuantity();
|
||||
break;
|
||||
case STRING:
|
||||
param = new ResourceIndexedSearchParamString();
|
||||
break;
|
||||
case TOKEN:
|
||||
param = new ResourceIndexedSearchParamToken();
|
||||
break;
|
||||
case URI:
|
||||
param = new ResourceIndexedSearchParamUri();
|
||||
break;
|
||||
case COMPOSITE:
|
||||
case HAS:
|
||||
case REFERENCE:
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
param.setResource(theEntity);
|
||||
param.setMissing(true);
|
||||
param.setParamName(nextParamName);
|
||||
paramCollection.add((T) param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSearchParamPresent(Map<String, Boolean> presentSearchParams, Set<? extends BaseResourceIndexedSearchParam> params) {
|
||||
for (BaseResourceIndexedSearchParam nextSearchParam : params) {
|
||||
presentSearchParams.put(nextSearchParam.getParamName(), Boolean.TRUE);
|
||||
|
|
|
@ -45,7 +45,6 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
|
|||
@Field()
|
||||
@Column(name = "SP_MISSING", nullable = true)
|
||||
@ColumnDefault("false")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private boolean myMissing;
|
||||
|
||||
@Field
|
||||
|
|
|
@ -3008,6 +3008,14 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
|||
|
||||
@Test
|
||||
public void testSortOnSparselyPopulatedSearchParameter() throws Exception {
|
||||
Patient pCA = new Patient();
|
||||
pCA.setId("CA");
|
||||
pCA.setActive(false);
|
||||
pCA.getAddressFirstRep().addLine("A");
|
||||
pCA.addName().setFamily("C").addGiven("A");
|
||||
pCA.addName().setFamily("Z").addGiven("A");
|
||||
myPatientDao.update(pCA);
|
||||
|
||||
Patient pBA = new Patient();
|
||||
pBA.setId("BA");
|
||||
pBA.setActive(true);
|
||||
|
@ -3036,14 +3044,6 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
|||
pAA.addName().setFamily("A").addGiven("A");
|
||||
myPatientDao.update(pAA);
|
||||
|
||||
Patient pCA = new Patient();
|
||||
pCA.setId("CA");
|
||||
pCA.setActive(false);
|
||||
pCA.getAddressFirstRep().addLine("A");
|
||||
pCA.addName().setFamily("C").addGiven("A");
|
||||
pCA.addName().setFamily("Z").addGiven("A");
|
||||
myPatientDao.update(pCA);
|
||||
|
||||
SearchParameterMap map;
|
||||
List<String> ids;
|
||||
|
||||
|
|
Loading…
Reference in New Issue