More work on perf
This commit is contained in:
parent
f48d0d677b
commit
660c2bde72
|
@ -3,19 +3,30 @@ root = true
|
|||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
tab_width = 3
|
||||
indent_size = 3
|
||||
|
||||
[*.java]
|
||||
charset = utf-8
|
||||
indent_style = tab
|
||||
tab_width = 3
|
||||
indent_size = 3
|
||||
|
||||
[*.xml]
|
||||
charset = utf-8
|
||||
indent_style = tab
|
||||
tab_width = 3
|
||||
indent_size = 3
|
||||
|
||||
[*.json]
|
||||
charset = utf-8
|
||||
indent_style = tab
|
||||
tab_width = 3
|
||||
indent_size = 3
|
||||
|
||||
[*.vm]
|
||||
charset = utf-8
|
||||
indent_style = tab
|
||||
tab_width = 3
|
||||
indent_size = 3
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package ca.uhn.fhir.model.api;
|
|||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
/*
|
||||
|
@ -33,7 +35,9 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||
* upgrading servers.
|
||||
* </p>
|
||||
*/
|
||||
public class Include {
|
||||
public class Include implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final boolean myImmutable;
|
||||
private boolean myRecurse;
|
||||
|
|
|
@ -104,9 +104,9 @@ public class TagList implements Set<Tag>, Serializable, IBase {
|
|||
* Add a new tag instance
|
||||
*
|
||||
* @param theScheme
|
||||
* The tag scheme
|
||||
* The tag scheme (the system)
|
||||
* @param theTerm
|
||||
* The tag term
|
||||
* The tag term (the code)
|
||||
* @return Returns the newly created tag instance. Note that the tag is added to the list by this method, so you
|
||||
* generally do not need to interact directly with the added tag.
|
||||
*/
|
||||
|
|
|
@ -1235,6 +1235,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
Set<ResourceIndexedSearchParamCoords> coordsParams = null;
|
||||
Set<ResourceLink> links = null;
|
||||
|
||||
Set<String> populatedResourceLinkParameters = null;
|
||||
if (theDeletedTimestampOrNull != null) {
|
||||
|
||||
stringParams = Collections.emptySet();
|
||||
|
@ -1334,7 +1335,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
}
|
||||
|
||||
links = new HashSet<ResourceLink>();
|
||||
Set<String> populatedResourceLinkParameters = extractResourceLinks(theEntity, theResource, links, theUpdateTime);
|
||||
populatedResourceLinkParameters = extractResourceLinks(theEntity, theResource, links, theUpdateTime);
|
||||
|
||||
/*
|
||||
* If the existing resource already has links and those match links we still want, use them instead of removing them and re adding them
|
||||
|
@ -1374,28 +1375,6 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
theEntity.setIndexStatus(INDEX_STATUS_INDEXED);
|
||||
populateFullTextFields(theResource, theEntity);
|
||||
|
||||
/*
|
||||
* Update the "search param present" table which is used for the
|
||||
* ?foo:missing=true queries
|
||||
*/
|
||||
Map<String, Boolean> presentSearchParams = new HashMap<String, Boolean>();
|
||||
for (String nextKey : populatedResourceLinkParameters) {
|
||||
presentSearchParams.put(nextKey, Boolean.TRUE);
|
||||
}
|
||||
updateSearchParamPresent(presentSearchParams, stringParams);
|
||||
updateSearchParamPresent(presentSearchParams, tokenParams);
|
||||
updateSearchParamPresent(presentSearchParams, numberParams);
|
||||
updateSearchParamPresent(presentSearchParams, quantityParams);
|
||||
updateSearchParamPresent(presentSearchParams, dateParams);
|
||||
updateSearchParamPresent(presentSearchParams, uriParams);
|
||||
updateSearchParamPresent(presentSearchParams, coordsParams);
|
||||
Set<String> activeSearchParamNames = mySearchParamRegistry.getActiveSearchParams(theEntity.getResourceType()).keySet();
|
||||
for (String nextSpName : activeSearchParamNames) {
|
||||
if (!presentSearchParams.containsKey(nextSpName)) {
|
||||
presentSearchParams.put(nextSpName, Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
mySearchParamPresenceSvc.updatePresence(theEntity, presentSearchParams);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -1426,6 +1405,31 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
postUpdate(theEntity, (T) theResource);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the "search param present" table which is used for the
|
||||
* ?foo:missing=true queries
|
||||
*/
|
||||
if (thePerformIndexing) {
|
||||
Map<String, Boolean> presentSearchParams = new HashMap<String, Boolean>();
|
||||
for (String nextKey : populatedResourceLinkParameters) {
|
||||
presentSearchParams.put(nextKey, Boolean.TRUE);
|
||||
}
|
||||
updateSearchParamPresent(presentSearchParams, stringParams);
|
||||
updateSearchParamPresent(presentSearchParams, tokenParams);
|
||||
updateSearchParamPresent(presentSearchParams, numberParams);
|
||||
updateSearchParamPresent(presentSearchParams, quantityParams);
|
||||
updateSearchParamPresent(presentSearchParams, dateParams);
|
||||
updateSearchParamPresent(presentSearchParams, uriParams);
|
||||
updateSearchParamPresent(presentSearchParams, coordsParams);
|
||||
Set<String> activeSearchParamNames = mySearchParamRegistry.getActiveSearchParams(theEntity.getResourceType()).keySet();
|
||||
for (String nextSpName : activeSearchParamNames) {
|
||||
if (!presentSearchParams.containsKey(nextSpName)) {
|
||||
presentSearchParams.put(nextSpName, Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
mySearchParamPresenceSvc.updatePresence(theEntity, presentSearchParams);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create history entry
|
||||
*/
|
||||
|
|
|
@ -88,8 +88,6 @@ public class SearchBuilder {
|
|||
private EntityManager myEntityManager;
|
||||
private IForcedIdDao myForcedIdDao;
|
||||
private SearchParameterMap myParams;
|
||||
private Collection<Long> myPids;
|
||||
private PlatformTransactionManager myPlatformTransactionManager;
|
||||
private IResourceIndexedSearchParamUriDao myResourceIndexedSearchParamUriDao;
|
||||
private String myResourceName;
|
||||
private Class<? extends IBaseResource> myResourceType;
|
||||
|
@ -97,16 +95,12 @@ public class SearchBuilder {
|
|||
private Search mySearchEntity;
|
||||
private ISearchResultDao mySearchResultDao;
|
||||
private ISearchParamRegistry mySearchParamRegistry;
|
||||
|
||||
private IHapiTerminologySvc myTerminologySvc;
|
||||
|
||||
private Root<ResourceTable> myResourceTableRoot;
|
||||
|
||||
private ArrayList<Predicate> myPredicates;
|
||||
|
||||
private CriteriaBuilder myBuilder;
|
||||
|
||||
private CriteriaQuery<Tuple> myResourceTableQuery;
|
||||
private PlatformTransactionManager myPlatformTransactionManager;
|
||||
|
||||
public SearchBuilder(FhirContext theFhirContext, EntityManager theEntityManager, PlatformTransactionManager thePlatformTransactionManager, IFulltextSearchSvc theFulltextSearchSvc,
|
||||
ISearchResultDao theSearchResultDao, BaseHapiFhirDao<?> theDao,
|
||||
|
@ -158,8 +152,8 @@ public class SearchBuilder {
|
|||
|
||||
private void addPredicateDate(String theParamName, List<? extends IQueryParameterType> theList) {
|
||||
|
||||
if (Boolean.TRUE.equals(theList.get(0).getMissing())) {
|
||||
addPredicateParamMissing("myParamsDate", theParamName, ResourceIndexedSearchParamDate.class);
|
||||
if (theList.get(0).getMissing() != null) {
|
||||
addPredicateParamMissing(theParamName, theList.get(0).getMissing());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -167,10 +161,6 @@ public class SearchBuilder {
|
|||
|
||||
List<Predicate> codePredicates = new ArrayList<Predicate>();
|
||||
for (IQueryParameterType nextOr : theList) {
|
||||
if (addPredicateMissingFalseIfPresent(myBuilder, theParamName, join, codePredicates, nextOr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IQueryParameterType params = nextOr;
|
||||
Predicate p = createPredicateDate(myBuilder, join, params);
|
||||
codePredicates.add(p);
|
||||
|
@ -304,40 +294,10 @@ public class SearchBuilder {
|
|||
return;
|
||||
}
|
||||
|
||||
private boolean addPredicateMissingFalseIfPresent(CriteriaBuilder theBuilder, String theParamName, From<?, ? extends BaseResourceIndexedSearchParam> from, List<Predicate> codePredicates,
|
||||
IQueryParameterType nextOr) {
|
||||
boolean missingFalse = false;
|
||||
if (nextOr.getMissing() != null) {
|
||||
if (nextOr.getMissing().booleanValue() == true) {
|
||||
throw new InvalidRequestException(myContext.getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "multipleParamsWithSameNameOneIsMissingTrue", theParamName));
|
||||
}
|
||||
Predicate singleCode = from.get("myId").isNotNull();
|
||||
Predicate name = theBuilder.equal(from.get("myParamName"), theParamName);
|
||||
codePredicates.add(theBuilder.and(name, singleCode));
|
||||
missingFalse = true;
|
||||
}
|
||||
return missingFalse;
|
||||
}
|
||||
|
||||
private boolean addPredicateMissingFalseIfPresentForResourceLink(CriteriaBuilder theBuilder, String theParamName, From<?,? extends ResourceLink> from, List<Predicate> codePredicates,
|
||||
IQueryParameterType nextOr) {
|
||||
boolean missingFalse = false;
|
||||
if (nextOr.getMissing() != null) {
|
||||
if (nextOr.getMissing().booleanValue() == true) {
|
||||
throw new InvalidRequestException(myContext.getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "multipleParamsWithSameNameOneIsMissingTrue", theParamName));
|
||||
}
|
||||
Predicate singleCode = from.get("mySourceResource").isNotNull();
|
||||
Predicate name = createResourceLinkPathPredicate(theParamName, from);
|
||||
codePredicates.add(theBuilder.and(name, singleCode));
|
||||
missingFalse = true;
|
||||
}
|
||||
return missingFalse;
|
||||
}
|
||||
|
||||
private void addPredicateNumber(String theParamName, List<? extends IQueryParameterType> theList) {
|
||||
|
||||
if (Boolean.TRUE.equals(theList.get(0).getMissing())) {
|
||||
addPredicateParamMissing("myParamsNumber", theParamName, ResourceIndexedSearchParamNumber.class);
|
||||
if (theList.get(0).getMissing() != null) {
|
||||
addPredicateParamMissing(theParamName, theList.get(0).getMissing());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -347,10 +307,6 @@ public class SearchBuilder {
|
|||
for (IQueryParameterType nextOr : theList) {
|
||||
IQueryParameterType params = nextOr;
|
||||
|
||||
if (addPredicateMissingFalseIfPresent(myBuilder, theParamName, join, codePredicates, nextOr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (params instanceof NumberParam) {
|
||||
NumberParam param = (NumberParam) params;
|
||||
|
||||
|
@ -376,62 +332,18 @@ public class SearchBuilder {
|
|||
myPredicates.add(myBuilder.or(toArray(codePredicates)));
|
||||
}
|
||||
|
||||
private void addPredicateParamMissing(String joinName, String theParamName, Class<? extends BaseResourceIndexedSearchParam> theParamTable) {
|
||||
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
|
||||
CriteriaQuery<Long> cq = builder.createQuery(Long.class);
|
||||
Root<ResourceTable> from = cq.from(ResourceTable.class);
|
||||
cq.select(from.get("myId").as(Long.class));
|
||||
private void addPredicateParamMissing(String theParamName, boolean theMissing) {
|
||||
Join<ResourceTable, SearchParamPresent> paramPresentJoin = myResourceTableRoot.join("mySearchParamPresents", JoinType.LEFT);
|
||||
Join<SearchParamPresent, SearchParam> paramJoin = paramPresentJoin.join("mySearchParam", JoinType.LEFT);
|
||||
|
||||
Subquery<Long> subQ = cq.subquery(Long.class);
|
||||
Root<? extends BaseResourceIndexedSearchParam> subQfrom = subQ.from(theParamTable);
|
||||
subQ.select(subQfrom.get("myResourcePid").as(Long.class));
|
||||
Predicate subQname = builder.equal(subQfrom.get("myParamName"), theParamName);
|
||||
Predicate subQtype = builder.equal(subQfrom.get("myResourceType"), myResourceName);
|
||||
subQ.where(builder.and(subQtype, subQname));
|
||||
|
||||
List<Predicate> predicates = new ArrayList<Predicate>();
|
||||
predicates.add(builder.not(builder.in(from.get("myId")).value(subQ)));
|
||||
predicates.add(builder.equal(from.get("myResourceType"), myResourceName));
|
||||
predicates.add(builder.isNull(from.get("myDeleted")));
|
||||
createPredicateResourceId(builder, cq, predicates, from.get("myId").as(Long.class));
|
||||
|
||||
cq.where(builder.and(toArray(predicates)));
|
||||
|
||||
ourLog.info("Adding :missing qualifier for parameter '{}'", theParamName);
|
||||
|
||||
TypedQuery<Long> q = myEntityManager.createQuery(cq);
|
||||
doSetPids(q.getResultList());
|
||||
}
|
||||
|
||||
private void addPredicateParamMissingResourceLink(String joinName, String theParamName) {
|
||||
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
|
||||
CriteriaQuery<Long> cq = builder.createQuery(Long.class);
|
||||
Root<ResourceTable> from = cq.from(ResourceTable.class);
|
||||
cq.select(from.get("myId").as(Long.class));
|
||||
|
||||
Subquery<Long> subQ = cq.subquery(Long.class);
|
||||
Root<ResourceLink> subQfrom = subQ.from(ResourceLink.class);
|
||||
subQ.select(subQfrom.get("mySourceResourcePid").as(Long.class));
|
||||
|
||||
// subQ.where(builder.equal(subQfrom.get("myParamName"), theParamName));
|
||||
Predicate path = createResourceLinkPathPredicate(theParamName, subQfrom);
|
||||
subQ.where(path);
|
||||
|
||||
List<Predicate> predicates = new ArrayList<Predicate>();
|
||||
createPredicateResourceId(builder, cq, predicates, from.get("myId").as(Long.class));
|
||||
predicates.add(builder.not(builder.in(from.get("myId")).value(subQ)));
|
||||
predicates.add(builder.equal(from.get("myResourceType"), myResourceName));
|
||||
|
||||
cq.where(builder.and(toArray(predicates)));
|
||||
|
||||
TypedQuery<Long> q = myEntityManager.createQuery(cq);
|
||||
List<Long> resultList = q.getResultList();
|
||||
doSetPids(new HashSet<Long>(resultList));
|
||||
myPredicates.add(myBuilder.equal(paramJoin.get("myResourceName"), myResourceName));
|
||||
myPredicates.add(myBuilder.equal(paramJoin.get("myParamName"), theParamName));
|
||||
myPredicates.add(myBuilder.equal(paramPresentJoin.get("myPresent"), !theMissing));
|
||||
}
|
||||
|
||||
private void addPredicateQuantity(String theParamName, List<? extends IQueryParameterType> theList) {
|
||||
if (Boolean.TRUE.equals(theList.get(0).getMissing())) {
|
||||
addPredicateParamMissing("myParamsQuantity", theParamName, ResourceIndexedSearchParamQuantity.class);
|
||||
if (theList.get(0).getMissing() != null) {
|
||||
addPredicateParamMissing(theParamName, theList.get(0).getMissing());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -439,9 +351,6 @@ public class SearchBuilder {
|
|||
|
||||
List<Predicate> codePredicates = new ArrayList<Predicate>();
|
||||
for (IQueryParameterType nextOr : theList) {
|
||||
if (addPredicateMissingFalseIfPresent(myBuilder, theParamName, join, codePredicates, nextOr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Predicate singleCode = createPredicateQuantity(myBuilder, join, nextOr);
|
||||
codePredicates.add(singleCode);
|
||||
|
@ -453,8 +362,8 @@ public class SearchBuilder {
|
|||
private void addPredicateReference(String theParamName, List<? extends IQueryParameterType> theList) {
|
||||
assert theParamName.contains(".") == false;
|
||||
|
||||
if (Boolean.TRUE.equals(theList.get(0).getMissing())) {
|
||||
addPredicateParamMissingResourceLink("myResourceLinks", theParamName);
|
||||
if (theList.get(0).getMissing() != null) {
|
||||
addPredicateParamMissing(theParamName, theList.get(0).getMissing());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -465,10 +374,6 @@ public class SearchBuilder {
|
|||
for (IQueryParameterType nextOr : theList) {
|
||||
IQueryParameterType params = nextOr;
|
||||
|
||||
if (addPredicateMissingFalseIfPresentForResourceLink(myBuilder, theParamName, join, codePredicates, nextOr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (params instanceof ReferenceParam) {
|
||||
ReferenceParam ref = (ReferenceParam) params;
|
||||
|
||||
|
@ -585,7 +490,7 @@ public class SearchBuilder {
|
|||
}
|
||||
|
||||
foundChainMatch = true;
|
||||
// Set<Long> pids = dao.searchForIds(chain, chainValue);
|
||||
// Set<Long> pids = dao.searchForIds(chain, chainValue);
|
||||
|
||||
Subquery<Long> subQ = myResourceTableQuery.subquery(Long.class);
|
||||
Root<ResourceTable> subQfrom = subQ.from(ResourceTable.class);
|
||||
|
@ -633,8 +538,8 @@ public class SearchBuilder {
|
|||
}
|
||||
|
||||
private void addPredicateString(String theParamName, List<? extends IQueryParameterType> theList) {
|
||||
if (Boolean.TRUE.equals(theList.get(0).getMissing())) {
|
||||
addPredicateParamMissing("myParamsString", theParamName, ResourceIndexedSearchParamString.class);
|
||||
if (theList.get(0).getMissing() != null) {
|
||||
addPredicateParamMissing(theParamName, theList.get(0).getMissing());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -643,10 +548,6 @@ public class SearchBuilder {
|
|||
List<Predicate> codePredicates = new ArrayList<Predicate>();
|
||||
for (IQueryParameterType nextOr : theList) {
|
||||
IQueryParameterType theParameter = nextOr;
|
||||
if (addPredicateMissingFalseIfPresent(myBuilder, theParamName, join, codePredicates, nextOr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Predicate singleCode = createPredicateString(theParameter, theParamName, myBuilder, join);
|
||||
codePredicates.add(singleCode);
|
||||
}
|
||||
|
@ -785,8 +686,8 @@ public class SearchBuilder {
|
|||
|
||||
private void addPredicateToken(String theParamName, List<? extends IQueryParameterType> theList) {
|
||||
|
||||
if (Boolean.TRUE.equals(theList.get(0).getMissing())) {
|
||||
addPredicateParamMissing("myParamsToken", theParamName, ResourceIndexedSearchParamToken.class);
|
||||
if (theList.get(0).getMissing() != null) {
|
||||
addPredicateParamMissing(theParamName, theList.get(0).getMissing());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -794,9 +695,6 @@ public class SearchBuilder {
|
|||
|
||||
List<Predicate> codePredicates = new ArrayList<Predicate>();
|
||||
for (IQueryParameterType nextOr : theList) {
|
||||
if (addPredicateMissingFalseIfPresent(myBuilder, theParamName, join, codePredicates, nextOr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nextOr instanceof TokenParam) {
|
||||
TokenParam id = (TokenParam) nextOr;
|
||||
|
@ -822,8 +720,8 @@ public class SearchBuilder {
|
|||
}
|
||||
|
||||
private void addPredicateUri(String theParamName, List<? extends IQueryParameterType> theList) {
|
||||
if (Boolean.TRUE.equals(theList.get(0).getMissing())) {
|
||||
addPredicateParamMissing("myParamsUri", theParamName, ResourceIndexedSearchParamUri.class);
|
||||
if (theList.get(0).getMissing() != null) {
|
||||
addPredicateParamMissing(theParamName, theList.get(0).getMissing());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -833,10 +731,6 @@ public class SearchBuilder {
|
|||
for (IQueryParameterType nextOr : theList) {
|
||||
IQueryParameterType params = nextOr;
|
||||
|
||||
if (addPredicateMissingFalseIfPresent(myBuilder, theParamName, join, codePredicates, nextOr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (params instanceof UriParam) {
|
||||
UriParam param = (UriParam) params;
|
||||
|
||||
|
@ -1265,7 +1159,7 @@ public class SearchBuilder {
|
|||
return singleCode;
|
||||
}
|
||||
|
||||
private Predicate createResourceLinkPathPredicate(String theParamName, From<?,? extends ResourceLink> from) {
|
||||
private Predicate createResourceLinkPathPredicate(String theParamName, From<?, ? extends ResourceLink> from) {
|
||||
return createResourceLinkPathPredicate(myCallingDao, myContext, theParamName, from, myResourceType);
|
||||
}
|
||||
|
||||
|
@ -1368,10 +1262,6 @@ public class SearchBuilder {
|
|||
thePredicates.add(theBuilder.equal(stringJoin.get("myParamName"), theSort.getParamName()));
|
||||
}
|
||||
|
||||
// Predicate p = theBuilder.equal(stringJoin.get("myParamName"), theSort.getParamName());
|
||||
// Predicate pn = theBuilder.isNull(stringJoin.get("myParamName"));
|
||||
// thePredicates.add(theBuilder.or(p, pn));
|
||||
|
||||
for (String next : sortAttrName) {
|
||||
if (theSort.getOrder() == null || theSort.getOrder() == SortOrderEnum.ASC) {
|
||||
theOrders.add(theBuilder.asc(stringJoin.get(next)));
|
||||
|
@ -1702,9 +1592,8 @@ public class SearchBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (!theParams.isEmpty()) {
|
||||
// searchForIdsWithAndOr(theParams, lu);
|
||||
// searchForIdsWithAndOr(theParams, lu);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1841,6 +1730,7 @@ public class SearchBuilder {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (orPids.size() > 0) {
|
||||
Predicate nextPredicate = myResourceTableRoot.get("myId").as(Long.class).in(orPids);
|
||||
|
@ -1848,8 +1738,6 @@ public class SearchBuilder {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void setType(Class<? extends IBaseResource> theResourceType, String theResourceName) {
|
||||
|
@ -1942,7 +1830,7 @@ public class SearchBuilder {
|
|||
return likeExpression.replace("%", "[%]") + "%";
|
||||
}
|
||||
|
||||
private static Predicate createResourceLinkPathPredicate(IDao theCallingDao, FhirContext theContext, String theParamName, From<?,? extends ResourceLink> from,
|
||||
private static Predicate createResourceLinkPathPredicate(IDao theCallingDao, FhirContext theContext, String theParamName, From<?, ? extends ResourceLink> from,
|
||||
Class<? extends IBaseResource> resourceType) {
|
||||
RuntimeResourceDefinition resourceDef = theContext.getResourceDefinition(resourceType);
|
||||
RuntimeSearchParam param = theCallingDao.getSearchParamByName(resourceDef, theParamName);
|
||||
|
|
|
@ -32,7 +32,7 @@ import ca.uhn.fhir.jpa.entity.SearchParamPresent;
|
|||
|
||||
public interface ISearchParamPresentDao extends JpaRepository<SearchParamPresent, Long> {
|
||||
|
||||
@Query("SELECT s FROM SearchParamPresent s WHERE s.myResourceTable = :res")
|
||||
@Query("SELECT s FROM SearchParamPresent s WHERE s.myResource = :res")
|
||||
public Collection<SearchParamPresent> findAllForResource(@Param("res") ResourceTable theResource);
|
||||
|
||||
}
|
||||
|
|
|
@ -236,6 +236,9 @@ public class ResourceTable extends BaseHasResource implements Serializable {
|
|||
@OneToMany(mappedBy = "myResource", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private Set<ResourceTag> myTags;
|
||||
|
||||
@OneToMany(mappedBy = "myResource", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private Collection<SearchParamPresent> mySearchParamPresents;
|
||||
|
||||
@Column(name = "RES_VER")
|
||||
private long myVersion;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ public class SearchParam {
|
|||
@Id
|
||||
@SequenceGenerator(name = "SEQ_SEARCHPARM_ID", sequenceName = "SEQ_SEARCHPARM_ID")
|
||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_SEARCHPARM_ID")
|
||||
@Column(name = "RES_ID")
|
||||
@Column(name = "PID")
|
||||
private Long myId;
|
||||
|
||||
@Column(name="PARAM_NAME", length=BaseResourceIndexedSearchParam.MAX_SP_NAME, nullable=false, updatable=false)
|
||||
|
|
|
@ -25,14 +25,14 @@ public class SearchParamPresent implements Serializable {
|
|||
|
||||
@ManyToOne()
|
||||
@JoinColumn(name = "RES_ID", referencedColumnName = "RES_ID", nullable = false, foreignKey = @ForeignKey(name = "FK_RESPARMPRES_RESID"))
|
||||
private ResourceTable myResourceTable;
|
||||
private ResourceTable myResource;
|
||||
|
||||
@ManyToOne()
|
||||
@JoinColumn(name = "SP_ID", referencedColumnName = "PID", nullable = false, foreignKey = @ForeignKey(name = "FK_RESPARMPRES_SPID"))
|
||||
private SearchParam mySearchParam;
|
||||
|
||||
public ResourceTable getResourceTable() {
|
||||
return myResourceTable;
|
||||
public ResourceTable getResource() {
|
||||
return myResource;
|
||||
}
|
||||
|
||||
public SearchParam getSearchParam() {
|
||||
|
@ -47,8 +47,8 @@ public class SearchParamPresent implements Serializable {
|
|||
myPresent = thePresent;
|
||||
}
|
||||
|
||||
public void setResourceTable(ResourceTable theResourceTable) {
|
||||
myResourceTable = theResourceTable;
|
||||
public void setResource(ResourceTable theResourceTable) {
|
||||
myResource = theResourceTable;
|
||||
}
|
||||
|
||||
public void setSearchParam(SearchParam theSearchParam) {
|
||||
|
|
|
@ -17,7 +17,7 @@ public class SearchParamPresenceSvcImpl implements ISearchParamPresenceSvc {
|
|||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchParamPresenceSvcImpl.class);
|
||||
|
||||
private Map<Pair<String, String>, SearchParam> myResourceTypeToSearchParamToEntity = new ConcurrentHashMap<Pair<String,String>, SearchParam>();
|
||||
private Map<Pair<String, String>, SearchParam> myResourceTypeToSearchParamToEntity = new ConcurrentHashMap<Pair<String, String>, SearchParam>();
|
||||
|
||||
@Autowired
|
||||
private ISearchParamDao mySearchParamDao;
|
||||
|
@ -32,7 +32,13 @@ public class SearchParamPresenceSvcImpl implements ISearchParamPresenceSvc {
|
|||
List<SearchParamPresent> entitiesToSave = new ArrayList<SearchParamPresent>();
|
||||
List<SearchParamPresent> entitiesToDelete = new ArrayList<SearchParamPresent>();
|
||||
|
||||
Collection<SearchParamPresent> existing = mySearchParamPresentDao.findAllForResource(theResource);
|
||||
Collection<SearchParamPresent> existing;
|
||||
// if (theResource.getId() != null) {
|
||||
existing = mySearchParamPresentDao.findAllForResource(theResource);
|
||||
// } else {
|
||||
// existing = Collections.emptyList();
|
||||
// }
|
||||
|
||||
for (SearchParamPresent nextExistingEntity : existing) {
|
||||
String nextSearchParamName = nextExistingEntity.getSearchParam().getParamName();
|
||||
Boolean existingValue = presenceMap.remove(nextSearchParamName);
|
||||
|
@ -65,7 +71,7 @@ public class SearchParamPresenceSvcImpl implements ISearchParamPresenceSvc {
|
|||
}
|
||||
|
||||
SearchParamPresent present = new SearchParamPresent();
|
||||
present.setResourceTable(theResource);
|
||||
present.setResource(theResource);
|
||||
present.setSearchParam(searchParam);
|
||||
present.setPresent(next.getValue());
|
||||
entitiesToSave.add(present);
|
||||
|
|
|
@ -30,28 +30,7 @@ import org.springframework.transaction.support.TransactionCallback;
|
|||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.entity.ForcedId;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceHistoryTable;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceHistoryTag;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamCoords;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamNumber;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamQuantity;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamToken;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamUri;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceLink;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceTag;
|
||||
import ca.uhn.fhir.jpa.entity.SearchInclude;
|
||||
import ca.uhn.fhir.jpa.entity.SearchResult;
|
||||
import ca.uhn.fhir.jpa.entity.SubscriptionFlaggedResource;
|
||||
import ca.uhn.fhir.jpa.entity.SubscriptionTable;
|
||||
import ca.uhn.fhir.jpa.entity.TagDefinition;
|
||||
import ca.uhn.fhir.jpa.entity.TermCodeSystem;
|
||||
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
||||
import ca.uhn.fhir.jpa.entity.TermConcept;
|
||||
import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink;
|
||||
import ca.uhn.fhir.jpa.entity.*;
|
||||
import ca.uhn.fhir.jpa.provider.SystemProviderDstu2Test;
|
||||
import ca.uhn.fhir.jpa.term.VersionIndependentConcept;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
|
@ -225,6 +204,9 @@ public abstract class BaseJpaTest {
|
|||
txTemplate.execute(new TransactionCallback<Void>() {
|
||||
@Override
|
||||
public Void doInTransaction(TransactionStatus theStatus) {
|
||||
entityManager.createQuery("DELETE from " + SearchParamPresent.class.getSimpleName() + " d").executeUpdate();
|
||||
entityManager.createQuery("DELETE from " + SearchParam.class.getSimpleName() + " d").executeUpdate();
|
||||
entityManager.createQuery("DELETE from " + SubscriptionFlaggedResource.class.getSimpleName() + " d").executeUpdate();
|
||||
entityManager.createQuery("DELETE from " + SubscriptionFlaggedResource.class.getSimpleName() + " d").executeUpdate();
|
||||
entityManager.createQuery("DELETE from " + ForcedId.class.getSimpleName() + " d").executeUpdate();
|
||||
entityManager.createQuery("DELETE from " + ResourceIndexedSearchParamDate.class.getSimpleName() + " d").executeUpdate();
|
||||
|
|
|
@ -2146,8 +2146,8 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
|||
param.setMissing(false);
|
||||
params.put(Patient.SP_BIRTHDATE, param);
|
||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params));
|
||||
assertThat(patients, not(containsInRelativeOrder(missing)));
|
||||
assertThat(patients, containsInRelativeOrder(notMissing));
|
||||
assertThat(patients, not(containsInRelativeOrder(missing)));
|
||||
}
|
||||
{
|
||||
Map<String, IQueryParameterType> params = new HashMap<String, IQueryParameterType>();
|
||||
|
@ -2158,6 +2158,14 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
|||
assertThat(patients, containsInRelativeOrder(missing));
|
||||
assertThat(patients, not(containsInRelativeOrder(notMissing)));
|
||||
}
|
||||
// {
|
||||
// Map<String, IQueryParameterType> params = new HashMap<String, IQueryParameterType>();
|
||||
// DateParam param = new DateParam();
|
||||
// param.setMissing(true);
|
||||
// params.put(Patient.SP_DECEASED, param);
|
||||
// List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params));
|
||||
// assertThat(patients, containsInRelativeOrder(missing, notMissing));
|
||||
// }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue