User GuideReference ManualIntegration Scenarios
 

2.3.1. Drag and Drop Transformation Functions

See: Managing Channels - Message Transformation Functions

In the drag and drop transformation pane, several transformations are available to configure your transformation proces.

The message transformation configuration is explained in the Transformation chapter. This topic lists all available functions.

Once you have added a transformation function, drag required node(s) to the newly added transformation function in the order they are going to be used by the selected function, then map the function node to the desired output node.

Transformation functions

Figure 2.28. Transformation functions


Constant String

A Constant String, as it names implies, allows you to create a string of characters that can be used elsewhere in your mapping either alone or combined with other items. You can further format this string using Format String function described hereunder. As illustrated, this function requires a Name, an optional Description and the constant string Value.

Constant string

Figure 2.29. Constant string


Constant Number

A Constant Number, as it names implies, allows you to create a number that can be used elsewhere in your mapping either alone or combined with other items. You can further format this number using Format Number function described hereunder. As illustrated, this function requires a Name, an optional Description and the constant number Value.

Constant number

Figure 2.30. Constant number


Current Date/Time

The Current Date/Time function, as it names implies, allows you to retrieve the current complete date (including time) and to use elsewhere in your mapping either alone or combined with other items. You can further format this date using Format Date function described hereunder. As illustrated, this function requires only a Name and an optional Description.

Current Date/Time

Figure 2.31. Current Date/Time


Custom Xpath expression

The Custom Xpath expression function allows you to define your own Xpath expression. For more information about Xpath syntax, see Xpath in External References chapter in appendix.

You can drag and drop any number of element on this custom function. In the order they are dropped, each element is binded to an argument $argN. $arg1 for the first, $arg2 for the second... You can use these argument in the Xpath expression.

Example 2.1. 

string-length($arg1)
concat($arg1,' - ',$arg2)
metadata-util:put($MSG,'com_babelway_messaging_context_message_reference', bfn:concat('YOUR_PREFIX', 'YOUR_SEPARATOR', 'YOUR_SUFFIX', metadata-util:get($MSG,'com_babelway_messaging_context_message_reference'), $arg1))
metadata-util:getAsBase64($MSG, 'attachment:Invoice.pdf')

You can also use the special argument $ARGS which correspond to the sequence of elements dropped, ie.: $ARGS = ($arg1, $arg2, $arg3, ..., $argN)

Example 2.2. 

(max($ARGS) - min($ARGS)) div 2
concat($ARGS)

This function requires a Name, an optional Description and the Xpath expression including one or more arguments if required.

Custom Xpath expression

Figure 2.32. Custom Xpath expression


By default, if the xpath expression use number values, the resulting number has only eleven significant digits. If you need more significant digits, you can either use the Big Number Xpath expression or you can explicitly cast the arguments using xs:decimal($arg1).

Note that all transformation functions can be replaced directly by their Xpath expression. All other functions are available for easy and quick message transformation, while Xpath expression allows for more specific or more complex operations.

Babelway is providing a set of useful predefined xpath functions. These are functions accessible through the right menu but they could also be used in more complexe xpath expression. Here is the list of available functions:

date-util:currentDate()

same as Current Date function

date-util:formatDate('date', 'formatIn', 'formatOut')

same as Format Date function

date-util:formatDateLenient('date', 'formatIn', 'formatOut', true)

same as Format Date function, except that it allows to use a loose date parsing. For instance Apr 31 will be parsed as May 1st.

hash-util:hashMD5('toHash')

return the MD5 hash for the string argument.

hash-util:hashSHA1('toHash')

return the SHA1 hash for the string argument.

hash-util:hashSHA256('toHash')

return the SHA256 hash for the string argument.

hash-util:hashSHA512('toHash')

return the SHA512 hash for the string argument.

String lookup:addLookupTableEntry(String lookupTableId, String[] cols)

same as addLookupTableEntry in context menu

String lookup:addLookupTableEntry(String lookupTableId,String colNameIn, String[] cols)

same as addLookupTableEntry in context menu

String lookup:sharedLookupTableValue(String tableShareKey, int colIndexIn, int colIndexOut, String whenNoResult, String defaultValue, String key)

same as sharedLookupTableValue in context menu

String lookup:sharedLookupTableValue(String tableShareKey, int colIndexIn, int colIndexOut, String whenNoResult, String defaultValue, String key, boolean subStringQuery)

same as sharedLookupTableValue in context menu

String lookup:sharedLookupTableValue(String tableShareKey, int colIndexIn, int colIndexOut, String whenNoResult, String defaultValue, String key, boolean subStringQuery, boolean messageCache)

