use of com.amazonaws.services.simpledb.model.DeletableItem in project camel by apache.
the class SdbComponentIntegrationTest method batchDeleteAttributes.
@Test
public void batchDeleteAttributes() {
final List<DeletableItem> deletableItems = Arrays.asList(new DeletableItem[] { new DeletableItem("ITEM1", null), new DeletableItem("ITEM2", null) });
template.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchDeleteAttributes);
exchange.getIn().setHeader(SdbConstants.DELETABLE_ITEMS, deletableItems);
}
});
}
use of com.amazonaws.services.simpledb.model.DeletableItem in project siena by mandubian.
the class SdbPersistenceManager method deleteByKeys.
@Override
public <T> int deleteByKeys(Class<T> clazz, Iterable<?> keys) {
List<DeletableItem> doList = new ArrayList<DeletableItem>();
int nb = 0;
String domain = SdbMappingUtils.getDomainName(clazz, prefix);
for (Object key : keys) {
doList.add(SdbMappingUtils.createDeletableItemFromKey(clazz, key));
nb++;
}
try {
checkDomain(domain);
int len = doList.size() > MAX_ITEMS_PER_CALL ? MAX_ITEMS_PER_CALL : doList.size();
for (int i = 0; i < doList.size(); i += len) {
int sz = i + len;
if (sz > doList.size()) {
sz = doList.size();
}
sdb.batchDeleteAttributes(new BatchDeleteAttributesRequest(domain, doList.subList(i, sz)));
}
} catch (AmazonClientException ex) {
throw new SienaException(ex);
}
return nb;
}
use of com.amazonaws.services.simpledb.model.DeletableItem in project camel by apache.
the class SdbComponentTest method batchDeleteAttributes.
@Test
public void batchDeleteAttributes() {
final List<DeletableItem> deletableItems = Arrays.asList(new DeletableItem[] { new DeletableItem("ITEM1", null), new DeletableItem("ITEM2", null) });
template.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchDeleteAttributes);
exchange.getIn().setHeader(SdbConstants.DELETABLE_ITEMS, deletableItems);
}
});
assertEquals("TestDomain", amazonSDBClient.batchDeleteAttributesRequest.getDomainName());
assertEquals(deletableItems, amazonSDBClient.batchDeleteAttributesRequest.getItems());
}
use of com.amazonaws.services.simpledb.model.DeletableItem in project camel by apache.
the class SdbComponentSpringTest method batchDeleteAttributes.
@Test
public void batchDeleteAttributes() {
final List<DeletableItem> deletableItems = Arrays.asList(new DeletableItem[] { new DeletableItem("ITEM1", null), new DeletableItem("ITEM2", null) });
template.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchDeleteAttributes);
exchange.getIn().setHeader(SdbConstants.DELETABLE_ITEMS, deletableItems);
}
});
assertEquals("TestDomain", amazonSDBClient.batchDeleteAttributesRequest.getDomainName());
assertEquals(deletableItems, amazonSDBClient.batchDeleteAttributesRequest.getItems());
}
use of com.amazonaws.services.simpledb.model.DeletableItem in project siena by mandubian.
the class SdbPersistenceManager method delete.
@Override
public int delete(Iterable<?> models) {
Map<String, List<DeletableItem>> doMap = new HashMap<String, List<DeletableItem>>();
int nb = 0;
for (Object obj : models) {
Class<?> clazz = obj.getClass();
String domain = SdbMappingUtils.getDomainName(clazz, prefix);
List<DeletableItem> doList = doMap.get(domain);
if (doList == null) {
doList = new ArrayList<DeletableItem>();
doMap.put(domain, doList);
}
doList.add(SdbMappingUtils.createDeletableItem(obj));
nb++;
}
try {
for (String domain : doMap.keySet()) {
checkDomain(domain);
List<DeletableItem> doList = doMap.get(domain);
int len = doList.size() > MAX_ITEMS_PER_CALL ? MAX_ITEMS_PER_CALL : doList.size();
for (int i = 0; i < doList.size(); i += len) {
int sz = i + len;
if (sz > doList.size()) {
sz = doList.size();
}
sdb.batchDeleteAttributes(new BatchDeleteAttributesRequest(domain, doList.subList(i, sz)));
}
}
} catch (AmazonClientException ex) {
throw new SienaException(ex);
}
return nb;
}
Aggregations