In situations where you want to manipulate data from flow context
to state context or vice versa, you can set data mappings to either
states or transitions. BTT names this kind of data mapping as data
formatter.
- Definition
Data formatter can be from a context to a context, from a complex
expression to a context or vice versa, defining all the data mappings
between the two sides. A data formatter may include multiple data
mappings. Each of them completes one mapping task.
After user
created a data formatter and associated it with the transition or
state, the processor, when changing from the source state to the target
state (in case of transition mappings) or when entering or exiting
one state (in case of state mappings), will call the defined mappings
in the data formatter sequentially.
- Direction
- There are two directions for data mapping:
- Output Mapping
- applied when going out of the state. It maps data from an expression
to the flow context. The expression can be a constant, expression,
function or source state context.
- Input Mapping
- applied when entering into the state. It maps data from an expression
to the target state context. The expression can be a constant, expression,
function or flow context.
- Mapping behavior
- Normally, when defined, state mappings would be called first whenever
entering or existing the state. If a transition from or to the state
need a different data mapping, users could define a new Transition
mapping and set it as ‘Override state mapping’ or ‘Apply after state
mapping’ according to different requirements.
- Override state mapping
- Only the transition mapping will be applied. If the transition
mapping is empty, then no mapping will be applied for this transition.
- Apply after state mapping
- Both state and transition mappings will be applied, first the
state mapping and then the transition mapping. In this way, a transition
can reuse the state mapping while at the same time selectively override
some of those mappings.
- Usage
- To set data mappings to a transition or a state, users could choose
to add an existing data formatter or define a new data formatter for
it. For defined data formatter, users could update, reorder and remove
its data mappings. When the data formatter is not needed, users could
remove it from the transition or state.