Example usage for com.amazonaws.services.simpledb.model GetAttributesRequest getItemName

List of usage examples for com.amazonaws.services.simpledb.model GetAttributesRequest getItemName

Introduction

In this page you can find the example usage for com.amazonaws.services.simpledb.model GetAttributesRequest getItemName.

Prototype


public String getItemName() 

Source Link

Document

The name of the item.

Usage

From source file:siena.sdb.SdbPersistenceManager.java

License:Apache License

public void get(Object obj) {
    Class<?> clazz = obj.getClass();
    ClassInfo info = ClassInfo.getClassInfo(obj.getClass());

    String domain = SdbMappingUtils.getDomainName(clazz, prefix);
    try {/*from w ww. j av a 2 s  .  c  o m*/
        checkDomain(domain);
        GetAttributesRequest req = SdbMappingUtils.createGetRequest(domain, clazz, obj);
        // sets consistent read to true when reading one single object
        req.setConsistentRead(isReadConsistent());
        GetAttributesResult res = sdb.getAttributes(req);
        if (res.getAttributes().size() == 0) {
            throw new SienaException(req.getItemName() + " not found in domain " + req.getDomainName());
        }

        SdbMappingUtils.fillModel(req.getItemName(), res, clazz, obj);

        // join management
        if (!info.joinFields.isEmpty()) {
            mapJoins(obj);
        }
    } catch (AmazonClientException ex) {
        throw new SienaException(ex);
    }
}

From source file:siena.sdb.SdbPersistenceManager.java

License:Apache License

public <T> T getByKey(Class<T> clazz, Object key) {
    String domain = SdbMappingUtils.getDomainName(clazz, prefix);
    try {// ww w  . j a  va  2  s .  c  o  m
        checkDomain(domain);
        GetAttributesRequest req = SdbMappingUtils.createGetRequestFromKey(domain, clazz, key);
        // sets consistent read to true when reading one single object
        req.setConsistentRead(isReadConsistent());
        GetAttributesResult res = sdb.getAttributes(req);
        if (res.getAttributes().size() == 0) {
            throw new SienaException(req.getItemName() + " not found in domain " + req.getDomainName());
        }

        T obj = Util.createObjectInstance(clazz);

        SdbMappingUtils.fillModel(req.getItemName(), res, clazz, obj);

        // join management
        if (!ClassInfo.getClassInfo(clazz).joinFields.isEmpty()) {
            mapJoins(obj);
        }

        return obj;
    } catch (AmazonClientException ex) {
        throw new SienaException(ex);
    }
}