The Java Mapper accesses the lookup tables, when running in Rhapsody, using a callback API that talks to the Lookup Table service in Rhapsody. The tables are accessible in the Map Designer through the Mapper Debugger, which performs the lookup using the Rhapsody Remote Monitoring API, which in turn exposes access to the Lookup Table service.
A native function in the Mapper, RhapsodyTableLookup()
, appears in the Functions drop-down list if the Map Designer is launched from Rhapsody IDE. This function calls back into the Map Designer using the Mapper Debugging API. The Map Designer can then perform lookups. The Rhapsody engine, the username and password are provided to the Map Designer in the XML file used to launch it from Rhapsody IDE.
Do not use the following characters in the password: '&', '> ' and '<'. Doing so will result in the lookup failing.
The Java Mapper allows a callback object to be provided at construction, which allows the table lookups to be performed. The RhapsodyTableLookup()
function in the Java Mapper uses this callback whenever it is called.
The Mapper filter provides an implementation of the callback when a mapping definition is loaded. The callback implementation performs the lookups using the Lookup Table service.
When testing mappings that contain lookup calls, it is recommended for performance reasons you test them in a Rhapsody route rather than in Map Designer.
RhapsodyTableLookup() Function
The RhapsodyTableLookup()
function, in the Mapper API, provides access to the Lookup Table service in Rhapsody:
RhapsodyTableLookup(output, tableName, resultColumnName, defaultValue, queryColumn1, queryValue1, queryColumn2, queryValue2, ...)
Where:
output
- can be a string object or a path to a string field. It is set to the result of the lookup, if successful, or the default value, if no match is found.tableName
- is the name of the lookup table in Rhapsody. An error is raised if the specified lookup table cannot be found.resultColumnName
- is the name of the column that should be used for the result. An error is raised if the specified column is not found in the lookup table. If multiple columns are wanted in the results, then the function should be called multiple times.defaultValue
- is used if no match is found using the search criteria provided. If an empty string is passed in for the default value, and no match is found, an error is raised.
The function returns a boolean that is true if a match is found, or false if no match is found, when a default value is provided.
After these parameters, this function takes an additional two or more parameters, where each set of two parameters represents a column name and value that is used to find the matching row in the lookup table. At least two parameters must be provided, that is, one column name and one value used to match rows in that column. There is no upper limit on the number of parameters provided. A column name parameter without an associated value, at the end of the function, is ignored.
The query values can either be string objects or paths to string fields. If a field is missing or hl7-null (empty or null keywords), then the input is treated as an empty string.
You can only call this method in the following scenarios:
- From a Map Designer that has been launched from Rhapsody IDE for a Rhapsody engine that supports this functionality.
- From a Mapper filter in Rhapsody.
It is not available in the standalone Symphonia C++ and Java Mapper. An error is raised, without performing any operations, if called outside these scenarios.
Example
// The code below would be replaced with a Rhapsody table lookup: // Usage: RhapsodyTableLookup( Output Variable, // Lookup table name, // Column to extract the value from // Default value (if lookup fails) // First lookup column // First lookup value // Second lookup column // Second lookup value ); boolean result = RhapsodyTableLookup(out.CountryCode,"CountryCode_DB","CountryID","NOT_FOUND","CountryCode",in.CountryCode);