Custom Java Activities in a workflow

Custom Java Activities in a workflow

book

Article ID: KB0082306

calendar_today

Updated On:

Products Versions
TIBCO MDM ALL Versions

Description

How to configure the workflow files to use a custom java activity,In this scenario we will merge the custom java classes into ECMClasses.jar file to achieve required validations which is not feasible through our normal rulebases.

Issue/Introduction

How to configure the workflow files to use a custom java activity by merging into ECMClasses.jar file

Environment

All

Resolution

 

1) Created a custom java file as below based on required use case and compiled that file to create  .class file.

2) After that the .class file has been merged under lib/ECMClasses.jar/com/tibco/mdm/workflow/engine/activities in the ECM.ear file.

3)In Addition to this,edited the addrecord workflow and added required activity and transitions as per use case.

 

4) Added below check action to verify whether the company name is valid or not

 

<Activity Name="ValidateValues">

<Action>Check</Action>

<Description lang="en">Check if company number is valid</Description>

<Parameter direction="in" name="InDocument" type="document" eval="variable">workDoc</Parameter>

<Parameter direction="in" name="companyNbr" eval="xpath" type="string" source="//CatalogItem/ItemData/Attribute[@name='COMPANY_NUMBER']/Value/text()">workDoc</Parameter>

<Parameter direction="out" name="result" eval="variable" type="string">result</Parameter>

</Activity>

 

5) Changed the transitions based on the requirement by adding ValidateValues activity in the workflow.

 

<Transition FromActivity="GetItemData" ToActivity="ValidateValues"/>

  

<Transition FromActivity="ValidateValues" ToActivity="SetStatusToError">

<Description lang="en">Result of ValidateValues is compared to string "INVALID Values".</Description>

<Rule>

<Parameter direction="in" name="status" type="string" eval="variable">result</Parameter>

<Parameter direction="in" name="inputParamString" eval="constant" type="string">INVALID Input</Parameter>

<Parameter name="result" type="boolean" direction="out"/>

<Condition format="java"><![CDATA[

com.tibco.mdm.workflow.engine.transition.WfSharedConditionTransition.equalsIgnoreCase(status, inputParamString);]]>

</Condition>

</Rule>

</Transition>

  

<Transition FromActivity="ValidateValues" ToActivity="CompareRecord"/>

 

6)By saving above modifications restarted the MDM instance to reflect the changes.

7) To Test the custom workflow activity and modifications configured in the workflow,Consider the scenario as  a record containing an invalid company number.

8) The number must be 9 digits long consisting only of numeric characters and some other logical conditions.

9)After that we can verify the event status in event log whether it is success or error based on the input validations.

Additional Information

Custom Java Activities,Rulebases,Workflow