List of usage examples for com.amazonaws.services.dynamodbv2.document Item withLong
public Item withLong(String attrName, long val)
From source file:com.kitac.kinesissamples.consumer.communication.DynamoDBManager.java
License:Open Source License
/** * Puts an item that represents the UnitRecord object * to the DynamoDB table whose name is specified by 'tableName' parameter. * @param record The UnitRecord object as an item of the DynamoDB table. * @param tableName Name of the DynamoDB table. * @return a PutItemOutcome object.//from w ww . j ava 2 s . c o m */ public PutItemOutcome putRecord(UnitRecord record, String tableName) { PutItemOutcome outcome = null; try { Table table = dynamoDBConnection.getTable(tableName); Item item = new Item() .withPrimaryKey("unit_id", record.getUnitId(), "datetime", record.getTime().toString()) .withLong("out", record.getOut()).withLong("safe", record.getSafe()) .withLong("start", record.getStart()).withLong("prize1", record.getPrize1()) .withLong("prize2", record.getPrize2()).withLong("prize3", record.getPrize3()) .withLong("input1", record.getInput1()).withLong("input2", record.getInput2()) .withLong("cheat1", record.getCheat1()).withLong("cheat2", record.getCheat2()) .withLong("cheat3", record.getCheat3()).withLong("cheat4", record.getCheat4()) .withLong("sales1", record.getSales1()).withLong("sales2", record.getSales2()) .withLong("sales3", record.getSales3()).withLong("sales4", record.getSales4()); record.getAdvancedDataTable().entrySet().stream() .forEach(entrySet -> item.withLong(entrySet.getKey().name(), entrySet.getValue())); outcome = table.putItem(item); } catch (ResourceNotFoundException e) { throw e; } return outcome; }