use of com.amazonaws.services.simpledb.model.ReplaceableAttribute 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;
}
use of com.amazonaws.services.simpledb.model.ReplaceableAttribute in project siena by mandubian.
the class SdbMappingUtils method createPutRequest.
public static PutAttributesRequest createPutRequest(String domain, Class<?> clazz, ClassInfo info, Object obj) {
PutAttributesRequest req = new PutAttributesRequest().withDomainName(domain);
req.withItemName(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);
req.withAttributes(attr);
} else {
if (ClassInfo.isEmbeddedNative(field)) {
SdbNativeSerializer.embed(req, ClassInfo.getSingleColumnName(field), value);
}
}
} catch (Exception e) {
throw new SienaException(e);
}
}
return req;
}
use of com.amazonaws.services.simpledb.model.ReplaceableAttribute in project camel by apache.
the class PutAttributesCommandTest method executeWithoutItemName.
@Test(expected = IllegalArgumentException.class)
public void executeWithoutItemName() {
List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>();
replaceableAttributes.add(new ReplaceableAttribute("NAME1", "VALUE1", true));
exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
command.execute();
}
use of com.amazonaws.services.simpledb.model.ReplaceableAttribute in project camel by apache.
the class PutAttributesCommandTest method execute.
@Test
public void execute() {
List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>();
replaceableAttributes.add(new ReplaceableAttribute("NAME1", "VALUE1", true));
exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
command.execute();
assertEquals("DOMAIN1", sdbClient.putAttributesRequest.getDomainName());
assertEquals("ITEM1", sdbClient.putAttributesRequest.getItemName());
assertEquals(updateCondition, sdbClient.putAttributesRequest.getExpected());
assertEquals(replaceableAttributes, sdbClient.putAttributesRequest.getAttributes());
}
use of com.amazonaws.services.simpledb.model.ReplaceableAttribute in project camel by apache.
the class PutAttributesCommandTest method determineReplaceableAttributes.
@Test
public void determineReplaceableAttributes() {
assertNull(this.command.determineReplaceableAttributes());
List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>();
replaceableAttributes.add(new ReplaceableAttribute("NAME1", "VALUE1", true));
exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
assertEquals(replaceableAttributes, this.command.determineReplaceableAttributes());
}
Aggregations