本文整理汇总了Java中com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.load方法的典型用法代码示例。如果您正苦于以下问题:Java DynamoDBMapper.load方法的具体用法?Java DynamoDBMapper.load怎么用?Java DynamoDBMapper.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper
的用法示例。
在下文中一共展示了DynamoDBMapper.load方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDevicePlatform
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
private Platform getDevicePlatform(DynamoDBMapper mapper,String token)
{
Dispositivo d = mapper.load(Dispositivo.class, token);
if(null==d)
return null;
if(d.getOs()==1)
return Platform.APNS_SANDBOX;
if(d.getOs()==2)
return Platform.GCM;
//Just for testing
return Platform.APNS_SANDBOX;
//return null;
}
示例2: put
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
/**
* Puts an object identified by a key
*
* @param key
* @param obj
*/
@Override
public void put(K key, T obj) {
try {
Object hashKey = getHashKey(key, obj);
Object rangeKey = getRangeKey(key, obj);
if (hashKey != null) {
DynamoDBMapper mapper = new DynamoDBMapper(
dynamoDBStoreHandler.getDynamoDbClient());
if (rangeKey != null) {
mapper.load(persistentClass, hashKey, rangeKey);
} else {
mapper.load(persistentClass, hashKey);
}
mapper.save(obj);
} else
throw new GoraException("No HashKey found in Key nor in Object.");
} catch (NullPointerException npe) {
LOG.error("Error while putting an item. " + npe.toString());
throw new NullArgumentException(npe.getMessage());
} catch (Exception e) {
LOG.error("Error while putting an item. " + obj.toString());
throw new RuntimeException(e);
}
}
示例3: FandomDAO
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
public FandomDAO() {
client = new AmazonDynamoDBClient(
new ClasspathPropertiesFileCredentialsProvider());
mapper = new DynamoDBMapper(client);
Fandom test = mapper.load(Fandom.class, "fandoms");
if (test == null) {
test = new Fandom();
test.setId("fandoms");
mapper.save(test);
}
}
示例4: CraftDAO
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
public CraftDAO(){
client = new AmazonDynamoDBClient(new ClasspathPropertiesFileCredentialsProvider());
mapper = new DynamoDBMapper(client);
Craft test = mapper.load(Craft.class, "crafts");
if(test == null){
test = new Craft();
test.setId("crafts");
mapper.save(test);
}
}
示例5: testBatchDelete
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
private static void testBatchDelete(DynamoDBMapper mapper) {
Book book1 = mapper.load(Book.class, 901);
Book book2 = mapper.load(Book.class, 902);
System.out.println("Deleting two books from the ProductCatalog table.");
mapper.batchDelete(Arrays.asList(book1, book2));
}
示例6: testBatchWrite
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
private static void testBatchWrite(DynamoDBMapper mapper) {
// Create Forum item to save
Forum forumItem = new Forum();
forumItem.name = "Test BatchWrite Forum";
forumItem.threads = 0;
forumItem.category = "Amazon Web Services";
// Create Thread item to save
Thread threadItem = new Thread();
threadItem.forumName = "AmazonDynamoDB";
threadItem.subject = "My sample question";
threadItem.message = "BatchWrite message";
List<String> tags = new ArrayList<String>();
tags.add("batch operations");
tags.add("write");
threadItem.tags = new HashSet<String>(tags);
// Load ProductCatalog item to delete
Book book3 = mapper.load(Book.class, 903);
List<Object> objectsToWrite = Arrays.asList(forumItem, threadItem);
List<Book> objectsToDelete = Arrays.asList(book3);
DynamoDBMapperConfig config = new DynamoDBMapperConfig(DynamoDBMapperConfig.SaveBehavior.CLOBBER);
mapper.batchWrite(objectsToWrite, objectsToDelete, config);
}
示例7: testCRUDOperations
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
private static void testCRUDOperations() {
CatalogItem item = new CatalogItem();
item.setId(601);
item.setTitle("Book 601");
item.setISBN("611-1111111111");
item.setBookAuthors(new HashSet<String>(Arrays.asList("Author1", "Author2")));
// Save the item (book).
DynamoDBMapper mapper = new DynamoDBMapper(client);
mapper.save(item);
// Retrieve the item.
CatalogItem itemRetrieved = mapper.load(CatalogItem.class, 601);
System.out.println("Item retrieved:");
System.out.println(itemRetrieved);
// Update the item.
itemRetrieved.setISBN("622-2222222222");
itemRetrieved.setBookAuthors(new HashSet<String>(Arrays.asList("Author1", "Author3")));
mapper.save(itemRetrieved);
System.out.println("Item updated:");
System.out.println(itemRetrieved);
// Retrieve the updated item.
DynamoDBMapperConfig config = new DynamoDBMapperConfig(DynamoDBMapperConfig.ConsistentReads.CONSISTENT);
CatalogItem updatedItem = mapper.load(CatalogItem.class, 601, config);
System.out.println("Retrieved the previously updated item:");
System.out.println(updatedItem);
// Delete the item.
mapper.delete(updatedItem);
// Try to retrieve deleted item.
CatalogItem deletedItem = mapper.load(CatalogItem.class, updatedItem.getId(), config);
if (deletedItem == null) {
System.out.println("Done - Sample item is deleted.");
}
}
示例8: getPerson
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
public static Person getPerson(String id) {
DynamoDBMapper mapper = new DynamoDBMapper(getClient());
return mapper.load(Person.class, id);
}
示例9: getBook
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
private Book getBook() {
DynamoDBMapper mapper = new DynamoDBMapper(getClient());
return mapper.load(Book.class, "1");
}
示例10: updateDenuncia
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
private Denuncia updateDenuncia(DynamoDBMapper mapper,String idDenuncia, String folio,int estatusDenuncia)
{
Denuncia d = mapper.load(Denuncia.class, idDenuncia);
if(DENUNCIA_RECIBIDA_SPF==estatusDenuncia)
d.setIdDenunciaSPF(folio);
d.setIdEstadoDenuncia(estatusDenuncia);
mapper.save(d);
return d;
}
示例11: GetBook
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
private static void GetBook(DynamoDBMapper mapper, int id) throws Exception {
System.out.println("GetBook: Get book Id='101' ");
System.out.println("Book table has no range key attribute, so you Get (but no query).");
Book book = mapper.load(Book.class, 101);
System.out.format("Id = %s Title = %s, ISBN = %s %n", book.getId(), book.getTitle(), book.getISBN() );
}
示例12: main
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
AmazonDynamoDBClient client = new AmazonDynamoDBClient(new ProfileCredentialsProvider());
DimensionType dimType = new DimensionType();
dimType.setHeight("8.00");
dimType.setLength("11.0");
dimType.setThickness("1.0");
Book book = new Book();
book.setId(502);
book.setTitle("Book 502");
book.setISBN("555-5555555555");
book.setBookAuthors(new HashSet<String>(Arrays.asList("Author1", "Author2")));
book.setDimensions(dimType);
System.out.println(book);
DynamoDBMapper mapper = new DynamoDBMapper(client);
mapper.save(book);
Book bookRetrieved = mapper.load(Book.class, 502);
System.out.println(bookRetrieved);
bookRetrieved.getDimensions().setHeight("9.0");
bookRetrieved.getDimensions().setLength("12.0");
bookRetrieved.getDimensions().setThickness("2.0");
mapper.save(bookRetrieved);
bookRetrieved = mapper.load(Book.class, 502);
System.out.println(bookRetrieved);
}
示例13: getDocument
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入方法依赖的package包/类
/**
* Acquire a document processor
* <p/>
* {@sample.xml ../../../doc/DynamoDB-connector.xml.sample dynamodb:get-document}
*
* @param tableName
* the name of the table to get the document from
* @param template
* an object with the document data that DynamoDB will match against
*
* @return Object the document from the table
*/
@Processor
public Object getDocument(final String tableName, @Optional @Default(PAYLOAD) final Object template) {
DynamoDBMapper mapper = getDbObjectMapper(tableName);
return mapper.load(template);
}