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

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

Introduction

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

Prototype

public ExpectedAttributeValue() 

Source Link

Document

Default constructor for ExpectedAttributeValue object.

Usage

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.amazon.janusgraph.diskstorage.dynamodb.builder.SingleExpectedAttributeValueBuilder.java

License:Open Source License

private void addExpectedValueIfPresent(final StaticBuffer column,
        final Map<String, ExpectedAttributeValue> expectedValueMap) {
    final String dynamoDbColumn = encodeKeyBuffer(column);

    if (expectedValueMap.containsKey(dynamoDbColumn)) {
        return;// www  .  j a va 2 s.  c  o  m
    }

    if (transaction.contains(store, key, column)) {
        final StaticBuffer expectedValue = transaction.get(store, key, column);
        final ExpectedAttributeValue expectedAttributeValue;
        if (expectedValue == null) {
            expectedAttributeValue = new ExpectedAttributeValue().withExists(false);
        } else {
            final AttributeValue attributeValue = encodeValue(expectedValue);
            expectedAttributeValue = new ExpectedAttributeValue().withValue(attributeValue)
                    .withComparisonOperator(ComparisonOperator.EQ);
        }
        expectedValueMap.put(dynamoDbColumn, expectedAttributeValue);
    }
}

From source file:com.rapid7.diskstorage.dynamodb.builder.SingleExpectedAttributeValueBuilder.java

License:Open Source License

private void addExpectedValueIfPresent(StaticBuffer key, StaticBuffer column,
        Map<String, ExpectedAttributeValue> expectedValueMap) {
    final String dynamoDbColumn = encodeKeyBuffer(column);

    if (expectedValueMap.containsKey(dynamoDbColumn)) {
        return;/*w ww  .  j  a va 2s  .  c  om*/
    }

    if (txh.contains(key, column)) {
        final StaticBuffer expectedValue = txh.get(key, column);
        ExpectedAttributeValue expectedAttributeValue;
        if (expectedValue == null) {
            expectedAttributeValue = new ExpectedAttributeValue().withExists(false);
        } else {
            final AttributeValue attributeValue = encodeValue(expectedValue);
            expectedAttributeValue = new ExpectedAttributeValue().withValue(attributeValue)
                    .withComparisonOperator(ComparisonOperator.EQ);
        }
        expectedValueMap.put(dynamoDbColumn, expectedAttributeValue);
    }
}