Rule API
Note
The rule definition relies on NRules and follows its DSL syntax. Refer to NRules for more details.
JobFlow adds a handful of additional helper methods to the already existing NRules DSL API. Please refer to NRules Documentation for more information on its complete API.
This is a quick overview of the API methods that JobFlow adds.
When() Conditions
These are the API methods provided for Matching conditions within NRules.
See LeftHandSideExtensions for more information.
Common
All JobFlow Entities (Job, WorkItem, Flow, etc.) have a corresponding Matcher object, which allows for refining the matching conditions for the Rule.
Every Matcher shares the folowing methods:
Match(params Expression<Func<T, bool>>[] expressions)
- Allows specifying any number of boolean Expression that will match against the respective entity object.
Job
HaveJob(matcher => { })
- HaveJob allows matching against any Job entity. This could be the completed job from the previously executed Flow step, or it could be any new Jobs created by previously executed Rules.
The Job Matcher provides the following methods:
WithNames(params string[] names)
- Match against any of the provides Job names.
IsStart()
- Utility method to match against the Start Job.
WithStatus(JobStatus jobStatus)
- Match against a particular Job status. This is useful for matching against newly created Jobs only, for example (
JobStatus.Created
).
JobResponse
HaveResponse(matcher => { })
- Match against a Job Response object - the return data from the previously executed Job.
The JobResponse Matcher provides the following methods:
WithStatus(JobResponseStatus jobResultStatus)
- Match against a response with the given status.
Document
HaveDocument(matcher => { })
- Match against the document.
The document matcher does not provide any additiona methods, though the WithConditions
commmon to all Matchers is available.
This would be used to match against any data provided with the original Work Item data. For example:
When().HaveDocument(_ => _.WithConditions(_ => _.Data.Order.Total > 1000));
This would execute the rule if the total of the Order provided is greater than 100. In this case the Order is part of the data orignally provided for the Work Item.
Then() Actions
StartJob( //..// )
JobFlow provides various methods for starting the new Job in the Flow.