@Test public void test() { QueryExpression queryExpression = new QueryExpression(null, null); DynamoDBQueryExpression expression = queryExpression.forQuery(); Assert.assertNull(expression); }
public DynamoDBQueryExpression<T> forQuery() { if(primaryKeyQueries.size() == 0) { logger.warn("No queries found with primary key field."); return null; } Map<String, AttributeValue> awsQueryValueMap = new HashMap<>(); DynamoDBQueryExpression<T> expression = new DynamoDBQueryExpression<>(); expression.withKeyConditionExpression(String.join(AND_STATEMENT, generateConditions(primaryKeyQueries, awsQueryValueMap))) .withExpressionAttributeValues(awsQueryValueMap) .withConsistentRead(false); if(filterAttributes != null) { expression.withProjectionExpression(filterAttributes); } if(queryIndex != null) { expression.withIndexName(queryIndex.getName()); } if(filterQueries != null && filterQueries.size() > 0) { expression.withFilterExpression(String.join(AND_STATEMENT, generateConditions(filterQueries, awsQueryValueMap))); } if(selectQuery != null) { expression.withSelect(selectQuery); } logger.info("DynamoDB query with key condition={}, value map={}, limit={}, fields={}", expression.getKeyConditionExpression(), awsQueryValueMap.toString(), expression.getLimit(), expression.getProjectionExpression()); return expression; }
QueryExpression { public DynamoDBQueryExpression<T> forQuery() { if(primaryKeyQueries.size() == 0) { logger.warn("No queries found with primary key field."); return null; } Map<String, AttributeValue> awsQueryValueMap = new HashMap<>(); DynamoDBQueryExpression<T> expression = new DynamoDBQueryExpression<>(); expression.withKeyConditionExpression(String.join(AND_STATEMENT, generateConditions(primaryKeyQueries, awsQueryValueMap))) .withExpressionAttributeValues(awsQueryValueMap) .withConsistentRead(false); if(filterAttributes != null) { expression.withProjectionExpression(filterAttributes); } if(queryIndex != null) { expression.withIndexName(queryIndex.getName()); } if(filterQueries != null && filterQueries.size() > 0) { expression.withFilterExpression(String.join(AND_STATEMENT, generateConditions(filterQueries, awsQueryValueMap))); } if(selectQuery != null) { expression.withSelect(selectQuery); } logger.info("DynamoDB query with key condition={}, value map={}, limit={}, fields={}", expression.getKeyConditionExpression(), awsQueryValueMap.toString(), expression.getLimit(), expression.getProjectionExpression()); return expression; } }
QueryExpression { public DynamoDBQueryExpression<T> forQuery() { if(primaryKeyQueries.size() == 0) { logger.warn("No queries found with primary key field."); return null; } Map<String, AttributeValue> awsQueryValueMap = new HashMap<>(); DynamoDBQueryExpression<T> expression = new DynamoDBQueryExpression<>(); expression.withKeyConditionExpression(String.join(AND_STATEMENT, generateConditions(primaryKeyQueries, awsQueryValueMap))) .withExpressionAttributeValues(awsQueryValueMap) .withConsistentRead(false); if(filterAttributes != null) { expression.withProjectionExpression(filterAttributes); } if(queryIndex != null) { expression.withIndexName(queryIndex.getName()); } if(filterQueries != null && filterQueries.size() > 0) { expression.withFilterExpression(String.join(AND_STATEMENT, generateConditions(filterQueries, awsQueryValueMap))); } if(selectQuery != null) { expression.withSelect(selectQuery); } logger.info("DynamoDB query with key condition={}, value map={}, limit={}, fields={}", expression.getKeyConditionExpression(), awsQueryValueMap.toString(), expression.getLimit(), expression.getProjectionExpression()); return expression; } QueryExpression(TableIndexes tableIndexes, List<Query> queries); }
QueryExpression { public DynamoDBQueryExpression<T> forQuery() { if(primaryKeyQueries.size() == 0) { logger.warn("No queries found with primary key field."); return null; } Map<String, AttributeValue> awsQueryValueMap = new HashMap<>(); DynamoDBQueryExpression<T> expression = new DynamoDBQueryExpression<>(); expression.withKeyConditionExpression(String.join(AND_STATEMENT, generateConditions(primaryKeyQueries, awsQueryValueMap))) .withExpressionAttributeValues(awsQueryValueMap) .withConsistentRead(false); if(filterAttributes != null) { expression.withProjectionExpression(filterAttributes); } if(queryIndex != null) { expression.withIndexName(queryIndex.getName()); } if(filterQueries != null && filterQueries.size() > 0) { expression.withFilterExpression(String.join(AND_STATEMENT, generateConditions(filterQueries, awsQueryValueMap))); } if(selectQuery != null) { expression.withSelect(selectQuery); } logger.info("DynamoDB query with key condition={}, value map={}, limit={}, fields={}", expression.getKeyConditionExpression(), awsQueryValueMap.toString(), expression.getLimit(), expression.getProjectionExpression()); return expression; } QueryExpression(TableIndexes tableIndexes, List<Query> queries); DynamoDBQueryExpression<T> forQuery(); DynamoDBScanExpression forScan(); boolean hasKey(); boolean hasCount(); Integer getLimit(); }
QueryExpression { public DynamoDBQueryExpression<T> forQuery() { if(primaryKeyQueries.size() == 0) { logger.warn("No queries found with primary key field."); return null; } Map<String, AttributeValue> awsQueryValueMap = new HashMap<>(); DynamoDBQueryExpression<T> expression = new DynamoDBQueryExpression<>(); expression.withKeyConditionExpression(String.join(AND_STATEMENT, generateConditions(primaryKeyQueries, awsQueryValueMap))) .withExpressionAttributeValues(awsQueryValueMap) .withConsistentRead(false); if(filterAttributes != null) { expression.withProjectionExpression(filterAttributes); } if(queryIndex != null) { expression.withIndexName(queryIndex.getName()); } if(filterQueries != null && filterQueries.size() > 0) { expression.withFilterExpression(String.join(AND_STATEMENT, generateConditions(filterQueries, awsQueryValueMap))); } if(selectQuery != null) { expression.withSelect(selectQuery); } logger.info("DynamoDB query with key condition={}, value map={}, limit={}, fields={}", expression.getKeyConditionExpression(), awsQueryValueMap.toString(), expression.getLimit(), expression.getProjectionExpression()); return expression; } QueryExpression(TableIndexes tableIndexes, List<Query> queries); DynamoDBQueryExpression<T> forQuery(); DynamoDBScanExpression forScan(); boolean hasKey(); boolean hasCount(); Integer getLimit();  }