use of com.amazonaws.services.dynamodbv2.document.PutItemOutcome in project aws-doc-sdk-examples by awsdocs.
the class MoviesItemOps01 method main.
public static void main(String[] args) throws Exception {
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-west-2")).build();
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Movies");
int year = 2015;
String title = "The Big New Movie";
final Map<String, Object> infoMap = new HashMap<String, Object>();
infoMap.put("plot", "Nothing happens at all.");
infoMap.put("rating", 0);
try {
System.out.println("Adding a new item...");
PutItemOutcome outcome = table.putItem(new Item().withPrimaryKey("year", year, "title", title).withMap("info", infoMap));
System.out.println("PutItem succeeded:\n" + outcome.getPutItemResult());
} catch (Exception e) {
System.err.println("Unable to add item: " + year + " " + title);
System.err.println(e.getMessage());
}
}
use of com.amazonaws.services.dynamodbv2.document.PutItemOutcome in project aws-doc-sdk-examples by awsdocs.
the class DocumentAPILocalSecondaryIndexExample method loadData.
public static void loadData() {
Table table = dynamoDB.getTable(tableName);
System.out.println("Loading data into table " + tableName + "...");
Item item = new Item().withPrimaryKey("CustomerId", "alice@example.com").withNumber("OrderId", 1).withNumber("IsOpen", 1).withNumber("OrderCreationDate", 20150101).withString("ProductCategory", "Book").withString("ProductName", "The Great Outdoors").withString("OrderStatus", "PACKING ITEMS");
// no ShipmentTrackingId attribute
PutItemOutcome putItemOutcome = table.putItem(item);
item = new Item().withPrimaryKey("CustomerId", "alice@example.com").withNumber("OrderId", 2).withNumber("IsOpen", 1).withNumber("OrderCreationDate", 20150221).withString("ProductCategory", "Bike").withString("ProductName", "Super Mountain").withString("OrderStatus", "ORDER RECEIVED");
// no ShipmentTrackingId attribute
putItemOutcome = table.putItem(item);
item = new Item().withPrimaryKey("CustomerId", "alice@example.com").withNumber("OrderId", 3).withNumber("OrderCreationDate", 20150304).withString("ProductCategory", "Music").withString("ProductName", "A Quiet Interlude").withString("OrderStatus", "IN TRANSIT").withString("ShipmentTrackingId", "176493");
putItemOutcome = table.putItem(item);
item = new Item().withPrimaryKey("CustomerId", "bob@example.com").withNumber("OrderId", 1).withNumber("OrderCreationDate", 20150111).withString("ProductCategory", "Movie").withString("ProductName", "Calm Before The Storm").withString("OrderStatus", "SHIPPING DELAY").withString("ShipmentTrackingId", "859323");
putItemOutcome = table.putItem(item);
item = new Item().withPrimaryKey("CustomerId", "bob@example.com").withNumber("OrderId", 2).withNumber("OrderCreationDate", 20150124).withString("ProductCategory", "Music").withString("ProductName", "E-Z Listening").withString("OrderStatus", "DELIVERED").withString("ShipmentTrackingId", "756943");
putItemOutcome = table.putItem(item);
item = new Item().withPrimaryKey("CustomerId", "bob@example.com").withNumber("OrderId", 3).withNumber("OrderCreationDate", 20150221).withString("ProductCategory", "Music").withString("ProductName", "Symphony 9").withString("OrderStatus", "DELIVERED").withString("ShipmentTrackingId", "645193");
putItemOutcome = table.putItem(item);
item = new Item().withPrimaryKey("CustomerId", "bob@example.com").withNumber("OrderId", 4).withNumber("IsOpen", 1).withNumber("OrderCreationDate", 20150222).withString("ProductCategory", "Hardware").withString("ProductName", "Extra Heavy Hammer").withString("OrderStatus", "PACKING ITEMS");
// no ShipmentTrackingId attribute
putItemOutcome = table.putItem(item);
item = new Item().withPrimaryKey("CustomerId", "bob@example.com").withNumber("OrderId", 5).withNumber("OrderCreationDate", 20150309).withString("ProductCategory", "Book").withString("ProductName", "How To Cook").withString("OrderStatus", "IN TRANSIT").withString("ShipmentTrackingId", "440185");
putItemOutcome = table.putItem(item);
item = new Item().withPrimaryKey("CustomerId", "bob@example.com").withNumber("OrderId", 6).withNumber("OrderCreationDate", 20150318).withString("ProductCategory", "Luggage").withString("ProductName", "Really Big Suitcase").withString("OrderStatus", "DELIVERED").withString("ShipmentTrackingId", "893927");
putItemOutcome = table.putItem(item);
item = new Item().withPrimaryKey("CustomerId", "bob@example.com").withNumber("OrderId", 7).withNumber("OrderCreationDate", 20150324).withString("ProductCategory", "Golf").withString("ProductName", "PGA Pro II").withString("OrderStatus", "OUT FOR DELIVERY").withString("ShipmentTrackingId", "383283");
putItemOutcome = table.putItem(item);
assert putItemOutcome != null;
}
Aggregations