Package com.amazonaws.services.dynamodbv2.document.spec

Examples of com.amazonaws.services.dynamodbv2.document.spec.UpdateItemSpec


            .withProjectionExpression("document.next_haircut"))
            ;
        System.out.println(partialDocItem);
        // Output: { Item: {document={next_haircut={month=10, year=2014, day=30}}} }
        // I can update part of a document. Here's how I would change my current_city back to Seattle:
        table.updateItem(new UpdateItemSpec()
            .withPrimaryKey(HASH_KEY_NAME, "B_PutItemJsonTest", RANGE_KEY_NAME, 1)
            .withUpdateExpression("SET document.current_city = :city")
            .withValueMap(new ValueMap().withString(":city", "Seattle"))
        );
        // Retrieve the entire item
View Full Code Here


            .withProjectionExpression("document.next_haircut"))
            ;
        System.out.println(partialDocItem);
        // Output: { Item: {document={next_haircut={month=10, year=2014, day=30}}} }
        // I can update part of a document. Here's how I would change my current_city back to Seattle:
        table.updateItem(new UpdateItemSpec()
            .withPrimaryKey(HASH_KEY_NAME, "howToPutItems_withJSONDoc", RANGE_KEY_NAME, 1)
            .withUpdateExpression("SET document.current_city = :city")
            .withValueMap(new ValueMap().withString(":city", "Seattle"))
        );
        // Retrieve the entire item
View Full Code Here

            .withProjectionExpression("next_haircut"))
            ;
        System.out.println(partialDocItem);
        // Output: { Item: {next_haircut={month=10, year=2014, day=30}} }
        // I can update part of a document. Here's how I would change my current_city back to Seattle:
        table.updateItem(new UpdateItemSpec()
            .withPrimaryKey(HASH_KEY_NAME, "howToPut_TopLevelJSON", RANGE_KEY_NAME, 1)
            .withUpdateExpression("SET current_city = :city")
            .withValueMap(new ValueMap().withString(":city", "Seattle"))
        );
        // Retrieve the entire item
View Full Code Here

    }

    @Override
    public UpdateItemOutcome updateItem(PrimaryKey primaryKey,
            AttributeUpdate... attributeUpdates) {
        return updateItem(new UpdateItemSpec()
                .withPrimaryKey(primaryKey)
                .withAttributeUpdate(attributeUpdates));
    }
View Full Code Here

    }

    @Override
    public UpdateItemOutcome updateItem(PrimaryKey primaryKey,
            Collection<Expected> expected, AttributeUpdate... attributeUpdates) {
        return updateItem(new UpdateItemSpec()
                .withPrimaryKey(primaryKey)
                .withExpected(expected)
                .withAttributeUpdate(attributeUpdates));
    }
View Full Code Here

    @Override
    public UpdateItemOutcome updateItem(PrimaryKey primaryKey,
            String updateExpression, Map<String, String> nameMap,
            Map<String, Object> valueMap) {
        return updateItem(new UpdateItemSpec()
                .withPrimaryKey(primaryKey)
                .withUpdateExpression(updateExpression)
                .withNameMap(nameMap)
                .withValueMap(valueMap));
    }
View Full Code Here

    @Override
    public UpdateItemOutcome updateItem(PrimaryKey primaryKey,
            String updateExpression, String conditionExpression,
            Map<String, String> nameMap, Map<String, Object> valueMap) {

        return updateItem(new UpdateItemSpec().withPrimaryKey(primaryKey)
                .withUpdateExpression(updateExpression)
                .withConditionExpression(conditionExpression)
                .withNameMap(nameMap)
                .withValueMap(valueMap));
    }
View Full Code Here

                if ( getterResult == null && reflector.isAssignableKey(method) ) {
                    onAutoGenerateAssignableKey(method, attributeName);
                }
               
                else {
                    AttributeValue newAttributeValue = getSimpleAttributeValue(method, getterResult);
                    if ( newAttributeValue == null ) {
                        throw new DynamoDBMappingException("Null or empty value for key: " + method);
                    }

                    onKeyAttributeValue(attributeName, newAttributeValue);
                }
            }

            /*
             * Next construct an update for every non-key property
             */
            for ( Method method : reflector.getRelevantGetters(clazz) ) {

                // Skip any key methods, since they are handled separately
                if ( keyGetters.contains(method) )
                    continue;

                Object getterResult = safeInvoke(method, object);
                String attributeName = reflector.getAttributeName(method);

                /*
                 * If this is a versioned field, update it
                 */
                if ( reflector.isVersionAttributeGetter(method) ) {
                    onVersionAttribute(method, getterResult, attributeName);
                    nonKeyAttributePresent = true;
                }

                /*
                 * Otherwise apply the update value for this attribute.
                 */
                else  {
                    AttributeValue currentValue = getSimpleAttributeValue(method, getterResult);
                    if ( currentValue != null ) {
                        onNonKeyAttribute(attributeName, currentValue);
                        nonKeyAttributePresent = true;
                    } else {
                        onNullNonKeyAttribute(attributeName);
View Full Code Here

        protected List<ValueUpdate> getInMemoryUpdates() {
            return inMemoryUpdates;
        }
       
        private void onAutoGenerateAssignableKey(Method method, String attributeName) {
            AttributeValue newVersionValue = getAutoGeneratedKeyAttributeValue(method, null);
           
            updateValues.put(attributeName,
                    new AttributeValueUpdate().withAction("PUT").withValue(newVersionValue));
            inMemoryUpdates.add(new ValueUpdate(method, newVersionValue, object));
           
View Full Code Here

                // update call
                ExpectedAttributeValue expected = new ExpectedAttributeValue();

                // For new objects, insist that the value doesn't exist.
                // For existing ones, insist it has the old value.
                AttributeValue currentValue = getSimpleAttributeValue(method, getterResult);
                expected.setExists(currentValue != null);
                if ( currentValue != null ) {
                    expected.setValue(currentValue);
                }
                expectedValues.put(attributeName, expected);
            }

            AttributeValue newVersionValue = getVersionAttributeValue(method, getterResult);
            updateValues
                    .put(attributeName, new AttributeValueUpdate().withAction("PUT").withValue(newVersionValue));
            inMemoryUpdates.add(new ValueUpdate(method, newVersionValue, object));
        }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodbv2.document.spec.UpdateItemSpec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.