Package com.amazonaws.services.dynamodb.model

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


        Method rangeKeyGetter = reflector.getRangeKeyGetter(clazz);
        if ( rangeKeyGetter != null ) {
            rangeKeyElement = getRangeKeyElement(safeInvoke(rangeKeyGetter, object), rangeKeyGetter);
        }

        Key objectKey = new Key().withHashKeyElement(hashKeyElement).withRangeKeyElement(rangeKeyElement);

        Map<String, AttributeValueUpdate> updateValues = new HashMap<String, AttributeValueUpdate>();
        Map<String, ExpectedAttributeValue> expectedValues = new HashMap<String, ExpectedAttributeValue>();

        boolean forcePut = config.getSaveBehavior() == SaveBehavior.CLOBBER;
View Full Code Here


        Method rangeKeyGetter = reflector.getRangeKeyGetter(clazz);
        if ( rangeKeyGetter != null ) {
            rangeKeyElement = getRangeKeyElement(safeInvoke(rangeKeyGetter, object), rangeKeyGetter);
        }

        Key objectKey = new Key().withHashKeyElement(hashKeyElement).withRangeKeyElement(rangeKeyElement);

        /*
         * If there is a version field, make sure we assert its value. If the
         * version field is null (only should happen in unusual circumstances),
         * pretend it doesn't have a version field after all.
View Full Code Here

            Method rangeKeyGetter = reflector.getRangeKeyGetter(clazz);
            if ( rangeKeyGetter != null ) {
                rangeKeyElement = getRangeKeyElement(safeInvoke(rangeKeyGetter, toDelete), rangeKeyGetter);
            }

            Key objectKey = new Key().withHashKeyElement(hashKeyElement).withRangeKeyElement(rangeKeyElement);

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }
View Full Code Here

                                    new KeysAndAttributes().withConsistentRead(consistentReads).withKeys(
                                            new LinkedList<Key>()));
                }

                requestItems.get(tableName).getKeys()
                        .add(new Key().withHashKeyElement(hashKeyElement).withRangeKeyElement(rangeKeyElement));

                // Reach the maximum number which can be handled in a single
                // batchGet
                if ( ++count == 100 ) {
                    processBatchGetRequest(classesByTableName, requestItems, resultSet);
View Full Code Here

    public static Key MapV2KeyToV1(
            Map<String, com.amazonaws.services.dynamodbv2.model.AttributeValue> v2Key,
            Table table) {

        Key v1Key = null;

        if ((v2Key != null) && (table != null)) {
            v1Key = new Key();
            for (String attrName : v2Key.keySet()) {
                com.amazonaws.services.dynamodbv2.model.AttributeValue v2AttrValue = v2Key.get(attrName);
                if (attrName.equals(table.getHashKeyName())) {
                    v1Key.setHashKeyElement(MapV2AttributeValueToV1(v2AttrValue));
                } else if (attrName.equals(table.getRangeKeyName())) {
                    v1Key.setRangeKeyElement(MapV2AttributeValueToV1(v2AttrValue));
                }
            }
        }

        return v1Key;
View Full Code Here

    public Boolean supports(Class clazz) {
        return Key.class.isAssignableFrom(clazz);
    }

    public List<Error> validate(Object target) {
        Key instance = (Key) target;
        List<Error> errors = ValidatorUtils.rejectIfNull(instance);
        if (errors.size() == 0) {
            errors.addAll(ValidatorUtils.rejectIfNull(instance.getHashKeyElement()));
          if(instance.getHashKeyElement() != null) {
            errors.addAll(ValidatorUtils.invokeValidator(new PrimaryKeyValidator(), instance.getHashKeyElement()));
          }
          if(instance.getRangeKeyElement() != null) {
       errors.addAll(ValidatorUtils.invokeValidator(new PrimaryKeyValidator(), instance.getRangeKeyElement()));
          }
        }
        return removeNulls(errors);
    }
View Full Code Here

      throw new AmazonServiceException(errors.toString());
    }

    // get information
    String tableName = request.getTableName();
    Key key = request.getKey();
    List<String> attributesToGet = request.getAttributesToGet();
    GetItemResult result = new GetItemResult();

    // Check to make sure table exists
    if (!this.tables.containsKey(tableName)) {
      throw new ResourceNotFoundException("The table you're currently trying to access (" + tableName + ") doesn't exists.");
    }
    // Check to make sure Key is valid
    String hashKeyValue = getKeyValue(key.getHashKeyElement());
        ItemRangeGroup rangeGroup = this.tables.get(tableName).getItemRangeGroup(hashKeyValue);

    if (rangeGroup == null) {
      return new GetItemResult();
      // throw new ResourceNotFoundException("No item with Hash Key (" + hashKeyValue + ") exists.");
    } else {
            String rangeKeyValue = getKeyValue(key.getRangeKeyElement());
            Map<String, AttributeValue> item = this.tables.get(tableName).getItem(hashKeyValue, rangeKeyValue);
            if (item == null) {
        return new GetItemResult();
        // throw new ResourceNotFoundException("No item with Hash Key (" + hashKeyValue + ") and Range Key )" + rangeKeyValue + ") exists.");
            }
View Full Code Here

        if (putRequest != null) {
          this.tables.get(tableName).putItem(putRequest.getItem());
        }
        DeleteRequest deleteRequest = writeRequest.getDeleteRequest();
        if (deleteRequest != null) {
          Key key = deleteRequest.getKey();
          if (key != null) {
            this.tables.get(tableName).removeItem(key.getHashKeyElement().getS());
          }
        }
      }
      batchWriteResponse.setConsumedCapacityUnits(1.0);
      responses.put(tableName, batchWriteResponse);
View Full Code Here

      throw new AmazonServiceException(errors.toString());
    }

    // get information
    String tableName = request.getTableName();
    Key key = request.getKey();
    Map<String, ExpectedAttributeValue> expected = request.getExpected();
    Map<String, AttributeValueUpdate> attributesToUpdate = request.getAttributeUpdates();
    String returnValues = request.getReturnValues();


    UpdateItemResult result = new UpdateItemResult();
    result.setConsumedCapacityUnits(0.5);

    // Check to make sure table exists
    if (!this.tables.containsKey(tableName)) {
      throw new ResourceNotFoundException("The table you're currently trying to access (" + tableName + ") doesn't exists.");
    }
    // Check to make sure Key is valid
        String hashKeyValue = getKeyValue(key.getHashKeyElement());
        String rangeKeyValue = getKeyValue(key.getRangeKeyElement());
        Map<String, AttributeValue> item = this.tables.get(tableName).getItem(hashKeyValue, rangeKeyValue);
      
    // Check conditional put
        validateExpected(request.getExpected(), item);
       
    if (item == null) {
      item = new HashMap<String, AttributeValue>();
      item.put(this.tables.get(tableName).getHashKeyName(), key.getHashKeyElement());
      if (key.getRangeKeyElement() != null) {
        item.put(this.tables.get(tableName).getRangeKeyName(), key.getRangeKeyElement());
      }
      for (String sKey : attributesToUpdate.keySet()) {
        if (attributesToUpdate.get(sKey).getValue() != null) {
          item.put(sKey, attributesToUpdate.get(sKey).getValue());
        }
View Full Code Here


public class KeyJsonUnmarshaller implements Unmarshaller<Key, JsonUnmarshallerContext> {

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

        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("HashKeyElement", targetDepth)) {
                    request.setHashKeyElement(AttributeValueJsonUnmarshaller.getInstance().unmarshall(context));
                }
              if (context.testExpression("RangeKeyElement", targetDepth)) {
                    request.setRangeKeyElement(AttributeValueJsonUnmarshaller.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

TOP

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

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.