Skip to content

Commit

Permalink
Extended the SpecialQueryType to include "NONE", which indicates a query
Browse files Browse the repository at this point in the history
that should have no results. Using this NONE value for "doublebuffer"-ed
queries that should have no results.
  • Loading branch information
rubendel committed Jan 30, 2020
1 parent 4b6303a commit a949d63
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.bimserver.database.queries.om.Query;
import org.bimserver.database.queries.om.QueryException;
import org.bimserver.database.queries.om.QueryPart;
import org.bimserver.database.queries.om.SpecialQueryType;
import org.bimserver.shared.QueryContext;

import com.fasterxml.jackson.core.JsonParseException;
Expand All @@ -46,8 +47,12 @@ public QueryStackFrame(QueryObjectProvider queryObjectProvider, QueryContext reu
@Override
public boolean process() throws BimserverDatabaseException, QueryException {
if (query.getSpecialQueryType() != null) {
queryObjectProvider.push(new AllStackFrame(queryObjectProvider, reusable));
return true;
if (query.getSpecialQueryType() == SpecialQueryType.ALL) {
queryObjectProvider.push(new AllStackFrame(queryObjectProvider, reusable));
return true;
} else if (query.getSpecialQueryType() == SpecialQueryType.NONE) {
return true;
}
}
if (queryIterator.hasNext()) {
QueryPart next = queryIterator.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.bimserver.database.queries.om.JsonQueryObjectModelConverter;
import org.bimserver.database.queries.om.Query;
import org.bimserver.database.queries.om.QueryPart;
import org.bimserver.database.queries.om.SpecialQueryType;
import org.bimserver.emf.PackageMetaData;
import org.bimserver.interfaces.objects.SCheckoutResult;
import org.bimserver.interfaces.objects.SProgressTopicType;
Expand Down Expand Up @@ -179,7 +180,13 @@ public LongStreamingDownloadAction(BimServer bimServer, String username, String
newQueryPart.addOid(next.getOid());
next = queryObjectProvider.next();
}
query = newQuery;
if (!newQueryPart.hasOids()) {
// When the original query has not returned any objects, we need to make sure the resulting new query is not interpreted to return all objects
query = new Query(packageMetaData);
query.setSpecialQueryType(SpecialQueryType.NONE);
} else {
query = newQuery;
}
}
// TODO passing a databasesession here, make sure it will be closed!!
QueryObjectProvider queryObjectProvider = new QueryObjectProvider(databaseSession, getBimServer(), query, roids, packageMetaData);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.bimserver.database.queries.om;

public enum SpecialQueryType {
ALL
ALL, NONE
}

0 comments on commit a949d63

Please sign in to comment.