One Star

Best practice for implementing business rules

Hi there,
I have an import process I am designing, that has a number of business rules that need to be evaluated.
Some of these rules have nothing to do with the data, in that the person sending it needs to be verified that they have the appropriate account type and etc...  
So to do this validation I thought I would create a child job that could be called by a number of the different import jobs.  This job will get some context parameters passed to it, one of which will be the user id.
The validation job will then look up the user and perform a number of checks on their record.
What I want to do is if one of these checks fails, write a record to the error log table, and then kill the job and it's parent jobs.
So I thought the best approach would be to use a tMysqlInput to get the user record, and then connect that to number of tAsserts each with a different check and error message.
I have another job: LogError, that I have created to write a record in the error database table, it requires a number of values to be passed in to it.
 - Operation ID
 - User ID
 - Message
 - Category
 - DieOnError
At the moment I have these as context variables that can get passed in by the parent job.
However I can't see a way to take action when a tAssert fails.  I have seen the tAssertCatcher, but the only way I have seen to be able to take action a tAssert fails is to  send the output of tAssertCatcher into a tFilterRow, and filter out all successes (where status field does not equal "Ok"), then run the child job from there.
Is there a better solution?
Like what I really want to do is say:
Parent Job runs Child Job passing in Operation ID and User ID via context variables.  
Child job looks up user record, performs three checks on the data in that record, and: 
   IF: one of them fails it runs ErrorLog job passing it the Operation ID, User ID, Message related to that check, Category and DieOnEror values via context variables, which logs the error in the db and then Dies and all parent jobs die as a result.
   ELSE: child job returns some data about the user to the parent job.
What is the best approach to doing this?
Regards,
Scott
1 REPLY
Community Manager

Re: Best practice for implementing business rules

Hi Scott
You can perform the checks and put the result to a global variable (boolean type), and trigger other business processing with runIf link, set the condition expression like:
(Boolean)globalMap.get("isFailed")  
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business