Best Practices for Configuring Groovy Scripts for Link Requests
In this topic we discuss the best practices for configuring groovy scripts.
- If you configure your implementation to use Groovy Scripts for linking, your duplicate resolution requests aren’t processed until a valid link management script has been deployed.
- Link request processing may handle very large volumes of records, so groovy scripts should be as fast and efficient as possible. Avoid using newView() functions and web service calls unless absolutely necessary; and if necessary, assure that these types of operations will be fast and reliable.
Overview of Groovy Scripting Functions
- Functions that let you inspect the records in the link requests
- Functions that let you define the result of the link request
These categories of specialized functions help you to process link requests using standard Groovy Script syntax and operations.
Input Functions
These functions provide the data that your logic evaluates. Generally, these functions are called at the beginning of your script to instantiate the information required to determine the proper link process outputs.
getObjectType()
This function lets you determine what type of party the link request is processing. This function returns PERSON or ORGANIZATION depending on which type of script calls it. It's generally not necessary to programmatically determine the object type because the scripts for Persons and Organizations are clearly differentiated as distinct functions within the Application Composer Data Quality Rules task. But there may be cases where it's helpful for logging or testing.
getMaster()
Copy
def rowMaster = getMaster();
def masterName = rowMaster.getAttribute("OrganizationName");
// etc...
getNonMasters()
This function lets you access the set of data records that have been identified as
the non-master records for the link request. This function is called without
parameters and it returns a list of row objects consisting of one list entry for
each non-master record. It's important to note that the
getNonMasters
list isn't an ADF recordset
object
. ADF recordset functions
such as reset() and
first() don't work with the list. The following example shows a typical usage of
this function:
Copy
getNonMasters()
def rowNonMasters = getNonMasters();
def nonmasterName;
for (nonmaster in rowNonMasters) {
nonmasterName = nonmaster.getAttribute("OrganizationName"); }
// etc...
getRows()
This function lets you access the full set of customer records for the link request,
which is the union of the master and non-master sets of rows. This function is
called without parameters and it returns a list of row objects consisting of one
list entry for each non-master record. Like the getNonMasters
function, it's important to note that the getRows
list isn't an
ADF recordset object
. ADF recordset functions
such as reset() and first() don't work with the list. The following example shows a
typical usage of this function:
Copy
def rowDuplicates = getRows()
def duplicateName;
for (duplicate in rowDuplicates) {
duplicateName = duplicate.getAttribute("OrganizationName"); }
// etc...
getSourceInfo(Row row,String attributeName)
This function lets you access information about which source system provided the current value of an attribute for a given master or non-master row. This function is called using the following parameters:
- A row object for the non-master or master row of interest
- The name of a source-confidence configured attribute
This function returns a source information record for the attribute in question. The structure of the source information record is as follows:
Attribute | Definition | Example |
---|---|---|
RecordId |
The party ID of the person or organization record referenced by the row object parameter. | 300100184760397 |
AttributeName |
The name of the attribute parameter. | OrganizationName |
AttributeValue |
The current value of the attribute on the row. | Pinnacle Systems |
Source |
The code of the registered source system for the attribute value. | RNOW |
SourceConfidenceLevel |
The configured attribute source confidence value of the given attribute for the given source system. | 90 |
SourceUpdateDate |
The time stamp when the person or organization record was updated with the current value. | 1/24/2020 11:48:03 PM |
Copy
def rowDuplicates = getRows();
def rowSource;
def bestSource;
def bestValue;
bestSource = getSourceInfo(rowDuplicates[0],"OrganizationName");
for (row in rowDuplicates) {
rowSource = getSourceInfo(row,"OrganizationName");
if(rowSource.SourceConfidenceLevel > bestSource.SourceConfidenceLevel) {
bestSource = rowSource;
}
}
bestValue = bestSource.AttributeValue;
Output Functions
Output functions create the final behavior of the based on the logic of a link process script. Generally, these functions are called at the end of the script after the data provided by the input functions has been evaluated with scripted logic.
selectMaster(Row row)
Copy
...
def masterRow = rowDuplicates[0];
for (row in rowDuplicates) {
if row.LastUpdateDate > masterRow.LastUpdateDate {
masterRow = row;
}
}
selectMaster(masterRow);
Evaluating the Data
Once you have called the appropriate functions, your script needs to evaluate the data to determine the correct link result. This evaluation process uses standard Groovy Script operators and functions. For more information about Groovy scripts, see the Oracle Applications Cloud Groovy Scripting Reference guide.
Putting It Together
- Call Input Functions
- Evaluate the Data
- Call Output Functions
Copy
/* Input Functions: call getRows() to initialize a list of the party records in the merge request and then
define a variable to designate the Master record and set it to the first record in the list of Rows */
def rowDuplicates = getRows();
def masterRow = rowDuplicates[0];
/* Evaluate the Data: iterate through the list of records to determine if the current list item
was more recently updated than whatever record has been designated the master. If the current record was more recently updated,
promote it to become the new Master */
for (row in rowDuplicates) {
if (row.LastUpdateDate > masterRow.LastUpdateDate) {
masterRow = row;
}
}
/* Call Output Functions: use the selectMaster() function to dictate which record from the merge set
should become the master */
selectMaster(masterRow);