fix npe
This commit is contained in:
parent
8114419110
commit
6ca97df1c9
|
@ -129,7 +129,6 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
private BaseHapiFhirDao<?> myCallingDao;
|
||||
private SearchParameterMap myParams;
|
||||
private String myResourceName;
|
||||
private AbstractQuery<Long> myResourceTableQuery;
|
||||
private Class<? extends IBaseResource> myResourceType;
|
||||
private String mySearchUuid;
|
||||
private int myFetchSize;
|
||||
|
@ -231,8 +230,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
assert !theCount;
|
||||
|
||||
outerQuery = myBuilder.createQuery(Long.class);
|
||||
myResourceTableQuery = outerQuery;
|
||||
myQueryRoot.push(myResourceTableQuery.from(ResourceTable.class));
|
||||
myQueryRoot.push(outerQuery);
|
||||
if (theCount) {
|
||||
outerQuery.multiselect(myBuilder.countDistinct(myQueryRoot.getRoot()));
|
||||
} else {
|
||||
|
@ -249,8 +247,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
} else {
|
||||
|
||||
outerQuery = myBuilder.createQuery(Long.class);
|
||||
myResourceTableQuery = outerQuery;
|
||||
myQueryRoot.push(myResourceTableQuery.from(ResourceTable.class));
|
||||
myQueryRoot.push(outerQuery);
|
||||
if (theCount) {
|
||||
outerQuery.multiselect(myBuilder.countDistinct(myQueryRoot.getRoot()));
|
||||
} else {
|
||||
|
@ -327,7 +324,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
List<Predicate> lastUpdatedPredicates = createLastUpdatedPredicates(lu, myBuilder, myQueryRoot.getRoot());
|
||||
myQueryRoot.addPredicates(lastUpdatedPredicates);
|
||||
|
||||
myResourceTableQuery.where(myBuilder.and(myQueryRoot.getPredicateArray()));
|
||||
myQueryRoot.where(myBuilder.and(myQueryRoot.getPredicateArray()));
|
||||
|
||||
/*
|
||||
* Now perform the search
|
||||
|
@ -895,10 +892,6 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
return myQueryRoot;
|
||||
}
|
||||
|
||||
public AbstractQuery<Long> getResourceTableQuery() {
|
||||
return myResourceTableQuery;
|
||||
}
|
||||
|
||||
public Class<? extends IBaseResource> getResourceType() {
|
||||
return myResourceType;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ abstract class BasePredicateBuilder {
|
|||
final QueryRoot myQueryRoot;
|
||||
final Class<? extends IBaseResource> myResourceType;
|
||||
final String myResourceName;
|
||||
final AbstractQuery<Long> myResourceTableQuery;
|
||||
final SearchParameterMap myParams;
|
||||
|
||||
// FIXME KHS autowire with lookup
|
||||
|
@ -47,7 +46,6 @@ abstract class BasePredicateBuilder {
|
|||
myQueryRoot = theSearchBuilder.getQueryRoot();
|
||||
myResourceType = theSearchBuilder.getResourceType();
|
||||
myResourceName = theSearchBuilder.getResourceName();
|
||||
myResourceTableQuery = theSearchBuilder.getResourceTableQuery();
|
||||
myParams = theSearchBuilder.getParams();
|
||||
}
|
||||
|
||||
|
|
|
@ -363,7 +363,7 @@ class PredicateBuilderReference extends BasePredicateBuilder {
|
|||
}
|
||||
|
||||
Subquery<Long> createLinkSubquery(boolean theFoundChainMatch, String theChain, String theSubResourceName, List<IQueryParameterType> theOrValues, RequestDetails theRequest) {
|
||||
Subquery<Long> subQ = myResourceTableQuery.subquery(Long.class);
|
||||
Subquery<Long> subQ = myQueryRoot.subquery(Long.class);
|
||||
Root<ResourceTable> subQfrom = subQ.from(ResourceTable.class);
|
||||
subQ.select(subQfrom.get("myId").as(Long.class));
|
||||
|
||||
|
@ -376,7 +376,7 @@ class PredicateBuilderReference extends BasePredicateBuilder {
|
|||
* stack and run a subquery
|
||||
*/
|
||||
|
||||
myQueryRoot.push(subQfrom);
|
||||
myQueryRoot.push(subQ);
|
||||
// FIXME KHS stack in all predicates
|
||||
|
||||
// Create the subquery predicates
|
||||
|
|
|
@ -135,7 +135,7 @@ class PredicateBuilderTag extends BasePredicateBuilder {
|
|||
if (paramInverted) {
|
||||
ourLog.debug("Searching for _tag:not");
|
||||
|
||||
Subquery<Long> subQ = myResourceTableQuery.subquery(Long.class);
|
||||
Subquery<Long> subQ = myQueryRoot.subquery(Long.class);
|
||||
Root<ResourceTag> subQfrom = subQ.from(ResourceTag.class);
|
||||
subQ.select(subQfrom.get("myResourceId").as(Long.class));
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import java.util.Stack;
|
|||
public class QueryRoot {
|
||||
private final Stack<QueryRootEntry> myQueryRootStack = new Stack<>();
|
||||
|
||||
public void push(Root<ResourceTable> theResourceTableRoot) {
|
||||
myQueryRootStack.push(new QueryRootEntry(theResourceTableRoot));
|
||||
public void push(AbstractQuery<Long> theResourceTableQuery) {
|
||||
myQueryRootStack.push(new QueryRootEntry(theResourceTableQuery));
|
||||
}
|
||||
|
||||
private QueryRootEntry top() {
|
||||
|
@ -62,4 +62,12 @@ public class QueryRoot {
|
|||
List<Predicate> getPredicates() {
|
||||
return top().getPredicates();
|
||||
}
|
||||
|
||||
public void where(Predicate theAnd) {
|
||||
top().where(theAnd);
|
||||
}
|
||||
|
||||
<T> Subquery<T> subquery(Class<T> theClass) {
|
||||
return top().subquery(theClass);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,14 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class QueryRootEntry {
|
||||
private final AbstractQuery<Long> myResourceTableQuery;
|
||||
private final Root<ResourceTable> myResourceTableRoot;
|
||||
private final ArrayList<Predicate> myPredicates = new ArrayList<>();
|
||||
private final IndexJoins myIndexJoins = new IndexJoins();
|
||||
|
||||
public QueryRootEntry(Root<ResourceTable> theResourceTableRoot) {
|
||||
myResourceTableRoot = theResourceTableRoot;
|
||||
public QueryRootEntry(AbstractQuery<Long> theResourceTableQuery) {
|
||||
myResourceTableQuery = theResourceTableQuery;
|
||||
myResourceTableRoot = theResourceTableQuery.from(ResourceTable.class);
|
||||
}
|
||||
|
||||
public Root<ResourceTable> getRoot() {
|
||||
|
@ -56,4 +58,12 @@ public class QueryRootEntry {
|
|||
List<Predicate> getPredicates() {
|
||||
return myPredicates;
|
||||
}
|
||||
|
||||
public void where(Predicate theAnd) {
|
||||
myResourceTableQuery.where(theAnd);
|
||||
}
|
||||
|
||||
<T> Subquery<T> subquery(Class<T> theClass) {
|
||||
return myResourceTableQuery.subquery(theClass);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue