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