FIXME
This commit is contained in:
parent
3e28047f78
commit
99949629a8
|
@ -39,7 +39,6 @@ abstract class BasePredicateBuilder {
|
||||||
final String myResourceName;
|
final String myResourceName;
|
||||||
final SearchParameterMap myParams;
|
final SearchParameterMap myParams;
|
||||||
|
|
||||||
// FIXME KHS autowire with lookup
|
|
||||||
BasePredicateBuilder(SearchBuilder theSearchBuilder) {
|
BasePredicateBuilder(SearchBuilder theSearchBuilder) {
|
||||||
myCallingDao = theSearchBuilder.getCallingDao();
|
myCallingDao = theSearchBuilder.getCallingDao();
|
||||||
myBuilder = theSearchBuilder.getBuilder();
|
myBuilder = theSearchBuilder.getBuilder();
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package ca.uhn.fhir.jpa.dao.predicate;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.persistence.criteria.Predicate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IPredicateBuilder {
|
||||||
|
@Nullable
|
||||||
|
Predicate addPredicate(String theResourceName,
|
||||||
|
String theParamName,
|
||||||
|
List<? extends IQueryParameterType> theList,
|
||||||
|
SearchFilterParser.CompareOperation operation);
|
||||||
|
}
|
|
@ -36,72 +36,47 @@ public class PredicateBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPredicateCoords(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd) {
|
void addPredicateCoords(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd) {
|
||||||
// FIXME KHS consolidate these predicate builders (e.g. all these mathods should have the same name)
|
myPredicateBuilderCoords.addPredicate(theResourceName, theParamName, theNextAnd);
|
||||||
myPredicateBuilderCoords.addPredicateCoords(theResourceName, theParamName, theNextAnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addPredicateDate(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd) {
|
|
||||||
myPredicateBuilderDate.addPredicateDate(theResourceName, theParamName, theNextAnd, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate addPredicateDate(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
Predicate addPredicateDate(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
||||||
return myPredicateBuilderDate.addPredicateDate(theResourceName, theParamName, theNextAnd, theOperation);
|
return myPredicateBuilderDate.addPredicate(theResourceName, theParamName, theNextAnd, theOperation);
|
||||||
}
|
|
||||||
|
|
||||||
private void addPredicateNumber(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd) {
|
|
||||||
myPredicateBuilderNumber.addPredicateNumber(theResourceName, theParamName, theNextAnd, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate addPredicateNumber(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
Predicate addPredicateNumber(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
||||||
return myPredicateBuilderNumber.addPredicateNumber(theResourceName, theParamName, theNextAnd, theOperation);
|
return myPredicateBuilderNumber.addPredicate(theResourceName, theParamName, theNextAnd, theOperation);
|
||||||
}
|
|
||||||
|
|
||||||
private void addPredicateQuantity(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd) {
|
|
||||||
myPredicateBuilderQuantity.addPredicateQuantity(theResourceName, theParamName, theNextAnd, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate addPredicateQuantity(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
Predicate addPredicateQuantity(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
||||||
return myPredicateBuilderQuantity.addPredicateQuantity(theResourceName, theParamName, theNextAnd, theOperation);
|
return myPredicateBuilderQuantity.addPredicate(theResourceName, theParamName, theNextAnd, theOperation);
|
||||||
}
|
|
||||||
|
|
||||||
private Predicate addPredicateReference(String theResourceName, String theParamName, List<? extends IQueryParameterType> theList, RequestDetails theRequest) {
|
|
||||||
return myPredicateBuilderReference.addPredicateReference(theResourceName, theParamName, theList, null, theRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPredicateString(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd) {
|
void addPredicateString(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd) {
|
||||||
myPredicateBuilderString.addPredicateString(theResourceName, theParamName, theNextAnd, SearchFilterParser.CompareOperation.sw);
|
myPredicateBuilderString.addPredicate(theResourceName, theParamName, theNextAnd, SearchFilterParser.CompareOperation.sw);
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate addPredicateString(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
Predicate addPredicateString(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
||||||
return myPredicateBuilderString.addPredicateString(theResourceName, theParamName, theNextAnd, theOperation);
|
return myPredicateBuilderString.addPredicate(theResourceName, theParamName, theNextAnd, theOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPredicateTag(List<List<IQueryParameterType>> theAndOrParams, String theParamName) {
|
void addPredicateTag(List<List<IQueryParameterType>> theAndOrParams, String theParamName) {
|
||||||
myPredicateBuilderTag.addPredicateTag(theAndOrParams, theParamName);
|
myPredicateBuilderTag.addPredicateTag(theAndOrParams, theParamName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPredicateToken(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd) {
|
|
||||||
myPredicateBuilderToken.addPredicateToken(theResourceName, theParamName, theNextAnd, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
Predicate addPredicateToken(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
Predicate addPredicateToken(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
||||||
return myPredicateBuilderToken.addPredicateToken(theResourceName, theParamName, theNextAnd, theOperation);
|
return myPredicateBuilderToken.addPredicate(theResourceName, theParamName, theNextAnd, theOperation);
|
||||||
}
|
|
||||||
|
|
||||||
private void addPredicateUri(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd) {
|
|
||||||
myPredicateBuilderUri.addPredicateUri(theResourceName, theParamName, theNextAnd, SearchFilterParser.CompareOperation.eq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate addPredicateUri(String theResourceName, String theName, List<? extends IQueryParameterType> theSingletonList, SearchFilterParser.CompareOperation theOperation) {
|
Predicate addPredicateUri(String theResourceName, String theName, List<? extends IQueryParameterType> theSingletonList, SearchFilterParser.CompareOperation theOperation) {
|
||||||
return myPredicateBuilderUri.addPredicateUri(theResourceName, theName, theSingletonList, theOperation);
|
return myPredicateBuilderUri.addPredicate(theResourceName, theName, theSingletonList, theOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void searchForIdsWithAndOr(String theResourceName, String theNextParamName, List<List<IQueryParameterType>> theAndOrParams, RequestDetails theRequest) {
|
public void searchForIdsWithAndOr(String theResourceName, String theNextParamName, List<List<IQueryParameterType>> theAndOrParams, RequestDetails theRequest) {
|
||||||
myPredicateBuilderReference.searchForIdsWithAndOr(theResourceName, theNextParamName, theAndOrParams, theRequest);
|
myPredicateBuilderReference.searchForIdsWithAndOr(theResourceName, theNextParamName, theAndOrParams, theRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
Subquery<Long> createLinkSubquery(boolean theFoundChainMatch, String theParameterName, String theTargetResourceType, ArrayList<IQueryParameterType> theOrValues, RequestDetails theRequest) {
|
Subquery<Long> createLinkSubquery(String theParameterName, String theTargetResourceType, ArrayList<IQueryParameterType> theOrValues, RequestDetails theRequest) {
|
||||||
return myPredicateBuilderReference.createLinkSubquery(theFoundChainMatch, theParameterName, theTargetResourceType, theOrValues, theRequest);
|
return myPredicateBuilderReference.createLinkSubquery(true, theParameterName, theTargetResourceType, theOrValues, theRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate createResourceLinkPathPredicate(String theTargetResourceType, String theParamReference, Join<ResourceTable, ResourceLink> theJoin) {
|
Predicate createResourceLinkPathPredicate(String theTargetResourceType, String theParamReference, Join<ResourceTable, ResourceLink> theJoin) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
public class PredicateBuilderCoords extends BasePredicateBuilder {
|
public class PredicateBuilderCoords extends BasePredicateBuilder implements IPredicateBuilder {
|
||||||
|
|
||||||
PredicateBuilderCoords(SearchBuilder theSearchBuilder) {
|
PredicateBuilderCoords(SearchBuilder theSearchBuilder) {
|
||||||
super(theSearchBuilder);
|
super(theSearchBuilder);
|
||||||
|
@ -89,8 +89,8 @@ public class PredicateBuilderCoords extends BasePredicateBuilder {
|
||||||
} else if (distanceKm < 0.0) {
|
} else if (distanceKm < 0.0) {
|
||||||
throw new IllegalArgumentException("Invalid " + Location.SP_NEAR_DISTANCE + " parameter '" + distanceKm + "' must be >= 0.0");
|
throw new IllegalArgumentException("Invalid " + Location.SP_NEAR_DISTANCE + " parameter '" + distanceKm + "' must be >= 0.0");
|
||||||
} else {
|
} else {
|
||||||
Double latitudeDegrees = Double.valueOf(latitudeValue);
|
double latitudeDegrees = Double.parseDouble(latitudeValue);
|
||||||
Double longitudeDegrees = Double.valueOf(longitudeValue);
|
double longitudeDegrees = Double.parseDouble(longitudeValue);
|
||||||
|
|
||||||
Point northPoint = CoordCalculator.findTarget(latitudeDegrees, longitudeDegrees, 0.0, distanceKm);
|
Point northPoint = CoordCalculator.findTarget(latitudeDegrees, longitudeDegrees, 0.0, distanceKm);
|
||||||
Point eastPoint = CoordCalculator.findTarget(latitudeDegrees, longitudeDegrees, 90.0, distanceKm);
|
Point eastPoint = CoordCalculator.findTarget(latitudeDegrees, longitudeDegrees, 90.0, distanceKm);
|
||||||
|
@ -110,9 +110,11 @@ public class PredicateBuilderCoords extends BasePredicateBuilder {
|
||||||
return combineParamIndexPredicateWithParamNamePredicate(theResourceName, theParamName, theFrom, singleCode);
|
return combineParamIndexPredicateWithParamNamePredicate(theResourceName, theParamName, theFrom, singleCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Predicate addPredicateCoords(String theResourceName,
|
@Override
|
||||||
|
public Predicate addPredicate(String theResourceName,
|
||||||
String theParamName,
|
String theParamName,
|
||||||
List<? extends IQueryParameterType> theList) {
|
List<? extends IQueryParameterType> theList,
|
||||||
|
SearchFilterParser.CompareOperation theOperation) {
|
||||||
Join<ResourceTable, ResourceIndexedSearchParamCoords> join = createJoin(SearchBuilderJoinEnum.COORDS, theParamName);
|
Join<ResourceTable, ResourceIndexedSearchParamCoords> join = createJoin(SearchBuilderJoinEnum.COORDS, theParamName);
|
||||||
|
|
||||||
if (theList.get(0).getMissing() != null) {
|
if (theList.get(0).getMissing() != null) {
|
||||||
|
|
|
@ -23,14 +23,15 @@ import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
public class PredicateBuilderDate extends BasePredicateBuilder {
|
public class PredicateBuilderDate extends BasePredicateBuilder implements IPredicateBuilder {
|
||||||
private static final Logger ourLog = LoggerFactory.getLogger(PredicateBuilderDate.class);
|
private static final Logger ourLog = LoggerFactory.getLogger(PredicateBuilderDate.class);
|
||||||
|
|
||||||
PredicateBuilderDate(SearchBuilder theSearchBuilder) {
|
PredicateBuilderDate(SearchBuilder theSearchBuilder) {
|
||||||
super(theSearchBuilder);
|
super(theSearchBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Predicate addPredicateDate(String theResourceName,
|
@Override
|
||||||
|
public Predicate addPredicate(String theResourceName,
|
||||||
String theParamName,
|
String theParamName,
|
||||||
List<? extends IQueryParameterType> theList,
|
List<? extends IQueryParameterType> theList,
|
||||||
SearchFilterParser.CompareOperation operation) {
|
SearchFilterParser.CompareOperation operation) {
|
||||||
|
|
|
@ -20,14 +20,15 @@ import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
class PredicateBuilderNumber extends BasePredicateBuilder {
|
class PredicateBuilderNumber extends BasePredicateBuilder implements IPredicateBuilder {
|
||||||
private static final Logger ourLog = LoggerFactory.getLogger(PredicateBuilderNumber.class);
|
private static final Logger ourLog = LoggerFactory.getLogger(PredicateBuilderNumber.class);
|
||||||
|
|
||||||
PredicateBuilderNumber(SearchBuilder theSearchBuilder) {
|
PredicateBuilderNumber(SearchBuilder theSearchBuilder) {
|
||||||
super(theSearchBuilder);
|
super(theSearchBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Predicate addPredicateNumber(String theResourceName,
|
@Override
|
||||||
|
public Predicate addPredicate(String theResourceName,
|
||||||
String theParamName,
|
String theParamName,
|
||||||
List<? extends IQueryParameterType> theList,
|
List<? extends IQueryParameterType> theList,
|
||||||
SearchFilterParser.CompareOperation operation) {
|
SearchFilterParser.CompareOperation operation) {
|
||||||
|
|
|
@ -21,16 +21,18 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
class PredicateBuilderQuantity extends BasePredicateBuilder {
|
class PredicateBuilderQuantity extends BasePredicateBuilder implements IPredicateBuilder {
|
||||||
|
|
||||||
PredicateBuilderQuantity(SearchBuilder theSearchBuilder) {
|
PredicateBuilderQuantity(SearchBuilder theSearchBuilder) {
|
||||||
super(theSearchBuilder);
|
super(theSearchBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate addPredicateQuantity(String theResourceName,
|
@Override
|
||||||
|
public Predicate addPredicate(String theResourceName,
|
||||||
String theParamName,
|
String theParamName,
|
||||||
List<? extends IQueryParameterType> theList,
|
List<? extends IQueryParameterType> theList,
|
||||||
SearchFilterParser.CompareOperation operation) {
|
SearchFilterParser.CompareOperation operation) {
|
||||||
|
|
||||||
Join<ResourceTable, ResourceIndexedSearchParamQuantity> join = createJoin(SearchBuilderJoinEnum.QUANTITY, theParamName);
|
Join<ResourceTable, ResourceIndexedSearchParamQuantity> join = createJoin(SearchBuilderJoinEnum.QUANTITY, theParamName);
|
||||||
|
|
||||||
if (theList.get(0).getMissing() != null) {
|
if (theList.get(0).getMissing() != null) {
|
||||||
|
|
|
@ -59,7 +59,8 @@ class PredicateBuilderReference extends BasePredicateBuilder {
|
||||||
/**
|
/**
|
||||||
* Add reference predicate to the current search
|
* Add reference predicate to the current search
|
||||||
*/
|
*/
|
||||||
Predicate addPredicateReference(String theResourceName,
|
|
||||||
|
public Predicate addPredicate(String theResourceName,
|
||||||
String theParamName,
|
String theParamName,
|
||||||
List<? extends IQueryParameterType> theList,
|
List<? extends IQueryParameterType> theList,
|
||||||
SearchFilterParser.CompareOperation operation,
|
SearchFilterParser.CompareOperation operation,
|
||||||
|
@ -438,7 +439,7 @@ class PredicateBuilderReference extends BasePredicateBuilder {
|
||||||
break;
|
break;
|
||||||
case REFERENCE:
|
case REFERENCE:
|
||||||
for (List<? extends IQueryParameterType> nextAnd : theAndOrParams) {
|
for (List<? extends IQueryParameterType> nextAnd : theAndOrParams) {
|
||||||
addPredicateReference(theResourceName, theParamName, nextAnd, null, theRequest);
|
addPredicate(theResourceName, theParamName, nextAnd, null, theRequest);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STRING:
|
case STRING:
|
||||||
|
@ -597,7 +598,7 @@ class PredicateBuilderReference extends BasePredicateBuilder {
|
||||||
String chain = (theFilter.getParamPath().getNext() != null) ? theFilter.getParamPath().getNext().toString() : null;
|
String chain = (theFilter.getParamPath().getNext() != null) ? theFilter.getParamPath().getNext().toString() : null;
|
||||||
String value = theFilter.getValue();
|
String value = theFilter.getValue();
|
||||||
ReferenceParam referenceParam = new ReferenceParam(resourceType, chain, value);
|
ReferenceParam referenceParam = new ReferenceParam(resourceType, chain, value);
|
||||||
return addPredicateReference(theResourceName, paramName, Collections.singletonList(referenceParam), operation, theRequest);
|
return addPredicate(theResourceName, paramName, Collections.singletonList(referenceParam), operation, theRequest);
|
||||||
} else if (typeEnum == RestSearchParameterTypeEnum.QUANTITY) {
|
} else if (typeEnum == RestSearchParameterTypeEnum.QUANTITY) {
|
||||||
return myPredicateBuilder.addPredicateQuantity(theResourceName, theFilter.getParamPath().getName(), Collections.singletonList(new QuantityParam(theFilter.getValue())), theFilter.getOperation());
|
return myPredicateBuilder.addPredicateQuantity(theResourceName, theFilter.getParamPath().getName(), Collections.singletonList(new QuantityParam(theFilter.getValue())), theFilter.getOperation());
|
||||||
} else if (typeEnum == RestSearchParameterTypeEnum.COMPOSITE) {
|
} else if (typeEnum == RestSearchParameterTypeEnum.COMPOSITE) {
|
||||||
|
@ -786,7 +787,7 @@ class PredicateBuilderReference extends BasePredicateBuilder {
|
||||||
orValues.addAll(next.getValuesAsQueryTokens());
|
orValues.addAll(next.getValuesAsQueryTokens());
|
||||||
}
|
}
|
||||||
|
|
||||||
Subquery<Long> subQ = myPredicateBuilder.createLinkSubquery(true, parameterName, targetResourceType, orValues, theRequest);
|
Subquery<Long> subQ = myPredicateBuilder.createLinkSubquery(parameterName, targetResourceType, orValues, theRequest);
|
||||||
|
|
||||||
Join<ResourceTable, ResourceLink> join = myQueryRoot.join("myResourceLinksAsTarget", JoinType.LEFT);
|
Join<ResourceTable, ResourceLink> join = myQueryRoot.join("myResourceLinksAsTarget", JoinType.LEFT);
|
||||||
Predicate pathPredicate = myPredicateBuilder.createResourceLinkPathPredicate(targetResourceType, paramReference, join);
|
Predicate pathPredicate = myPredicateBuilder.createResourceLinkPathPredicate(targetResourceType, paramReference, join);
|
||||||
|
|
|
@ -37,9 +37,10 @@ class PredicateBuilderResourceId extends BasePredicateBuilder {
|
||||||
super(theSearchBuilder);
|
super(theSearchBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
Predicate addPredicateResourceId(List<List<IQueryParameterType>> theValues, String theResourceName, SearchFilterParser.CompareOperation theOperation, RequestDetails theRequest) {
|
Predicate addPredicateResourceId(List<List<IQueryParameterType>> theValues, String theResourceName, SearchFilterParser.CompareOperation theOperation, RequestDetails theRequest) {
|
||||||
|
|
||||||
Predicate nextPredicate = createPredicateResourceId(myQueryRoot.getRoot(), theResourceName, theValues, theOperation, theRequest);
|
Predicate nextPredicate = createPredicate(myQueryRoot.getRoot(), theResourceName, theValues, theOperation, theRequest);
|
||||||
|
|
||||||
if (nextPredicate != null) {
|
if (nextPredicate != null) {
|
||||||
myQueryRoot.addPredicate(nextPredicate);
|
myQueryRoot.addPredicate(nextPredicate);
|
||||||
|
@ -50,7 +51,7 @@ class PredicateBuilderResourceId extends BasePredicateBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Predicate createPredicateResourceId(Root<ResourceTable> theRoot, String theResourceName, List<List<IQueryParameterType>> theValues, SearchFilterParser.CompareOperation theOperation, RequestDetails theRequest) {
|
private Predicate createPredicate(Root<ResourceTable> theRoot, String theResourceName, List<List<IQueryParameterType>> theValues, SearchFilterParser.CompareOperation theOperation, RequestDetails theRequest) {
|
||||||
Predicate nextPredicate = null;
|
Predicate nextPredicate = null;
|
||||||
|
|
||||||
Set<ResourcePersistentId> allOrPids = null;
|
Set<ResourcePersistentId> allOrPids = null;
|
||||||
|
|
|
@ -22,13 +22,14 @@ import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
class PredicateBuilderString extends BasePredicateBuilder {
|
class PredicateBuilderString extends BasePredicateBuilder implements IPredicateBuilder {
|
||||||
|
|
||||||
PredicateBuilderString(SearchBuilder theSearchBuilder) {
|
PredicateBuilderString(SearchBuilder theSearchBuilder) {
|
||||||
super(theSearchBuilder);
|
super(theSearchBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate addPredicateString(String theResourceName,
|
@Override
|
||||||
|
public Predicate addPredicate(String theResourceName,
|
||||||
String theParamName,
|
String theParamName,
|
||||||
List<? extends IQueryParameterType> theList,
|
List<? extends IQueryParameterType> theList,
|
||||||
SearchFilterParser.CompareOperation operation) {
|
SearchFilterParser.CompareOperation operation) {
|
||||||
|
|
|
@ -61,29 +61,6 @@ class PredicateBuilderTag extends BasePredicateBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* We have a parameter of ResourceType?_tag:not=foo This means match resources that don't have the given tag(s)
|
|
||||||
*/
|
|
||||||
if (notTags.isEmpty() == false) {
|
|
||||||
// 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<ResourceTag> subQfrom = subQ.from(ResourceTag.class);
|
|
||||||
// subQ.select(subQfrom.get("myResourceId").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));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (List<? extends IQueryParameterType> nextAndParams : theList) {
|
for (List<? extends IQueryParameterType> nextAndParams : theList) {
|
||||||
boolean haveTags = false;
|
boolean haveTags = false;
|
||||||
for (IQueryParameterType nextParamUncasted : nextAndParams) {
|
for (IQueryParameterType nextParamUncasted : nextAndParams) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
class PredicateBuilderToken extends BasePredicateBuilder {
|
class PredicateBuilderToken extends BasePredicateBuilder implements IPredicateBuilder {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ITermReadSvc myTerminologySvc;
|
private ITermReadSvc myTerminologySvc;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -43,7 +43,8 @@ class PredicateBuilderToken extends BasePredicateBuilder {
|
||||||
myPredicateBuilder = thePredicateBuilder;
|
myPredicateBuilder = thePredicateBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate addPredicateToken(String theResourceName,
|
@Override
|
||||||
|
public Predicate addPredicate(String theResourceName,
|
||||||
String theParamName,
|
String theParamName,
|
||||||
List<? extends IQueryParameterType> theList,
|
List<? extends IQueryParameterType> theList,
|
||||||
SearchFilterParser.CompareOperation operation) {
|
SearchFilterParser.CompareOperation operation) {
|
||||||
|
@ -178,19 +179,19 @@ class PredicateBuilderToken extends BasePredicateBuilder {
|
||||||
// System only
|
// System only
|
||||||
List<VersionIndependentConcept> systemOnlyCodes = sortedCodesList.stream().filter(t -> isBlank(t.getCode())).collect(Collectors.toList());
|
List<VersionIndependentConcept> systemOnlyCodes = sortedCodesList.stream().filter(t -> isBlank(t.getCode())).collect(Collectors.toList());
|
||||||
if (!systemOnlyCodes.isEmpty()) {
|
if (!systemOnlyCodes.isEmpty()) {
|
||||||
retVal.add(addPredicateToken(theResourceName, theParamName, theBuilder, theFrom, systemOnlyCodes, modifier, SearchBuilderTokenModeEnum.SYSTEM_ONLY));
|
retVal.add(addPredicate(theResourceName, theParamName, theBuilder, theFrom, systemOnlyCodes, modifier, SearchBuilderTokenModeEnum.SYSTEM_ONLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Code only
|
// Code only
|
||||||
List<VersionIndependentConcept> codeOnlyCodes = sortedCodesList.stream().filter(t -> t.getSystem() == null).collect(Collectors.toList());
|
List<VersionIndependentConcept> codeOnlyCodes = sortedCodesList.stream().filter(t -> t.getSystem() == null).collect(Collectors.toList());
|
||||||
if (!codeOnlyCodes.isEmpty()) {
|
if (!codeOnlyCodes.isEmpty()) {
|
||||||
retVal.add(addPredicateToken(theResourceName, theParamName, theBuilder, theFrom, codeOnlyCodes, modifier, SearchBuilderTokenModeEnum.VALUE_ONLY));
|
retVal.add(addPredicate(theResourceName, theParamName, theBuilder, theFrom, codeOnlyCodes, modifier, SearchBuilderTokenModeEnum.VALUE_ONLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
// System and code
|
// System and code
|
||||||
List<VersionIndependentConcept> systemAndCodeCodes = sortedCodesList.stream().filter(t -> isNotBlank(t.getCode()) && t.getSystem() != null).collect(Collectors.toList());
|
List<VersionIndependentConcept> systemAndCodeCodes = sortedCodesList.stream().filter(t -> isNotBlank(t.getCode()) && t.getSystem() != null).collect(Collectors.toList());
|
||||||
if (!systemAndCodeCodes.isEmpty()) {
|
if (!systemAndCodeCodes.isEmpty()) {
|
||||||
retVal.add(addPredicateToken(theResourceName, theParamName, theBuilder, theFrom, systemAndCodeCodes, modifier, SearchBuilderTokenModeEnum.SYSTEM_AND_VALUE));
|
retVal.add(addPredicate(theResourceName, theParamName, theBuilder, theFrom, systemAndCodeCodes, modifier, SearchBuilderTokenModeEnum.SYSTEM_AND_VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -240,7 +241,7 @@ class PredicateBuilderToken extends BasePredicateBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Predicate addPredicateToken(String theResourceName, String theParamName, CriteriaBuilder theBuilder, From<?, ResourceIndexedSearchParamToken> theFrom, List<VersionIndependentConcept> theTokens, TokenParamModifier theModifier, SearchBuilderTokenModeEnum theTokenMode) {
|
private Predicate addPredicate(String theResourceName, String theParamName, CriteriaBuilder theBuilder, From<?, ResourceIndexedSearchParamToken> theFrom, List<VersionIndependentConcept> theTokens, TokenParamModifier theModifier, SearchBuilderTokenModeEnum theTokenMode) {
|
||||||
if (myDontUseHashesForSearch) {
|
if (myDontUseHashesForSearch) {
|
||||||
final Path<String> systemExpression = theFrom.get("mySystem");
|
final Path<String> systemExpression = theFrom.get("mySystem");
|
||||||
final Path<String> valueExpression = theFrom.get("myValue");
|
final Path<String> valueExpression = theFrom.get("myValue");
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
class PredicateBuilderUri extends BasePredicateBuilder {
|
class PredicateBuilderUri extends BasePredicateBuilder implements IPredicateBuilder {
|
||||||
private static final Logger ourLog = LoggerFactory.getLogger(PredicateBuilderUri.class);
|
private static final Logger ourLog = LoggerFactory.getLogger(PredicateBuilderUri.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private IResourceIndexedSearchParamUriDao myResourceIndexedSearchParamUriDao;
|
private IResourceIndexedSearchParamUriDao myResourceIndexedSearchParamUriDao;
|
||||||
|
@ -31,7 +31,8 @@ class PredicateBuilderUri extends BasePredicateBuilder {
|
||||||
super(theSearchBuilder);
|
super(theSearchBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate addPredicateUri(String theResourceName,
|
@Override
|
||||||
|
public Predicate addPredicate(String theResourceName,
|
||||||
String theParamName,
|
String theParamName,
|
||||||
List<? extends IQueryParameterType> theList,
|
List<? extends IQueryParameterType> theList,
|
||||||
SearchFilterParser.CompareOperation operation) {
|
SearchFilterParser.CompareOperation operation) {
|
||||||
|
|
Loading…
Reference in New Issue