| 36 | } |
| 37 | |
| 38 | public List<Game> loadGames(String sessionId) throws SessionNotFoundException { |
| 39 | if ( sessionModel.loadSession(sessionId) == null ) { |
| 40 | throw new SessionNotFoundException(sessionId); |
| 41 | } |
| 42 | Map<String, AttributeValue> eav = new HashMap<String, AttributeValue>(); |
| 43 | eav.put(":val1", new AttributeValue().withS(sessionId)); |
| 44 | |
| 45 | Map<String, String> ean = new HashMap<String, String>(); |
| 46 | ean.put("#key1", "session"); |
| 47 | |
| 48 | DynamoDBQueryExpression<Game> queryExpression = new DynamoDBQueryExpression<Game>() |
| 49 | .withIndexName("session-index") |
| 50 | .withExpressionAttributeValues(eav) |
| 51 | .withExpressionAttributeNames(ean) |
| 52 | .withKeyConditionExpression("#key1 = :val1") |
| 53 | .withConsistentRead(false); |
| 54 | |
| 55 | List<Game> sessionGames = mapper.query(Game.class, queryExpression); |
| 56 | return sessionGames; |
| 57 | } |
| 58 | |
| 59 | public void deleteGame(String sessionId, String gameId) throws GameNotFoundException { |
| 60 | Game game = mapper.load(Game.class, gameId); |