Download source code

Download this directory

MigrationAssistant
|
+-- IncidentMigrationAssistant (Deprecated)
|
+-- JsonMigrationAssistant
|
+--using JsonTransformation Interface
The JsonTransformation interface is implemented by in two
different ways:
AbstractJsonTransformation
| implements JsonTransformation, JsonNodeExplorer
|
+-- JoltTransformation --> relying on Jolt [1]
|
+-- SimpleJsonTransformation --> relying on Jackson JsonNode
The JsonTransformation interface provides a three step process
of to transform a given scenario File were each consumes a JsonNode
and returns the changed JsonNode.
1) preHooks
2) transformation
3) postHooks
The MigrationAssistant selects the correct implementation by
using the JsonTransformationFactory which map a given Version
to the corresponding implementation of some JsonTransformation.
1. Subclass either JoltTransformation or SimpeJsonTransformation.
(a) If JoltTransformation is used, a specialized transformation syntax
must be used. See [1] for Doc.
(b) If SimpleJsonTransformation is used no additional input is needed.
The transformation is done by manually manipulating the Jackson
JsonNode-Tree
2. add annotation where X.X resembles the Version label i.e. "0.8"
@MigrationTransformation(targetVersionLabel = "X.X")
3. add the default constructor with no arguments and the
call super constructor passing the Version
4. Implement initDefaultHooks() and add the pre- and postHook
LinkedList with JsonTransformationHooks
(a) use add[Post|Pre][First|Last] methods.
(b) add addPostHookLast(AbstractJsonTransformation::sort) to ensure
the right sorting order within the scenario file.
5. (optional) overwrite any of applyPreHooks, applyTransformation,
applyPostHooks if needed.
6. (optional) add generic JsonNode manipulations to JsonNodeExplorer
This interface contains useful default implementation to navigate a
JsonNode-Tree such as:
path(jsonNode, "some/path/within/the/json") <-- will return empty nodes
with path das not exist
pathMustExist(jsonNode, "some/path/within/the/json") <-- will throw
MigrationException
renameField(node, "release", "version") <-- rename keys
iteratorProcessorsByType(jsonRoot, "org...PedestrianVelocityProcessor )
<-- returns an iterator of JsonNodes representing a
PedestrianVelocityProcessor
[1]: https://github.com/bazaarvoice/joltSigned-off-by: hm-schuhba1's avatarhm-schuhba1 <stefan.schuhbaeck@hm.edu>