Example usage for com.amazonaws.services.dynamodbv2.model UpdateItemRequest UpdateItemRequest

List of usage examples for com.amazonaws.services.dynamodbv2.model UpdateItemRequest UpdateItemRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model UpdateItemRequest UpdateItemRequest.

Prototype

public UpdateItemRequest(String tableName, java.util.Map<String, AttributeValue> key,
        java.util.Map<String, AttributeValueUpdate> attributeUpdates) 

Source Link

Document

Constructs a new UpdateItemRequest object.

Usage

From source file:com.erudika.para.persistence.AWSDynamoDAO.java

License:Apache License

private void updateRow(String key, String appid, Map<String, AttributeValue> row) {
    if (StringUtils.isBlank(key) || StringUtils.isBlank(appid) || row == null || row.isEmpty()) {
        return;//w w w.ja  v  a2 s  . c o  m
    }
    Map<String, AttributeValueUpdate> rou = new HashMap<String, AttributeValueUpdate>();
    try {
        for (Entry<String, AttributeValue> attr : row.entrySet()) {
            rou.put(attr.getKey(), new AttributeValueUpdate(attr.getValue(), AttributeAction.PUT));
        }
        UpdateItemRequest updateItemRequest = new UpdateItemRequest(getTableNameForAppid(appid),
                Collections.singletonMap(Config._KEY, new AttributeValue(getKeyForAppid(key, appid))), rou);
        client().updateItem(updateItemRequest);
    } catch (Exception e) {
        logger.error("Could not update row in DB - appid={}, key={}", appid, key, e);
    }
}