Search in sources :

Example 6 with ReplaceableItem

use of com.amazonaws.services.simpledb.model.ReplaceableItem in project siena by mandubian.

the class SdbMappingUtils method createItem.

public static ReplaceableItem createItem(Object obj) {
    Class<?> clazz = obj.getClass();
    ReplaceableItem item = new ReplaceableItem(getItemName(clazz, obj));
    for (Field field : ClassInfo.getClassInfo(clazz).updateFields) {
        try {
            String value = objectFieldToString(obj, field);
            if (value != null) {
                ReplaceableAttribute attr = new ReplaceableAttribute(getAttributeName(field), value, true);
                item.withAttributes(attr);
            } else {
                if (ClassInfo.isEmbeddedNative(field)) {
                    SdbNativeSerializer.embed(item, ClassInfo.getSingleColumnName(field), value);
                }
            }
        } catch (Exception e) {
            throw new SienaException(e);
        }
    }
    return item;
}
Also used : Field(java.lang.reflect.Field) SienaException(siena.SienaException) ReplaceableItem(com.amazonaws.services.simpledb.model.ReplaceableItem) SienaException(siena.SienaException) SienaRestrictedApiException(siena.SienaRestrictedApiException) IOException(java.io.IOException) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute)

Example 7 with ReplaceableItem

use of com.amazonaws.services.simpledb.model.ReplaceableItem in project camel by apache.

the class BatchPutAttributesCommandTest method execute.

@Test
public void execute() {
    List<ReplaceableItem> replaceableItems = new ArrayList<ReplaceableItem>();
    replaceableItems.add(new ReplaceableItem("ITEM1"));
    exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ITEMS, replaceableItems);
    command.execute();
    assertEquals("DOMAIN1", sdbClient.batchPutAttributesRequest.getDomainName());
    assertEquals(replaceableItems, sdbClient.batchPutAttributesRequest.getItems());
}
Also used : ArrayList(java.util.ArrayList) ReplaceableItem(com.amazonaws.services.simpledb.model.ReplaceableItem) Test(org.junit.Test)

Example 8 with ReplaceableItem

use of com.amazonaws.services.simpledb.model.ReplaceableItem in project camel by apache.

the class SdbComponentIntegrationTest method batchPutAttributes.

@Test
public void batchPutAttributes() {
    final List<ReplaceableItem> replaceableItems = Arrays.asList(new ReplaceableItem[] { new ReplaceableItem("ITEM1") });
    template.send("direct:start", new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchPutAttributes);
            exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ITEMS, replaceableItems);
        }
    });
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) ReplaceableItem(com.amazonaws.services.simpledb.model.ReplaceableItem) Test(org.junit.Test)

Aggregations

ReplaceableItem (com.amazonaws.services.simpledb.model.ReplaceableItem)8 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 Exchange (org.apache.camel.Exchange)3 Processor (org.apache.camel.Processor)3 SienaException (siena.SienaException)3 AmazonClientException (com.amazonaws.AmazonClientException)2 BatchPutAttributesRequest (com.amazonaws.services.simpledb.model.BatchPutAttributesRequest)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ReplaceableAttribute (com.amazonaws.services.simpledb.model.ReplaceableAttribute)1 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 SienaRestrictedApiException (siena.SienaRestrictedApiException)1