same as sharedLookupTableValue in context menu

String lookup:lookupTableValue(String tableid, String colNameIn, String colNameOut, String whenNoResult, String defaultValue, String key)

same as lookupTableValue in context menu

String lookup:lookupTableValue(String tableid, String colNameIn, String colNameOut, String whenNoResult, String defaultValue, String key, boolean subStringQuery)

same as lookupTableValue in context menu

String lookup:lookupTableValue(String tableid, String colNameIn, String colNameOut, String whenNoResult, String defaultValue, String key, boolean subStringQuery, boolean messageCache)

same as lookupTableValue in context menu

int metadata-util:counter(String key)

return a auto incrementing number

String metadata-util:get(String key)

return the metadata with this name

void metadata-util:put(String key, String value)

add a metadata with the given name and value

String metadata-util:getAsBase64(String key)

return the metadatavalue encoded as Base64

String metadata-util:encodeBase64(Object value)

return an object encoded as Base64

byte[] metadata-util:decodeBase64(Object value)

return an object decoded as Base64

String metadata-util:replace(String key)

return replace metadata in the given string

String number-util:formatNumber(Number number, String format)

same as formatNumber in context menu

String number-util:formatNumber(String number, String formatIn, String formatOut)

same as formatNumber in context menu

String string-util:paddingString(String str, int strSize, String padding, String align)

same as paddingString in context menu

String string-util:unescapeXml(String aText)

return this string unescaped from the xml encoding

String string-util:unescapeHtml(String aText)

return this string unescaped from the html encoding

String string-util:unescapeFilenane(String aText)

return this string unescaped from the filename encoding

String string-util:escapeXml(String aText)

return this string escaped with the xml encoding

String string-util:escapeHtml(String aText)

return this string escaped with the html encoding

String string-util:escapeFilenane(String aText)

return this string escaped with the filename encoding

void validate:assertTrue(boolean assertion, String message)

raise an error if the assertion is not true

void validate:assertFalse(boolean assertion, String message)

raise an error if the assertion is not false

boolean validate:validateDate(String date, String formatIn)

return true if the assertion is true

boolean validate:validateDateLenient(String date, String formatIn, boolean lenient)

return true if date is valid

void validate:assertDateValid(String date, String formatIn, String formatOut, String message)

return true if date is valid

void validate:assertDateValid(String date, String formatIn, String formatOut, String message, boolean lenient)

return true if date is valid

String enrich:getMessageIn(String uuid)

return the content of the message in corresponding to the message key uuid

String enrich:getMessageIn(String uuid boolean ignoreMissing)

return the content of the message in corresponding to the message key uuid

String enrich:getMessageIn(String uuid, boolean omitXmlDeclaration, boolean ignoreMissing)

return the content of the message in corresponding to the message key uuid

String enrich:enrich:getXmlIn(String uuid)

return the content of the message xml in corresponding to the message key uuid

String enrich:enrich:getXmlIn(String uuid, boolean omitXmlDeclaration)

return the content of the message xml in corresponding to the message key uuid

String enrich:enrich:getXmlIn(String uuid, boolean omitXmlDeclaration, boolean ignoreMissing)

return the content of the message xml in corresponding to the message key uuid

String enrich:enrich:getXmlOut(String uuid)

return the content of the message xml out corresponding to the message key uuid

String enrich:enrich:getXmlOut(String uuid, boolean omitXmlDeclaration)

return the content of the message xml out corresponding to the message key uuid

String enrich:enrich:getXmlOut(String uuid, boolean omitXmlDeclaration, boolean ignoreMissing)

return the content of the message xml out corresponding to the message key uuid

String enrich:getMessageOut(String uuid)

return the content of the message out corresponding to the message key uuid

String enrich:getMessageOut(String uuid, boolean omitXmlDeclaration)

return the content of the message out corresponding to the message key uuid

String enrich:getMessageOut(String uuid, boolean omitXmlDeclaration, boolean ignoreMissing)

return the content of the message out corresponding to the message key uuid

String bfn:concat(String prefix, String separator, String suffix, String list)

return the concatenaition using prefix, suffix and separator

String bfn:substring(String str , String from, String to)

return substring

String bfn:replace(String str , String searchStr, String replaceStr, String ignoreCase)

return replace

loop bfn:sort(loop, String sort-key)

return the same loop of elements but sorted using the sort-key

loop bfn:sort-case-insensitive(loop, String sort-key)

return the same loop of elements but sorted using the sort-key case insensitive

