Simple templates are a string substitution and templating facility provided within Aspire. It is used currently by the Storage Handler, but it is expected to be used throughout Aspire over time.
Note that Simple Templates are usually used to substitute data into strings for AspireObject objects and pipeline jobs. Therefore, most of the substutitions available are related to these two objects.
On this page:
Simple templates are simply strings with curly-braces for substituting variable data.
For example:
"The number of unique assignees is {uniqueAssigneeCount}."
will be converted to:
"The number of unique assignees is 32."
after template substitution.
The following substitutions are provided.
All variables stored with an AspireObject are directly accessible.
For example:
"The number of unique assignees is {uniqueAssigneeCount}."
will be converted to:
"The number of unique assignees is 32."
Objects are converted using the "toString()" method on the object.
XML tags within the AspireObject can be directly accessed with {XML:tag}.
For example:
"data/vector/{XML:APPLICANT_ID}.vec"
will be converted to:
"data/vector/3290423.vec"
This is only available for tags which are direct children of the root-level <doc> tag.
Any XML within the document can be accessed using {XPATH:/path/to/element}.
For example:
"data/{XPATH:/doc/categories/category[@id='32']}/myfile.cat"
will be converted to:
"data/jobs/myfile.cat"
(assuming that <categories>/<category id="32">jobs</category></categories> exists within the document)
This is only available for tags which are direct children of the root-level <doc> tag.
This is available with {now(date-pattern)}. For example:
"data/logfile-{now(yyyy-MM-dd)}.txt"
will be converted to:
"data/jobs/2010-11-06.txt"
The default format for text is "yyyy-MM-dd'T'HHmmss'Z'". Therefore:
"data/logfile-{now()}.txt"
will be converted to:
"data/jobs/2010-11-06T133800Z.txt"
Note that all dates and times are specified in GMT, always.
For more information on the date format, see [SimpleDateFormat].
To get the Job ID, use the literal {JOBID}. For example:
"data/logfile-{JOBID}.txt"
will be converted to:
"data/jobs/CRAWLER-0932-32.txt"
To use the simple templates in custom Groovy/Java code:
import com.searchtechnologies.aspire.framework.SimpleTemplate; SimpleTemplate simpleTemplate = new SimpleTemplate("data/logfile-{JOBID}.txt"); result = simpleTemplate.evaluate(job);
Note that this is a simple templating capability. Many items are not available, including: