Metadata
- Source
- FLUID-5300
- Type
- Improvement
- Priority
- Major
- Status
- Closed
- Resolution
- Fixed
- Assignee
- Kasper Galschiot Markus
- Reporter
- Cindy Li
- Created
2014-04-02T15:05:07.516-0400 - Updated
2024-07-22T10:35:01.724-0400 - Versions
- N/A
- Fixed Versions
- N/A
- Component
-
- Model Transformation System
Description
When a literal value needs to be mapped to an object that has multiple paths and values, for example:
var inputModel = {
hazard: "flashing"
};
var expectedTransformedObject = {
hasHazard: true,
audio: true
};
The transformation rule that performs this transformation successfully looks like:
{
type: "fluid.transforms.valueMapper",
inputPath: "hazard",
options: {
"flashing": {
"outputValue": {
transform: [{
type: "fluid.transforms.literalValue",
value: true,
outputPath: "hasHazard"
}, {
type: "fluid.transforms.literalValue",
value: true,
outputPath: "sound"
}]
}
}
}
};
Note that in this rule:
1. "outputValue" needs to be specified as a key in the map options;
2. Nested transformation rules needs to be defined for each output key value pair rather than a direct compound values.
It would be nice to simplify the rule to be:
{
type: "fluid.transforms.valueMapper",
inputPath: "hazard",
options: {
"flashing": {
"hasHazard": true,
"sound": true
}
}
}
In today's conversation at irc channel, Antranig expressed concerns that the implementation of the valueMapper is not consistent with that of our other transforms:
https://botbot.me/freenode/fluid-work/2014-04-02/?tz=America/Havana
at 11:19AM onwards.
Comments
-
Antranig Basman commented
2016-04-15T12:01:10.399-0400 Two changes have altered the terrain around this issue since it was filed -
i) FLUID-5867 altered the default framework behaviour on encountering nested transforms to be consistent with this behaviour
ii) We supported the "literalValue": "x" syntax to more compactly encode literal values -
Antranig Basman commented
2016-04-15T12:04:42.185-0400 With these changes, cindy's transform becomes
{ type: "fluid.transforms.valueMapper", inputPath: "hazard", options: { "flashing": { "outputValue": { "hasHazard": true "sound": true } } } };
which I think is pretty reasonable