ACS-1425 Get stores at start of query (#421)

* ACS-1425 Get stores at start of query

* ACS-1425 Get stores at start of query

* ACS-1425 Get stores at start of accelerated query

* ACS-1425 Tidy up
This commit is contained in:
Sara
2021-04-29 10:25:41 +01:00
committed by GitHub
parent e5770ddfda
commit 96ef362d6d

View File

@@ -35,6 +35,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import javax.annotation.concurrent.NotThreadSafe; import javax.annotation.concurrent.NotThreadSafe;
@@ -113,6 +114,8 @@ public class DBQueryEngine implements QueryEngine
protected EntityLookupCache<Long, Node, NodeRef> nodesCache; protected EntityLookupCache<Long, Node, NodeRef> nodesCache;
private List<Pair<Long, StoreRef>> stores;
AclCrudDAO aclCrudDAO; AclCrudDAO aclCrudDAO;
public void setAclCrudDAO(AclCrudDAO aclCrudDAO) public void setAclCrudDAO(AclCrudDAO aclCrudDAO)
@@ -314,6 +317,9 @@ public class DBQueryEngine implements QueryEngine
FilteringResultSet acceleratedNodeSelection(QueryOptions options, DBQuery dbQuery, NodePermissionAssessor permissionAssessor) FilteringResultSet acceleratedNodeSelection(QueryOptions options, DBQuery dbQuery, NodePermissionAssessor permissionAssessor)
{ {
// get list of stores from database
stores = nodeDAO.getStores();
List<Node> nodes = new ArrayList<>(); List<Node> nodes = new ArrayList<>();
int requiredNodes = computeRequiredNodesCount(options); int requiredNodes = computeRequiredNodesCount(options);
@@ -464,10 +470,9 @@ public class DBQueryEngine implements QueryEngine
{ {
StoreEntity storeEntity = node.getStore(); StoreEntity storeEntity = node.getStore();
logger.debug("Adding store info for store id " + storeEntity.getId()); logger.debug("Adding store info for store id " + storeEntity.getId());
List<Pair<Long, StoreRef>> stores = nodeDAO.getStores();
for (Pair<Long, StoreRef> storeRefPair : stores) for (Pair<Long, StoreRef> storeRefPair : stores)
{ {
if (storeEntity.getId() == storeRefPair.getFirst()) if (Objects.equals(storeEntity.getId(), storeRefPair.getFirst()))
{ {
StoreRef storeRef = storeRefPair.getSecond(); StoreRef storeRef = storeRefPair.getSecond();
storeEntity.setIdentifier(storeRef.getIdentifier()); storeEntity.setIdentifier(storeRef.getIdentifier());