Package com.amazonaws.services.dynamodb.model

Examples of com.amazonaws.services.dynamodb.model.ExpectedAttributeValue


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

                    ExpectedAttributeValue expected = new ExpectedAttributeValue();
                    AttributeValue currentValue = getSimpleAttributeValue(method, getterResult);
                    expected.setExists(currentValue != null);
                    if ( currentValue != null )
                        expected.setValue(currentValue);
                    expectedValues.put(attributeName, expected);
                    break;
                }
            }
        }
View Full Code Here


        Map<String, ExpectedAttributeValue> v1Expected = null;
        if (v2Expected != null) {
            v1Expected = new HashMap<String, ExpectedAttributeValue>();
            for (String key : v2Expected.keySet()) {
                com.amazonaws.services.dynamodbv2.model.ExpectedAttributeValue v2ExpValue = v2Expected.get(key);
                ExpectedAttributeValue v1ExpValue = MapV2ExpectedAttributeValueToV1(v2ExpValue);
                v1Expected.put(key, v1ExpValue);
            }
        }
        return v1Expected;
    }
View Full Code Here

    }

    public static ExpectedAttributeValue MapV2ExpectedAttributeValueToV1(
            com.amazonaws.services.dynamodbv2.model.ExpectedAttributeValue v2Expected) {

        ExpectedAttributeValue v1Expected =
            new ExpectedAttributeValue()
                .withExists(v2Expected.getExists())
                .withValue(MapV2AttributeValueToV1(v2Expected.getValue()))
                ;
        return v1Expected;
    }
View Full Code Here

    Map<String, ExpectedAttributeValue> instance = (Map<String, ExpectedAttributeValue>) target;
    List<Error> errors = new ArrayList<Error>();
    Charset utf = Charset.forName("UTF-8");
    for (Map.Entry<String, ExpectedAttributeValue> entry : instance.entrySet()) {
      String key = entry.getKey();
      ExpectedAttributeValue value = entry.getValue();
      // Check key size
      errors.addAll(ValidatorUtils.rejectIfSizeOutOfBounds(key, 1, 255));
      // check if value is null
      errors.addAll(ValidatorUtils.rejectIfNull(value));
      if (value.getExists() != null && value.getExists() && value == null) {
        errors.add(new Error("If exists is True, Value mush be set"));
      }
      if (value != null && value.getValue() == null && value.getExists() == null) {
        errors.add(new Error("AttributeValue or Exists must be non-null for Expected to work."));
      }
    }

    return removeNulls(errors);
View Full Code Here

 
  private void validateExpected(Map<String, ExpectedAttributeValue> expected, Map<String, AttributeValue> item) {
    if (expected != null) {
      for (Map.Entry<String, ExpectedAttributeValue> entry : expected.entrySet()) {
        String key = entry.getKey();
        ExpectedAttributeValue value = entry.getValue();
        value.setExists(value.getValue() != null);
        if ((value.getExists() && item == null) || (!value.getExists() && item != null)) {
          throw new ConditionalCheckFailedException("The exist conditional could not be met.");
        }
        if (value.getValue() != null) {
          // check to see if value conditional is equal
          if (!compareAttributeValues(value.getValue(), item.get(key))) {
            throw new ConditionalCheckFailedException("The value conditional could is not equal");
          }
        }
      }
    }
View Full Code Here


public class ExpectedAttributeValueJsonUnmarshaller implements Unmarshaller<ExpectedAttributeValue, JsonUnmarshallerContext> {

    public ExpectedAttributeValue unmarshall(JsonUnmarshallerContext context) throws Exception {
        ExpectedAttributeValue request = new ExpectedAttributeValue();

        int originalDepth = context.getCurrentDepth();
        int targetDepth = originalDepth + 1;

        JsonToken token = context.currentToken;
        if (token == null) token = context.nextToken();

       while (true) {
            if (token == null) break;
            if (token == JsonToken.FIELD_NAME || token == JsonToken.START_OBJECT) {
                if (context.testExpression("Value", targetDepth)) {
                    request.setValue(AttributeValueJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("Exists", targetDepth)) {
                    context.nextToken();
                    request.setExists(SimpleTypeJsonUnmarshallers.BooleanJsonUnmarshaller.getInstance().unmarshall(context));
                }
            } else if (token == JsonToken.END_ARRAY || token == JsonToken.END_OBJECT) {
                if (context.getCurrentDepth() <= originalDepth) break;
            }
            token = context.nextToken();
View Full Code Here

        //conditional update
        HashMap<String, AttributeValueUpdate> newValues = new HashMap<String, AttributeValueUpdate> ();
        newValues.put("count", new AttributeValueUpdate(new AttributeValue().withN("102"), AttributeAction.PUT));
       
        HashMap<String, ExpectedAttributeValue> expectedValues = new HashMap<String, ExpectedAttributeValue> ();
        expectedValues.put("count", new ExpectedAttributeValue().withValue(new AttributeValue().withN("100")));
       
        update = new UpdateItemRequest().withTableName(tableName).withKey(key).withAttributeUpdates(newValues).withExpected(expectedValues);       
        getClient().updateItem(update);

        inProcessClient.save(PERSISTENCE_PATH);
View Full Code Here

        HashMap<String, AttributeValueUpdate> newValues = new HashMap<String, AttributeValueUpdate> ();
        newValues.put("count", new AttributeValueUpdate(new AttributeValue().withN("102"), AttributeAction.PUT));
        newValues.put("ids", new AttributeValueUpdate(new AttributeValue().withS("[er, er]"), AttributeAction.ADD));
       
        HashMap<String, ExpectedAttributeValue> expectedValues = new HashMap<String, ExpectedAttributeValue> ();
        expectedValues.put("count", new ExpectedAttributeValue().withValue(new AttributeValue().withN("100")));
       
        update = new UpdateItemRequest().withTableName(tableName).withKey(key).withAttributeUpdates(newValues).withExpected(expectedValues);       
        getClient().updateItem(update);

        inProcessClient.save(PERSISTENCE_PATH);
View Full Code Here

        HashMap<String, AttributeValueUpdate> newValues = new HashMap<String, AttributeValueUpdate> ();
        newValues.put("count", new AttributeValueUpdate(new AttributeValue().withN("102"), AttributeAction.PUT));
        newValues.put("ids", new AttributeValueUpdate(new AttributeValue().withS("[er, er]"), AttributeAction.PUT));
       
        HashMap<String, ExpectedAttributeValue> expectedValues = new HashMap<String, ExpectedAttributeValue> ();
        expectedValues.put("count", new ExpectedAttributeValue().withValue(new AttributeValue().withN("100")));
       
        update = new UpdateItemRequest().withTableName(tableName).withKey(key).withAttributeUpdates(newValues).withExpected(expectedValues);       
        getClient().updateItem(update);

        inProcessClient.save(PERSISTENCE_PATH);
View Full Code Here

        //conditional update
        HashMap<String, AttributeValueUpdate> newValues = new HashMap<String, AttributeValueUpdate> ();
        newValues.put("count", new AttributeValueUpdate(new AttributeValue().withN("102"), AttributeAction.PUT));
       
        HashMap<String, ExpectedAttributeValue> expectedValues = new HashMap<String, ExpectedAttributeValue> ();
        expectedValues.put("count", new ExpectedAttributeValue().withValue(new AttributeValue().withN("10")));
       
        update = new UpdateItemRequest().withTableName(tableName).withKey(key).withAttributeUpdates(newValues).withExpected(expectedValues);
       
        try{
          getClient().updateItem(update);
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodb.model.ExpectedAttributeValue

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.