Class RulePlugin

java.lang.Object
org.imixs.workflow.engine.plugins.AbstractPlugin
org.imixs.workflow.engine.plugins.RulePlugin
All Implemented Interfaces:
Plugin

public class RulePlugin extends AbstractPlugin
The Imixs Rule Plugin evaluates a business rule provided by the current ActiviyEntity. A business rule can be written in any script language supported by the JVM. The Script Language is defined by the property 'txtBusinessRuleEngine' from the current Event element. The script is defined by the property 'txtBusinessRule'. The Script can access all basic item values from the current workItem and also the event by the provided JSON objects 'workitem' and 'event'. // test first value of the workitem attribute 'txtname' var isValid = ('Anna'==workitem.txtname[0]); A script can add new values for the current workitem by providing the JSON object 'result'. var result={ someitem:'Hello World', somenumber:1}; Also change values of the event object can be made by the script. These changes will be reflected back for further processing. // disable mail event.keymailenabled='0'; A script can set the variables 'isValid' and 'followUp' to validate a workItem or set a new followUp activity. result={ isValid:false }; If the script set the variable 'isValid' to false then the plugin throws a PluginExcpetion. The Plugin evaluates the variables 'errorCode' and errorMessage. If these variables are set by the Script then the PluginException will be updates with the corresponding errorCode and the 'errorMessage' as params[]. If no errorCode is set then the errorCode of the PluginException will default to 'VALIDATION_ERROR'. If the script set the variable 'followUp' the follow-up behavior of the current ActivityEntity will be updated. If a script can not be evaluated by the scriptEngin a PluginExcpetion with the errorCode 'INVALID_SCRIPT' will be thrown. NOTE: all variable names are case sensitive! All JSON object elements are lower case!
Version:
3.0
Author:
Ralph Soika
  • Field Details

  • Constructor Details

    • RulePlugin

      public RulePlugin()
  • Method Details

    • run

      public ItemCollection run(ItemCollection workitem, ItemCollection event) throws PluginException
      The run method evaluates a script provided by an activityEntity with the specified scriptEngine. After successful evaluation the method verifies the object value 'isValid'. If isValid is false then the method throws a PluginException. In addition the method evaluates the object values 'errorCode' and 'errorMessage' which will be part of the PluginException. If 'isValid' is true or undefined the method evaluates the object value 'followUp'. If a followUp value is defined by the script the method update the model follow up definition. If a script changes properties of the activity entity the method will evaluate these changes and update the ItemCollection for further processing.
      Parameters:
      workitem - the workitem to be processed
      event - the workflow event containing the processing instructions
      Returns:
      updated workitem for further processing
      Throws:
      PluginException