loop bfn:sort-as-numeric(loop, String sort-key)

return the same loop of elements but sorted using the sort-key numeric

String bfn:newline()

return a new line

xmlNode searchMessage(String createdFrom)

search the message records and creates an xml as the result. This xml can optionally contain the actual content of the messages.

Request example:

enrich:searchMessage('2012-01-30T00:00:00')

result:


<?xml version="1.0" encoding="UTF-8"?>
<messages>
  <message id="9999999" key="7b65d710-ef9b-9999-83ad-deef8b47aaae">
    <record>
      <channelId>99999</channelId>
      <errorDescription>Message is not equal to metadata : {metadataName}
      </errorDescription>
      <gatewayInId>99999</gatewayInId>
      <gatewayInMessageKey>7b65d710-ef9b-4718-83ad-deef8b47aaae
      </gatewayInMessageKey>
      <gatewayInMessageStatus>Related to message
      6e57d755-9cf1-9999-a94c-0b7ede2a9869 </gatewayInMessageStatus>
      <gatewayInTimestamp>2012-01-29T09:07:48</gatewayInTimestamp>
      <gatewayOutTimestamp>2012-01-29T09:07:49</gatewayOutTimestamp>
      <hubId>999999</hubId>
      <id>999999</id>
      <inSize>17257</inSize>
      <messageFormatFileNameIn>2549518.edi</messageFormatFileNameIn>
      <messageFormatFileNameOut>2549518.edi</messageFormatFileNameOut>
      <messageFormatInHash>93f112bdb52b33e...</messageFormatInHash>
      <messageFormatInSignHash>3f20f88...</messageFormatInSignHash>
      <messageFormatOutHash>826c6ad23da17...</messageFormatOutHash>
      <messageFormatOutSignHash>984cc...</messageFormatOutSignHash>
      <messageFormatToXmlTimestamp>2012-01-29T09:07:48
      </messageFormatToXmlTimestamp>
      <messageKey>7b65d710-ef9b-4718-83ad-deef8b47aaae</messageKey>
      <messageReference>25495189.edi</messageReference>
      <outSize>5817</outSize>
      <parentMessageId>5741867</parentMessageId>
      <receiveTimestamp>2012-01-29T09:07:48</receiveTimestamp>
      <status>DONE</status>
      <type>REGULAR</type>
      <xmlInSize>17257</xmlInSize>
      <xmlOutSize>10924</xmlOutSize>
      <xmlToMessageFormatElapse>22</xmlToMessageFormatElapse>
      <xmlToMessageFormatTimestamp>2012-01-29T09:07:49
      </xmlToMessageFormatTimestamp>
      <xmlToXmlElapse>7</xmlToXmlElapse>
      <xmlToXmlTimestamp>2012-01-29T09:07:48</xmlToXmlTimestamp>
    </record>
  </message>
  <message id="9999999" key="7b65d710-ef9b-9999-83ad-deef8b47aaae"> 
  ...   
  </message>   
</messages>

					

xmlNode searchMessage(String createdFrom, String createdTo)

same as searchMessage with default values

xmlNode searchMessage(String createdFrom, String createdTo, String status)

same as searchMessage with default values

status possible values : IN_PROGRESS, WAITING_ACK, DONE, ERROR

xmlNode searchMessage(String createdFrom, String createdTo, String status, String messageMultiKeys)

same as searchMessage with default values

xmlNode searchMessage(String createdFrom, String createdTo, String status, String messageMultiKeys, String messageRef)

same as searchMessage with default values

xmlNode searchMessage(String createdFrom, String createdTo, String status, String messageMultiKeys, String messageRef, String channelName)

same as searchMessage with default values

xmlNode searchMessage(String createdFrom, String createdTo, String status, String messageMultiKeys, String messageRef, String channelName, String errorDesc, String fileName, String fromName, String toName, String maxSize, String minSize, String maxResults, String order, String type, String hash)

same as searchMessage with default values

type possible values : TEST, REGULAR

xmlNode searchMessage(String createdFrom, String createdTo, String status, String messageMultiKeys, String messageRef, String channelName, String errorDesc, String fileName, String fromName, String toName, String maxSize, String minSize, String maxResults, String order, String type, String hash, String messageInPayloadType, String xmlInPayloadType, String xmlOutPayloadType, String messageOutPayloadType,String contextPayloadType)

same as searchMessage with default values

PayloadType allow to specify if the content of the message must be included in the output. Default is NONE.

payloadType possible values : NONE, XML, Base64

Big Number Xpath expression

