Merged James' most recent changes.
This commit is contained in:
parent
09daf7aacc
commit
49ed6b48dc
|
@ -1865,9 +1865,11 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
codes.addAll(myTerminologySvc.expandValueSet(code));
|
||||
} else if (modifier == TokenParamModifier.ABOVE) {
|
||||
system = determineSystemIfMissing(theParamName, code, system);
|
||||
validateHaveSystemAndCodeForToken(theParamName, code, system);
|
||||
codes.addAll(myTerminologySvc.findCodesAbove(system, code));
|
||||
} else if (modifier == TokenParamModifier.BELOW) {
|
||||
system = determineSystemIfMissing(theParamName, code, system);
|
||||
validateHaveSystemAndCodeForToken(theParamName, code, system);
|
||||
codes.addAll(myTerminologySvc.findCodesBelow(system, code));
|
||||
} else {
|
||||
codes.add(new VersionIndependentConcept(system, code));
|
||||
|
@ -1910,6 +1912,19 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
private void validateHaveSystemAndCodeForToken(String theParamName, String theCode, String theSystem) {
|
||||
String systemDesc = defaultIfBlank(theSystem, "(missing)");
|
||||
String codeDesc = defaultIfBlank(theCode, "(missing)");
|
||||
if (isBlank(theCode)) {
|
||||
String msg = myContext.getLocalizer().getMessage(SearchBuilder.class, "invalidCodeMissingSystem", theParamName, systemDesc, codeDesc);
|
||||
throw new InvalidRequestException(msg);
|
||||
}
|
||||
if (isBlank(theSystem)) {
|
||||
String msg = myContext.getLocalizer().getMessage(SearchBuilder.class, "invalidCodeMissingCode", theParamName, systemDesc, codeDesc);
|
||||
throw new InvalidRequestException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private Predicate addPredicateToken(String theResourceName, String theParamName, CriteriaBuilder theBuilder, From<?, ResourceIndexedSearchParamToken> theFrom, List<VersionIndependentConcept> theTokens, TokenParamModifier theModifier, TokenModeEnum theTokenMode) {
|
||||
if (myDontUseHashesForSearch) {
|
||||
final Path<String> systemExpression = theFrom.get("mySystem");
|
||||
|
@ -2064,6 +2079,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
outerQuery.multiselect(myBuilder.countDistinct(myResourceTableRoot));
|
||||
} else {
|
||||
outerQuery.multiselect(myResourceTableRoot.get("myId").as(Long.class));
|
||||
outerQuery.distinct(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3133,6 +3149,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
|
||||
private final SearchRuntimeDetails mySearchRuntimeDetails;
|
||||
private final RequestDetails myRequest;
|
||||
private final boolean myHaveRawSqlHooks;
|
||||
private final boolean myHavePerftraceFoundIdHook;
|
||||
private boolean myFirst = true;
|
||||
private IncludesIterator myIncludesIterator;
|
||||
private Long myNext;
|
||||
|
@ -3151,13 +3169,16 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
if (myParams.getEverythingMode() != null) {
|
||||
myStillNeedToFetchIncludes = true;
|
||||
}
|
||||
|
||||
myHavePerftraceFoundIdHook =JpaInterceptorBroadcaster.hasHooks(Pointcut.JPA_PERFTRACE_SEARCH_FOUND_ID, myInterceptorBroadcaster, myRequest);
|
||||
myHaveRawSqlHooks = JpaInterceptorBroadcaster.hasHooks(Pointcut.JPA_PERFTRACE_RAW_SQL, myInterceptorBroadcaster, myRequest);
|
||||
|
||||
}
|
||||
|
||||
private void fetchNext() {
|
||||
|
||||
boolean haveRawSqlHooks = JpaInterceptorBroadcaster.hasHooks(Pointcut.JPA_PERFTRACE_RAW_SQL, myInterceptorBroadcaster, myRequest);
|
||||
try {
|
||||
if (haveRawSqlHooks) {
|
||||
if (myHaveRawSqlHooks) {
|
||||
CurrentThreadCaptureQueriesListener.startCapturing();
|
||||
}
|
||||
|
||||
|
@ -3198,6 +3219,13 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
if (myNext == null) {
|
||||
while (myResultsIterator.hasNext()) {
|
||||
Long next = myResultsIterator.next();
|
||||
if (myHavePerftraceFoundIdHook) {
|
||||
HookParams params = new HookParams()
|
||||
.add(Integer.class, System.identityHashCode(this))
|
||||
.add(Object.class, next);
|
||||
JpaInterceptorBroadcaster.doCallHooks(myInterceptorBroadcaster, myRequest, Pointcut.JPA_PERFTRACE_SEARCH_FOUND_ID, params);
|
||||
}
|
||||
|
||||
if (next != null) {
|
||||
if (myPidSet.add(next)) {
|
||||
myNext = next;
|
||||
|
@ -3236,7 +3264,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
mySearchRuntimeDetails.setFoundMatchesCount(myPidSet.size());
|
||||
|
||||
} finally {
|
||||
if (haveRawSqlHooks) {
|
||||
if (myHaveRawSqlHooks) {
|
||||
SqlQueryList capturedQueries = CurrentThreadCaptureQueriesListener.getCurrentQueueAndStopCapturing();
|
||||
HookParams params = new HookParams()
|
||||
.add(RequestDetails.class, myRequest)
|
||||
|
|
Loading…
Reference in New Issue