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

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

Introduction

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

Prototype


public String getDomainName() 

Source Link

Document

The name of the domain in which to perform the operation.

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   www . j  av  a  2s  .  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 {//  w  ww.  j  a  v  a2 s  .  com
        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);
    }
}