Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Anchor
top
top

Note

DRAFT; Incomplete

Div
classfloatRight
Panel
titleOn This Page

Table of Contents
maxLevel5
minLevel3
stylenone

 

 

 

 

The Framework currently several transforms that can be used as part of a model transformation, as described below.

fluid.transforms.arrayToObject

Transforms an array into a JavaScript object.

back to top

fluid.transforms.arrayToSetMembership

 

back to top

fluid.transforms.arrayValue

Transforms a value into an aray. If the value is already an array, the expander will have no effect.

For example:

Section
Column

Start:

Code Block
javascript
javascript
var source = {
    cat: "meow",
    sheep: [
        "baaa",
        "wooooool"
    ],
    ...
}
Column



>>

Column

Rule to convert to arrays:

Code Block
javascript
javascript
var rules = {
    cat: {                                          
        transform: {
            type: "fluid.transforms.arrayValue",
            inputPath "cat"
        }
    },
    sheep: {
        transform: {
            type: "fluid.transforms.arrayValue",
            inputPath "sheep"
        }
    } 
    ....
}
Column



>>

Column

Result:

Code Block
javascript
javascript
{
    cat: ["meow"],
    sheep: [
        "baaa",
        "wooooool"
    ],
    ...
}

Note that the value of cat is now an array, but the value of sheep is unaffected.

 

back to top

fluid.transforms.binaryOp

 

back to top

fluid.transforms.binaryLookup.*

 

back to top

fluid.transforms.condition

 

back to top

fluid.transforms.count

 

back to top

fluid.transforms.linearScale

 

back to top

fluid.transforms.literalValue

 

back to top

fluid.transforms.objectToArray

 

back to top

fluid.transforms.round

 

back to top

fluid.transforms.setMembershipToArray

 

back to top

fluid.transforms.value

This extracts and/or the value of a given path, and can be used for the following purposes:

To rename a property:

Section
Column

Start:

Code Block
javascript
javascript
var source = {
    cat: "meow",
    ...
}
Column



>>

Column

Rule to rename "cat" to "feline":

Code Block
javascript
javascript
var rules = {
    feline: { 
        transform: {
            type: "fluid.transforms.value",
            // specify only the path to transform
            inputPath: "cat"
        }
    },
    ....
}
Column



>>

Column

Result:

Code Block
javascript
javascript
{
    feline: "meow",
    ...
}

To set a default value:

Section
Column

Start:

Code Block
javascript
javascript
var source = {
    gerbil: undefined,
    // or if "gerbil" doesn't exist
    ...
}
Column



>>

Column

Rule to set default value of "gerbil":

Code Block
javascript
javascript
var rules = {
    gerbil: { 
        transform: {
            type: "fluid.transforms.value",
            // specify path and default value
            inputPath "gerbil",
            value: "squeek"
        }
    },
    ....
}
Column



>>

Column

Result:

Code Block
javascript
javascript
{
    gerbil: "squeek",
    ...
}

Note that if "gerbil" has a value initially, it will be unaffected.

To specify a literal value:

Section
Column

Start:

Code Block
javascript
javascript
var source = {
    // no mention of kangaroos
    ...
}
Column



>>

Column

Rule to set a value for "kangaroo":

Code Block
javascript
javascript
var rules = {
    kangaroo: { 
        transform: {
            type: "fluid.transforms.value",
            // specify only a value
            value: "boingg"
        }
    },
    ....
}
Column



>>

Column

Result:

Code Block
javascript
javascript
{
    kangaroo: "boingg",
    ...
}

To change the structure/nesting:

Section
Column

Start:

Code Block
javascript
javascript
var source = {
    goat: false,
    sheep: [
        "baaa",
        "wooooool"
    ],
    ...
}
Column



>>

Column

Rule to change the nesting:

Code Block
javascript
javascript
var rules = {
    "farm.goat": {                                          
        transform: {
            type: "fluid.transforms.value",
            inputPath "goat"
        }
    },
    "farm.sheep": {
        transform: {
            type: "fluid.transforms.value",
            inputPath "sheep"
        }
    } 
    ....
}
Column



>>

Column

Result:

Code Block
javascript
javascript
{
    farm: {
        goat: false,
        sheep: [
            "baaa",
            "wooooool"
        ]
    },
    ...
}

 

back to top

fluid.transforms.value.invert

 

back to top

fluid.transforms.valueMapper

 

back to top