The Model Gateway Macros allow the user to specify some of the Rule Model values at import/export time. The mechanism consist in replacing macro identifiers by user defined or pre defined values. The macro substitution mechanism is supported by the following Rule Model values:
- the column default value
- the column value filter
The Model Gateway provides some predefined macros:
- %FileName%: replaced by the file name with its extension (import only)
- %SheetName%: replaced the name of the imported sheet (import only)
The user can also provide his own macros by passing a dictionary to the import/export functions (refer to the Model Gateway API).
- If you use a macro in the value filter, note that the macro identifier needs to be a valid regular expression (you are safe if you use the same naming scheme as pre defined macros).
Specifying import root object
Suppose you need to import a collection of objects within a parent which is chosen by the user at import time.
This can be achieved by using of a virtual column with a macro as its default as shown by this sample.
In the Rule Model the 'root' object in which the other objects will be imported is represented by a virtual column (indeed this root object is not represented in the imported data, otherwise we would not need such a mechanism). Note the default value of the virtual column, %Root%, which is also our user macro identifier.
Now we need to specify to the Model Gateway that %Root% is a macro and gives its replacement value. For this example we will use the name of the object from which the script is ran:
other example to match only the exact value