Functions
Extend the capabilities of custom checks by creating user-defined functions (UDFs) in iceDQ. UDFs offer the following benefits:
- Reusable code: Reuse UDFs across the workspace to save time and effort when implementing the same checks for different data sources.
- Custom functionality: Create and maintain a library of out-of-the-box checks specific to your domain.
- Increased efficiency: Implement complex transformation, conversion, lookup, and other checks not available out-of-the-box.
Components
There are two components in a (User Defined) Function: Overview, Code
Overview
User can can provide function alias name, select the type of language and more.
| Property | Description | Note |
|---|---|---|
| Function Alias | Name used in custom checks to trigger the actual function. | |
| Resource Type | ||
| Language | Use Java for both Java/ Groovy language | |
| Function Type | Use Custom for all UDFs | |
| Scope | Scope defines if the function can be used only in workspace or across the application. | Currently only local scope is supported. |
| Function Class Name | Choose the functional class name that will be triggered when the function is invoked. | |
| Parameters | Displays the function input parameter datatype | |
| Return Type | Displays the function return type |
Code
Users can provide the complete class and function code written in Java or Groovy, following these key points:
IMPORTANT
The CODE textbox is not an IDE. To debug complex code more easily, develop and test the code in an IDE.
- Always capitalize the class name in the code
- Create only one Java class
- Each class can have multiple functions
How To: Create a UDF
This video shows you how to create a user defined function.
How To: Invoke a UDF
This video shows you how to use a user defined function in a custom check.
Sample Code
Following is the code used in the above videos.
class MyDemoClassOne {
def static countryCheck(countrycode, countryname)
{
def mappedname = ""
switch ( countrycode ) {
case "US":
mappedname = "UNITED STATES"
break;
case "AUS":
mappedname = "AUSTRALIA"
break;
case "IND":
mappedname = "INDIA"
break;
default:
mappedname = "NA"
}
return (countryname.toUpperCase() == mappedname )
}
}
class MyDemoClass {
def static countryLookUp(countrycode)
{
def country = [US: 'UNITED STATES', AUS: 'AUSTRALIA', IND: 'INDIA']
def x = country.getAt(countrycode)
if(x)
return x
else
return countrycode
}
}