3.0 JavaScript API for Rules and Actions

From AlfrescoWiki

Jump to: navigation, search


Draft. Work in progress.

Contents

[edit] rules

This is a host object providing access to rules and related objects.

Array getRuleTypes() 
Get the rule types
Rule createRule(ScriptNode ruleNode, RuleType[] RuleTypes, Action action, Array properties) 
Create a rule
Rule getRule(ScriptNode ruleNode) 
Get the rule associated with the given rule node
Actiondefinition[] getAllActionDefinitions() 
Get all deployed action definitions
ActionDefinition getActionDefinition(string name) 
Get the action definition which has been deployed under the given name
ActionConditionDefinition[] getAllActionConditionDefinitions 
Get all deployed action condition definitions
ActionConditiondefintion getActionConditionDefintion(string name) 
Get the action condition definition deployed under the given name
Action createAction(String id, ScriptNode actionNode, string actionDefinitionName, ActionCondition[] actionConditions, Action compensatingAction, Array properties, Array parameterValues) 
Create an Action object.

[edit] Add to ScriptNode API

applyRule(Rule rule) 
Apply the given rule to the node. If the rule has already been applied to this node then it’s details will be updated.
removeRule(Rule rule) 
Remove the given rule from the node
removeAllRules() 
Remove all rules from the node
Rule[] getRules() 
Get the rules associated with the actionable node including those rules inherited from its parents
Rule[] getRules(boolean includeInherited) 
Get the rules associated with the actionable node, optionally including those rules inherited from its parents. The includeInherited parameter indicates whether rules inherited from the node's parents should be included in the returned array of rules.
Rule[] getRules(boolean includeInherited, string ruleTypeName) 
Get the rules assocated with the actionable node that are of the specified rule type. The includeInherited parameter indicates whether rules inherited from the node's parents (of the specified rule type) should also be included in the returned array of rules.
number countRules() 
Returns the number of rules associated with the actionable node
disableRules() 
Disable the rules applied to this node. When the rules are disabled they will not execute.
enablerules() 
Enable the rules applied to this node. When the rules are enabled they will execute a usual. By default all rules are enabled.
ActionDefinitions[] getActionDefinitions() 
Get all the action definitions that are applicable for the node
executeAction(Action action) 
execute the given action against the node. The action conditions are checked before executing the action. If the conditions do not all pass, then the action is not executed. Whether the action is executed synchronously or synchronously, depends on whether the executeAsychronously property on that action is set to true or false.
executeAction(Action action, boolean checkConditions) 
execute the given action against the node, optionally checking the action conditions. The checkConditions parameter indicates whether or not to check the action conditions. If checkConditions is set to true and the conditions do not all pass, then the action is not executed. Whether the action is executed synchronously or synchronously, depends on whether the executeAsychronously property on that action is set to true or false.
boolean executeAction(Action action, boolean checkConditions, boolean executeAsynchronously) 
execute the given action against the node, optionally checking the action conditions. The checkConditions parameter indicates whether or not to check the action conditions. If checkConditions is set to true and the conditions do not all pass, then the action is not executed. Whether the action is executed synchronously or synchronously, depends on whether the executeAsychronously parameter is set to true or false. The value given for the executeAsychronously parameter overrides the value for the property of the given action.
boolean evaluateActionConditions(Action action) 
Evaluate if the action conditions for the given action pass when applied to the node.
boolean evaluateActionCondition(ActionCondition actionCondition) 
Evaluate if the given action condition passes when applied to the node.
applyAction(Action action) 
Apply the given action to the node. If the action has already been applied to this node then it’s details will be updated.
Action[] getActions() 
Get actions applied to this node.
Action getAction(string actionId) 
gets an action applied to this node by the given action id.
removeAction(Action action) 
Remove the given action from this node.
removeAllActions() 
Remove all actions from this node.

[edit] Rule

ScriptNode ruleNode 
the node that represents this rule.
string title 
The title of the rule.
string description 
The description of the rule.
RuleType[] ruleTypes 
The rule types associated with this rule;
Action action 
The action associated with this rule;
boolean executeAsynchronously 
Indicates whether the rule should execute the action asynchronously or not.
boolean ruleDisabled 
Indicates whether or not this rule is marked as disabled or not.
boolean isAppliedToChildren 
Indicates whether the rule is applied to all the children of the associated (actionable) node (rather than just the node itself).
ScriptNode getOwningNode() 
 ??? TODO Gets the node to which the rule has been applied ???
enable() 
Enables a rule (if it has previously been disabled)
disable() 
Disables a rule, preventing it from being fired
boolean hasRules() 
Indicates whether the actionable node has any rules associated with it (this includes any rules inherited from its parents) : ??? TODO Do I want to include the option of NOT including rules from its parents. ???

[edit] RuleType

string name 
The name of the rule type.
string displayLabel 
The display label of the rule type.
trigger(ScriptNode actionableNode, ScriptNode actionedUponNode, boolean executeRuleImmediately) 
Trigger the rules of this rule type (found on the specified actionable node) on the specified actioned upon Node. The executeRuleImmediately parameter indicates whether the rule should be executed immediately or not.

[edit] Action

string id 
Unique identifier for the action.
ScriptNode actionNode 
the node that represents the action
string actionDefinitionName 
The name of the action definition that relates to this action
string title
The title of the action
string description
The description of the action
boolean executeAsynchronously 
Indicates whether to run the action asynchronously or not.
Action compensatingAction 
Action which is executed if the action failure behaviour is to compensate and the action fails to execute.
ActionConditions[] actionConditions 
The action conditions set for this action
Array parameterValues 
Associative array (map) of parameter values.

[edit] ActionCondition

string id 
Unique identifier for this action condition object.
Array parameterValues 
An associative array (map) of parameter values for the action condition.
string actionConditionDefinitionName 
The action condition definition name for the action condition.
invertCondition 
Indicates whether the condition result should be inverted. The inversion is achieved by applying the NOT logical operator to the result. The default value is false.

[edit] ActionDefinition

string[] applicableTypes 
Array of types (from the content model) that this action definition is applicable for.
string name 
The name of this action definition.
string title 
The title of this action definition.
string description 
The description of this action definition.
boolean adhocPropertiesAllowed 
Indicates whether this action definition allows adhoc properties to be set.
boolean hasParameterDefinitions 
Indicates whether this action definition has any parameter definitions set.
ParameterDefinition[] parameterDefinitions 
An array of parameter definitions for this action definition.

[edit] ActionConditionDefinition

string name 
The name of this action definition.
string title 
The title of this action definition.
string description 
The description of this action definition.
boolean adhocPropertiesAllowed 
Indicates whether this action definition allows adhoc properties to be set.
boolean hasParameterDefinitions 
Indicates whether this action definition has any parameter definitions set.
ParameterDefinition[] parameterDefinitions 
An array of parameter definitions for this action definition.

[edit] Parameter Definition

string name 
The name of the parameter. This is unique and is used to identify the parameter.
string displayLabel 
The display label of the parameter.
string type 
The type (QName) of the parameter from the content model.
boolean multiValued 
Indicates if the parameter has multiple values.
boolean mandatory 
Indicates if the parameter is mandatory or not. If a parameter is mandatory it means that the value can not be null or undefined.