Example usage for com.amazonaws.services.dynamodbv2.document Item asMap

List of usage examples for com.amazonaws.services.dynamodbv2.document Item asMap

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.document Item asMap.

Prototype

public Map<String, Object> asMap() 

Source Link

Document

Returns all attributes of the current item as a map.

Usage

From source file:com.erudika.para.persistence.AWSDynamoDAO.java

License:Apache License

private <P extends ParaObject> String readPageFromSharedTable(String appid, Pager pager,
        LinkedList<P> results) {
    String lastKeyFragment = "";
    ValueMap valueMap = new ValueMap().withString(":aid", appid);
    NameMap nameMap = null;/*from  www  . ja v  a  2 s.co  m*/

    if (!StringUtils.isBlank(pager.getLastKey())) {
        lastKeyFragment = " and #stamp > :ts";
        valueMap.put(":ts", pager.getLastKey());
        nameMap = new NameMap().with("#stamp", Config._TIMESTAMP);
    }

    Index index = getSharedIndex();
    QuerySpec spec = new QuerySpec().withMaxPageSize(pager.getLimit()).withMaxResultSize(pager.getLimit())
            .withKeyConditionExpression(Config._APPID + " = :aid" + lastKeyFragment).withValueMap(valueMap)
            .withNameMap(nameMap);

    if (index != null) {
        Page<Item, QueryOutcome> items = index.query(spec).firstPage();
        for (Item item : items) {
            P obj = ParaObjectUtils.setAnnotatedFields(item.asMap());
            if (obj != null) {
                results.add(obj);
            }
        }
    }

    if (!results.isEmpty()) {
        return Long.toString(results.peekLast().getTimestamp());
    } else {
        return null;
    }
}