Data Mapping with a Script

This mapper is used to give you the flexibility of building your own mapper without the need to compile from source. The source uses JSR-223 Scripting Engine. The script language can be changed by setting the property mapper.lang in your requisition.properties file. The following example runs your script in the the JavaScript Rhino engine:

### File: requisition.properties

## source configuration part
source = ...

## Run a no operation mapper
mapper = echo

# run mapper script in JavaScript
mapper.lang=javascript
mapper.file = myJavaScriptSource.js

If you don’t set the language lang property the script engine tries to detect the language by evaluating the file extension.

Parameter Required Description

mapper

*

script to use JSR-223 Script Engine as source

mapper.file

*

Path to script source relative to requisition.properties

mapper.lang

JSR-223 Script language by name

You can find a working example in Groovy in the configs/examples/script.mapper directory.

In addition to any other mapper, a final script mapper can be used by specifying script.file in your requisition.properties` file. The specified script will run after the configured mapper and can be used to transform the mapper’s output further.

To specify the scripting language, the script.lang property can be used (see mapper.lang).