The Big Number Xpath expression function as the same purpose as the Custom Xpath Expression except that it is meant to only accpet numbers as arguments and only return a number. All arguments are treated as big numbers allowing calculation requiring more than eleven significant digits.

This function requires a Name, an optional Description and the Xpath expression including one or more arguments if required (see Custom Xpath expression for more information about arguments).

Big Number Xpath expression

Figure 2.33. Big Number Xpath expression


Format Number

The Format Number function allows you to format any number according to your specific needs. A short description of available symbols is given in the dialog box as illustrated. This function requires a Name, an optional Description, an optional Source Format and a Target Format.

Example 2.3. 

For example, 1234 will be displayed as "01234.00" using a "00000.00" format or as "1,234.0" using a "#,###.0" format.


Format Number

Figure 2.34. Format Number


Format String

The Format String function allows you to format any string of character according to your specific needs. This function requires a Name, an optional Description, and three format parameters: Size to define the string length, Padding Character to define the character used to fill empty spaces and Align to define where the original string is aligned ( Left with padding characters added right, Right with padding characters added left or Center with padding characters distributed on both sides).

Format String

Figure 2.35. Format String


Format Date

The Format Date function allows you to format any date and time according to your specific needs. A short description of available symbols is given in the dialog box as illustrated. This function requires a Name, an optional Description, an optional Date format In and a Date Format out.

Example 2.4. 

For example, a date will be displayed as "15-Sep-2009" using a " dd-MMM-yyyy" format or as "2009-09-15" using a "yyyyy-MM-dd" format.


Format Date

Figure 2.36. Format Date


Arithmetic Operations

All arithmetic operations, allows you to arithmetically combine two arguments. As illustrated, these functions require only a Name and an optional Description.

  • Add(+) function returns the sum of both numbers entered as arguments.

  • Multiply(*) function returns the product of both numbers entered as arguments.

  • Minus(-) function returns the difference of both numbers entered as arguments.

  • Div function returns the integer part of the division of both numbers entered as arguments.

  • Mod function returns the reminder of the division of both numbers entered as arguments.

Arithmetical operation

Figure 2.37. Arithmetical operation


Concat

The Concat function allows you to concatenate together two strings to form a new one. You can also add additional characters before, between and/or after both concatenated strings. As illustrated, this function requires a Name, an optional Description, and three optional format parameters to define additional characters to be added in front of ( Prefix ) and behind ( Suffix ) the concatenated string and between ( Separator ) both original strings.

Concat

Figure 2.38. Concat


Replace

The Replace function allows you to replace, inside a string, a defined pattern by another one. As illustrated, this function requires a Name, an optional Description, a Search Pattern defining the character or string to be searched and replaced and a Replace Pattern defining the new character or string that will replace the found one inside the string. If Ignore case? is checked, the search will be case insensitive.

Replace

Figure 2.39. Replace


Substring

The Substring function returns a substring of the attached argument starting at the position specified in the From field and ending at the position specified in To field. As illustrated, this function requires a Name, an optional Description, a From defining the character starting position,and To defining the character ending position.

Substring

Figure 2.40. Substring


Lookup Table - Lookup Table

The Lookup Table function allows you to replace an item with the matching item from a lookup table. To use this function, first you select a lookup table in Table name drop down list. Then you select In column, this is the column where the item will be searched for. If a match is found, the value in selected Out column will be returned. In and Out are fields are selected from lookup table available columns. If no match is found, the result will depends on the When no result setup ( Default value will return the value defined in the following Default value field, Same value will return as output the incoming value, Raise Error will return an error in such a case). As illustrated, this function also requires a Name and an optional Description.

Lookup table

Figure 2.41. Lookup table


Lookup Table - Shared Lookup Table

The use of a shared lookup table is the same as a standard lookup table but for its name that is replaces by its Access Key (automatically defined when lookup table is defined as shared) and In and Out that are respectively replaced by Column index of the source and Column index of the destination.

Shared lookup table

Figure 2.42. Shared lookup table


Lookup Table - Add Lookup Table Entry

You can add an new entry in your lookup table using this transformation function. As illustrated, this function requires a Name, an optional Description, Table name, Replace based on column

A compléter

Add lookup table entry

Figure 2.43. Add lookup table entry


Lookup Table - Lookup Table Increment Value

The transformation function “Lookup Table Increment Value” is used to increase a lookup table value by 1. It could be used to implement a persistent counter. As illustrated, this function requires a Name, an optional Description, Table name, In and Out column

A compléter

Increment value

Figure 2.44. Increment value