use of com.amazonaws.services.dynamodbv2.datamodeling.QueryResultPage in project BridgeServer2 by Sage-Bionetworks.
the class DynamoSurveyDao method getSurveyGuidForIdentifier.
/**
* {@inheritDoc}
*/
@Override
public String getSurveyGuidForIdentifier(String appId, String surveyId) {
// Hash key.
DynamoSurvey hashKey = new DynamoSurvey();
hashKey.setAppId(appId);
// Range key.
Condition rangeKeyCondition = new Condition().withComparisonOperator(ComparisonOperator.EQ).withAttributeValueList(new AttributeValue().withS(surveyId));
// Construct query.
DynamoDBQueryExpression<DynamoSurvey> expression = new DynamoDBQueryExpression<DynamoSurvey>().withConsistentRead(false).withHashKeyValues(hashKey).withRangeKeyCondition("identifier", rangeKeyCondition).withLimit(1);
// Execute query.
QueryResultPage<DynamoSurvey> resultPage = surveyMapper.queryPage(DynamoSurvey.class, expression);
List<DynamoSurvey> surveyList = resultPage.getResults();
if (surveyList.isEmpty()) {
return null;
}
return surveyList.get(0).getGuid();
}
Aggregations