-
Notifications
You must be signed in to change notification settings - Fork 82
Script Helper
The Metl Groovy Script component comes with a set of predefined variables and methods available for use in your script component.
Variable | Description |
---|---|
log |
Use this to log to the Metl log file. |
context |
The context under which the component runtime was called. |
flowStep |
The configuration of the flow step. |
flow |
The configuration of the entire flow. |
resource |
Access to the resource runtime if it is set. |
unitOfWorkBoundaryReached |
A boolean indicator that a Control Message has been received from each source link. |
scriptContext |
A context object that can be used by scripts to save objects between calls to OnHandle. This variable is a Map<String, Object> type. |
inputMessage |
The message that was received. This can be accessed from the OnHandle method. |
callback |
This is a handle to the API that can be used to send outbound Messages. |
componentStatistics |
Access to component statistics. |
Method | Description |
---|---|
isControlMessage() |
Returns true if the inputMessage is of a ControlMessage type. |
isTextMessage() |
Returns true if the inputMessage is of a TextMessage type. |
isEntityDataMessage() |
Returns true if the inputMessage is of an EntityDataMessage type. |
getInputMessageSourceName() |
Returns the name of the flow step from which the input message came from. |
getJdbcTemplate() |
If the resource is a DataSource, then this method returns a Spring JdbcTemplate. |
getBasicDataSource() |
If the resource is a DataSource, then this returns a reference to the DataSource. |
getDirectory() |
If the resource is a directory, this is the reference to the directory. |
doesFileExist(String relativePath) |
Returns true if the passed in value exists. |
countFiles(String relativePath) |
Returns the number of files that exist in the passed in relative path. |
classpathToDirectory(String fileName) |
This is mainly to support unit tests or components that need to copy a classpath resource to a directory resource in a script. Accepts as input the file to extract as a file resource. |
nextRowFromInputMessage() |
If there is an Input Model and the message is of an EntityDataMessage type this will return the next row of data. |
debug(String message, Object… args) |
Call this method to record debug level messages in the component log. Use string format(String, Object…) syntax if you are using the args. |
info(String message + Object… args) |
Call this method to record info level messages in the component log. Use string format(String + Object…) syntax if you are using the args: info("Output Text" + fieldToOutput + " More Text" + anotherDataElement) |
warn(String message + Object… args) |
Call this method to record warn level messages in the component log. Use string format(String + Object…) syntax if you are using the args: warn("Output Text" + fieldToOutput) |
error(String message + Object… args) |
Call this method to record error level messages in the component log. Use string format(String + Object…) syntax if you are using the args: error("Output Text" + fieldToOutput) |
containsEntity(String entityName, EntityData data) |
Returns true when the Input Model data object contains data for a Model Entity with the provided entityName. Params: entityName - the name to check for data - the data object to check |
putAttributeValue(String entityName, String attributeName, EntityData data, Object value) |
Method to set a Model Attribute in the Entity Data object. Params: entityName - the name of the Model Entity attributeName - the name of the Model Attribute data - the data object on which to set the attribute value - the value of the attribute |
getAttributeValue(String entityName, String attributeName, EntityData data) |
Method to get an attribute value from the data object by name. Params: entityName - the name of the Model Entity attributeName - the name of the Model Attribute data - the data object from which to get the attribute |
getAttributeValue(String entityName, String attributeName) |
Method to get an attribute value from the first data object in the current Input Message. Params: entityName - the name of the Model Entity attributeName - the name of the Model Attribute |
getAttributeValue(String attributeName, EntityData data) |
Method to get an attribute value from the data object by attribute name only. Params: attributeName - the name of the Model Attribute data - the data object from which to get the attribute |
getAttributeValues(String entityName, String attributeName) |
Method to get a list of attribute values with a specific entity and attribute name from all the data objects in an Input Message. Params: entityName - the name of the Model Entity attributeName - the name of the Model Attribute |
setAttributeValue(String entityName, String attributeName, EntityData data, Object value) |
Method to set a Model Attribute value in the Entity Data object. Params: entityName - the name of the Model Entity attributeName - the name of the Model Attribute data - the data object on which to set the attribute value - the value of the attribute |
forwardMessageWithParameter(String parameterName, Serializable value) |
Method to forward the current inputMessage with the provided parameter. Params: parameterName - the name of a parameter to add to the message header value - the value of the parameter being added |
forwardMessageWithParameters(Map<String, Serializable> params) |
Method to forward the current inputMessage with the provided set of parameters. Params: params - map of parameters to add to the message header |
forwardMessage() |
Method to forward the current inputMessage. |
sendControlMessage() |
Method to send a control message. |
sendEntityDataMessage(ArrayList<EntityData> payload) |
Method to send an entity data message. Params: payload - list of entity data objects to include in the message |