-
Notifications
You must be signed in to change notification settings - Fork 1
Templates
A template is a text containing
- calls with <call> tags.
- variables from EO with $[path].
These active elements will be processed by TemplateCall.
| Description | value |
|---|---|
| super class | CallIO.java |
| configuration | TemplateConfig.java extends FileConfig.java |
| json configuration | TemplateConfig.json |
| methods | execute |
| config key | templateKey |
| fixed keys | |
| variable keys | content, loopPath, keep, if, path, mapPath |
In the test section there are several examples showing the usage.
In TemplateCallSimpleTest.executeDirectContent there is a template call with a String.
- create a new TemplateCall with configsCache
- add a String as template via setContent
- execute with an EO.
final TemplateCall action = new TemplateCall(TestObjectProvider.EO_CONFIGS_CACHE);
action.setContent("key='$[key]'<call path=\"level0/level1\">level0/level1/key='$[key]'</call>");
final EO root = TestObjectProvider.create();
root.add("key").set("value");
root.add("level0/level1/key").set("value with path");
final String result = action.execute(root);
Assert.assertEquals(INFO_COMPARE_FAILS, "key='value'level0/level1/key='value with path'",result);
The test TemplateCallSimpleTest show a more complex scenario: The associated template SimpleInsertWithPathAndJson.tpl contain a call reading a json file with key SimpleInsertWithPath.
So it loads at first the json data from SimpleInsertWithPath.json.
Despite of simple direct java call example, calls are usually predefined by configruation files referenced by a key. This accomplish serializing of the calls e.g. for loading data.
final String result = TestCallsProvider.executeTemplateCall("SimpleInsertWithPathAndJson");
Assert.assertEquals("
key0='test'
Start call: path='level0' --> key0='testOther' :End call
level0/key0='testOther'",result)
Here we reference the template 'SimpleInsertWithPath.tpl' by key defined in TemplateConfig.json:
<call execute="JsonCall.read(SimpleInsertWithPath)" />
key0='$[key0]'
Start call: <call path="level0">path='level0' --> key0='$[key0]' </call> :End call
level0/key0='$[level0/key0]'
The template contains the JsonCall to read SimpleInsertWithPath.json by key defined in JsonConfig.json.
{
"key0": "test",
"level0": {
"key0": "testOther"
}
}