List of usage examples for com.amazonaws.services.dynamodbv2.model UpdateItemRequest addKeyEntry
public UpdateItemRequest addKeyEntry(String key, AttributeValue value)
From source file:awslabs.lab22.SolutionCode.java
License:Open Source License
@Override public void updateIfMatch(AmazonDynamoDBClient ddbClient, String tableName, String email, String company, String firstNameTarget, String firstNameMatch) { // Construct an UpdateItemRequest object for the specified table. UpdateItemRequest updateItemRequest = new UpdateItemRequest().withTableName(tableName); // Add KeyEntry elements to the request containing AttributeValue objects for the company name and email // address provided. updateItemRequest.addKeyEntry("Company", new AttributeValue().withS(company)); updateItemRequest.addKeyEntry("Email", new AttributeValue().withS(email)); // Add an ExpectedEntry element to the request containing an ExpectedAttributeValue object that contains // the value in the firstNameMatch parameter. updateItemRequest.addExpectedEntry("First", new ExpectedAttributeValue().withValue(new AttributeValue().withS(firstNameMatch))); // Add an AttributeUpdatesEntry element to the request containing an AttributeValueUpdate object that // contains the value in the firstNameTarget parameter updateItemRequest.addAttributeUpdatesEntry("First", new AttributeValueUpdate().withAction("PUT") .withValue(new AttributeValue().withS(firstNameTarget))); // Submit the request using the updateItem method of the ddbClient object. ddbClient.updateItem(updateItemRequest); }
From source file:com.nandanu.halomama.controller.DynamoDBRouter.java
License:Open Source License
public void incrementSeen(String userNameTwitter, String createdDate) { UpdateItemRequest upd = new UpdateItemRequest(); upd.setTableName(Constants.TABLE_NAME); AttributeValue unt = new AttributeValue(); unt.setS(userNameTwitter);//from www .j ava2s . c o m AttributeValue cd = new AttributeValue(); cd.setS(createdDate); upd.addKeyEntry(Constants.TAG_USERNAME, unt); upd.addKeyEntry(Constants.TAG_CREATED_DATE, cd); AttributeValue s = new AttributeValue(); s.setN("1"); AttributeValueUpdate seen = new AttributeValueUpdate(s, AttributeAction.ADD); upd.addAttributeUpdatesEntry(Constants.TAG_SEEN, seen); dDBClient.updateItem(upd); }