Package com.amazonaws.services.dynamodb.model

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


                    //begin table
                    jsonWriter.key(tableKey).array();
                    for (WriteRequest request : unprocessedItems.get(tableKey)) {
                        //begin each object of array
                        jsonWriter.object();
                        PutRequest putRequest = request.getPutRequest();
                        DeleteRequest deleteRequest = request.getDeleteRequest();
                        if (putRequest != null) {
                            //Begin put request
                            jsonWriter.key("PutRequest").object();
                            Map<String, AttributeValue> item = putRequest.getItem();
                            if (item != null) {
                                for (String itemKey : item.keySet()) {
                                    //begin attribute value
                                    jsonWriter.key(itemKey).object();
                                    AttributeValue value = item.get(itemKey);
View Full Code Here


        // Test: write items to database
        Map<String, AttributeValue> forumItem = new HashMap<String, AttributeValue>();
        forumItem.put(hashKeyValue1, new AttributeValue().withN("1"));
        forumItem.put("range", new AttributeValue().withS("a"));
        List<WriteRequest> forumList = new ArrayList<WriteRequest>();
        forumList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(forumItem)));

        Map<String, AttributeValue> forumItem1 = new HashMap<String, AttributeValue>();
        forumItem1.put(hashKeyValue1, new AttributeValue().withN("2"));
        forumItem1.put("range", new AttributeValue().withS("b"));
        forumList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(forumItem1)));

        Map<String, AttributeValue> forumItem5 = new HashMap<String, AttributeValue>();
        forumItem5.put(hashKeyValue1, new AttributeValue().withN("3"));
        forumItem5.put("range", new AttributeValue().withS("c"));
        forumList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(forumItem5)));

        Map<String, AttributeValue> forumItem2 = new HashMap<String, AttributeValue>();
        forumItem2.put(hashKeyValue1, new AttributeValue().withN("4"));
        forumItem2.put("range", new AttributeValue().withS("d"));
        forumList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(forumItem2)));

        Map<String, AttributeValue> forumItem3 = new HashMap<String, AttributeValue>();
        forumItem3.put(hashKeyValue1, new AttributeValue().withN("5"));
        forumItem3.put("range", new AttributeValue().withS("e"));
        forumList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(forumItem3)));

        Map<String, AttributeValue> forumItem4 = new HashMap<String, AttributeValue>();
        forumItem4.put(hashKeyValue1, new AttributeValue().withN("6"));
        forumItem4.put("range", new AttributeValue().withS("f"));
        forumList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(forumItem4)));

        //Test case: with duplicated hashkey item but distinguished range key input.
        Map<String, AttributeValue> forumItem6 = new HashMap<String, AttributeValue>();
        forumItem6.put(hashKeyValue1, new AttributeValue().withN("6"));
        forumItem6.put("range", new AttributeValue().withS("ff"));
        forumList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(forumItem6)));

        //Test case: Delete Request
//        forumList.add(new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(new Key(new AttributeValue("7")))));
//        forumList.add(new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(new Key(new AttributeValue("1")))));
//        forumList.add(new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(new Key(new AttributeValue("4")))));
//        forumList.add(new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(new Key(new AttributeValue("5")))));

        //Test case: Duplicated delete request
//        forumList.add(new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(new Key(new AttributeValue("7")))));

        //Test on Table 2
        Map<String, AttributeValue> forumItemT2 = new HashMap<String, AttributeValue>();
        forumItemT2.put(hashKeyValue2, new AttributeValue().withN("1"));
        forumItemT2.put("range", new AttributeValue().withS("a"));
        List<WriteRequest> forumListT2 = new ArrayList<WriteRequest>();
        forumListT2.add(new WriteRequest().withPutRequest(new PutRequest().withItem(forumItemT2)));

        requestItems.put(tableName1, forumList);
        requestItems.put(tableName2, forumListT2);
        do {
            System.out.println("Making the request.");
View Full Code Here

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

            requestItems.get(tableName).add(
                    new WriteRequest().withPutRequest(new PutRequest().withItem(transformAttributes(clazz, attributeValues))));
        }

        for ( Object toDelete : objectsToDelete ) {
            Class<?> clazz = toDelete.getClass();
View Full Code Here

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

            requestItems.get(tableName).add(
                    new WriteRequest().withPutRequest(new PutRequest().withItem(transformAttributes(clazz, attributeValues))));
        }

        for ( Object toDelete : objectsToDelete ) {
            Class<?> clazz = toDelete.getClass();
View Full Code Here

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

            requestItems.get(tableName).add(
                    new WriteRequest().withPutRequest(new PutRequest().withItem(transformAttributes(clazz, attributeValues))));
        }

        for ( Object toDelete : objectsToDelete ) {
            Class<?> clazz = toDelete.getClass();
View Full Code Here

TOP

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

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.