Reformatted the code

This commit is contained in:
Frank Tao 2021-09-02 22:26:55 -04:00
parent be96adb694
commit 56890dba93
1 changed files with 23 additions and 31 deletions

View File

@ -985,14 +985,14 @@ public class QueryStack {
} }
public Condition createPredicateToken(@Nullable DbColumn theSourceJoinColumn, String theResourceName, public Condition createPredicateToken(@Nullable DbColumn theSourceJoinColumn, String theResourceName,
String theSpnamePrefix, RuntimeSearchParam theSearchParam, List<? extends IQueryParameterType> theList, String theSpnamePrefix, RuntimeSearchParam theSearchParam, List<? extends IQueryParameterType> theList,
SearchFilterParser.CompareOperation theOperation, RequestPartitionId theRequestPartitionId) { SearchFilterParser.CompareOperation theOperation, RequestPartitionId theRequestPartitionId) {
List<IQueryParameterType> tokens = new ArrayList<>();
List<IQueryParameterType> tokens = new ArrayList<>();
boolean paramInverted = false; boolean paramInverted = false;
TokenParamModifier modifier = null; TokenParamModifier modifier = null;
for (IQueryParameterType nextOr : theList) { for (IQueryParameterType nextOr : theList) {
if (nextOr instanceof TokenParam) { if (nextOr instanceof TokenParam) {
if (!((TokenParam) nextOr).isEmpty()) { if (!((TokenParam) nextOr).isEmpty()) {
@ -1000,24 +1000,20 @@ public class QueryStack {
if (id.isText()) { if (id.isText()) {
// Check whether the :text modifier is actually enabled here // Check whether the :text modifier is actually enabled here
boolean tokenTextIndexingEnabled = BaseSearchParamExtractor boolean tokenTextIndexingEnabled = BaseSearchParamExtractor.tokenTextIndexingEnabledForSearchParam(myModelConfig, theSearchParam);
.tokenTextIndexingEnabledForSearchParam(myModelConfig, theSearchParam);
if (!tokenTextIndexingEnabled) { if (!tokenTextIndexingEnabled) {
String msg; String msg;
if (myModelConfig.isSuppressStringIndexingInTokens()) { if (myModelConfig.isSuppressStringIndexingInTokens()) {
msg = myFhirContext.getLocalizer().getMessage(PredicateBuilderToken.class, msg = myFhirContext.getLocalizer().getMessage(PredicateBuilderToken.class, "textModifierDisabledForServer");
"textModifierDisabledForServer");
} else { } else {
msg = myFhirContext.getLocalizer().getMessage(PredicateBuilderToken.class, msg = myFhirContext.getLocalizer().getMessage(PredicateBuilderToken.class, "textModifierDisabledForSearchParam");
"textModifierDisabledForSearchParam");
} }
throw new MethodNotAllowedException(msg); throw new MethodNotAllowedException(msg);
} }
return createPredicateString(theSourceJoinColumn, theResourceName, theSpnamePrefix, return createPredicateString(theSourceJoinColumn, theResourceName, theSpnamePrefix, theSearchParam, theList, null, theRequestPartitionId);
theSearchParam, theList, null, theRequestPartitionId); }
}
modifier = id.getModifier(); modifier = id.getModifier();
// for :not modifier, create a token and remove the :not modifier // for :not modifier, create a token and remove the :not modifier
if (modifier != null && modifier == TokenParamModifier.NOT) { if (modifier != null && modifier == TokenParamModifier.NOT) {
@ -1039,39 +1035,35 @@ public class QueryStack {
String paramName = getParamNameWithPrefix(theSpnamePrefix, theSearchParam.getName()); String paramName = getParamNameWithPrefix(theSpnamePrefix, theSearchParam.getName());
Condition predicate; Condition predicate;
BaseJoiningPredicateBuilder join; BaseJoiningPredicateBuilder join;
if (paramInverted) { if (paramInverted) {
SearchQueryBuilder sqlBuilder = mySqlBuilder.newChildSqlBuilder(); SearchQueryBuilder sqlBuilder = mySqlBuilder.newChildSqlBuilder();
TokenPredicateBuilder tokenSelector = sqlBuilder.addTokenPredicateBuilder(null); TokenPredicateBuilder tokenSelector = sqlBuilder.addTokenPredicateBuilder(null);
sqlBuilder.addPredicate(tokenSelector.createPredicateToken(tokens, theResourceName, theSpnamePrefix, sqlBuilder.addPredicate(tokenSelector.createPredicateToken(tokens, theResourceName, theSpnamePrefix, theSearchParam, theRequestPartitionId));
theSearchParam, theRequestPartitionId));
SelectQuery sql = sqlBuilder.getSelect(); SelectQuery sql = sqlBuilder.getSelect();
Expression subSelect = new Subquery(sql); Expression subSelect = new Subquery(sql);
join = mySqlBuilder.getOrCreateFirstPredicateBuilder(); join = mySqlBuilder.getOrCreateFirstPredicateBuilder();
if (theSourceJoinColumn == null) { if (theSourceJoinColumn == null) {
predicate = new InCondition(join.getResourceIdColumn(), subSelect).setNegate(true); predicate = new InCondition(join.getResourceIdColumn(), subSelect).setNegate(true);
} else { } else {
//-- for the resource link, need join with target_resource_id //-- for the resource link, need join with target_resource_id
predicate = new InCondition(theSourceJoinColumn, subSelect).setNegate(true); predicate = new InCondition(theSourceJoinColumn, subSelect).setNegate(true);
} }
} else { } else {
TokenPredicateBuilder tokenJoin = createOrReusePredicateBuilder(PredicateBuilderTypeEnum.TOKEN, TokenPredicateBuilder tokenJoin = createOrReusePredicateBuilder(PredicateBuilderTypeEnum.TOKEN, theSourceJoinColumn, paramName, () -> mySqlBuilder.addTokenPredicateBuilder(theSourceJoinColumn)).getResult();
theSourceJoinColumn, paramName, () -> mySqlBuilder.addTokenPredicateBuilder(theSourceJoinColumn))
.getResult();
if (theList.get(0).getMissing() != null) { if (theList.get(0).getMissing() != null) {
return tokenJoin.createPredicateParamMissingForNonReference(theResourceName, paramName, return tokenJoin.createPredicateParamMissingForNonReference(theResourceName, paramName, theList.get(0).getMissing(), theRequestPartitionId);
theList.get(0).getMissing(), theRequestPartitionId);
} }
predicate = tokenJoin.createPredicateToken(tokens, theResourceName, theSpnamePrefix, theSearchParam, theOperation, theRequestPartitionId); predicate = tokenJoin.createPredicateToken(tokens, theResourceName, theSpnamePrefix, theSearchParam, theOperation, theRequestPartitionId);
join = tokenJoin; join = tokenJoin;
} }
return join.combineWithRequestPartitionIdPredicate(theRequestPartitionId, predicate); return join.combineWithRequestPartitionIdPredicate(theRequestPartitionId, predicate);
} }