Implementing Custom Java Function with Save Record Activity to Create 'N' number of records in unrelated repository with single workflow
book
Article ID: KB0072589
calendar_today
Updated On:
Products
Versions
TIBCO MDM
9.0.1
Description
Consider we have two repositories product and price as separate(No relationship between them) in an enterprise.
Example scenario: As a part of workflow, the product record gets configured in the product repository with its other relationships. As a part of the same workflow, price records should get created in the price repository. For a particular product there can be 'N' number of prices. To achieve the above requirement we have implemented a custom Java function with Save Record Activity.
Environment
All
Resolution
Below are the steps we have followed to implement the mentioned requirement. 1). Created CUSTOM Java Function that will take input as Starting character for the product ids that need to be created and a number of records that need to be created.
2). Find the snippet below for the RuleBase function and custom Java function.
<constraint> <name>FetchArray</name> <description>Generate Productids based on the input and counter</description> <action> <assign> <var>arrayDerivedIDs</var> <op func="returnIncrCount"> <const type="string">PRICEID_</const> <const type="number">10</const> </op> </assign> </action> </constraint>
3). The above constraint will pass “PRICEID_” and number of price id to be created to our custom Java function.
for (int i=1;i<=cntr;i++) { retValue.add(str1+"_"+i); }
return retValue;
// System.out.println("Returning for value:" + retValue);
//return(retValue);
//MqLog.log(this,MqLog.INFO,"returnAttributeValue: Number of arguments: " + argList.size());
} catch (Exception ex) { System.out.println("EXCEPTION IN CUSTOM FUNCTION BEGIN "); System.out.println(ex); ex.printStackTrace(); System.out.println("EXCEPTION IN CUSTOM FUNCTION END "); }
return (null); } }
4), Compile this Java code by adding “AllECMClasses.jar, ECMClasses.jar and Log4j.x.jar “ in the Classpath parameter.
5). Modify / Customize out of box workflow to call this Rulebase in the workflow. Updated out of the box by including the following three activities.