List of usage examples for com.amazonaws.services.dynamodbv2.model ReturnValue UPDATED_NEW
ReturnValue UPDATED_NEW
To view the source code for com.amazonaws.services.dynamodbv2.model ReturnValue UPDATED_NEW.
Click Source Link
From source file:com.nodestone.ksum.RecordProcessor.java
License:Open Source License
/** * Update DynamoDB record:// w ww.ja va2s . c o m * - updating updates count * - updating total sum */ private void updateRecord(RawData rawData) { UpdateItemSpec updateItemSpec = new UpdateItemSpec().withPrimaryKey("CustomerId", rawData.custId) .withUpdateExpression("set TotalSum = TotalSum + :val, Updates = Updates + :inc") .withValueMap( new ValueMap().withNumber(":val", Integer.parseInt(rawData.value)).withNumber(":inc", 1)) .withReturnValues(ReturnValue.UPDATED_NEW); try { UpdateItemOutcome outcome = this.dbTable.updateItem(updateItemSpec); LOG.info("UpdateItem succeeded:\n" + outcome.getItem().toJSONPretty()); } catch (Exception e) { LOG.info("Update failed with exception:"); LOG.info(e.getMessage()); } }
From source file:io.milton.s3.db.DynamoDBServiceImpl.java
License:Open Source License
@Override public UpdateItemResult updateItem(String tableName, HashMap<String, AttributeValue> primaryKey, Map<String, AttributeValueUpdate> updateItems) { Map<String, AttributeValueUpdate> attributeValueUpdates = new HashMap<String, AttributeValueUpdate>(); attributeValueUpdates.putAll(updateItems); UpdateItemRequest updateItemRequest = new UpdateItemRequest().withTableName(tableName).withKey(primaryKey) .withReturnValues(ReturnValue.UPDATED_NEW).withAttributeUpdates(updateItems); UpdateItemResult updateItemResult = dynamoDBClient.updateItem(updateItemRequest); LOG.info("Successful by updating item from " + tableName + ": " + updateItemResult); return updateItemResult; }
From source file:org.springframework.integration.aws.metadata.DynamoDbMetaDataStore.java
License:Apache License
@Override public boolean replace(String key, String oldValue, String newValue) { Assert.hasText(key, "'key' must not be empty."); Assert.hasText(oldValue, "'value' must not be empty."); Assert.hasText(newValue, "'newValue' must not be empty."); awaitForActive();//from w w w . j av a 2s. c o m try { return this.table.updateItem(new UpdateItemSpec().withPrimaryKey(KEY, key) .withAttributeUpdate(new AttributeUpdate(VALUE).put(newValue)) .withExpected(new Expected(VALUE).eq(oldValue)).withReturnValues(ReturnValue.UPDATED_NEW)) .getItem() != null; } catch (ConditionalCheckFailedException e) { return false; } }