Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/implicit-thing-creation'…
Browse files Browse the repository at this point in the history
… into feature/implicit-thing-creation

Signed-off-by: Johannes Schneider <johannes.schneider@bosch.io>
  • Loading branch information
jokraehe committed Aug 24, 2020
2 parents 23e5c9f + a1701ac commit 7912a05
Showing 1 changed file with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ The following message mappers are included in the Ditto codebase:
| [JavaScript](#javascript-mapper) | Converts arbitrary messages from and to the [Ditto Protocol](protocol-overview.html) format using **custom** JavaScript code executed by Ditto. |||
| [Normalized](#normalized-mapper) | Transforms the payload of events to a normalized view. | ||
| [ConnectionStatus](#connectionstatus-mapper) | This mapper handles messages containing `creation-time` and `ttd` headers by updating a feature of the targeted thing with [definition](basic-feature.html#feature-definition) [ConnectionStatus](https://vorto.eclipse.org/#/details/org.eclipse.ditto:ConnectionStatus:1.0.0). || |
| [ImplicitThingCreation](#implicitthingcreation-mapper) | This mapper handles messages for which a Thing should be created automatically based on a defined template|| |

### Ditto mapper

Expand Down Expand Up @@ -172,6 +173,30 @@ Example of a resulting `ConnectionStatus` feature:
fixed value or resolved from a message header (e.g. `{%raw%}{{ header:feature_id }}{%endraw%}`).


### ImplicitThingCreation Mapper
This mapper implicitly creates a new thing for an incoming message.

The created thing contains the values defined in the template, configured in the `mappingDefinitions` `options`.<br/>

#### Configuration options

* `thing` (required): The values of the thing that is created implicitly. It can either contain fixed values
or header placeholders (e.g. `{%raw%}{{ header:device_id }}{%endraw%}`).

Example of a template defined in `options`:
```json
{
"thing": {
"thingId": "{{header:device_id}}",
"policyId": "{{header:entity.id}}",
"attributes": {
"CreatedBy": "ImplicitThingCreation"
}
}
}
```



## Example connection with multiple mappers

Expand Down Expand Up @@ -206,6 +231,39 @@ The following example connection defines a `ConnectionStatus` mapping with the I



## Example connection with mapping conditions

The following example connection defines `conditions` for the ConnectionStatus mapping engine.<br/>
Optional conditions are validated before the mapping.<br/>
Conditional Mapping can be achieved by using [function expressions](basic-placeholder.html#function-expressions).
When multiple conditions are defined for one `mappingEngine`, all have to equal true for the mapping to be executed.

```json
{
...
"name": "exampleConnection",
"sources": [{
"addresses": ["<source>"],
"authorizationContext": ["ditto:inbound"],
"payloadMapping": ["status"]
}
],
"mappingDefinitions": {
"status": {
"mappingEngine": "ConnectionStatus",
"conditions": [
"fn:filter(header:mapping-required,'eq','true')"
],
"options": {
"thingId": "{%raw%}{{ header:device_id }}{%endraw%}"
}
}
}
}
```



## JavaScript mapping engine

Ditto utilizes the [Rhino](https://github.com/mozilla/rhino) JavaScript engine for Java for evaluating the JavaScript
Expand Down

0 comments on commit 7912a05

Please sign in to comment.