Class Ddb2JsonDataTypeTransformer
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.spi.Transformer
org.apache.camel.component.aws2.ddb.transform.Ddb2JsonDataTypeTransformer
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.HasCamelContext,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
@DataTypeTransformer(name="aws2-ddb:application-json")
public class Ddb2JsonDataTypeTransformer
extends org.apache.camel.spi.Transformer
Maps Json body to DynamoDB attribute value map and sets the attribute map as Camel DynamoDB header entries.
Json property names map to attribute keys and Json property values map to attribute values.
During mapping the Json property types resolve to the respective attribute types
(
String, StringSet, Boolean, Number, NumberSet, Map, Null). Primitive typed arrays in Json get mapped to
StringSet or NumberSet attribute values.
The input type supports the operations: PutItem, UpdateItem, DeleteItem
For PutItem operation the Json body defines all item attributes.
For DeleteItem operation the Json body defines only the primary key attributes that identify the item to delete.
For UpdateItem operation the Json body defines both key attributes to identify the item to be updated and all item
attributes tht get updated on the item.
The given Json body can use "operation", "key" and "item" as top level properties that will be mapped to respective
attribute value maps:
{
"operation": "PutItem"
"key": {},
"item": {}
}
The transformer will extract the objects and set respective attribute value maps as header entries. This is a
comfortable way to define different key and item attribute value maps e.g. on UpdateItem operation.
In case key and item attribute value maps are identical you can omit the special top level properties completely. The
transformer will map the whole Json body as is then and use it as source for the attribute value map.-
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidtransform(org.apache.camel.Message message, org.apache.camel.spi.DataType fromType, org.apache.camel.spi.DataType toType) Methods inherited from class org.apache.camel.spi.Transformer
doStop, getCamelContext, getFrom, getName, getTo, setCamelContext, setFrom, setName, setName, setTo, toStringMethods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doStart, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
Ddb2JsonDataTypeTransformer
public Ddb2JsonDataTypeTransformer()
-
-
Method Details
-
transform
public void transform(org.apache.camel.Message message, org.apache.camel.spi.DataType fromType, org.apache.camel.spi.DataType toType) - Specified by:
transformin classorg.apache.camel.spi.Transformer
-